summaryrefslogtreecommitdiff
path: root/src/openglgraphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openglgraphics.cpp')
-rw-r--r--src/openglgraphics.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index d831d9ff..0b79e933 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -33,6 +33,8 @@
#include <SDL.h>
+#include <cmath>
+
#ifndef GL_TEXTURE_RECTANGLE_ARB
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
@@ -84,6 +86,8 @@ bool OpenGLGraphics::setVideoMode(int w, int h, bool fs)
int windowFlags = SDL_WINDOW_OPENGL;
+ mScale = getScale(w, h);
+
if (fs)
{
windowFlags |= SDL_WINDOW_FULLSCREEN;
@@ -108,7 +112,7 @@ bool OpenGLGraphics::setVideoMode(int w, int h, bool fs)
return false;
}
- SDL_SetWindowMinimumSize(window, 640, 480);
+ SDL_SetWindowMinimumSize(window, 640, 360);
SDL_GLContext glContext = SDL_GL_CreateContext(window);
if (!glContext) {
@@ -118,8 +122,8 @@ bool OpenGLGraphics::setVideoMode(int w, int h, bool fs)
mTarget = window;
mContext = glContext;
- mWidth = w;
- mHeight = h;
+ mWidth = w / mScale;
+ mHeight = h / mScale;
mFullscreen = fs;
if (mSync)
@@ -128,7 +132,7 @@ bool OpenGLGraphics::setVideoMode(int w, int h, bool fs)
}
// Setup OpenGL
- glViewport(0, 0, w, h);
+ glViewport(0, 0, mWidth * mScale, mHeight * mScale);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
int gotDoubleBuffer;
SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer);
@@ -162,8 +166,9 @@ void OpenGLGraphics::videoResized(int w, int h)
{
_endDraw();
- mWidth = w;
- mHeight = h;
+ mScale = getScale(w, h);
+ mWidth = w / mScale;
+ mHeight = h / mScale;
glViewport(0, 0, w, h);
@@ -745,12 +750,15 @@ bool OpenGLGraphics::pushClipArea(gcn::Rectangle area)
transX += mClipStack.top().xOffset;
transY += mClipStack.top().yOffset;
+ int x = (int) (mClipStack.top().x * mScale);
+ int y = (int) ((mHeight - mClipStack.top().y -
+ mClipStack.top().height) * mScale);
+ int width = (int) (mClipStack.top().width * mScale);
+ int height = (int) (mClipStack.top().height * mScale);
+
glPushMatrix();
glTranslatef(transX, transY, 0);
- glScissor(mClipStack.top().x,
- mHeight - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(x, y, width, height);
return result;
}
@@ -763,11 +771,14 @@ void OpenGLGraphics::popClipArea()
if (mClipStack.empty())
return;
+ int x = (int) (mClipStack.top().x * mScale);
+ int y = (int) ((mHeight - mClipStack.top().y -
+ mClipStack.top().height) * mScale);
+ int width = (int) (mClipStack.top().width * mScale);
+ int height = (int) (mClipStack.top().height * mScale);
+
glPopMatrix();
- glScissor(mClipStack.top().x,
- mHeight - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(x, y, width, height);
}
void OpenGLGraphics::setColor(const gcn::Color& color)