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:
XTra.KrazzY 2009-01-29 23:35:31 +00:00
parent d3677a0247
commit cd658ac755
21 changed files with 1158 additions and 650 deletions

View File

@ -271,7 +271,7 @@ void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) {
case sf::Key::Divide: sprintf(keyStr, "/"); break; case sf::Key::Divide: sprintf(keyStr, "/"); break;
case sf::Key::Left: sprintf(keyStr, "Left"); break; case sf::Key::Left: sprintf(keyStr, "Left"); break;
case sf::Key::Right: sprintf(keyStr, "Right"); 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::Down: sprintf(keyStr, "Down"); break;
case sf::Key::Numpad0: sprintf(keyStr, "NP 0"); break; case sf::Key::Numpad0: sprintf(keyStr, "NP 0"); break;
case sf::Key::Numpad1: sprintf(keyStr, "NP 1"); 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::F13: sprintf(keyStr, "F13"); break;
case sf::Key::F14: sprintf(keyStr, "F14"); break; case sf::Key::F14: sprintf(keyStr, "F14"); break;
case sf::Key::F15: sprintf(keyStr, "F15"); 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: default:
if (keycode > sf::Key::Escape) if (keycode > sf::Key::Escape)
sprintf(keyStr, "Invalid Key"); sprintf(keyStr, "Invalid Key");
else else
sprintf(keyStr, "%c", keycode); sprintf(keyStr, "%c", toupper(keycode));
break; break;
} }
} }

View File

@ -587,7 +587,8 @@ void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus)
#endif #endif
// Set buttons status from wxWidgets in the main application // 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) void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)

View File

@ -163,7 +163,7 @@
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="0" EnableEnhancedInstructionSet="0"
FloatingPointModel="0" FloatingPointModel="0"
UsePrecompiledHeader="0" UsePrecompiledHeader="1"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch" PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch"
AssemblerListingLocation="$(IntDir)\" AssemblerListingLocation="$(IntDir)\"
@ -187,12 +187,13 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dxerr9.lib dinput8.lib xinput.lib comctl32.lib" AdditionalDependencies="comctl32.lib"
OutputFile="..\..\..\Binary\x64\plugins\Plugin_PadSimpleEvnt.dll" OutputFile="..\..\..\Binary\x64\plugins\Plugin_PadSimpleEvnt.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"
GenerateManifest="false" GenerateManifest="false"
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb" ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
LinkTimeCodeGeneration="1"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" DataExecutionPrevention="0"
ImportLibrary="$(TargetDir)$(TargetName).lib" ImportLibrary="$(TargetDir)$(TargetName).lib"
@ -642,6 +643,10 @@
RelativePath=".\Src\PadSimple.h" RelativePath=".\Src\PadSimple.h"
> >
</File> </File>
<File
RelativePath="..\..\PluginSpecs\pluginspecs_pad.h"
>
</File>
<File <File
RelativePath=".\Src\SConscript" RelativePath=".\Src\SConscript"
> >

View File

