static void do_bloom(CTexture* t) { glBindTexture(GL_TEXTURE_2D, 0); glViewport(0, 0, t->_size, t->_size); glCullFace(GL_BACK); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(true); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_FOG); glFogf(GL_FOG_START, RenderFogDistance() / 2); glFogf(GL_FOG_END, RenderFogDistance()); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); EntityRender(); CarRender(); LightRender(); glBindTexture(GL_TEXTURE_2D, t->_glid); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, t->_size, t->_size, 0); }
void RenderUpdate (void) { GLvector pos; GLvector angle; GLrgba color; int elapsed; frames++; do_fps (); glViewport (0, 0, WinWidth (), WinHeight ()); glDepthMask (true); glClearColor (0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_DEPTH_TEST); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (letterbox) glViewport (0, letterbox_offset, render_width, render_height); if (LOADING_SCREEN && TextureReady () && !EntityReady ()) { do_effects (EFFECT_NONE); SwapBuffers (hDC); return; } glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glShadeModel(GL_SMOOTH); glFogi (GL_FOG_MODE, GL_LINEAR); glDepthFunc(GL_LEQUAL); glEnable (GL_CULL_FACE); glCullFace (GL_BACK); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode (GL_TEXTURE); glLoadIdentity(); glMatrixMode (GL_MODELVIEW); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glLoadIdentity(); glLineWidth (1.0f); pos = CameraPosition (); angle = CameraAngle (); glRotatef (angle.x, 1.0f, 0.0f, 0.0f); glRotatef (angle.y, 0.0f, 1.0f, 0.0f); glRotatef (angle.z, 0.0f, 0.0f, 1.0f); glTranslatef (-pos.x, -pos.y, -pos.z); glEnable (GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //Render all the stuff in the whole entire world. glDisable (GL_FOG); SkyRender (); if (show_fog) { glEnable (GL_FOG); glFogf (GL_FOG_START, fog_distance - 100); glFogf (GL_FOG_END, fog_distance); color = glRgba (0.0f); glFogfv (GL_FOG_COLOR, &color.red); } WorldRender (); if (effect == EFFECT_GLASS_CITY) { glDisable (GL_CULL_FACE); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); glDepthFunc (false); glDisable(GL_DEPTH_TEST); glMatrixMode (GL_TEXTURE); glTranslatef ((pos.x + pos.z) / SEGMENTS_PER_TEXTURE, 0, 0); glMatrixMode (GL_MODELVIEW); } else { glEnable (GL_CULL_FACE); glDisable (GL_BLEND); } EntityRender (); if (!LOADING_SCREEN) { elapsed = 3000 - WorldSceneElapsed (); if (elapsed >= 0 && elapsed <= 3000) { RenderFogFX ((float)elapsed / 3000.0f); glDisable (GL_TEXTURE_2D); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); EntityRender (); } } if (EntityReady ()) LightRender (); CarRender (); if (show_wireframe) { glDisable (GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); EntityRender (); } do_effects (effect); //Framerate tracker if (show_fps) RenderPrint (1, "FPS=%d : Entities=%d : polys=%d", current_fps, EntityCount () + LightCount () + CarCount (), EntityPolyCount () + LightCount () + CarCount ()); //Show the help overlay if (show_help) do_help (); SwapBuffers (hDC); }
void hack_draw (xstuff_t * XStuff, double currentTime, float frameTime) { GLvector pos; GLvector angle; GLrgba color; int elapsed; incrementTickCount(frameTime * 1000); CameraUpdate (); EntityUpdate (); WorldUpdate (); TextureUpdate (); VisibleUpdate (); CarUpdate (); glViewport (0, 0, render_width, render_height); glDepthMask (true); glClearColor (0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_DEPTH_TEST); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (letterbox) glViewport (0, letterbox_offset, render_width, render_height); if (LOADING_SCREEN && TextureReady () && !EntityReady ()) { do_effects (EFFECT_NONE); return; } glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glShadeModel(GL_SMOOTH); glFogi (GL_FOG_MODE, GL_LINEAR); glDepthFunc(GL_LEQUAL); glEnable (GL_CULL_FACE); glCullFace (GL_BACK); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode (GL_TEXTURE); glLoadIdentity(); glMatrixMode (GL_MODELVIEW); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glLoadIdentity(); glLineWidth (1.0f); pos = CameraPosition (); angle = CameraAngle (); glRotatef (angle.x, 1.0f, 0.0f, 0.0f); glRotatef (angle.y, 0.0f, 1.0f, 0.0f); glRotatef (angle.z, 0.0f, 0.0f, 1.0f); glTranslatef (-pos.x, -pos.y, -pos.z); glEnable (GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //Render all the stuff in the whole entire world. glDisable (GL_FOG); SkyRender (); if (show_fog) { glEnable (GL_FOG); glFogf (GL_FOG_START, fog_distance - 100); glFogf (GL_FOG_END, fog_distance); color = glRgba (0.0f); glFogfv (GL_FOG_COLOR, &color.red); } WorldRender (); if (effect == EFFECT_GLASS_CITY) { glDisable (GL_CULL_FACE); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); glDepthFunc (false); glDisable(GL_DEPTH_TEST); glMatrixMode (GL_TEXTURE); glTranslatef ((pos.x + pos.z) / SEGMENTS_PER_TEXTURE, 0, 0); glMatrixMode (GL_MODELVIEW); } else { glEnable (GL_CULL_FACE); glDisable (GL_BLEND); } EntityRender (); if (!LOADING_SCREEN) { elapsed = 3000 - WorldSceneElapsed (); if (elapsed >= 0 && elapsed <= 3000) { RenderFogFX ((float)elapsed / 3000.0f); glDisable (GL_TEXTURE_2D); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); EntityRender (); } } if (EntityReady ()) LightRender (); CarRender (); if (show_wireframe) { glDisable (GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); EntityRender (); } do_effects (effect); }