More WIP OGL EventHandler work by shuffle2 and myself. Wiimote isn't implemented yet and OGL window is too small (should take window borders into account when creating window).
Not committing VideoOGL.vcproj so that project compiles with old OGL video window. In order to test just replace main.cpp/GLUtil.cpp/GLUtil.h with nmain.cpp/nGLUtil.cpp/nGLUtil.h in the project. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2038 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
d3677a0247
commit
cd658ac755
|
@ -271,7 +271,7 @@ void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) {
|
|||
case sf::Key::Divide: sprintf(keyStr, "/"); break;
|
||||
case sf::Key::Left: sprintf(keyStr, "Left"); break;
|
||||
case sf::Key::Right: sprintf(keyStr, "Right"); break;
|
||||
case sf::Key::Up: sprintf(keyStr, "UP"); break;
|
||||
case sf::Key::Up: sprintf(keyStr, "Up"); break;
|
||||
case sf::Key::Down: sprintf(keyStr, "Down"); break;
|
||||
case sf::Key::Numpad0: sprintf(keyStr, "NP 0"); break;
|
||||
case sf::Key::Numpad1: sprintf(keyStr, "NP 1"); break;
|
||||
|
@ -298,12 +298,12 @@ void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) {
|
|||
case sf::Key::F13: sprintf(keyStr, "F13"); break;
|
||||
case sf::Key::F14: sprintf(keyStr, "F14"); break;
|
||||
case sf::Key::F15: sprintf(keyStr, "F15"); break;
|
||||
case sf::Key::Pause: sprintf(keyStr, "Paues"); break;
|
||||
case sf::Key::Pause: sprintf(keyStr, "Pause"); break;
|
||||
default:
|
||||
if (keycode > sf::Key::Escape)
|
||||
sprintf(keyStr, "Invalid Key");
|
||||
else
|
||||
sprintf(keyStr, "%c", keycode);
|
||||
sprintf(keyStr, "%c", toupper(keycode));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -587,7 +587,8 @@ void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus)
|
|||
#endif
|
||||
// Set buttons status from wxWidgets in the main application
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PAD_Input(u16 _Key, u8 _UpDown) {}
|
||||
void PAD_Input(u16 _Key, u8 _UpDown) {
|
||||
}
|
||||
|
||||
|
||||
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
EnableFunctionLevelLinking="true"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
FloatingPointModel="0"
|
||||
UsePrecompiledHeader="0"
|
||||
UsePrecompiledHeader="1"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch"
|
||||
AssemblerListingLocation="$(IntDir)\"
|
||||
|
@ -187,12 +187,13 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="dxguid.lib dxerr9.lib dinput8.lib xinput.lib comctl32.lib"
|
||||
AdditionalDependencies="comctl32.lib"
|
||||
OutputFile="..\..\..\Binary\x64\plugins\Plugin_PadSimpleEvnt.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateManifest="false"
|
||||
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
|
||||
LinkTimeCodeGeneration="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(TargetDir)$(TargetName).lib"
|
||||
|
@ -642,6 +643,10 @@
|
|||
RelativePath=".\Src\PadSimple.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\PluginSpecs\pluginspecs_pad.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\SConscript"
|
||||
>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "Common.h"
|
||||
|
||||
#include "pluginspecs_pad.h"
|
||||
#include "PadSimple.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
|
@ -99,32 +100,32 @@ bool registerKey(int nPad, int id, sf::Key::Code code, int mods) {
|
|||
key.mods = mods;
|
||||
|
||||
if (!eventHandler) {
|
||||
PanicAlert("Can't get event handler");
|
||||
return false;
|
||||
PanicAlert("Can't get event handler");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!eventHandler->RegisterEventListener(ParseKeyEvent, key)) {
|
||||
char codestr[100];
|
||||
eventHandler->SFKeyToString(code, codestr);
|
||||
PanicAlert("Failed to register %s, might be already in use", codestr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// FIXME: unregister old event
|
||||
|
||||
|
||||
// We need to handle mod change
|
||||
// and double registers
|
||||
if (pad[nPad].keyForControl[id] != 0) {
|
||||
|
||||
oldKey.inputType = KeyboardInput;
|
||||
oldKey.keyCode = pad[nPad].keyForControl[id];
|
||||
oldKey.mods = mods;
|
||||
oldKey.inputType = KeyboardInput;
|
||||
oldKey.keyCode = pad[nPad].keyForControl[id];
|
||||
oldKey.mods = mods;
|
||||
|
||||
|
||||
// Might be not be registered yet
|
||||
// Might be not be registered yet
|
||||
eventHandler->RemoveEventListener(oldKey);
|
||||
}
|
||||
|
||||
if (!eventHandler->RegisterEventListener(ParseKeyEvent, key)) {
|
||||
char codestr[100];
|
||||
eventHandler->SFKeyToString(code, codestr);
|
||||
PanicAlert("Failed to register %s, might be already in use", codestr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
pad[nPad].keyForControl[id] = code;
|
||||
|
||||
return true;
|
||||
|
@ -253,17 +254,19 @@ bool ParseKeyEvent(sf::Event ev) {
|
|||
fprintf(stderr, "parsing type %d code %d\n", ev.Type, ev.Key.Code);
|
||||
|
||||
// FIXME: should we support more than one control?
|
||||
for (int i = 0; i < NUMCONTROLS; i++) {
|
||||
if (ev.Key.Code == pad[0].keyForControl[i]) {
|
||||
KeyStatus[i] = (ev.Type == sf::Event::KeyPressed);
|
||||
break;
|
||||
for (int i = 0; i < NUMCONTROLS; i++) {
|
||||
if (ev.Key.Code == pad[0].keyForControl[i]) {
|
||||
KeyStatus[i] = (ev.Type == sf::Event::KeyPressed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void PAD_Input(u16 _Key, u8 _UpDown) {
|
||||
}
|
||||
|
||||
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
{
|
||||
|
@ -342,9 +345,6 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
#endif
|
||||
}
|
||||
|
||||
void PAD_Input(u8 _Key, u8 _UpDown) {
|
||||
}
|
||||
|
||||
void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) {
|
||||
}
|
||||
|
||||
|
@ -404,12 +404,12 @@ void LoadConfig()
|
|||
file.Get(SectionName, "Attached", &pad[i].bAttached, i==0);
|
||||
file.Get(SectionName, "DisableOnBackground", &pad[i].bDisable, false);
|
||||
for (int x = 0; x < NUMCONTROLS; x++) {
|
||||
int key;
|
||||
file.Get(SectionName, controlNames[x],
|
||||
&key, (i==0)?defaultKeyForControl[x]:0);
|
||||
|
||||
if (i == g_PADInitialize.padNumber && pad[i].bAttached)
|
||||
registerKey(i, x, (sf::Key::Code)key);
|
||||
int key;
|
||||
file.Get(SectionName, controlNames[x],
|
||||
&key, (i==0)?defaultKeyForControl[x]:0);
|
||||
|
||||
if (i == g_PADInitialize.padNumber && pad[i].bAttached)
|
||||
registerKey(i, x, (sf::Key::Code)key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,12 @@
|
|||
#include "pluginspecs_video.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define GLEW_STATIC
|
||||
|
||||
#include <GLew/glew.h>
|
||||
#include <GLew/wglew.h>
|
||||
#include <GLew/gl.h>
|
||||
#include <GLew/glext.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
@ -20,118 +25,118 @@
|
|||
#include <GL/gl.h>
|
||||
#endif
|
||||
enum OGL_Props {
|
||||
OGL_FULLSCREEN,
|
||||
OGL_KEEPRATIO,
|
||||
OGL_HIDECURSOR,
|
||||
OGL_PROP_COUNT
|
||||
OGL_FULLSCREEN,
|
||||
OGL_KEEPRATIO,
|
||||
OGL_HIDECURSOR,
|
||||
OGL_PROP_COUNT
|
||||
};
|
||||
|
||||
struct res {
|
||||
u32 x;
|
||||
u32 y;
|
||||
u32 x;
|
||||
u32 y;
|
||||
};
|
||||
|
||||
class GLWindow {
|
||||
private:
|
||||
private:
|
||||
|
||||
// TODO: what is xmax and ymax? do we need [xy]render?
|
||||
u32 xWin, yWin; // windows size
|
||||
int xOffset, yOffset; // offset in window
|
||||
float xMax, yMax; // ???
|
||||
u32 xRender, yRender; // render area
|
||||
// TODO: what is xmax and ymax? do we need [xy]render?
|
||||
u32 xWin, yWin; // Windows' size
|
||||
int xOffset, yOffset; // Offset in window
|
||||
float xMax, yMax; // ???
|
||||
u32 xRender, yRender; // Render area
|
||||
|
||||
bool properties[OGL_PROP_COUNT];
|
||||
bool properties[OGL_PROP_COUNT];
|
||||
|
||||
protected:
|
||||
|
||||
EventHandler* eventHandler;
|
||||
res origRes, currFullRes, currWinRes;
|
||||
static std::vector<res> fullResolutions;
|
||||
virtual void SetRender(u32 x, u32 y) {
|
||||
xRender = x;
|
||||
yRender = y;
|
||||
}
|
||||
EventHandler* eventHandler;
|
||||
res origRes, currFullRes, currWinRes;
|
||||
static std::vector<res> fullResolutions;
|
||||
virtual void SetRender(u32 x, u32 y) {
|
||||
xRender = x;
|
||||
yRender = y;
|
||||
}
|
||||
|
||||
static const std::vector<res>& getFsResolutions() {
|
||||
return fullResolutions;
|
||||
}
|
||||
|
||||
static void addFSResolution(res fsr) {
|
||||
fullResolutions.push_back(fsr);
|
||||
}
|
||||
static const std::vector<res>& getFsResolutions() {
|
||||
return fullResolutions;
|
||||
}
|
||||
|
||||
static void addFSResolution(res fsr) {
|
||||
fullResolutions.push_back(fsr);
|
||||
}
|
||||
public:
|
||||
|
||||
virtual void SwapBuffers() {};
|
||||
virtual void SetWindowText(const char *text) {};
|
||||
virtual bool PeekMessages() {return false;};
|
||||
virtual void Update() {};
|
||||
virtual bool MakeCurrent() {return false;};
|
||||
virtual void SwapBuffers() {};
|
||||
virtual void SetWindowText(const char *text) {};
|
||||
virtual bool PeekMessages() {return false;};
|
||||
virtual void Update() {};
|
||||
virtual bool MakeCurrent() {return false;};
|
||||
|
||||
virtual void updateDim() {
|
||||
if (GetProperty(OGL_FULLSCREEN))
|
||||
SetWinSize(currFullRes.x, currFullRes.y);
|
||||
else
|
||||
SetWinSize(currWinRes.x, currWinRes.y);
|
||||
|
||||
float FactorX = 640.0f / (float)GetXwin();
|
||||
float FactorY = 480.0f / (float)GetYwin();
|
||||
// float Max = (FactorX < FactorY) ? FactorX : FactorY;
|
||||
virtual void updateDim() {
|
||||
if (GetProperty(OGL_FULLSCREEN))
|
||||
SetWinSize(currFullRes.x, currFullRes.y);
|
||||
else
|
||||
SetWinSize(currWinRes.x, currWinRes.y);
|
||||
|
||||
SetMax(1.0f / FactorX, 1.0f / FactorY);
|
||||
SetOffset(0,0);
|
||||
}
|
||||
|
||||
void SetEventHandler(EventHandler *eh) { eventHandler = eh;}
|
||||
bool GetProperty(OGL_Props prop) {return properties[prop];}
|
||||
virtual bool SetProperty(OGL_Props prop, bool value)
|
||||
{return properties[prop] = value;}
|
||||
float FactorX = 640.0f / (float)GetXwin();
|
||||
float FactorY = 480.0f / (float)GetYwin();
|
||||
//float Max = (FactorX < FactorY) ? FactorX : FactorY;
|
||||
|
||||
u32 GetXrender() {return xRender;}
|
||||
u32 GetYrender() {return yRender;}
|
||||
SetMax(1.0f / FactorX, 1.0f / FactorY);
|
||||
SetOffset(0,0);
|
||||
}
|
||||
|
||||
u32 GetXwin() {return xWin;}
|
||||
u32 GetYwin() {return yWin;}
|
||||
void SetWinSize(u32 x, u32 y) {
|
||||
xWin = x;
|
||||
yWin = y;
|
||||
}
|
||||
void SetEventHandler(EventHandler *eh) { eventHandler = eh;}
|
||||
bool GetProperty(OGL_Props prop) {return properties[prop];}
|
||||
virtual bool SetProperty(OGL_Props prop, bool value)
|
||||
{return properties[prop] = value;}
|
||||
|
||||
int GetYoff() {return yOffset;}
|
||||
int GetXoff() {return xOffset;}
|
||||
void SetOffset(int x, int y) {
|
||||
yOffset = y;
|
||||
xOffset = x;
|
||||
}
|
||||
u32 GetXrender() {return xRender;}
|
||||
u32 GetYrender() {return yRender;}
|
||||
|
||||
void SetMax(float x, float y) {
|
||||
yMax = y;
|
||||
xMax = x;
|
||||
}
|
||||
u32 GetXwin() {return xWin;}
|
||||
u32 GetYwin() {return yWin;}
|
||||
void SetWinSize(u32 x, u32 y) {
|
||||
xWin = x;
|
||||
yWin = y;
|
||||
}
|
||||
|
||||
float GetXmax() {return xMax;}
|
||||
float GetYmax() {return yMax;}
|
||||
int GetYoff() {return yOffset;}
|
||||
int GetXoff() {return xOffset;}
|
||||
void SetOffset(int x, int y) {
|
||||
yOffset = y;
|
||||
xOffset = x;
|
||||
}
|
||||
|
||||
static bool valid() { return false;}
|
||||
void SetMax(float x, float y) {
|
||||
yMax = y;
|
||||
xMax = x;
|
||||
}
|
||||
|
||||
GLWindow() {
|
||||
float GetXmax() {return xMax;}
|
||||
float GetYmax() {return yMax;}
|
||||
|
||||
// Load defaults
|
||||
sscanf(g_Config.iFSResolution, "%dx%d",
|
||||
&currFullRes.x, &currFullRes.y);
|
||||
static bool valid() { return false;}
|
||||
|
||||
sscanf(g_Config.iWindowedRes, "%dx%d",
|
||||
&currWinRes.x, &currWinRes.y);
|
||||
GLWindow() {
|
||||
|
||||
SetProperty(OGL_FULLSCREEN, g_Config.bFullscreen);
|
||||
SetProperty(OGL_KEEPRATIO, g_Config.bKeepAR);
|
||||
SetProperty(OGL_HIDECURSOR, g_Config.bHideCursor);
|
||||
// Load defaults
|
||||
sscanf(g_Config.iFSResolution, "%dx%d",
|
||||
&currFullRes.x, &currFullRes.y);
|
||||
|
||||
updateDim();
|
||||
}
|
||||
sscanf(g_Config.iWindowedRes, "%dx%d",
|
||||
&currWinRes.x, &currWinRes.y);
|
||||
|
||||
SetProperty(OGL_FULLSCREEN, g_Config.bFullscreen);
|
||||
SetProperty(OGL_KEEPRATIO, g_Config.bKeepAR);
|
||||
SetProperty(OGL_HIDECURSOR, g_Config.bHideCursor);
|
||||
|
||||
updateDim();
|
||||
}
|
||||
|
||||
|
||||
// setResolution
|
||||
// resolution iter
|
||||
// setResolution
|
||||
// resolution iter
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
#include "Profiler.h"
|
||||
#include "x64Emitter.h"
|
||||
#include "ABI.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "Globals.h"
|
||||
#include "Profiler.h"
|
||||
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgGL.h>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgGL.h>
|
||||
|
@ -56,7 +56,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "OS/Win32.h"
|
||||
#include "Win32Window.h" // warning: crapcode
|
||||
#else
|
||||
#endif
|
||||
/////////////////////////////
|
||||
|
@ -494,19 +494,19 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
|
|||
|
||||
if (oldscreen && !g_Config.bFullscreen) { // if transitioning from full screen
|
||||
#ifdef _WIN32
|
||||
RECT rc;
|
||||
rc.left = 0; rc.top = 0;
|
||||
rc.right = nNewWidth; rc.bottom = nNewHeight;
|
||||
AdjustWindowRect(&rc, EmuWindow::g_winstyle, FALSE);
|
||||
//RECT rc;
|
||||
//rc.left = 0; rc.top = 0;
|
||||
//rc.right = nNewWidth; rc.bottom = nNewHeight;
|
||||
//AdjustWindowRect(&rc, EmuWindow::g_winstyle, FALSE);
|
||||
|
||||
RECT rcdesktop;
|
||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||
//RECT rcdesktop;
|
||||
//GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||
|
||||
SetWindowLong(EmuWindow::GetWnd(), GWL_STYLE, EmuWindow::g_winstyle);
|
||||
SetWindowPos(EmuWindow::GetWnd(), HWND_TOP, ((rcdesktop.right-rcdesktop.left)-(rc.right-rc.left))/2,
|
||||
((rcdesktop.bottom-rcdesktop.top)-(rc.bottom-rc.top))/2,
|
||||
rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
|
||||
UpdateWindow(EmuWindow::GetWnd());
|
||||
//SetWindowLong(EmuWindow::GetWnd(), GWL_STYLE, EmuWindow::g_winstyle);
|
||||
//SetWindowPos(EmuWindow:GetWnd(), HWND_TOP, ((rcdesktop.right-rcdesktop.left)-(rc.right-rc.left))/2,
|
||||
// ((rcdesktop.bottom-rcdesktop.top)-(rc.bottom-rc.top))/2,
|
||||
// rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
|
||||
//UpdateWindow(EmuWindow::GetWnd());
|
||||
#else // linux
|
||||
#endif
|
||||
}
|
||||
|
@ -1216,4 +1216,4 @@ void UpdateViewport()
|
|||
}
|
||||
|
||||
glDepthRange((xfregs.rawViewport[5]- xfregs.rawViewport[2])/16777215.0f, xfregs.rawViewport[5]/16777215.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
#include "SDLWindow.h"
|
||||
|
||||
void SDLWindow::SwapBuffers() {
|
||||
SDL_GL_SwapBuffers();
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
|
||||
void SDLWindow::SetWindowText(const char *text) {
|
||||
SDL_WM_SetCaption(text, NULL);
|
||||
SDL_WM_SetCaption(text, NULL);
|
||||
}
|
||||
|
||||
bool SDLWindow::PeekMessages() {
|
||||
// TODO implement
|
||||
return false;
|
||||
// TODO implement
|
||||
return false;
|
||||
}
|
||||
|
||||
void SDLWindow::Update() {
|
||||
|
||||
SDL_Surface *surface = SDL_GetVideoSurface();
|
||||
if (!surface) {
|
||||
PanicAlert("Can't ge t surface to update");
|
||||
return;
|
||||
}
|
||||
|
||||
// SetSize(surface->w, surface->h);
|
||||
updateDim();
|
||||
|
||||
SDL_Surface *surface = SDL_GetVideoSurface();
|
||||
if (!surface) {
|
||||
PanicAlert("Can't get surface to update");
|
||||
return;
|
||||
}
|
||||
|
||||
//SetSize(surface->w, surface->h);
|
||||
updateDim();
|
||||
|
||||
}
|
||||
|
||||
bool SDLWindow::MakeCurrent() {
|
||||
/* Note: The reason for having the call to SDL_SetVideoMode in here instead
|
||||
of in OpenGL_Create() is that "make current" is part of the video
|
||||
mode setting and is not available as a separate call in SDL. We
|
||||
have to do "make current" here because this method runs in the CPU
|
||||
thread while OpenGL_Create() runs in a diferent thread and "make
|
||||
current" has to be done in the same thread that will be making
|
||||
calls to OpenGL. */
|
||||
|
||||
// Fetch video info.
|
||||
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
||||
if (!videoInfo) {
|
||||
PanicAlert("Couldn't get video info");
|
||||
SDL_Quit();
|
||||
return false;
|
||||
}
|
||||
// Compute video mode flags.
|
||||
const int videoFlags = SDL_OPENGL
|
||||
| ( videoInfo->hw_available ? SDL_HWSURFACE : SDL_SWSURFACE )
|
||||
| ( g_Config.bFullscreen ? SDL_FULLSCREEN : 0);
|
||||
// Set vide mode.
|
||||
// TODO: Can we use this field or is a separate field needed?
|
||||
SDL_Surface *screen = SDL_SetVideoMode(GetXwin(), GetYwin(),
|
||||
0, videoFlags);
|
||||
if (!screen) {
|
||||
PanicAlert("Couldn't set video mode");
|
||||
SDL_Quit();
|
||||
return false;
|
||||
}
|
||||
/* Note: The reason for having the call to SDL_SetVideoMode in here instead
|
||||
of in OpenGL_Create() is that "make current" is part of the video
|
||||
mode setting and is not available as a separate call in SDL. We
|
||||
have to do "make current" here because this method runs in the CPU
|
||||
thread while OpenGL_Create() runs in a diferent thread and "make
|
||||
current" has to be done in the same thread that will be making
|
||||
calls to OpenGL. */
|
||||
|
||||
return true;
|
||||
// Fetch video info.
|
||||
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
||||
if (!videoInfo) {
|
||||
PanicAlert("Couldn't get video info");
|
||||
SDL_Quit();
|
||||
return false;
|
||||
}
|
||||
// Compute video mode flags.
|
||||
const int videoFlags = SDL_OPENGL
|
||||
| ( videoInfo->hw_available ? SDL_HWSURFACE : SDL_SWSURFACE )
|
||||
| ( g_Config.bFullscreen ? SDL_FULLSCREEN : 0);
|
||||
// Set vide mode.
|
||||
// TODO: Can we use this field or is a separate field needed?
|
||||
SDL_Surface *screen = SDL_SetVideoMode(GetXwin(), GetYwin(),
|
||||
0, videoFlags);
|
||||
if (!screen) {
|
||||
PanicAlert("Couldn't set video mode");
|
||||
SDL_Quit();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SDLWindow::~SDLWindow() {
|
||||
SDL_Quit();
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
SDLWindow::SDLWindow() : GLWindow() {
|
||||
|
||||
//init sdl video
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
PanicAlert("Failed to init SDL: %s", SDL_GetError());
|
||||
SDL_Quit();
|
||||
// return NULL;
|
||||
}
|
||||
|
||||
//setup ogl to use double buffering
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
//init sdl video
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
PanicAlert("Failed to init SDL: %s", SDL_GetError());
|
||||
SDL_Quit();
|
||||
//return NULL;
|
||||
}
|
||||
|
||||
// Setup ogl to use double buffering
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
}
|
||||
|
|
|
@ -8,22 +8,22 @@
|
|||
class SDLWindow : public GLWindow
|
||||
{
|
||||
public:
|
||||
virtual void SwapBuffers();
|
||||
virtual void SetWindowText(const char *text);
|
||||
virtual bool PeekMessages();
|
||||
virtual void Update();
|
||||
virtual bool MakeCurrent();
|
||||
virtual void SwapBuffers();
|
||||
virtual void SetWindowText(const char *text);
|
||||
virtual bool PeekMessages();
|
||||
virtual void Update();
|
||||
virtual bool MakeCurrent();
|
||||
|
||||
static bool valid() { return true; }
|
||||
~SDLWindow();
|
||||
SDLWindow();
|
||||
static bool valid() { return true; }
|
||||
~SDLWindow();
|
||||
SDLWindow();
|
||||
|
||||
};
|
||||
#else
|
||||
class SDLWindow : public GLWindow
|
||||
{
|
||||
public:
|
||||
SDLWindow() {}
|
||||
public:
|
||||
SDLWindow() {}
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "Globals.h"
|
||||
#include "Config.h"
|
||||
#include "ImageWrite.h"
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
#include "Render.h"
|
||||
|
||||
namespace TextureConverter
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define _TEXTURECONVERTER_H
|
||||
|
||||
#include "VideoCommon.h"
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
|
||||
// Converts textures between formats
|
||||
// TODO: support multiple texture formats
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <map>
|
||||
|
||||
#include "VideoCommon.h"
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
#include "BPStructs.h"
|
||||
|
||||
class TextureMngr
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "Config.h"
|
||||
#include "Statistics.h"
|
||||
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgGL.h>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,24 +6,65 @@
|
|||
#ifdef _WIN32
|
||||
class Win32Window : public GLWindow
|
||||
{
|
||||
virtual void SwapBuffers();
|
||||
virtual void SetWindowText(const char *text);
|
||||
virtual bool PeekMessages();
|
||||
virtual void Update();
|
||||
virtual bool MakeCurrent();
|
||||
|
||||
static bool valid() { return true; }
|
||||
~Win32Window();
|
||||
Win32Window();
|
||||
static sf::Key::Code KeysymToSF(KeySym Sym);
|
||||
public:
|
||||
virtual void SwapBuffers();
|
||||
virtual void SetWindowText(const char *text);
|
||||
virtual bool PeekMessages();
|
||||
virtual void Update();
|
||||
virtual bool MakeCurrent();
|
||||
HWND GetWnd(){return myHandle;};
|
||||
HWND GetParentWnd(){return myParent;};
|
||||
|
||||
static bool valid() { return true; }
|
||||
~Win32Window();
|
||||
Win32Window();
|
||||
static sf::Key::Code VirtualKeyCodeToSF(WPARAM VirtualKey, LPARAM Flags);
|
||||
static sf::Key::Code GetShiftState(bool KeyDown);
|
||||
|
||||
private:
|
||||
struct VideoMode
|
||||
{
|
||||
unsigned int Width;
|
||||
unsigned int Height;
|
||||
unsigned int BitsPerPixel;
|
||||
unsigned int DepthBits;
|
||||
unsigned int StencilBits;
|
||||
unsigned int AntialiasingLevel;
|
||||
};
|
||||
|
||||
virtual void ShowMouseCursor(bool Show);
|
||||
void RegisterWindowClass();
|
||||
void SwitchToFullscreen(const VideoMode& Mode);
|
||||
void CreateContext(VideoMode& Mode);
|
||||
void Cleanup();
|
||||
void ProcessEvent(UINT Message, WPARAM WParam, LPARAM LParam);
|
||||
static LRESULT CALLBACK GlobalOnEvent(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam);
|
||||
|
||||
// Static member data
|
||||
static unsigned int ourWindowCount;
|
||||
static const char* ourClassName;
|
||||
static Win32Window* ourFullscreenWindow;
|
||||
|
||||
// Member data
|
||||
HWND myHandle;
|
||||
HINSTANCE myhInstance;
|
||||
HWND myParent; // Possibly not wanted here
|
||||
long myCallback;
|
||||
HCURSOR myCursor;
|
||||
HICON myIcon;
|
||||
bool myKeyRepeatEnabled;
|
||||
bool myIsCursorIn;
|
||||
HDC myDeviceContext;
|
||||
HGLRC myGLContext;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class Win32Window : public GLWindow
|
||||
{
|
||||
public:
|
||||
Win32Window {}
|
||||
public:
|
||||
Win32Window {}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif //_WIN32
|
||||
#endif //_WIN32WINDOW_H
|
||||
|
|
|
@ -351,7 +351,7 @@ sf::Key::Code X11Window::KeysymToSF(KeySym Sym) {
|
|||
case XK_KP_6 : return sf::Key::Numpad6;
|
||||
case XK_KP_7 : return sf::Key::Numpad7;
|
||||
case XK_KP_8 : return sf::Key::Numpad8;
|
||||
case XK_Z : return sf::Key::Z;
|
||||
case XK_Z : return sf::Key::Z;
|
||||
case XK_E : return sf::Key::E;
|
||||
case XK_R : return sf::Key::R;
|
||||
case XK_T : return sf::Key::T;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// Preliminary non-working code.
|
||||
|
||||
#include "Globals.h"
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
#include "MemoryUtil.h"
|
||||
#include "Render.h"
|
||||
#include "TextureMngr.h"
|
||||
|
|
|
@ -26,112 +26,114 @@ GLWindow *glWin = NULL;
|
|||
|
||||
void OpenGL_SwapBuffers()
|
||||
{
|
||||
glWin->SwapBuffers();
|
||||
glWin->SwapBuffers();
|
||||
}
|
||||
|
||||
void OpenGL_SetWindowText(const char *text)
|
||||
{
|
||||
glWin->SetWindowText(text);
|
||||
glWin->SetWindowText(text);
|
||||
}
|
||||
|
||||
unsigned int Callback_PeekMessages()
|
||||
{
|
||||
return glWin->PeekMessages();
|
||||
return glWin->PeekMessages();
|
||||
}
|
||||
|
||||
void UpdateFPSDisplay(const char *text)
|
||||
{
|
||||
char temp[512];
|
||||
sprintf(temp, "SVN R%s: GL: %s", SVN_REV_STR, text);
|
||||
OpenGL_SetWindowText(temp);
|
||||
char temp[512];
|
||||
sprintf(temp, "SVN R%s: GL: %s", SVN_REV_STR, text);
|
||||
OpenGL_SetWindowText(temp);
|
||||
|
||||
}
|
||||
|
||||
// =======================================================================================
|
||||
// Create window. Called from main.cpp
|
||||
bool OpenGL_Create(SVideoInitialize &_VideoInitialize,
|
||||
int width, int height)
|
||||
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int width, int height)
|
||||
{
|
||||
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
|
||||
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
|
||||
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
|
||||
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
|
||||
|
||||
if (strncasecmp(g_Config.iBackend, "sdl", 10) == 0)
|
||||
glWin = new SDLWindow();
|
||||
else if (strncasecmp(g_Config.iBackend, "x11", 10) == 0)
|
||||
glWin = new X11Window();
|
||||
else if (strncasecmp(g_Config.iBackend, "wxgl", 10) == 0)
|
||||
glWin = new WXGLWindow();
|
||||
else
|
||||
PanicAlert("Invalid backend %s", g_Config.iBackend);
|
||||
|
||||
if (! glWin)
|
||||
return false;
|
||||
if (strncasecmp(g_Config.iBackend, "sdl", 10) == 0)
|
||||
glWin = new SDLWindow();
|
||||
else if (strncasecmp(g_Config.iBackend, "x11", 10) == 0)
|
||||
glWin = new X11Window();
|
||||
else if (strncasecmp(g_Config.iBackend, "wxgl", 10) == 0)
|
||||
glWin = new WXGLWindow();
|
||||
else if (strncasecmp(g_Config.iBackend, "windows", 10) == 0)
|
||||
glWin = new Win32Window();
|
||||
else
|
||||
PanicAlert("Invalid backend %s", g_Config.iBackend);
|
||||
|
||||
glWin->SetEventHandler((EventHandler *)globals->eventHandler);
|
||||
return true;
|
||||
if (! glWin)
|
||||
return false;
|
||||
|
||||
glWin->SetEventHandler((EventHandler *)globals->eventHandler);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenGL_MakeCurrent()
|
||||
{
|
||||
return glWin->MakeCurrent();
|
||||
return glWin->MakeCurrent();
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================================
|
||||
// Update window width, size and etc. Called from Render.cpp
|
||||
// Update window width, size and etc. Called from Render.cpp and XFB.cpp
|
||||
// ----------------
|
||||
void OpenGL_Update()
|
||||
{
|
||||
glWin->Update();
|
||||
glWin->Update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// =======================================================================================
|
||||
// Close plugin
|
||||
// ----------------
|
||||
void OpenGL_Shutdown()
|
||||
{
|
||||
delete glWin;
|
||||
delete glWin;
|
||||
}
|
||||
|
||||
u32 OpenGL_GetWidth() {
|
||||
return glWin->GetXwin();
|
||||
return glWin->GetXwin();
|
||||
}
|
||||
|
||||
u32 OpenGL_GetHeight() {
|
||||
return glWin->GetYwin();
|
||||
return glWin->GetYwin();
|
||||
}
|
||||
|
||||
void OpenGL_SetSize(u32 width, u32 height) {
|
||||
glWin->SetWinSize(width, height);
|
||||
glWin->SetWinSize(width, height);
|
||||
}
|
||||
|
||||
int OpenGL_GetXoff() {
|
||||
return glWin->GetXoff();
|
||||
return glWin->GetXoff();
|
||||
}
|
||||
|
||||
int OpenGL_GetYoff() {
|
||||
return glWin->GetYoff();
|
||||
return glWin->GetYoff();
|
||||
}
|
||||
|
||||
float OpenGL_GetXmax() {
|
||||
return glWin->GetXmax();
|
||||
return glWin->GetXmax();
|
||||
}
|
||||
|
||||
float OpenGL_GetYmax() {
|
||||
return glWin->GetYmax();
|
||||
return glWin->GetYmax();
|
||||
}
|
||||
|
||||
void OpenGL_AddBackends(ConfigDialog *frame) {
|
||||
if(SDLWindow::valid())
|
||||
frame->AddRenderBackend("SDL");
|
||||
if(X11Window::valid())
|
||||
frame->AddRenderBackend("X11");
|
||||
if(WXGLWindow::valid())
|
||||
frame->AddRenderBackend("WXGL");
|
||||
if(SDLWindow::valid())
|
||||
frame->AddRenderBackend("SDL");
|
||||
if(X11Window::valid())
|
||||
frame->AddRenderBackend("X11");
|
||||
if(WXGLWindow::valid())
|
||||
frame->AddRenderBackend("WXGL");
|
||||
if(Win32Window::valid())
|
||||
frame->AddRenderBackend("Windows"); // Not "Win32" because retarded people will ask where "win64" is...
|
||||
}
|
||||
|
||||
void OpenGL_AddResolutions(ConfigDialog *frame) {
|
||||
// TODO get resolution iter
|
||||
// TODO get resolution iter
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "SDLWindow.h"
|
||||
#include "X11Window.h"
|
||||
#include "WXGLWindow.h"
|
||||
#include "Win32Window.h"
|
||||
|
||||
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
|
||||
#define GL_DEPTH_STENCIL_EXT 0x84F9
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "LookUpTables.h"
|
||||
#include "ImageWrite.h"
|
||||
#include "Render.h"
|
||||
#include "GLUtil.h"
|
||||
#include "nGLUtil.h"
|
||||
#include "Fifo.h"
|
||||
#include "OpcodeDecoding.h"
|
||||
#include "TextureMngr.h"
|
||||
|
@ -47,6 +47,53 @@
|
|||
SVideoInitialize g_VideoInitialize;
|
||||
PLUGIN_GLOBALS* globals;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Nasty stuff which win32 needs for wxw
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined(_WIN32) && defined(HAVE_WX) && HAVE_WX
|
||||
HINSTANCE g_hInstance;
|
||||
|
||||
class wxDLLApp : public wxApp
|
||||
{
|
||||
bool OnInit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
||||
|
||||
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
||||
|
||||
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
||||
DWORD dwReason, // reason called
|
||||
LPVOID lpvReserved) // reserved
|
||||
{
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{ // Use wxInitialize() if you don't want GUI instead of the following 12 lines
|
||||
wxSetInstance((HINSTANCE)hinstDLL);
|
||||
int argc = 0;
|
||||
char **argv = NULL;
|
||||
wxEntryStart(argc, argv);
|
||||
if ( !wxTheApp || !wxTheApp->CallOnInit() )
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
wxEntryCleanup(); // Use wxUninitialize() if you don't want GUI
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
g_hInstance = hinstDLL;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Create debugging window. There's currently a strange crash that occurs whe a game is loaded
|
||||
if the OpenGL plugin was loaded before. I'll try to fix that. Currently you may have to
|
||||
clsoe the window if it has auto started, and then restart it after the dll has loaded
|
||||
|
@ -102,11 +149,15 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {
|
|||
|
||||
void DllConfig(HWND _hParent)
|
||||
{
|
||||
ConfigDialog frame(NULL);
|
||||
g_Config.Load();
|
||||
OpenGL_AddBackends(&frame);
|
||||
OpenGL_AddResolutions(&frame);
|
||||
frame.ShowModal();
|
||||
wxWindow * win = new wxWindow();
|
||||
win->SetHWND((WXHWND)_hParent);
|
||||
win->AdoptAttributesFromHWND();
|
||||
//win->Reparent(wxGetApp().GetTopWindow());
|
||||
ConfigDialog *frame = new ConfigDialog(win);
|
||||
g_Config.Load();
|
||||
OpenGL_AddBackends(frame);
|
||||
OpenGL_AddResolutions(frame);
|
||||
frame->ShowModal();
|
||||
}
|
||||
|
||||
void Initialize(void *init)
|
||||
|
@ -242,14 +293,6 @@ unsigned int Video_Screenshot(TCHAR* _szFilename)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void Video_UpdateXFB(u8* _pXFB, u32 _dwWidth, u32 _dwHeight, s32 _dwYOffset)
|
||||
{
|
||||
if(g_Config.bUseXFB)
|
||||
{
|
||||
XFB_Draw(_pXFB, _dwWidth, _dwHeight, _dwYOffset);
|
||||
}
|
||||
}
|
||||
|
||||
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
||||
{
|
||||
Renderer::AddMessage(pstr,milliseconds);
|
||||
|
|
Loading…
Reference in New Issue