@ -20,6 +20,7 @@
#include "Common.h" #include "Common.h"
#include "pluginspecs_pad.h"
#include "PadSimple.h" #include "PadSimple.h"
#include "IniFile.h" #include "IniFile.h"
@ -99,32 +100,32 @@ bool registerKey(int nPad, int id, sf::Key::Code code, int mods) {
key.mods = mods; key.mods = mods;
if (!eventHandler) { if (!eventHandler) {
PanicAlert("Can't get event handler"); PanicAlert("Can't get event handler");
return false; 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 // We need to handle mod change
// and double registers // and double registers
if (pad[nPad].keyForControl[id] != 0) { if (pad[nPad].keyForControl[id] != 0) {
oldKey.inputType = KeyboardInput; oldKey.inputType = KeyboardInput;
oldKey.keyCode = pad[nPad].keyForControl[id]; oldKey.keyCode = pad[nPad].keyForControl[id];
oldKey.mods = mods; oldKey.mods = mods;
// Might be not be registered yet // Might be not be registered yet
eventHandler->RemoveEventListener(oldKey); 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; pad[nPad].keyForControl[id] = code;
return true; return true;
@ -253,17 +254,19 @@ bool ParseKeyEvent(sf::Event ev) {
fprintf(stderr, "parsing type %d code %d\n", ev.Type, ev.Key.Code); fprintf(stderr, "parsing type %d code %d\n", ev.Type, ev.Key.Code);
// FIXME: should we support more than one control? // FIXME: should we support more than one control?
for (int i = 0; i < NUMCONTROLS; i++) { for (int i = 0; i < NUMCONTROLS; i++) {
if (ev.Key.Code == pad[0].keyForControl[i]) { if (ev.Key.Code == pad[0].keyForControl[i]) {
KeyStatus[i] = (ev.Type == sf::Event::KeyPressed); KeyStatus[i] = (ev.Type == sf::Event::KeyPressed);
break; break;
}
} }
}
return true; return true;
} }
void PAD_Input(u16 _Key, u8 _UpDown) {
}
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{ {
@ -342,9 +345,6 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
#endif #endif
} }
void PAD_Input(u8 _Key, u8 _UpDown) {
}
void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) { 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, "Attached", &pad[i].bAttached, i==0);
file.Get(SectionName, "DisableOnBackground", &pad[i].bDisable, false); file.Get(SectionName, "DisableOnBackground", &pad[i].bDisable, false);
for (int x = 0; x < NUMCONTROLS; x++) { for (int x = 0; x < NUMCONTROLS; x++) {
int key; int key;
file.Get(SectionName, controlNames[x], file.Get(SectionName, controlNames[x],
&key, (i==0)?defaultKeyForControl[x]:0); &key, (i==0)?defaultKeyForControl[x]:0);
if (i == g_PADInitialize.padNumber && pad[i].bAttached) if (i == g_PADInitialize.padNumber && pad[i].bAttached)
registerKey(i, x, (sf::Key::Code)key); registerKey(i, x, (sf::Key::Code)key);
} }
} }
} }

View File

