tightens ogl state handling (also fixes unreadably thick text for stats display)

This commit is contained in:
tosh 2013-04-04 10:59:57 +02:00
parent 9046e5e89c
commit de4734d6fb
2 changed files with 15 additions and 12 deletions

View file

@ -527,8 +527,6 @@ void display(void)
{ {
PerfStat("display"); PerfStat("display");
glEnable (GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
@ -559,14 +557,12 @@ void display(void)
-myHead.getRenderPitch(), glm::vec3(1.0f,0.0f,0.0f)) ); -myHead.getRenderPitch(), glm::vec3(1.0f,0.0f,0.0f)) );
glLoadMatrixf( glm::value_ptr(fov.getWorldViewerXform()) ); glLoadMatrixf( glm::value_ptr(fov.getWorldViewerXform()) );
glRotatef(myHead.getRenderPitch(), 1, 0, 0);
glRotatef(myHead.getRenderYaw(), 0, 1, 0);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
if (::starsOn) { if (::starsOn) {
// should be the first rendering pass - w/o depth buffer / lighting
stars.render(fov); stars.render(fov);
} }
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@ -670,7 +666,11 @@ void display(void)
if (display_levels) serialPort.renderLevels(WIDTH,HEIGHT); if (display_levels) serialPort.renderLevels(WIDTH,HEIGHT);
// Display miscellaneous text stats onscreen // Display miscellaneous text stats onscreen
if (stats_on) display_stats(); if (stats_on) {
glLineWidth(1.0f);
glPointSize(1.0f);
display_stats();
}
// Draw number of nearby people always // Draw number of nearby people always
char agents[100]; char agents[100];

View file

@ -106,8 +106,8 @@ namespace starfield {
this->glUpload(n); this->glUpload(n);
} }
~Renderer() ~Renderer() {
{
delete[] _arrData; delete[] _arrData;
delete[] _arrTile; delete[] _arrTile;
delete[] _arrBatchCount; delete[] _arrBatchCount;
@ -119,8 +119,7 @@ namespace starfield {
void render(float perspective, void render(float perspective,
float aspect, float aspect,
mat4 const& orientation, mat4 const& orientation,
BrightnessLevel minBright) BrightnessLevel minBright) {
{
// fprintf(stderr, " // fprintf(stderr, "
// Stars.cpp: rendering at minimal brightness %d\n", minBright); // Stars.cpp: rendering at minimal brightness %d\n", minBright);
@ -479,6 +478,9 @@ namespace starfield {
// fprintf(stderr, "Stars.cpp: Batch #%d - %d stars @ %d\n", i, // fprintf(stderr, "Stars.cpp: Batch #%d - %d stars @ %d\n", i,
// _arrBatchOffs[i], _arrBatchCount[i]); // _arrBatchOffs[i], _arrBatchCount[i]);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
// setup modelview matrix (identity) // setup modelview matrix (identity)
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
@ -507,6 +509,7 @@ namespace starfield {
glBindVertexArray(0); glBindVertexArray(0);
glUseProgram(0); glUseProgram(0);
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
glDisable(GL_POINT_SMOOTH);
glPopMatrix(); glPopMatrix();
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPopMatrix(); glPopMatrix();