text color

Started by
3 comments, last by Phy 19 years ago
im trying go further on lesson 10. i've made walls stop you from going through them and built a couple of small rooms. i wanted to put some text on top that says simple world engine, but if it's black it doesn't show up well with my texture. i try to change the color and everything but the text changes. so thew is a colored tint. here is the draw part: -------------------------------------- int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View GLfloat x_m, y_m, z_m, u_m, v_m; GLfloat xtrans = -xpos; GLfloat ztrans = -zpos; GLfloat ytrans = -walkbias-0.25f; GLfloat sceneroty = 360.0f - yrot; int numtriangles; glRotatef(lookupdown,1.0f,0,0); glRotatef(sceneroty,0,1.0f,0); glTranslatef(xtrans, ytrans, ztrans); glBindTexture(GL_TEXTURE_2D, texture[filter]); numtriangles = sector1.numtriangles; // Process Each Triangle for (int loop_m = 0; loop_m < numtriangles; loop_m++) { glBegin(GL_TRIANGLES); glNormal3f( 0.0f, 0.0f, 1.0f); x_m = sector1.triangle[loop_m].vertex[0].x; y_m = sector1.triangle[loop_m].vertex[0].y; z_m = sector1.triangle[loop_m].vertex[0].z; u_m = sector1.triangle[loop_m].vertex[0].u; v_m = sector1.triangle[loop_m].vertex[0].v; glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); x_m = sector1.triangle[loop_m].vertex[1].x; y_m = sector1.triangle[loop_m].vertex[1].y; z_m = sector1.triangle[loop_m].vertex[1].z; u_m = sector1.triangle[loop_m].vertex[1].u; v_m = sector1.triangle[loop_m].vertex[1].v; glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); x_m = sector1.triangle[loop_m].vertex[2].x; y_m = sector1.triangle[loop_m].vertex[2].y; z_m = sector1.triangle[loop_m].vertex[2].z; u_m = sector1.triangle[loop_m].vertex[2].u; v_m = sector1.triangle[loop_m].vertex[2].v; glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); glEnd(); } // text---------------------------- glLoadIdentity(); glTranslatef(0.0f,0.0f,-0.15f); // Position The Text On The Screen glRasterPos2f(0.012f,0.057f); glColor3f(1.0f,0.5f,0.0f);// text color glPrint("Simple World Engine"); // Print GL Text To The Screen //------------- sorry im new i don't know how to put that in a block.
Advertisement
Quote:Original post by badbrad29
// text----------------------------
glLoadIdentity();
glTranslatef(0.0f,0.0f,-0.15f);
// Position The Text On The Screen
glRasterPos2f(0.012f,0.057f);
//glColor3f(0.1f,1.0f,0.0f);// text color
glPrint("B-Rad's Game Engine"); // Print GL Text To The Screen


After you use the glColor3f(0.1f,1.0f,0.0f); I think all you should have to do is reset the color to black again and it should be fine. So try this:
 // text----------------------------glLoadIdentity();glTranslatef(0.0f,0.0f,-0.15f); // Position The Text On The ScreenglRasterPos2f(0.012f,0.057f);glColor3f(0.1f,1.0f,0.0f);// text colorglPrint("B-Rad's Game Engine");	// Print GL Text To The ScreenglColor3f(0.0f,0.0f,0.0f); // color back to black now


If that does not work you will probabally then have to do this:
 // text----------------------------glDisable( GL_TEXTURE_2D );glLoadIdentity();glTranslatef(0.0f,0.0f,-0.15f); // Position The Text On The ScreenglRasterPos2f(0.012f,0.057f);glColor3f(0.1f,1.0f,0.0f);// text colorglPrint("B-Rad's Game Engine");	// Print GL Text To The ScreenglColor3f(0.0f,0.0f,0.0f); // color back to black nowglEnable( GL_TEXTURE_2D );


Give those a shot. To see how to post code, take a quick look towards the bottom of the FAQ [wink]. Good luck! And if none of that works, you may have to do something different with your text drawing.

- Drew
If, when changing the colour to black nothing shows up, try changing it to white instead (glColor3f(1,1,1)).
I think OpenGL defaults to white and if you set the colour to black your entire scene would just be black. I'm not sure though, just something to keep in mind.
it didn't work i don't know what's going on. i tried to figure out what the deal the code works with everything else just not with what's in lesson 10. It doesn't change the screen, but the text stays blaack any ideas why?
Same thing happens to me, I think that the problem is with wglBuildBitmapFonts. I run a scene from my game and render everything, then draw information using the code from NeHe's glPrint, and it's all sorts of different colors. With a bunch of tinkering around I finaly think that the text is using GL_LIGHTING with the last vertex's normals that I have drawn, but theres no way to disable it. I tried glDisable(GL_LIGHTING) and that didnt work, I disabled every light in my game after that and the text stays black. I think that somewhere in the list it stores a cmd to enable lighting.

This topic is closed to new replies.

Advertisement