summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application.cpp25
-rw-r--r--bulletpattern.cpp8
-rw-r--r--config.h21
3 files changed, 43 insertions, 11 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();
diff --git a/bulletpattern.cpp b/bulletpattern.cpp
index 7d16e71..5e3d93d 100644
--- a/bulletpattern.cpp
+++ b/bulletpattern.cpp
@@ -14,10 +14,10 @@ BulletPattern::BulletPattern() {
int k = 0;
for(float i = 0; i < M_PI * 16; i += 0.1) {
- bullets[k++] = 50.0 + cosf(i) * 5;
- bullets[k++] = 50.0 + sinf(i) * 5;
- bullets[k++] = cosf(i) / 100.0;
- bullets[k++] = sinf(i) / 100.0;
+ bullets[k++] = 0.5 + cosf(i) * 0.05;
+ bullets[k++] = 0.5 + sinf(i) * 0.05;
+ bullets[k++] = cosf(i);
+ bullets[k++] = sinf(i);
}
}
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..fdab6e2
--- /dev/null
+++ b/config.h
@@ -0,0 +1,21 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+namespace Config {
+ const unsigned int window_w = 1280;
+ const unsigned int window_h = 720;
+
+ const unsigned int viewport_x = 20;
+ const unsigned int viewport_y = 20;
+ const unsigned int viewport_w = 600;
+ const unsigned int viewport_h = 680;
+
+ const unsigned int viewport_overscan = 10;
+
+ const float viewport_aspect = float(viewport_h) / float(viewport_w);
+
+ const unsigned int fps_x = 641;
+ const unsigned int fps_y = 1;
+};
+
+#endif