1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-06-08 01:22:02 +00:00

Avoid recreating the GL context on Alt+Tab, resolution change, or windowed/fullscreen switch

This commit is contained in:
fgenesis 2016-11-09 01:16:55 +01:00
parent b8aaccd7a1
commit 1bad4d006d
8 changed files with 184 additions and 283 deletions

View file

@ -230,27 +230,11 @@ DSQ::~DSQ()
dsq = 0; dsq = 0;
} }
void DSQ::onAltTab()
{
if (getAltState())
{
if (!core->isNested())
{
if (_fullscreen)
{
core->toggleScreenMode(false);
}
}
}
}
// actually toggle // actually toggle
void DSQ::toggleFullscreen() void DSQ::toggleFullscreen()
{ {
setFullscreen(!_fullscreen);
core->toggleScreenMode(!_fullscreen);
user.video.full = _fullscreen; user.video.full = _fullscreen;
} }
// for handling the input, not the actual switch functionality // for handling the input, not the actual switch functionality

View file

@ -514,7 +514,6 @@ protected:
void reloadDevice(); void reloadDevice();
void onSwitchScreenMode(); void onSwitchScreenMode();
void onAltTab();
void onPlayVoice(); void onPlayVoice();
void onStopVoice(); void onStopVoice();

View file

@ -3252,7 +3252,7 @@ void InGameMenu::onOptionsSave()
|| dsq->user.video.full != dsq->user_backup.video.full || dsq->user.video.full != dsq->user_backup.video.full
|| dsq->user.video.vsync != dsq->user_backup.video.vsync) || dsq->user.video.vsync != dsq->user_backup.video.vsync)
{ {
dsq->resetGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full); dsq->initGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full);
if (dsq->confirm("", "graphics", false, 10)) { if (dsq->confirm("", "graphics", false, 10)) {
} else { } else {
dsq->user.video.resx = dsq->user_backup.video.resx; dsq->user.video.resx = dsq->user_backup.video.resx;
@ -3263,7 +3263,7 @@ void InGameMenu::onOptionsSave()
dsq->user.apply(); dsq->user.apply();
dsq->resetGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full); dsq->initGraphics(dsq->user.video.resx, dsq->user.video.resy, dsq->user.video.full);
} }
} }

View file

@ -462,7 +462,7 @@ void Nag::onBuy()
if (core->isFullscreen()) if (core->isFullscreen())
{ {
core->toggleScreenMode(0); core->setFullscreen(false);
dsq->run(0.6); dsq->run(0.6);
} }

View file

