summaryrefslogtreecommitdiff
path: root/application.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-05-17 21:48:32 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-05-17 21:48:32 +0200
commit9edb297bbd720daca3d3211d28d0a01e0a97c620 (patch)
tree492d28b0bd1abb14246c006253be49e10dc8ac31 /application.cpp
parent59a1f2052cb3abef7cbc24f8f9fde3ebc0db2275 (diff)
Added config.h.
Diffstat (limited to 'application.cpp')
-rw-r--r--application.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/application.cpp b/application.cpp
index 371ef2f..75fbb44 100644
--- a/application.cpp
+++ b/application.cpp
@@ -1,5 +1,7 @@
#include "application.h"
+#include "config.h"
+
#include "texturesdl.h"
#include <SDL/SDL_opengl.h>
@@ -104,7 +106,7 @@ Application::Application() {
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
// Get our surface
- surface = SDL_SetVideoMode(1280, 720, 32, flags);
+ surface = SDL_SetVideoMode(Config::window_w, Config::window_h, 32, flags);
if(!surface) {
throw(std::runtime_error("Video mode set failed"));
}
@@ -183,8 +185,12 @@ void Application::run() {
void Application::main_loop(unsigned int tick, unsigned int step) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glViewport(-10, -10, 660, 740);
- glScissor(0, 0, 640, 720);
+ glViewport(
+ Config::viewport_x - Config::viewport_overscan,
+ Config::viewport_y - Config::viewport_overscan,
+ Config::viewport_w + Config::viewport_overscan * 2,
+ Config::viewport_h + Config::viewport_overscan * 2);
+ glScissor(Config::viewport_x, Config::viewport_y, Config::viewport_w, Config::viewport_h);
glEnable(GL_SCISSOR_TEST);
glMatrixMode(GL_PROJECTION);
@@ -223,7 +229,12 @@ void Application::main_loop(unsigned int tick, unsigned int step) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(-10, 110, -10, 110, 0, 10);
+ glOrtho(
+ -float(Config::viewport_overscan) / float(Config::viewport_w),
+ 1.0 + float(Config::viewport_overscan) / float(Config::viewport_w),
+ -float(Config::viewport_overscan) / float(Config::viewport_h),
+ Config::viewport_aspect + float(Config::viewport_overscan) / float(Config::viewport_h),
+ 0, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -247,11 +258,11 @@ void Application::main_loop(unsigned int tick, unsigned int step) {
glUseProgram(0);
glDisable(GL_SCISSOR_TEST);
- glViewport(640, 0, 640, 720);
+ glViewport(0, 0, Config::window_w, Config::window_h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0, 100, 0, 100, 0, 10);
+ glOrtho(0, Config::window_w, 0, Config::window_h, 0, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -268,7 +279,7 @@ void Application::main_loop(unsigned int tick, unsigned int step) {
frames++;
}
snprintf(s, 0xff, "FPS: %.2f", fps);
- glRasterPos2f(1, 1);
+ glRasterPos2f(Config::fps_x, Config::fps_y);
font->Render(s);
SDL_GL_SwapBuffers();