[Fix] Fixed some issues introduced with the scaling.

This commit is contained in:
Allanis 2014-05-16 19:19:45 +01:00
parent 6758fd9393
commit a14034411e
2 changed files with 15 additions and 13 deletions

View File

@ -1188,20 +1188,22 @@ int gl_init(void) {
gl_screen.rw = SCREEN_W;
gl_screen.rh = SCREEN_H;
gl_screen.scale = 1.;
if((SCREEN_W < 640) && (SCREEN_W <= SCREEN_H)) {
gl_screen.scale = (double)gl_screen.w / 640.;
if((SCREEN_W < 600) && (SCREEN_W <= SCREEN_H)) {
gl_screen.scale = (double)gl_screen.w / 600.;
/* Must keep the proportion the same for the screen. */
gl_screen.w = (gl_screen.w * 640) / SCREEN_H;
gl_screen.rw = (gl_screen.rw * SCREEN_H) / 640;
gl_screen.h = 640;
gl_screen.w = (gl_screen.w * 600) / SCREEN_H;
gl_screen.rw = (gl_screen.rw * SCREEN_H) / 600;
gl_screen.h = 600;
}
else if((SCREEN_W < 640) && (SCREEN_W >= SCREEN_H)) {
gl_screen.scale = (double)gl_screen.h / 640.;
else if((SCREEN_W < 600) && (SCREEN_W >= SCREEN_H)) {
gl_screen.scale = (double)gl_screen.h / 600.;
/* Must keep the proportion the same for the screen. */
gl_screen.w = (gl_screen.w * 640) / SCREEN_H;
gl_screen.rw = (gl_screen.rw * SCREEN_H) / 640;
gl_screen.h = 640;
gl_screen.w = (gl_screen.w * 600) / SCREEN_H;
gl_screen.rw = (gl_screen.rw * SCREEN_H) / 600;
gl_screen.h = 600;
}
gl_screen.wscale = (double)gl_screen.w / (double)gl_screen.rw;
gl_screen.hscale = (double)gl_screen.h / (double)gl_screen.rh;
/* Handle setting the default viewport. */
gl_defViewport();
@ -1226,7 +1228,7 @@ void gl_defViewport(void) {
1.); /* Far. */
/* Take into account possible scaling. */
if(gl_screen.scale != 1.)
glScaled(gl_screen.scale, gl_screen.scale, 1.);
glScaled(gl_screen.wscale, gl_screen.hscale, 1.);
}
/**

View File

@ -41,6 +41,8 @@ typedef struct glInfo_ {
int rw; /**< Real window width. */
int rh; /**< Real window height. */
double scale; /**< Scale factor. */
double wscale; /**< Width scale factor. */
double hscale; /**< Height scale factor. */
int depth; /**< Depth in bpp. */
int r; /**< Amount of red bits. */
int g; /**< Amount of green bits. */
@ -60,8 +62,6 @@ extern glInfo gl_screen; /* Local structure set with gl_init etc. */
#define ACOLOUR(x,a) glColor4d((x).r, (x).g, (x).b, a) /**< Change colour and override alpha. */
/**
* @struct glTexture
*
* @brief Abstraction for rendering spritesheets.
*
* The basic unit all the graphic rendering works with.