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

@ -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