void hrDrawBackground(void) { rndClearToBlack(); if (hrBackgroundTexture) { real32 x = -((real32)hrBackXSize / (real32)MAIN_WindowWidth); real32 y = -((real32)hrBackYSize / (real32)MAIN_WindowHeight); GLfloat v[8], t[8]; sdword oldTex = rndTextureEnable(TRUE); udword oldMode = rndTextureEnvironment(RTE_Replace); bool cull = glIsEnabled(GL_CULL_FACE) ? TRUE : FALSE; bool blend = glIsEnabled(GL_BLEND) ? TRUE : FALSE; glDisable(GL_CULL_FACE); glEnable(GL_BLEND); trClearCurrent(); glBindTexture(GL_TEXTURE_2D, hrBackgroundTexture); t[0] = 0.0f; t[1] = 0.0f; t[2] = hrBackXFrac; t[3] = 0.0f; t[4] = 0.0f; t[5] = hrBackYFrac; t[6] = hrBackXFrac; t[7] = hrBackYFrac; v[0] = primScreenToGLX(hrScaleMissionLoadingScreens ? feResRepositionScaledX(0) : feResRepositionCentredX(0)); v[1] = primScreenToGLY(hrScaleMissionLoadingScreens ? feResRepositionScaledY(0) : feResRepositionCentredY(0)); v[2] = primScreenToGLX(hrScaleMissionLoadingScreens ? feResRepositionScaledX(640) : feResRepositionCentredX(640)); v[3] = primScreenToGLY(hrScaleMissionLoadingScreens ? feResRepositionScaledY(0) : feResRepositionCentredY(0)); v[4] = primScreenToGLX(hrScaleMissionLoadingScreens ? feResRepositionScaledX(0) : feResRepositionCentredX(0)); v[5] = primScreenToGLY(hrScaleMissionLoadingScreens ? feResRepositionScaledY(480) : feResRepositionCentredY(480)); v[6] = primScreenToGLX(hrScaleMissionLoadingScreens ? feResRepositionScaledX(640) : feResRepositionCentredX(640)); v[7] = primScreenToGLY(hrScaleMissionLoadingScreens ? feResRepositionScaledY(480) : feResRepositionCentredY(480)); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, t); glVertexPointer(2, GL_FLOAT, 0, v); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); rndTextureEnvironment(oldMode); rndTextureEnable(oldTex); if (cull) glEnable(GL_CULL_FACE); if (!blend) glDisable(GL_BLEND); } }
void hrRectSolidTextured2(rectangle *rect) { glColor3ub(255, 255, 255); rndTextureEnvironment(RTE_Replace); rndTextureEnable(TRUE); glBegin(GL_QUADS); COORD(0.0f, 0.0f, rect->x0, rect->y0); COORD(0.0f, 1.0f, rect->x0, rect->y1 - 1); COORD(1.0f, 1.0f, rect->x1, rect->y1 - 1); COORD(1.0f, 0.0f, rect->x1, rect->y0); glEnd(); rndTextureEnable(FALSE); rndTextureEnvironment(RTE_Modulate); }
void hrRectSolidTextured2(rectangle *rect) { GLfloat t[8] = { 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f }; GLfloat v[8] = { primScreenToGLX(rect->x0), primScreenToGLY(rect->y1 - 1), primScreenToGLX(rect->x1), primScreenToGLY(rect->y1 - 1), primScreenToGLX(rect->x0), primScreenToGLY(rect->y0), primScreenToGLX(rect->x1), primScreenToGLY(rect->y0) }; glColor4f(1.0f, 1.0f, 1.0f, 1.0f); rndTextureEnvironment(RTE_Replace); rndTextureEnable(TRUE); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FLOAT, 0, v); glTexCoordPointer(2, GL_FLOAT, 0, t); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); rndTextureEnable(FALSE); rndTextureEnvironment(RTE_Modulate); }
/*----------------------------------------------------------------------------- Name : btgRender Description : renders the background. assumes modelview already set Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void btgRender() { udword nStar; sdword lightOn, index; GLboolean texOn, blendOn, depthOn; udword* dlast; udword* dnext; static sdword lastFade = 255; #if MR_KEYBOARD_CHEATS extern bool gMosaic; #endif if (btgHead == NULL) { #ifdef _WIN32 btgLoad("BTG\\default.btg"); #else btgLoad("BTG/default.btg"); #endif } #if MR_KEYBOARD_CHEATS glShadeModel(gMosaic ? GL_FLAT : GL_SMOOTH); #else glShadeModel(GL_SMOOTH); #endif glGetFloatv(GL_COLOR_CLEAR_VALUE, _bgColor); for (index = 0; index < 4; index++) { _bgByte[index] = (GLubyte)(_bgColor[index] * 255.0f); } dnext = (udword*)_bgByte; dlast = (udword*)lastbg; depthOn = glIsEnabled(GL_DEPTH_TEST); lightOn = rndLightingEnable(FALSE); texOn = glIsEnabled(GL_TEXTURE_2D); blendOn = glIsEnabled(GL_BLEND); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); rndAdditiveBlends(FALSE); if (useVBO) glBindBuffer(GL_ARRAY_BUFFER, vboTransVerts); //polys if (btgFade != lastFade || *dnext != *dlast) { if (btgFade < 0) { btgFade = 255; } #ifndef _WIN32_FIXME btgColorVertices(); #endif if (useVBO) glBufferData(GL_ARRAY_BUFFER, btgHead->numVerts * sizeof(btgTransVertex), btgTransVerts, GL_STATIC_DRAW); *dlast = *dnext; lastFade = btgFade; } //use DrawElements to render the bg polys glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); if (useVBO) { glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(btgTransVertex), 0); glVertexPointer(3, GL_FLOAT, sizeof(btgTransVertex), (GLvoid*)4); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndices); glDrawElements(GL_TRIANGLES, 3 * btgHead->numPolys, GL_UNSIGNED_SHORT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } else { glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(btgTransVertex), (GLubyte*)btgTransVerts); glVertexPointer(3, GL_FLOAT, sizeof(btgTransVertex), ((GLubyte*)btgTransVerts) + 4); glDrawElements(GL_TRIANGLES, 3 * btgHead->numPolys, GL_UNSIGNED_SHORT, btgIndices); } glDisableClientState(GL_COLOR_ARRAY); //stars rndPerspectiveCorrection(FALSE); rndAdditiveBlends(TRUE); trClearCurrent(); glEnable(GL_TEXTURE_2D); rndTextureEnvironment(RTE_Modulate); glEnableClientState(GL_TEXTURE_COORD_ARRAY); if (useVBO) { glBindBuffer(GL_ARRAY_BUFFER, vboTransStars); glVertexPointer(3, GL_FLOAT, sizeof(GLfloat) * 5, 0); glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat) * 5, (GLubyte*)sizeof(vector)); glBindBuffer(GL_ARRAY_BUFFER, 0); } else { glVertexPointer(3, GL_FLOAT, sizeof(GLfloat) * 5, (GLubyte*)btgTransStars); glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat) * 5, ((GLubyte*)btgTransStars) + sizeof(vector)); } for (nStar = 0; nStar < btgHead->numStars; nStar++) { if (btgStars[nStar].glhandle) { glColor4ub((GLubyte)btgStars[nStar].red, (GLubyte)btgStars[nStar].green, (GLubyte)btgStars[nStar].blue, (GLubyte)btgStars[nStar].alpha); glBindTexture(GL_TEXTURE_2D, btgStars[nStar].glhandle); glDrawArrays(GL_TRIANGLE_STRIP, nStar * 4, 4); } } glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_BLEND); rndAdditiveBlends(FALSE); rndLightingEnable(lightOn); if (texOn) glEnable(GL_TEXTURE_2D); if (blendOn) { glEnable(GL_BLEND); } else { glDisable(GL_BLEND); } glEnable(GL_CULL_FACE); if (depthOn) { glEnable(GL_DEPTH_TEST); } else { glDisable(GL_DEPTH_TEST); } }