From ef03e87306ff26c247ef530c172b6ccd9bc6d69e Mon Sep 17 00:00:00 2001 From: laochailan Date: Fri, 20 Jul 2012 21:24:12 +0200 Subject: [PATCH] Resolution independence --- src/global.h | 5 ++++- src/main.c | 2 +- src/stage.c | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/global.h b/src/global.h index e6cd92cb..ccea81f5 100644 --- a/src/global.h +++ b/src/global.h @@ -35,9 +35,12 @@ #define CONFIG_FILE "config" enum { + RESX = 800, + RESY = 600, + SCREEN_W = 800, SCREEN_H = 600, - + VIEWPORT_X = 40, VIEWPORT_Y = 20, VIEWPORT_W = 480, diff --git a/src/main.c b/src/main.c index 320f74e7..b212bbc3 100644 --- a/src/main.c +++ b/src/main.c @@ -64,7 +64,7 @@ int main(int argc, char** argv) { if(tconfig.intval[FULLSCREEN]) flags |= SDL_FULLSCREEN; - if((display = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 32, flags)) == NULL) + if((display = SDL_SetVideoMode(RESX, RESY, 32, flags)) == NULL) errx(-1, "Error opening screen: %s", SDL_GetError()); printf("-- SDL viewport\n"); diff --git a/src/stage.c b/src/stage.c index e25edab4..de419013 100644 --- a/src/stage.c +++ b/src/stage.c @@ -170,8 +170,11 @@ void draw_hud() { } void stage_draw(StageRule bgdraw, ShaderRule *shaderrules, int time) { - if(!tconfig.intval[NO_SHADER]) + if(!tconfig.intval[NO_SHADER]) { glBindFramebuffer(GL_FRAMEBUFFER, resources.fbg[0].fbo); + if(!global.menu) + glViewport(0,0,SCREEN_W,SCREEN_H); + } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(-(VIEWPORT_X+VIEWPORT_W/2.0), -(VIEWPORT_Y+VIEWPORT_H/2.0),0); @@ -241,7 +244,7 @@ void stage_draw(StageRule bgdraw, ShaderRule *shaderrules, int time) { if(!tconfig.intval[NO_SHADER]) { glBindFramebuffer(GL_FRAMEBUFFER, 0); - + glViewport(0,0,RESX,RESY); glPushMatrix(); if(global.plr.cha == Marisa && global.plr.shot == MarisaLaser && global.frames - global.plr.recovery < 0) glTranslatef(8*sin(global.frames),8*sin(global.frames+3),0);