2008-12-17 23:49:35 +00:00
|
|
|
#ifndef _GLWINDOW_H
|
|
|
|
#define _GLWINDOW_H
|
|
|
|
|
2009-01-06 20:54:47 +00:00
|
|
|
#include <vector>
|
2008-12-17 23:49:35 +00:00
|
|
|
#include "Common.h"
|
2009-01-05 22:51:35 +00:00
|
|
|
#include "EventHandler.h"
|
2008-12-17 23:49:35 +00:00
|
|
|
#include "Globals.h"
|
|
|
|
#include "Config.h"
|
|
|
|
#include "pluginspecs_video.h"
|
|
|
|
|
2009-01-15 11:46:09 +00:00
|
|
|
#ifdef _WIN32
|
2009-01-29 23:35:31 +00:00
|
|
|
#define GLEW_STATIC
|
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
#include <GLew/glew.h>
|
2009-01-29 23:35:31 +00:00
|
|
|
#include <GLew/wglew.h>
|
|
|
|
#include <GLew/gl.h>
|
|
|
|
#include <GLew/glext.h>
|
2009-01-15 11:46:09 +00:00
|
|
|
#else
|
|
|
|
#include <GL/glew.h>
|
|
|
|
#endif
|
2008-12-18 21:40:50 +00:00
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
#if defined(__APPLE__)
|
2008-12-18 21:40:50 +00:00
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#else
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#endif
|
2009-01-06 08:30:31 +00:00
|
|
|
enum OGL_Props {
|
2009-01-29 23:35:31 +00:00
|
|
|
OGL_FULLSCREEN,
|
|
|
|
OGL_KEEPRATIO,
|
|
|
|
OGL_HIDECURSOR,
|
|
|
|
OGL_PROP_COUNT
|
2009-01-06 08:30:31 +00:00
|
|
|
};
|
2008-12-18 21:40:50 +00:00
|
|
|
|
2009-01-06 20:54:47 +00:00
|
|
|
struct res {
|
2009-01-29 23:35:31 +00:00
|
|
|
u32 x;
|
|
|
|
u32 y;
|
2009-01-06 20:54:47 +00:00
|
|
|
};
|
|
|
|
|
2008-12-17 23:49:35 +00:00
|
|
|
class GLWindow {
|
2009-01-29 23:35:31 +00:00
|
|
|
private:
|
2009-01-19 21:39:53 +00:00
|
|
|
|
2009-01-29 23:35:31 +00:00
|
|
|
// 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
|
2009-01-06 20:54:47 +00:00
|
|
|
|
2009-01-29 23:35:31 +00:00
|
|
|
bool properties[OGL_PROP_COUNT];
|
2009-01-06 20:54:47 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2009-01-29 23:35:31 +00:00
|
|
|
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);
|
|
|
|
}
|
2009-01-06 08:30:31 +00:00
|
|
|
public:
|
2009-01-15 06:48:15 +00:00
|
|
|
|
2009-01-29 23:35:31 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
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;}
|
|
|
|
|
|
|
|
u32 GetXrender() {return xRender;}
|
|
|
|
u32 GetYrender() {return yRender;}
|
|
|
|
|
|
|
|
u32 GetXwin() {return xWin;}
|
|
|
|
u32 GetYwin() {return yWin;}
|
|
|
|
void SetWinSize(u32 x, u32 y) {
|
|
|
|
xWin = x;
|
|
|
|
yWin = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetYoff() {return yOffset;}
|
|
|
|
int GetXoff() {return xOffset;}
|
|
|
|
void SetOffset(int x, int y) {
|
|
|
|
yOffset = y;
|
|
|
|
xOffset = x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMax(float x, float y) {
|
|
|
|
yMax = y;
|
|
|
|
xMax = x;
|
|
|
|
}
|
|
|
|
|
|
|
|
float GetXmax() {return xMax;}
|
|
|
|
float GetYmax() {return yMax;}
|
|
|
|
|
|
|
|
static bool valid() { return false;}
|
|
|
|
|
|
|
|
GLWindow() {
|
|
|
|
|
|
|
|
// Load defaults
|
|
|
|
sscanf(g_Config.iFSResolution, "%dx%d",
|
|
|
|
&currFullRes.x, &currFullRes.y);
|
|
|
|
|
|
|
|
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
|
2008-12-17 23:49:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|