@ -123,7 +123,66 @@ void Core::reloadDevice()
afterEffectManager->reloadDevice(); afterEffectManager->reloadDevice();
} }
void Core::resetGraphics(int w, int h, int fullscreen, int vsync, int bpp) void Core::setup_opengl()
{
#ifdef BBGE_BUILD_SDL2
assert(gGLctx);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(gScreen);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(gScreen);
const char *name = SDL_GetCurrentVideoDriver();
SDL_SetWindowGrab(gScreen, SDL_TRUE);
#else
SDL_WM_GrabInput(grabInputOnReentry == 0 ? SDL_GRAB_OFF : SDL_GRAB_ON);
char name[256];
SDL_VideoDriverName((char*)name, 256);
#endif
glViewport(0, 0, width, height);
std::ostringstream os2;
os2 << "Video Driver Name [" << name << "]";
debugLog(os2.str());
SDL_ShowCursor(SDL_DISABLE);
SDL_PumpEvents();
for(int i = 0; i < KEY_MAXARRAY; i++)
{
keys[i] = 0;
}
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
glClearDepth(1.0); // Depth Buffer Setup
glDisable(GL_CULL_FACE);
glLoadIdentity();
glFinish();
setClearColor(clearColor);
clearBuffers();
showBuffer();
lib_graphics = true;
_hasFocus = true;
enumerateScreenModes();
}
void Core::initGraphics(int w, int h, int fullscreen, int vsync, int bpp)
{ {
if (fullscreen == -1) if (fullscreen == -1)
fullscreen = _fullscreen; fullscreen = _fullscreen;
@ -140,38 +199,85 @@ void Core::resetGraphics(int w, int h, int fullscreen, int vsync, int bpp)
if (bpp == -1) if (bpp == -1)
bpp = _bpp; bpp = _bpp;
unloadDevice(); width = w;
unloadResources(); height = h;
_vsync = vsync;
_fullscreen = fullscreen;
_bpp = bpp;
shutdownGraphicsLibrary(); #ifdef BBGE_BUILD_SDL2
if(vsync)
{
if(SDL_GL_SetSwapInterval(-1) != 0)
SDL_GL_SetSwapInterval(1);
}
else
SDL_GL_SetSwapInterval(0);
initGraphicsLibrary(w, h, fullscreen, vsync, bpp); SDL_SetWindowSize(gScreen, w, h);
int disp = SDL_GetWindowDisplayIndex(gScreen);
int screenflags = 0;
if(fullscreen)
{
// Use desktop fullscreen if possible, but only if the resolution
// matches the actual desktop resolution.
// Else we'll get unused areas on the screen.
if(disp >= 0)
{
SDL_Rect bounds;
SDL_DisplayMode desktop;
if(SDL_GetDisplayBounds(disp, &bounds) == 0
&& SDL_GetDesktopDisplayMode(disp, &desktop) == 0)
{
//SDL_SetWindowPosition(gScreen, bounds.x, bounds.y);
if(w == desktop.w && h == desktop.h)
{
screenflags = SDL_WINDOW_FULLSCREEN_DESKTOP;
debugLog("Switching to desktop fullscreen");
}
}
}
if(!screenflags)
{
screenflags = SDL_WINDOW_FULLSCREEN;
debugLog("Switching to fullscreen");
}
}
SDL_SetWindowFullscreen(gScreen, screenflags);
if(!fullscreen)
{
SDL_SetWindowSize(gScreen, w, h);
SDL_SetWindowPosition(gScreen, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
#else
# error FIXME: backport to support SDL 1.2
#endif
setup_opengl();
enable2DWide(w, h); enable2DWide(w, h);
reloadResources();
reloadDevice();
resetTimer(); resetTimer();
} }
void Core::toggleScreenMode(int t) void Core::setFullscreen(bool full)
{ {
if(full == !!_fullscreen)
return;
sound->pause(); sound->pause();
resetGraphics(-1, -1, t); initGraphics(-1, -1, full);
cacheRender(); cacheRender();
resetTimer(); resetTimer();
sound->resume(); sound->resume();
} }
void Core::setWindowCaption(const std::string &caption, const std::string &icon)
{
#ifndef BBGE_BUILD_SDL2
SDL_WM_SetCaption(caption.c_str(), icon.c_str());
#endif
}
RenderObjectLayer *Core::getRenderObjectLayer(int i) RenderObjectLayer *Core::getRenderObjectLayer(int i)
{ {
if (i == LR_NONE) if (i == LR_NONE)
@ -253,7 +359,6 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n
: ActionMapper(), StateManager(), appName(appName) : ActionMapper(), StateManager(), appName(appName)
{ {
sound = NULL; sound = NULL;
screenCapScale = Vector(1,1,1);
_extraDataDir = extraDataDir; _extraDataDir = extraDataDir;
if (userDataSubFolder.empty()) if (userDataSubFolder.empty())
@ -330,9 +435,6 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n
old_dt = 0; old_dt = 0;
current_dt = 0; current_dt = 0;
aspectX = 4;
aspectY = 3;
virtualOffX = virtualOffY = 0; virtualOffX = virtualOffY = 0;
viewOffX = viewOffY = 0; viewOffX = viewOffY = 0;
@ -377,9 +479,6 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n
keys[i] = 0; keys[i] = 0;
} }
aspect = (aspectX/aspectY);
globalResolutionScale = globalScale = Vector(1,1,1); globalResolutionScale = globalScale = Vector(1,1,1);
initRenderObjectLayers(numRenderLayers); initRenderObjectLayers(numRenderLayers);
@ -533,11 +632,27 @@ void Core::init()
SDL_putenv((char *) "SDL_MOUSE_RELATIVE=0"); SDL_putenv((char *) "SDL_MOUSE_RELATIVE=0");
#endif #endif
if((SDL_Init(0))==-1) if((SDL_Init(SDL_INIT_EVERYTHING))==-1)
{ {
exit_error("Failed to init SDL"); exit_error("Failed to init SDL");
} }
#if BBGE_BUILD_OPENGL_DYNAMIC
if (SDL_GL_LoadLibrary(NULL) == -1)
{
std::string err = std::string("SDL_GL_LoadLibrary Error: ") + std::string(SDL_GetError());
SDL_Quit();
exit_error(err);
}
if (!lookup_all_glsyms())
{
std::ostringstream os;
os << "Couldn't load OpenGL symbols we need\n";
SDL_Quit();
exit_error(os.str());
}
#endif
loopDone = false; loopDone = false;
@ -596,11 +711,7 @@ bool Core::getKeyState(int k)
void Core::initJoystickLibrary() void Core::initJoystickLibrary()
{ {
#ifndef BBGE_BUILD_SDL2
#ifdef BBGE_BUILD_SDL2
SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER);
#else
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
detectJoysticks(); detectJoysticks();
#endif #endif
@ -693,41 +804,10 @@ void Core::setClearColor(const Vector &c)
} }
void Core::setSDLGLAttributes() bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, bool vsync, int bpp)
{ {
std::ostringstream os;
os << "setting vsync: " << _vsync;
debugLog(os.str());
#ifndef BBGE_BUILD_SDL2
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, _vsync);
#endif
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
}
bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync, int bpp, bool recreate)
{
static bool didOnce = false;
aspectX = width;
aspectY = height;
aspect = (aspectX/aspectY);
this->width = width;
this->height = height;
_vsync = vsync;
_fullscreen = fullscreen;
_bpp = bpp;
_hasFocus = false; _hasFocus = false;
#ifndef BBGE_BUILD_SDL2 #ifndef BBGE_BUILD_SDL2
#if !defined(BBGE_BUILD_MACOSX) #if !defined(BBGE_BUILD_MACOSX)
// have to cast away constness, since SDL_putenv() might be #defined to // have to cast away constness, since SDL_putenv() might be #defined to
@ -735,33 +815,24 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync
// when you try to pass a (const!) string literal here... --ryan. // when you try to pass a (const!) string literal here... --ryan.
SDL_putenv((char *) "SDL_VIDEO_CENTERED=1"); SDL_putenv((char *) "SDL_VIDEO_CENTERED=1");
#endif #endif
SDL_WM_SetCaption(appName.c_str(), appName.c_str());
#endif #endif
if (recreate)
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
{
exit_error(std::string("SDL Error: ") + std::string(SDL_GetError()));
}
#if BBGE_BUILD_OPENGL_DYNAMIC
if (SDL_GL_LoadLibrary(NULL) == -1)
{
std::string err = std::string("SDL_GL_LoadLibrary Error: ") + std::string(SDL_GetError());
SDL_Quit();
exit_error(err);
}
#endif
}
setWindowCaption(appName, appName);
initIcon(gScreen); initIcon(gScreen);
// Create window // Create window
setSDLGLAttributes(); std::ostringstream os;
os << "setting vsync: " << vsync;
debugLog(os.str());
#ifndef BBGE_BUILD_SDL2
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, vsync);
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
#ifdef _DEBUG
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS SDL_GL_CONTEXT_DEBUG_FLAG);
#endif
#endif
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
{ {
#ifdef BBGE_BUILD_SDL2 #ifdef BBGE_BUILD_SDL2
@ -787,6 +858,11 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync
SDL_Quit(); SDL_Quit();
exit(0); exit(0);
} }
debugLog("GL vendor, renderer & version:");
debugLog((const char*)glGetString(GL_VENDOR));
debugLog((const char*)glGetString(GL_RENDERER));
debugLog((const char*)glGetString(GL_VERSION));
#else #else
Uint32 flags = 0; Uint32 flags = 0;
flags = SDL_OPENGL; flags = SDL_OPENGL;
@ -802,79 +878,9 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync
exit_error(os.str()); exit_error(os.str());
} }
#endif #endif
#if BBGE_BUILD_OPENGL_DYNAMIC
if (!lookup_all_glsyms())
{
std::ostringstream os;
os << "Couldn't load OpenGL symbols we need\n";
SDL_Quit();
exit_error(os.str());
}
#endif
} }
setWindowCaption(appName, appName); initGraphics(width, height, fullscreen, vsync, bpp);
#ifdef BBGE_BUILD_SDL2
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(gScreen);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(gScreen);
if ((_vsync != 1) || (SDL_GL_SetSwapInterval(-1) == -1))
SDL_GL_SetSwapInterval(_vsync);
const char *name = SDL_GetCurrentVideoDriver();
SDL_SetWindowGrab(gScreen, SDL_TRUE);
#else
SDL_WM_GrabInput(grabInputOnReentry==0 ? SDL_GRAB_OFF : SDL_GRAB_ON);
char name[256];
SDL_VideoDriverName((char*)name, 256);
#endif
glViewport(0, 0, width, height);
glScissor(0, 0, width, height);
std::ostringstream os2;
os2 << "Video Driver Name [" << name << "]";
debugLog(os2.str());
SDL_ShowCursor(SDL_DISABLE);
SDL_PumpEvents();
for (int i = 0; i < KEY_MAXARRAY; i++)
{
keys[i] = 0;
}
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
glClearDepth(1.0); // Depth Buffer Setup
glDisable(GL_CULL_FACE);
glLoadIdentity();
glFinish();
setClearColor(clearColor);
clearBuffers();
showBuffer();
lib_graphics = true;
_hasFocus = true;
enumerateScreenModes();
if (!didOnce)
didOnce = true;
// init success // init success
return true; return true;
@ -1020,35 +1026,6 @@ bool Core::createWindow(int width, int height, int bits, bool fullscreen, std::s
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
#endif #endif
static void
bbgePerspective(float fovy, float aspect, float zNear, float zFar)
{
float sine, cotangent, deltaZ;
float radians = fovy / 2.0f * M_PI / 180.0f;
deltaZ = zFar - zNear;
sine = sinf(radians);
if ((deltaZ == 0.0f) || (sine == 0.0f) || (aspect == 0.0f)) {
return;
}
cotangent = cosf(radians) / sine;
GLfloat m[4][4] = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }
};
m[0][0] = (GLfloat) (cotangent / aspect);
m[1][1] = (GLfloat) cotangent;
m[2][2] = (GLfloat) (-(zFar + zNear) / deltaZ);
m[2][3] = -1.0f;
m[3][2] = (GLfloat) (-2.0f * zNear * zFar / deltaZ);
m[3][3] = 0.0f;
glMultMatrixf(&m[0][0]);
}
void Core::setPixelScale(int pixelScaleX, int pixelScaleY) void Core::setPixelScale(int pixelScaleX, int pixelScaleY)
{ {
@ -1090,32 +1067,27 @@ void Core::enable2DWide(int rx, int ry)
{ {
int vw = int(float(baseVirtualHeight) * (float(rx)/float(ry))); int vw = int(float(baseVirtualHeight) * (float(rx)/float(ry)));
core->enable2D(vw, baseVirtualHeight, 1); enable2D(vw, baseVirtualHeight, 1);
} }
else else
{ {
int vh = int(float(baseVirtualWidth) * (float(ry)/float(rx))); int vh = int(float(baseVirtualWidth) * (float(ry)/float(rx)));
core->enable2D(baseVirtualWidth, vh, 1); enable2D(baseVirtualWidth, vh, 1);
} }
} }
static void bbgeOrtho2D(float left, float right, float bottom, float top) static void bbgeOrtho2D(float left, float right, float bottom, float top)
{ {
glOrtho(left, right, bottom, top, -1.0, 1.0); glOrtho(left, right, bottom, top, -1.0, 1.0);
} }
void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale) void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale)
{ {
GLint viewPort[4];
glGetIntegerv(GL_VIEWPORT, viewPort);
glMatrixMode(GL_PROJECTION);
GLint viewPort[4]; glLoadIdentity();
glGetIntegerv(GL_VIEWPORT, viewPort);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float vw=0,vh=0; float vw=0,vh=0;
@ -1126,46 +1098,28 @@ void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale)
if (aspect >= 1.4f) if (aspect >= 1.4f)
{ {
vw = float(baseVirtualWidth * viewPort[3]) / float(baseVirtualHeight); vw = float(baseVirtualWidth * viewPort[3]) / float(baseVirtualHeight);
viewOffX = (viewPort[2] - vw) * 0.5f; viewOffX = (viewPort[2] - vw) * 0.5f;
} }
else if (aspect < 1.3f) else if (aspect < 1.3f)
{ {
vh = float(baseVirtualHeight * viewPort[2]) / float(baseVirtualWidth); vh = float(baseVirtualHeight * viewPort[2]) / float(baseVirtualWidth);
viewOffY = (viewPort[3] - vh) * 0.5f; viewOffY = (viewPort[3] - vh) * 0.5f;
} }
bbgeOrtho2D(0.0f-viewOffX,viewPort[2]-viewOffX,viewPort[3]-viewOffY,0.0f-viewOffY); bbgeOrtho2D(0.0f-viewOffX,viewPort[2]-viewOffX,viewPort[3]-viewOffY,0.0f-viewOffY);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
setupRenderPositionAndScale(); setupRenderPositionAndScale();
if (forcePixelScale || (pixelScaleX!=0 && core->width!=pixelScaleX) || (pixelScaleY!=0 && core->height!=pixelScaleY)) if (forcePixelScale || (pixelScaleX!=0 && core->width!=pixelScaleX) || (pixelScaleY!=0 && core->height!=pixelScaleY))
{ {
float widthFactor = core->width/float(pixelScaleX); float widthFactor = core->width/float(pixelScaleX);
float heightFactor = core->height/float(pixelScaleY); float heightFactor = core->height/float(pixelScaleY);
core->globalResolutionScale = Vector(widthFactor,heightFactor,1.0f); core->globalResolutionScale = Vector(widthFactor,heightFactor,1.0f);
setPixelScale(pixelScaleX, pixelScaleY); setPixelScale(pixelScaleX, pixelScaleY);
} }
setPixelScale(pixelScaleX, pixelScaleY); setPixelScale(pixelScaleX, pixelScaleY);
} }
void Core::quitNestedMain() void Core::quitNestedMain()
@ -1186,10 +1140,6 @@ void Core::resetTimer()
} }
} }
void Core::setDockIcon(const std::string &ident)
{
}
void Core::setMousePosition(const Vector &p) void Core::setMousePosition(const Vector &p)
{ {
Vector lp = core->mouse.position; Vector lp = core->mouse.position;
@ -1203,9 +1153,6 @@ void Core::setMousePosition(const Vector &p)
#else #else
SDL_WarpMouse( px * (float(width)/float(virtualWidth)), py * (float(height)/float(virtualHeight))); SDL_WarpMouse( px * (float(width)/float(virtualWidth)), py * (float(height)/float(virtualHeight)));
#endif #endif
} }
// used to update all render objects either uniformly or as part of a time sliced update process // used to update all render objects either uniformly or as part of a time sliced update process
@ -1365,17 +1312,7 @@ void Core::run(float runTime)
resetTimer(); resetTimer();
} }
debugLog("app back in focus, reset"); debugLog("app back in focus");
// Don't do this on Linux, it's not necessary and causes big stalls.
// We don't actually _lose_ the device like Direct3D anyhow.
#ifndef BBGE_BUILD_UNIX
if (_fullscreen)
{
// calls reload device - reloadDevice()
resetGraphics(width, height);
}
#endif
resetTimer(); resetTimer();
@ -1481,7 +1418,7 @@ void Core::clearBuffers()
void Core::setupRenderPositionAndScale() void Core::setupRenderPositionAndScale()
{ {
glScalef(globalScale.x*globalResolutionScale.x*screenCapScale.x, globalScale.y*globalResolutionScale.y*screenCapScale.y, globalScale.z*globalResolutionScale.z); glScalef(globalScale.x*globalResolutionScale.x, globalScale.y*globalResolutionScale.y, globalScale.z*globalResolutionScale.z);
glTranslatef(-(cameraPos.x+cameraOffset.x), -(cameraPos.y+cameraOffset.y), -(cameraPos.z+cameraOffset.z)); glTranslatef(-(cameraPos.x+cameraOffset.x), -(cameraPos.y+cameraOffset.y), -(cameraPos.z+cameraOffset.z));
} }

