[Change] A little opengl code cleanup.

This commit is contained in:
Allanis 2013-06-28 13:05:32 +01:00
parent 68833542be
commit 14fed140c3
3 changed files with 33 additions and 8 deletions

View File

@ -460,7 +460,7 @@ void gl_blitSprite(const glTexture* sprite, const double bx, const double by,
x = bx - VX(*gl_camera) - sprite->sw/2. + gui_xoff;
y = by - VY(*gl_camera) - sprite->sh/2. + gui_yoff;
/* Don't draw if offscreen. */
/* Check if inbounds. */
if((fabs(x) > SCREEN_W/2 + sprite->sw) ||
(fabs(y) > SCREEN_H/2 + sprite->sh))
return;
@ -473,6 +473,23 @@ void gl_blitSprite(const glTexture* sprite, const double bx, const double by,
gl_blitTexture(sprite, x, y, tx, ty, c);
}
/* Blit the sprite at pos (blits absolute position). */
void gl_blitStaticSprite(const glTexture* sprite, const double bx,
const double by, const int sx, const int sy, const glColour* c) {
double x, y, tx, ty;
x = bx - (double)SCREEN_W/2.;
y = by - (double)SCREEN_H/2.;
/* Texture coords. */
tx = sprite->sw*(double)(sx)/sprite->rw;
ty = sprite->sh*(sprite->sy-(double)sy-1)/sprite->rh;
/* Actual blitting. */
gl_blitTexture(sprite, x, y, tx, ty, c);
}
/* Like gl_blitSprite but will use the actual direction, for things that */
/* can just rotate around. */
void gl_blitRotate(const glTexture* texture,
@ -485,11 +502,6 @@ void gl_blitRotate(const glTexture* texture,
x = bx - VX(*gl_camera) - texture->sw/2. + gui_xoff;
y = by - VY(*gl_camera) - texture->sh/2. + gui_yoff;
/* Don't draw if offscreen. */
if((fabs(x) > SCREEN_W/2 + texture->sw) ||
(fabs(y) > SCREEN_H/2 + texture->sh))
return;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glRotated(dir, 0., 0., 1.);

View File

@ -74,6 +74,11 @@ void gl_freeTexture(glTexture* texture);
void gl_blitSprite(const glTexture* sprite, const double bx, const double by,
const int sx, const int sy, const glColour* c);
/* Blit a sprite, absolute position. */
void gl_blitStaticSprite(const glTexture* sprite,
const double bx, const double by,
const int sx, const int sy, const glColour* c);
/* Blits a texture rotated, relative pos. */
void gl_blitRotate(const glTexture* texture,
const double bx, const double by,

View File

@ -34,6 +34,9 @@
#define START_DATA "../dat/start.xml"
#define TARGET_WIDTH 128
#define TARGET_HEIGHT 96
/* Player stuff. */
Pilot* player = NULL; /* extern in pilot.h */
static Ship* player_ship = NULL; /* Temp ship to hold when naming it. */
@ -640,9 +643,8 @@ void player_render(void) {
/* Render the targetted pilot. */
if(j != 0) gui_renderPilot(pilot_stack[j]);
/* Player. */
/* The + sign in the middle of the radar represents the player. */
glBegin(GL_LINES);
/* Player. -- Drawn last. */
COLOUR(cRadar_player);
glVertex2d( 0., -3.);
glVertex2d( 0., 3.);
@ -726,7 +728,13 @@ void player_render(void) {
if(player_target != PLAYER_ID) {
p = pilot_get(player_target);
/* Blit the pilot target. */
gl_blitStatic(p->ship->gfx_target, gui.target.x, gui.target.y, NULL);
/* Blit the pilot space image. */
/*x = gui.target.x + (TARGET_WIDTH - p->ship->gfx_space->sw)/2.;
y = gui.target.y + (TARGET_HEIGHT - p->ship->gfx_space->sh)/2.;
gl_blitStaticSprite(p->ship->gfx_space,
x, y, p->tsx, p->tsy, NULL);*/
/* Target name. */
gl_print(NULL, gui.target_name.x, gui.target_name.y,