Merge pull request #702 from Akz-/spritefix

GRIM: Fix regression in sprite drawing
This commit is contained in:
Einar Johan Trøan Sømåen 2013-01-01 20:36:40 -08:00
commit 024f273a26
2 changed files with 59 additions and 24 deletions

View File

@ -595,19 +595,37 @@ void GfxOpenGL::drawSprite(const Sprite *sprite) {
glEnable(GL_ALPHA_TEST);
glDisable(GL_LIGHTING);
float halfWidth = (sprite->_width / 2) * _scaleW;
float halfHeight = (sprite->_height / 2) * _scaleH;
if (g_grim->getGameType() == GType_MONKEY4) {
float halfWidth = (sprite->_width / 2) * _scaleW;
float halfHeight = (sprite->_height / 2) * _scaleH;
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-halfWidth, -halfHeight, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-halfWidth, +halfHeight, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(+halfWidth, +halfHeight, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(+halfWidth, -halfHeight, 0.0f);
glEnd();
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-halfWidth, -halfHeight, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-halfWidth, +halfHeight, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(+halfWidth, +halfHeight, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(+halfWidth, -halfHeight, 0.0f);
glEnd();
} else {
// In Grim, the bottom edge of the sprite is at y=0 and
// the texture is flipped along the X-axis.
float halfWidth = (sprite->_width / 2) * _scaleW;
float height = sprite->_height * _scaleH;
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(+halfWidth, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(+halfWidth, +height, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-halfWidth, +height, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-halfWidth, 0.0f, 0.0f);
glEnd();
}
glEnable(GL_LIGHTING);
glDisable(GL_ALPHA_TEST);

View File

@ -685,20 +685,37 @@ void GfxTinyGL::drawSprite(const Sprite *sprite) {
tglDisable(TGL_LIGHTING);
float halfWidth = (sprite->_width / 2) * _scaleW;
float halfHeight = (sprite->_height / 2) * _scaleH;
if (g_grim->getGameType() == GType_MONKEY4) {
float halfWidth = (sprite->_width / 2) * _scaleW;
float halfHeight = (sprite->_height / 2) * _scaleH;
tglBegin(TGL_POLYGON);
tglTexCoord2f(0.0f, 1.0f);
tglVertex3f(-halfWidth, -halfHeight, 0.0f);
tglTexCoord2f(0.0f, 0.0f);
tglVertex3f(-halfWidth, +halfHeight, 0.0f);
tglTexCoord2f(1.0f, 0.0f);
tglVertex3f(+halfWidth, +halfHeight, 0.0f);
tglTexCoord2f(1.0f, 1.0f);
tglVertex3f(+halfWidth, -halfHeight, 0.0f);
tglEnd();
} else {
// In Grim, the bottom edge of the sprite is at y=0 and
// the texture is flipped along the X-axis.
float halfWidth = (sprite->_width / 2) * _scaleW;
float height = sprite->_height * _scaleH;
tglBegin(TGL_POLYGON);
tglTexCoord2f(0.0f, 1.0f);
tglVertex3f(-halfWidth, -halfHeight, 0.0f);
tglTexCoord2f(0.0f, 0.0f);
tglVertex3f(-halfWidth, +halfHeight, 0.0f);
tglTexCoord2f(1.0f, 0.0f);
tglVertex3f(+halfWidth, +halfHeight, 0.0f);
tglTexCoord2f(1.0f, 1.0f);
tglVertex3f(+halfWidth, -halfHeight, 0.0f);
tglEnd();
tglBegin(TGL_POLYGON);
tglTexCoord2f(0.0f, 1.0f);
tglVertex3f(+halfWidth, 0.0f, 0.0f);
tglTexCoord2f(0.0f, 0.0f);
tglVertex3f(+halfWidth, +height, 0.0f);
tglTexCoord2f(1.0f, 0.0f);
tglVertex3f(-halfWidth, +height, 0.0f);
tglTexCoord2f(1.0f, 1.0f);
tglVertex3f(-halfWidth, 0.0f, 0.0f);
tglEnd();
}
tglEnable(TGL_LIGHTING);