View file

@ -168,8 +168,6 @@ public:
bool cull; bool cull;
bool update; bool update;
int mode;
Vector color; Vector color;
protected: protected:
@ -225,8 +223,6 @@ public:
void cacheRender(); void cacheRender();
void setSDLGLAttributes();
void reloadResources(); void reloadResources();
void unloadResources(); void unloadResources();
@ -247,7 +243,7 @@ public:
void setMousePosition(const Vector &p); void setMousePosition(const Vector &p);
void toggleScreenMode(int t=0); void setFullscreen(bool full);
void enable2D(int pixelScaleX=0, int pixelScaleY=0, bool forcePixelScale=false); void enable2D(int pixelScaleX=0, int pixelScaleY=0, bool forcePixelScale=false);
void addRenderObject(RenderObject *o, int layer=0); void addRenderObject(RenderObject *o, int layer=0);
@ -286,11 +282,7 @@ public:
unsigned getTicks(); unsigned getTicks();
void resetGraphics(int w, int h, int fullscreen=-1, int vsync=-1, int bpp=-1); void initGraphics(int w, int h, int fullscreen=-1, int vsync=-1, int bpp=-1);
void setDockIcon(const std::string &ident);
Vector getGameCursorPosition(); Vector getGameCursorPosition();
Vector getGamePosition(const Vector &v); Vector getGamePosition(const Vector &v);
@ -311,15 +303,10 @@ public:
SoundManager *sound; SoundManager *sound;
float aspect;
int width, height; int width, height;
enum Modes { MODE_NONE=-1, MODE_3D=0, MODE_2D };
InterpolatedVector globalScale; InterpolatedVector globalScale;
Vector globalResolutionScale; Vector globalResolutionScale;
Vector screenCapScale;
virtual void onResetScene(){} virtual void onResetScene(){}
@ -404,6 +391,7 @@ public:
bool debugLogTextures; bool debugLogTextures;
void setup_opengl();
void setClearColor(const Vector &c); void setClearColor(const Vector &c);
Vector getClearColor(); Vector getClearColor();
int flipMouseButtons; int flipMouseButtons;
@ -418,16 +406,12 @@ public:
int overrideStartLayer, overrideEndLayer; int overrideStartLayer, overrideEndLayer;
void setWindowCaption(const std::string &caption, const std::string &icon);
ParticleEffect* createParticleEffect(const std::string &name, const Vector &position, int layer, float rotz=0); ParticleEffect* createParticleEffect(const std::string &name, const Vector &position, int layer, float rotz=0);
std::string secondaryTexturePath; std::string secondaryTexturePath;
bool hasFocus(); bool hasFocus();
float aspectX, aspectY;
float get_old_dt() { return old_dt; } float get_old_dt() { return old_dt; }
float get_current_dt() { return current_dt; } float get_current_dt() { return current_dt; }
@ -505,7 +489,7 @@ protected:
bool initSoundLibrary(const std::string &defaultDevice); bool initSoundLibrary(const std::string &defaultDevice);
bool initInputLibrary(); bool initInputLibrary();
void initJoystickLibrary(); void initJoystickLibrary();
bool initGraphicsLibrary(int w, int h, bool fullscreen, int vsync, int bpp, bool recreate=true); bool initGraphicsLibrary(int w, int h, bool fullscreen, bool vsync, int bpp);
void shutdownInputLibrary(); void shutdownInputLibrary();
void shutdownJoystickLibrary(); void shutdownJoystickLibrary();
void shutdownGraphicsLibrary(bool kill=true); void shutdownGraphicsLibrary(bool kill=true);

