Merge branch 'testing'

This commit is contained in:
Allanis 2013-07-23 12:13:45 +01:00
commit 11b31c9be7
5 changed files with 30 additions and 13 deletions

View File

@ -212,9 +212,11 @@ void nebu_render(const double dt) {
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
/* Compensate possible rubmle. */ /* Compensate possible rubmle. */
if(!paused) {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glTranslated(shake_pos.x, shake_pos.y, 0.); glTranslated(shake_pos.x, shake_pos.y, 0.);
}
/* Now render. */ /* Now render. */
glBegin(GL_QUADS); glBegin(GL_QUADS);
@ -235,6 +237,7 @@ void nebu_render(const double dt) {
glVertex2d(-SCREEN_W/2., SCREEN_H/2.); glVertex2d(-SCREEN_W/2., SCREEN_H/2.);
glEnd(); glEnd();
if(!paused)
glPopMatrix(); /* GL_PROJECTION */ glPopMatrix(); /* GL_PROJECTION */
/* Set values to defaults. */ /* Set values to defaults. */
@ -262,6 +265,8 @@ void nebu_renderOverlay(const double dt) {
/* Prepare the matrix. */ /* Prepare the matrix. */
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glTranslated(gui_xoff, gui_yoff, 0.);
if(!paused)
glTranslated(gui_xoff+shake_pos.x, gui_yoff+shake_pos.y, 0.); glTranslated(gui_xoff+shake_pos.x, gui_yoff+shake_pos.y, 0.);
/* Mask for area player can still see (partially). */ /* Mask for area player can still see (partially). */

View File

@ -936,6 +936,17 @@ int gl_init(void) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* Good blend model. */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* Good blend model. */
/* Set up the matrix. */ /* Set up the matrix. */
gl_defViewport();
/* Finishing touches. */
glClear(GL_COLOR_BUFFER_BIT); /* Must clear the buffer first. */
gl_checkErr();
return 0;
}
/* Reset viewport to default. */
void gl_defViewport(void) {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho(-SCREEN_W /2, /* Left edge. */ glOrtho(-SCREEN_W /2, /* Left edge. */
@ -944,13 +955,6 @@ int gl_init(void) {
SCREEN_H /2, /* Top edge. */ SCREEN_H /2, /* Top edge. */
-1., /* Near. */ -1., /* Near. */
1.); /* Far. */ 1.); /* Far. */
/* Finishing touches. */
glClear(GL_COLOR_BUFFER_BIT); /* Must clear the buffer first. */
gl_checkErr();
return 0;
} }
/* Clean up our mess. */ /* Clean up our mess. */

View File

@ -104,6 +104,7 @@ int gl_init(void);
void gl_exit(void); void gl_exit(void);
/* Misc. */ /* Misc. */
void gl_defViewport(void);
int gl_pot(int n); int gl_pot(int n);
int gl_isTrans(const glTexture* t, const int x, const int y); int gl_isTrans(const glTexture* t, const int x, const int y);
void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir); void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir);

View File

@ -58,9 +58,11 @@ static int spfx_base_load(char* name, int anim, char* gfx, int sx, int sy) {
SPFX_Base* cur; SPFX_Base* cur;
char buf[PATH_MAX]; char buf[PATH_MAX];
/* Create new effect. */
spfx_effects = realloc(spfx_effects, ++spfx_neffects*sizeof(SPFX_Base)); spfx_effects = realloc(spfx_effects, ++spfx_neffects*sizeof(SPFX_Base));
cur = &spfx_effects[spfx_neffects-1]; cur = &spfx_effects[spfx_neffects-1];
/* Fill it with the data. */
cur->name = strdup(name); cur->name = strdup(name);
cur->anim = (double)anim / 1000.; cur->anim = (double)anim / 1000.;
sprintf(buf, SPFX_GFX"%s", gfx); sprintf(buf, SPFX_GFX"%s", gfx);
@ -83,8 +85,11 @@ int spfx_get(char* name) {
return 0; return 0;
} }
/* Load/Unload. */ /* Load/Unload.
* TODO: make it customizable?
*/
int spfx_load(void) { int spfx_load(void) {
/* Standard explosion effects. */
spfx_base_load("ExpS", 400, "exps.png", 6, 5); spfx_base_load("ExpS", 400, "exps.png", 6, 5);
spfx_base_load("ExpM", 450, "expm.png", 6, 5); spfx_base_load("ExpM", 450, "expm.png", 6, 5);
spfx_base_load("ExpL", 500, "expl.png", 6, 5); spfx_base_load("ExpL", 500, "expl.png", 6, 5);
@ -207,6 +212,7 @@ void spfx_start(double dt) {
vect_pset(&shake_vel, shake_rad, vect_pset(&shake_vel, shake_rad,
-VANGLE(shake_pos) + (RNGF()-0.5) * M_PI); -VANGLE(shake_pos) + (RNGF()-0.5) * M_PI);
} }
/* The shake decays over time. */
shake_rad -= SHAKE_DECAY * dt; shake_rad -= SHAKE_DECAY * dt;
if(shake_rad < 0.) shake_rad = 0.; if(shake_rad < 0.) shake_rad = 0.;

View File

@ -498,6 +498,7 @@ unsigned int window_create(char* name, const int x, const int y,
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
toolkit = 1; /* Enable it. */ toolkit = 1; /* Enable it. */
pause_game(); pause_game();
gl_defViewport(); /* Reset the default viewport. */
} }
return wid; return wid;