From c7e2a69d91bf7caef54b77d880b06c3536e6823a Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Thu, 25 Jul 2013 19:26:45 +0100 Subject: [PATCH] [Change] Replaced unused and depricated gl_blitRotate with gl_blitScale. --- src/opengl.c | 44 +++++++++++++++++++++++++++++++------------- src/opengl.h | 6 +++--- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/opengl.c b/src/opengl.c index afa9c6c..a035af1 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -607,26 +607,44 @@ void gl_blitStaticSprite(const glTexture* sprite, const double bx, 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, +/* Like gl_blitStatic but scales to size. */ +void gl_blitScale(const glTexture* texture, const double bx, const double by, - const double dir, const glColour* c) { + const double bw, const double bh, const glColour* c) { double x, y; + double tw, th; + double tx, ty; - /* Calculate position - we'll use relative coords to player. */ - x = bx - VX(*gl_camera) - texture->sw/2. + gui_xoff; - y = by - VY(*gl_camera) - texture->sh/2. + gui_yoff; + /* Here we use absolute coords. */ + x = bx - (double)SCREEN_W/2.; + y = by - (double)SCREEN_H/2.; - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glRotated(dir, 0., 0., 1.); + /* Texture dimensions. */ + tw = texture->sw / texture->rw; + th = texture->sh / texture->rh; + tx = ty = 0.; - /* Blit. */ - gl_blitTexture(texture, x, y, 0, 0, c); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, texture->texture); + glBegin(GL_QUADS); + /* Set colour or default if not set. */ + if(c == NULL) glColor4d(1., 1., 1., 1.); + else COLOUR(*c); - glPopMatrix(); /* GL_PROJECTION. */ + glTexCoord2d(tx, ty); + glVertex2d(x, y); + + glTexCoord2d(tx+tw, ty); + glVertex2d(x+bw, y+bh); + + glTexCoord2d(tx, ty+th); + glVertex2d(x, y+bh); + glEnd(); + glDisable(GL_TEXTURE_2D); + + /* Anything failed? */ + gl_checkErr(); } /* Just straight out blit the thing at position. */ diff --git a/src/opengl.h b/src/opengl.h index 469e86b..03a7f37 100644 --- a/src/opengl.h +++ b/src/opengl.h @@ -81,10 +81,10 @@ 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, +/* Blit a texture scaled, absolure pos. */ +void gl_blitScale(const glTexture* texture, const double bx, const double by, - const double dir, const glColour* c); + const double bw, const double bh, const glColour* c); /* Blit the entire image, absolute pos. */ void gl_blitStatic(const glTexture* texture, const double bx, const double by,