View file

@ -62,7 +62,7 @@ GL_FUNC(void,glTexSubImage2D,(GLenum target, GLint level, GLint xoffset, GLint y
GL_FUNC(void,glTranslatef,(GLfloat x, GLfloat y, GLfloat z),(x,y,z),) GL_FUNC(void,glTranslatef,(GLfloat x, GLfloat y, GLfloat z),(x,y,z),)
GL_FUNC(void,glVertexPointer,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer),(size,type,stride,pointer),) GL_FUNC(void,glVertexPointer,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer),(size,type,stride,pointer),)
GL_FUNC(void,glViewport,(GLint x, GLint y, GLsizei width, GLsizei height),(x,y,width,height),) GL_FUNC(void,glViewport,(GLint x, GLint y, GLsizei width, GLsizei height),(x,y,width,height),)
GL_FUNC(void,glScissor,(GLint x, GLint y, GLsizei width, GLsizei height),(x,y,width,height),) //GL_FUNC(void,glScissor,(GLint x, GLint y, GLsizei width, GLsizei height),(x,y,width,height),)
GL_FUNC(void,glBegin,(GLenum e),(e),) GL_FUNC(void,glBegin,(GLenum e),(e),)
GL_FUNC(void,glEnd,(void),(),) GL_FUNC(void,glEnd,(void),(),)
GL_FUNC(void,glEndList,(void),(),) GL_FUNC(void,glEndList,(void),(),)
@ -91,9 +91,8 @@ GL_FUNC(void,glVertex3i,(GLint x, GLint y, GLint z),(x,y,z),)
GL_FUNC(void,glGetIntegerv,(GLenum pname, GLint *params),(pname,params),) GL_FUNC(void,glGetIntegerv,(GLenum pname, GLint *params),(pname,params),)
GL_FUNC(const GLubyte *,glGetString,(GLenum name),(name),return) GL_FUNC(const GLubyte *,glGetString,(GLenum name),(name),return)
GL_FUNC(void,glGetTexLevelParameteriv,(GLenum target, GLint level, GLenum pname, GLint *params),(target,level,pname,params),) GL_FUNC(void,glGetTexLevelParameteriv,(GLenum target, GLint level, GLenum pname, GLint *params),(target,level,pname,params),)
GL_FUNC(void,glMultMatrixf,(const GLfloat *m),(m),) //GL_FUNC(void,glMultMatrixf,(const GLfloat *m),(m),)
GL_FUNC(void,glGetTexImage,(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels),(target,level,format,type,pixels),) GL_FUNC(void,glGetTexImage,(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels),(target,level,format,type,pixels),)
GL_FUNC(void,glTexImage1D,(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels),(target,level,internalFormat,width,border,format,type,pixels),) //GL_FUNC(void,glTexImage1D,(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels),(target,level,internalFormat,width,border,format,type,pixels),)
GL_FUNC(void,glTexImage2D,(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels),(target,level,internalFormat,width,height,border,format,type,pixels),) GL_FUNC(void,glTexImage2D,(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels),(target,level,internalFormat,width,height,border,format,type,pixels),)
GL_FUNC(void,glTexImage3D,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels),(target,level,internalformat,width,height,depth,border,format,type,pixels),) //GL_FUNC(void,glTexImage3D,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels),(target,level,internalformat,width,height,depth,border,format,type,pixels),)

View file

@ -34,8 +34,6 @@ RenderObjectLayer::RenderObjectLayer()
update = true; update = true;
optimizeStatic = false; optimizeStatic = false;
mode = Core::MODE_2D;
color = Vector(1,1,1); color = Vector(1,1,1);
displayListValid = false; displayListValid = false;