@ -9,7 +9,12 @@
#include "pluginspecs_video.h" #include "pluginspecs_video.h"
#ifdef _WIN32 #ifdef _WIN32
#define GLEW_STATIC
#include <GLew/glew.h> #include <GLew/glew.h>
#include <GLew/wglew.h>
#include <GLew/gl.h>
#include <GLew/glext.h>
#else #else
#include <GL/glew.h> #include <GL/glew.h>
#endif #endif
@ -20,118 +25,118 @@
#include <GL/gl.h> #include <GL/gl.h>
#endif #endif
enum OGL_Props { enum OGL_Props {
OGL_FULLSCREEN, OGL_FULLSCREEN,
OGL_KEEPRATIO, OGL_KEEPRATIO,
OGL_HIDECURSOR, OGL_HIDECURSOR,
OGL_PROP_COUNT OGL_PROP_COUNT
}; };
struct res { struct res {
u32 x; u32 x;
u32 y; u32 y;
}; };
class GLWindow { class GLWindow {
private: private:
// TODO: what is xmax and ymax? do we need [xy]render? // TODO: what is xmax and ymax? do we need [xy]render?
u32 xWin, yWin; // windows size u32 xWin, yWin; // Windows' size
int xOffset, yOffset; // offset in window int xOffset, yOffset; // Offset in window
float xMax, yMax; // ??? float xMax, yMax; // ???
u32 xRender, yRender; // render area u32 xRender, yRender; // Render area
bool properties[OGL_PROP_COUNT]; bool properties[OGL_PROP_COUNT];
protected: protected:
EventHandler* eventHandler; EventHandler* eventHandler;
res origRes, currFullRes, currWinRes; res origRes, currFullRes, currWinRes;
static std::vector<res> fullResolutions; static std::vector<res> fullResolutions;
virtual void SetRender(u32 x, u32 y) { virtual void SetRender(u32 x, u32 y) {
xRender = x; xRender = x;
yRender = y; yRender = y;
} }
static const std::vector<res>& getFsResolutions() { static const std::vector<res>& getFsResolutions() {
return fullResolutions; return fullResolutions;
} }
static void addFSResolution(res fsr) { static void addFSResolution(res fsr) {
fullResolutions.push_back(fsr); fullResolutions.push_back(fsr);
} }
public: public:
virtual void SwapBuffers() {}; virtual void SwapBuffers() {};
virtual void SetWindowText(const char *text) {}; virtual void SetWindowText(const char *text) {};
virtual bool PeekMessages() {return false;}; virtual bool PeekMessages() {return false;};
virtual void Update() {}; virtual void Update() {};
virtual bool MakeCurrent() {return false;}; virtual bool MakeCurrent() {return false;};
virtual void updateDim() { virtual void updateDim() {
if (GetProperty(OGL_FULLSCREEN)) if (GetProperty(OGL_FULLSCREEN))
SetWinSize(currFullRes.x, currFullRes.y); SetWinSize(currFullRes.x, currFullRes.y);
else else
SetWinSize(currWinRes.x, currWinRes.y); SetWinSize(currWinRes.x, currWinRes.y);
float FactorX = 640.0f / (float)GetXwin();
float FactorY = 480.0f / (float)GetYwin();
// float Max = (FactorX < FactorY) ? FactorX : FactorY;
SetMax(1.0f / FactorX, 1.0f / FactorY); float FactorX = 640.0f / (float)GetXwin();
SetOffset(0,0); float FactorY = 480.0f / (float)GetYwin();
} //float Max = (FactorX < FactorY) ? FactorX : FactorY;
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;}
u32 GetXrender() {return xRender;} SetMax(1.0f / FactorX, 1.0f / FactorY);
u32 GetYrender() {return yRender;} SetOffset(0,0);
}
u32 GetXwin() {return xWin;} void SetEventHandler(EventHandler *eh) { eventHandler = eh;}
u32 GetYwin() {return yWin;} bool GetProperty(OGL_Props prop) {return properties[prop];}
void SetWinSize(u32 x, u32 y) { virtual bool SetProperty(OGL_Props prop, bool value)
xWin = x; {return properties[prop] = value;}
yWin = y;
}
int GetYoff() {return yOffset;} u32 GetXrender() {return xRender;}
int GetXoff() {return xOffset;} u32 GetYrender() {return yRender;}
void SetOffset(int x, int y) {
yOffset = y;
xOffset = x;
}
void SetMax(float x, float y) { u32 GetXwin() {return xWin;}
yMax = y; u32 GetYwin() {return yWin;}
xMax = x; void SetWinSize(u32 x, u32 y) {
} xWin = x;
yWin = y;
}
float GetXmax() {return xMax;} int GetYoff() {return yOffset;}
float GetYmax() {return yMax;} 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 static bool valid() { return false;}
sscanf(g_Config.iFSResolution, "%dx%d",
&currFullRes.x, &currFullRes.y);
sscanf(g_Config.iWindowedRes, "%dx%d", GLWindow() {
&currWinRes.x, &currWinRes.y);
SetProperty(OGL_FULLSCREEN, g_Config.bFullscreen); // Load defaults
SetProperty(OGL_KEEPRATIO, g_Config.bKeepAR); sscanf(g_Config.iFSResolution, "%dx%d",
SetProperty(OGL_HIDECURSOR, g_Config.bHideCursor); &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 // setResolution
// resolution iter // resolution iter
}; };
#endif #endif

View File

@ -15,7 +15,7 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "GLUtil.h" #include "nGLUtil.h"
#include "Profiler.h" #include "Profiler.h"
#include "x64Emitter.h" #include "x64Emitter.h"
#include "ABI.h" #include "ABI.h"

View File

@ -18,7 +18,7 @@
#include "Globals.h" #include "Globals.h"
#include "Profiler.h" #include "Profiler.h"
#include "GLUtil.h" #include "nGLUtil.h"
#include <Cg/cg.h> #include <Cg/cg.h>
#include <Cg/cgGL.h> #include <Cg/cgGL.h>

View File

@ -24,7 +24,7 @@
#include <vector> #include <vector>
#include <cmath> #include <cmath>
#include "GLUtil.h" #include "nGLUtil.h"
#include <Cg/cg.h> #include <Cg/cg.h>
#include <Cg/cgGL.h> #include <Cg/cgGL.h>
@ -56,7 +56,7 @@
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
#include "OS/Win32.h" #include "Win32Window.h" // warning: crapcode
#else #else
#endif #endif
///////////////////////////// /////////////////////////////
@ -494,19 +494,19 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
if (oldscreen && !g_Config.bFullscreen) { // if transitioning from full screen if (oldscreen && !g_Config.bFullscreen) { // if transitioning from full screen
#ifdef _WIN32 #ifdef _WIN32
RECT rc; //RECT rc;
rc.left = 0; rc.top = 0; //rc.left = 0; rc.top = 0;
rc.right = nNewWidth; rc.bottom = nNewHeight; //rc.right = nNewWidth; rc.bottom = nNewHeight;
AdjustWindowRect(&rc, EmuWindow::g_winstyle, FALSE); //AdjustWindowRect(&rc, EmuWindow::g_winstyle, FALSE);
RECT rcdesktop; //RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop); //GetWindowRect(GetDesktopWindow(), &rcdesktop);
SetWindowLong(EmuWindow::GetWnd(), GWL_STYLE, EmuWindow::g_winstyle); //SetWindowLong(EmuWindow::GetWnd(), GWL_STYLE, EmuWindow::g_winstyle);
SetWindowPos(EmuWindow::GetWnd(), HWND_TOP, ((rcdesktop.right-rcdesktop.left)-(rc.right-rc.left))/2, //SetWindowPos(EmuWindow:GetWnd(), HWND_TOP, ((rcdesktop.right-rcdesktop.left)-(rc.right-rc.left))/2,
((rcdesktop.bottom-rcdesktop.top)-(rc.bottom-rc.top))/2, // ((rcdesktop.bottom-rcdesktop.top)-(rc.bottom-rc.top))/2,
rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW); // rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
UpdateWindow(EmuWindow::GetWnd()); //UpdateWindow(EmuWindow::GetWnd());
#else // linux #else // linux
#endif #endif
} }
@ -1216,4 +1216,4 @@ void UpdateViewport()
} }
glDepthRange((xfregs.rawViewport[5]- xfregs.rawViewport[2])/16777215.0f, xfregs.rawViewport[5]/16777215.0f); glDepthRange((xfregs.rawViewport[5]- xfregs.rawViewport[2])/16777215.0f, xfregs.rawViewport[5]/16777215.0f);
} }

