void TinyGLRenderer::setupCameraPerspective(float pitch, float heading, float fov) { Renderer::setupCameraPerspective(pitch, heading, fov); // NOTE: tinyGL viewport implementation needs to be checked as it doesn't behave the same as openGL tglViewport(0, kTopBorderHeight, kOriginalWidth, kFrameHeight); tglMatrixMode(TGL_PROJECTION); tglLoadMatrixf(_projectionMatrix.getData()); tglMatrixMode(TGL_MODELVIEW); tglLoadMatrixf(_modelViewMatrix.getData()); }
void GfxTinyGL::drawSprite(const Sprite *sprite) { tglMatrixMode(TGL_TEXTURE); tglLoadIdentity(); tglMatrixMode(TGL_MODELVIEW); tglPushMatrix(); tglTranslatef(sprite->_pos.x(), sprite->_pos.y(), sprite->_pos.z()); TGLfloat modelview[16]; tglGetFloatv(TGL_MODELVIEW_MATRIX, modelview); // We want screen-aligned sprites so reset the rotation part of the matrix. for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (i == j) { modelview[i * 4 + j] = 1.0f; } else { modelview[i * 4 + j] = 0.0f; } } } tglLoadMatrixf(modelview); tglDisable(TGL_LIGHTING); tglBegin(TGL_POLYGON); tglTexCoord2f(0.0f, 0.0f); tglVertex3f(sprite->_width / 2, sprite->_height, 0.0f); tglTexCoord2f(0.0f, 1.0f); tglVertex3f(sprite->_width / 2, 0.0f, 0.0f); tglTexCoord2f(1.0f, 1.0f); tglVertex3f(-sprite->_width / 2, 0.0f, 0.0f); tglTexCoord2f(1.0f, 0.0f); tglVertex3f(-sprite->_width / 2, sprite->_height, 0.0f); tglEnd(); tglEnable(TGL_LIGHTING); tglPopMatrix(); }