View File

@ -1,77 +1,77 @@
#include "SDLWindow.h" #include "SDLWindow.h"
void SDLWindow::SwapBuffers() { void SDLWindow::SwapBuffers() {
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();
} }
void SDLWindow::SetWindowText(const char *text) { void SDLWindow::SetWindowText(const char *text) {
SDL_WM_SetCaption(text, NULL); SDL_WM_SetCaption(text, NULL);
} }
bool SDLWindow::PeekMessages() { bool SDLWindow::PeekMessages() {
// TODO implement // TODO implement
return false; return false;
} }
void SDLWindow::Update() { void SDLWindow::Update() {
SDL_Surface *surface = SDL_GetVideoSurface(); SDL_Surface *surface = SDL_GetVideoSurface();
if (!surface) { if (!surface) {
PanicAlert("Can't ge t surface to update"); PanicAlert("Can't get surface to update");
return; return;
} }
// SetSize(surface->w, surface->h); //SetSize(surface->w, surface->h);
updateDim(); updateDim();
} }
bool SDLWindow::MakeCurrent() { bool SDLWindow::MakeCurrent() {
/* Note: The reason for having the call to SDL_SetVideoMode in here instead /* 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 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 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 have to do "make current" here because this method runs in the CPU
thread while OpenGL_Create() runs in a diferent thread and "make thread while OpenGL_Create() runs in a diferent thread and "make
current" has to be done in the same thread that will be making current" has to be done in the same thread that will be making
calls to OpenGL. */ 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;
}
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() { SDLWindow::~SDLWindow() {
SDL_Quit(); SDL_Quit();
} }
SDLWindow::SDLWindow() : GLWindow() { SDLWindow::SDLWindow() : GLWindow() {
//init sdl video //init sdl video
if (SDL_Init(SDL_INIT_VIDEO) < 0) { if (SDL_Init(SDL_INIT_VIDEO) < 0) {
PanicAlert("Failed to init SDL: %s", SDL_GetError()); PanicAlert("Failed to init SDL: %s", SDL_GetError());
SDL_Quit(); SDL_Quit();
// return NULL; //return NULL;
} }
//setup ogl to use double buffering // Setup ogl to use double buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
} }

View File

@ -8,22 +8,22 @@
class SDLWindow : public GLWindow class SDLWindow : public GLWindow
{ {
public: public:
virtual void SwapBuffers(); virtual void SwapBuffers();
virtual void SetWindowText(const char *text); virtual void SetWindowText(const char *text);
virtual bool PeekMessages(); virtual bool PeekMessages();
virtual void Update(); virtual void Update();
virtual bool MakeCurrent(); virtual bool MakeCurrent();
static bool valid() { return true; } static bool valid() { return true; }
~SDLWindow(); ~SDLWindow();
SDLWindow(); SDLWindow();
}; };
#else #else
class SDLWindow : public GLWindow class SDLWindow : public GLWindow
{ {
public: public:
SDLWindow() {} SDLWindow() {}
}; };
#endif #endif
#endif #endif

View File

@ -22,7 +22,7 @@
#include "Globals.h" #include "Globals.h"
#include "Config.h" #include "Config.h"
#include "ImageWrite.h" #include "ImageWrite.h"
#include "GLUtil.h" #include "nGLUtil.h"
#include "Render.h" #include "Render.h"
namespace TextureConverter namespace TextureConverter

View File

@ -19,7 +19,7 @@
#define _TEXTURECONVERTER_H #define _TEXTURECONVERTER_H
#include "VideoCommon.h" #include "VideoCommon.h"
#include "GLUtil.h" #include "nGLUtil.h"
// Converts textures between formats // Converts textures between formats
// TODO: support multiple texture formats // TODO: support multiple texture formats

View File

@ -21,7 +21,7 @@
#include <map> #include <map>
#include "VideoCommon.h" #include "VideoCommon.h"
#include "GLUtil.h" #include "nGLUtil.h"
#include "BPStructs.h" #include "BPStructs.h"
class TextureMngr class TextureMngr

View File

@ -22,7 +22,7 @@
#include "Config.h" #include "Config.h"
#include "Statistics.h" #include "Statistics.h"
#include "GLUtil.h" #include "nGLUtil.h"
#include <Cg/cg.h> #include <Cg/cg.h>
#include <Cg/cgGL.h> #include <Cg/cgGL.h>

File diff suppressed because it is too large Load Diff

View File

@ -6,24 +6,65 @@
#ifdef _WIN32 #ifdef _WIN32
class Win32Window : public GLWindow class Win32Window : public GLWindow
{ {
virtual void SwapBuffers(); public:
virtual void SetWindowText(const char *text); virtual void SwapBuffers();
virtual bool PeekMessages(); virtual void SetWindowText(const char *text);
virtual void Update(); virtual bool PeekMessages();
virtual bool MakeCurrent(); virtual void Update();
virtual bool MakeCurrent();
static bool valid() { return true; } HWND GetWnd(){return myHandle;};
~Win32Window(); HWND GetParentWnd(){return myParent;};
Win32Window();
static sf::Key::Code KeysymToSF(KeySym Sym); 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 #else
class Win32Window : public GLWindow class Win32Window : public GLWindow
{ {
public: public:
Win32Window {} Win32Window {}
}; };
#endif #endif //_WIN32
#endif //_WIN32WINDOW_H

View File

@ -351,7 +351,7 @@ sf::Key::Code X11Window::KeysymToSF(KeySym Sym) {
case XK_KP_6 : return sf::Key::Numpad6; case XK_KP_6 : return sf::Key::Numpad6;
case XK_KP_7 : return sf::Key::Numpad7; case XK_KP_7 : return sf::Key::Numpad7;
case XK_KP_8 : return sf::Key::Numpad8; 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_E : return sf::Key::E;
case XK_R : return sf::Key::R; case XK_R : return sf::Key::R;
case XK_T : return sf::Key::T; case XK_T : return sf::Key::T;

View File

@ -19,7 +19,7 @@
// Preliminary non-working code. // Preliminary non-working code.
#include "Globals.h" #include "Globals.h"
#include "GLUtil.h" #include "nGLUtil.h"
#include "MemoryUtil.h" #include "MemoryUtil.h"
#include "Render.h" #include "Render.h"
#include "TextureMngr.h" #include "TextureMngr.h"

View File

@ -26,112 +26,114 @@ GLWindow *glWin = NULL;
void OpenGL_SwapBuffers() void OpenGL_SwapBuffers()
{ {
glWin->SwapBuffers(); glWin->SwapBuffers();
} }
void OpenGL_SetWindowText(const char *text) void OpenGL_SetWindowText(const char *text)
{ {
glWin->SetWindowText(text); glWin->SetWindowText(text);
} }
unsigned int Callback_PeekMessages() unsigned int Callback_PeekMessages()
{ {
return glWin->PeekMessages(); return glWin->PeekMessages();
} }
void UpdateFPSDisplay(const char *text) void UpdateFPSDisplay(const char *text)
{ {
char temp[512]; char temp[512];
sprintf(temp, "SVN R%s: GL: %s", SVN_REV_STR, text); sprintf(temp, "SVN R%s: GL: %s", SVN_REV_STR, text);
OpenGL_SetWindowText(temp); OpenGL_SetWindowText(temp);
} }
// ======================================================================================= // =======================================================================================
// Create window. Called from main.cpp // Create window. Called from main.cpp
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int width, int height)
int width, int height)
{ {
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
if (strncasecmp(g_Config.iBackend, "sdl", 10) == 0) if (strncasecmp(g_Config.iBackend, "sdl", 10) == 0)
glWin = new SDLWindow(); glWin = new SDLWindow();
else if (strncasecmp(g_Config.iBackend, "x11", 10) == 0) else if (strncasecmp(g_Config.iBackend, "x11", 10) == 0)
glWin = new X11Window(); glWin = new X11Window();
else if (strncasecmp(g_Config.iBackend, "wxgl", 10) == 0) else if (strncasecmp(g_Config.iBackend, "wxgl", 10) == 0)
glWin = new WXGLWindow(); glWin = new WXGLWindow();
else else if (strncasecmp(g_Config.iBackend, "windows", 10) == 0)
PanicAlert("Invalid backend %s", g_Config.iBackend); glWin = new Win32Window();
else
if (! glWin) PanicAlert("Invalid backend %s", g_Config.iBackend);
return false;
glWin->SetEventHandler((EventHandler *)globals->eventHandler); if (! glWin)
return true; return false;
glWin->SetEventHandler((EventHandler *)globals->eventHandler);
return true;
} }
bool OpenGL_MakeCurrent() 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() void OpenGL_Update()
{ {
glWin->Update(); glWin->Update();
} }
// ======================================================================================= // =======================================================================================
// Close plugin // Close plugin
// ---------------- // ----------------
void OpenGL_Shutdown() void OpenGL_Shutdown()
{ {
delete glWin; delete glWin;
} }
u32 OpenGL_GetWidth() { u32 OpenGL_GetWidth() {
return glWin->GetXwin(); return glWin->GetXwin();
} }
u32 OpenGL_GetHeight() { u32 OpenGL_GetHeight() {
return glWin->GetYwin(); return glWin->GetYwin();
} }
void OpenGL_SetSize(u32 width, u32 height) { void OpenGL_SetSize(u32 width, u32 height) {
glWin->SetWinSize(width, height); glWin->SetWinSize(width, height);
} }
int OpenGL_GetXoff() { int OpenGL_GetXoff() {
return glWin->GetXoff(); return glWin->GetXoff();
} }
int OpenGL_GetYoff() { int OpenGL_GetYoff() {
return glWin->GetYoff(); return glWin->GetYoff();
} }
float OpenGL_GetXmax() { float OpenGL_GetXmax() {
return glWin->GetXmax(); return glWin->GetXmax();
} }
float OpenGL_GetYmax() { float OpenGL_GetYmax() {
return glWin->GetYmax(); return glWin->GetYmax();
} }
void OpenGL_AddBackends(ConfigDialog *frame) { void OpenGL_AddBackends(ConfigDialog *frame) {
if(SDLWindow::valid()) if(SDLWindow::valid())
frame->AddRenderBackend("SDL"); frame->AddRenderBackend("SDL");
if(X11Window::valid()) if(X11Window::valid())
frame->AddRenderBackend("X11"); frame->AddRenderBackend("X11");
if(WXGLWindow::valid()) if(WXGLWindow::valid())
frame->AddRenderBackend("WXGL"); frame->AddRenderBackend("WXGL");
if(Win32Window::valid())
frame->AddRenderBackend("Windows"); // Not "Win32" because retarded people will ask where "win64" is...
} }
void OpenGL_AddResolutions(ConfigDialog *frame) { void OpenGL_AddResolutions(ConfigDialog *frame) {
// TODO get resolution iter // TODO get resolution iter
} }

View File

@ -26,6 +26,7 @@
#include "SDLWindow.h" #include "SDLWindow.h"
#include "X11Window.h" #include "X11Window.h"
#include "WXGLWindow.h" #include "WXGLWindow.h"
#include "Win32Window.h"
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils #ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
#define GL_DEPTH_STENCIL_EXT 0x84F9 #define GL_DEPTH_STENCIL_EXT 0x84F9

View File

@ -26,7 +26,7 @@
#include "LookUpTables.h" #include "LookUpTables.h"
#include "ImageWrite.h" #include "ImageWrite.h"
#include "Render.h" #include "Render.h"
#include "GLUtil.h" #include "nGLUtil.h"
#include "Fifo.h" #include "Fifo.h"
#include "OpcodeDecoding.h" #include "OpcodeDecoding.h"
#include "TextureMngr.h" #include "TextureMngr.h"
@ -47,6 +47,53 @@
SVideoInitialize g_VideoInitialize; SVideoInitialize g_VideoInitialize;
PLUGIN_GLOBALS* globals; 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 /* 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 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 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) void DllConfig(HWND _hParent)
{ {
ConfigDialog frame(NULL); wxWindow * win = new wxWindow();
g_Config.Load(); win->SetHWND((WXHWND)_hParent);
OpenGL_AddBackends(&frame); win->AdoptAttributesFromHWND();
OpenGL_AddResolutions(&frame); //win->Reparent(wxGetApp().GetTopWindow());
frame.ShowModal(); ConfigDialog *frame = new ConfigDialog(win);
g_Config.Load();
OpenGL_AddBackends(frame);
OpenGL_AddResolutions(frame);
frame->ShowModal();
} }
void Initialize(void *init) void Initialize(void *init)
@ -242,14 +293,6 @@ unsigned int Video_Screenshot(TCHAR* _szFilename)
return FALSE; 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) void Video_AddMessage(const char* pstr, u32 milliseconds)
{ {
Renderer::AddMessage(pstr,milliseconds); Renderer::AddMessage(pstr,milliseconds);