Jump to content
  • Advertisement

hellspawn198369

Member
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

122 Neutral

About hellspawn198369

  • Rank
    Newbie
  1. hellspawn198369

    2D text drawing in a 3D scene by resizing

    well, there can be a number of things causing your problems. One issue i had was translating the text into the screen using glTranslatef(0.0f,0.0f,-1.0f); to make shure it doesn't get clipped out of the final image. You also need to clear the depth buffer bit so the text remains on the top of the screen. (with that in mind, it's also a good idea to draw the text at the end of your drawing routine so it is on the top). also check your raster positions, and you might need to call glLoadIdentity(); . Hope that helps. -Steve
  2. hellspawn198369

    Using text in OpenGL

    allright, got it working. The solution was actually kinda simple. I added this code right before setting the color, raster position and calling the print command: /////////////////////////////////////////// //this is the testing ground for the text// glDisable(GL_TEXTURE_2D); glClear(GL_DEPTH_BUFFER_BIT); // Clear Depth Buffer so text will be on top of everything on the screen glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(0.0f,0.0f,-1.0f); // Move Text One Unit Into The Screen so it isn't cliped glColor3f(1.0f,1.0f,1.0f); // Position The Text On The Screen glRasterPos2f(-0.2f, 0.22f); glPrint(message); //////////////////////////////////////////// glFlush(); return TRUE; // Everything Went OK thanks for the help, i was thinking in the wrong direction before your sugestions. -Steve
  3. hellspawn198369

    OpenGL Using text in OpenGL

    I'm writing a simple game engine for openGL and i'm having some issues on text. I did some research on the subject, and i was able to implement the bitmap text algrathm from NEHE's Opengl tortutial, but it only works for a blank screen(ie, when there is no 3d drawing being done) Here's my code for drawing the scene(note, the everything up to this point has been initalized, including the buildfont and i've currently put the text output code at the bottom) int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { //bool once = false; //used for old movement st glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View clock_t time_elapsed; time_elapsed = clock(); GLfloat x_m, y_m, z_m, u_m, v_m; GLfloat xtrans = -xpos; GLfloat ztrans = -zpos; GLfloat ytrans = -headbob-0.4f; GLfloat sceneroty = 360.0f - yrot; int numpolygons; // if (once) //old movement style // { //glRotatef(lookupdown,1.0f,0,0);//rotates scene up and down //glRotatef(sceneroty,0,1.0f,0);//rotates scene right and left //glTranslatef(xtrans, ytrans, ztrans);//moves the scene to simulate camera movement // //once = false; // } glLoadIdentity(); gluLookAt( -xtrans, -ytrans, -ztrans, -xtrans-sin(yrot*piover180)*100,-tan(lookupdown*piover180)*100, -ztrans-cos(yrot*piover180)*100, 0.0, 1.0, 0.0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[1]); numpolygons = sector1.numpolygons; //create the world // Process Each polygon for (int loop_m = 0; loop_m < numpolygons; loop_m++) { if (loop_m == 2) glBindTexture(GL_TEXTURE_2D, texture[2]); if (loop_m == 3) glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); glNormal3f( 0.0f, 0.0f, 1.0f); x_m = sector1.polygon[loop_m].vertex[0].x; y_m = sector1.polygon[loop_m].vertex[0].y; z_m = sector1.polygon[loop_m].vertex[0].z; u_m = sector1.polygon[loop_m].vertex[0].u; v_m = sector1.polygon[loop_m].vertex[0].v; glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); x_m = sector1.polygon[loop_m].vertex[1].x; y_m = sector1.polygon[loop_m].vertex[1].y; z_m = sector1.polygon[loop_m].vertex[1].z; u_m = sector1.polygon[loop_m].vertex[1].u; v_m = sector1.polygon[loop_m].vertex[1].v; glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); x_m = sector1.polygon[loop_m].vertex[2].x; y_m = sector1.polygon[loop_m].vertex[2].y; z_m = sector1.polygon[loop_m].vertex[2].z; u_m = sector1.polygon[loop_m].vertex[2].u; v_m = sector1.polygon[loop_m].vertex[2].v; glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); x_m = sector1.polygon[loop_m].vertex[3].x; y_m = sector1.polygon[loop_m].vertex[3].y; z_m = sector1.polygon[loop_m].vertex[3].z; u_m = sector1.polygon[loop_m].vertex[3].u; v_m = sector1.polygon[loop_m].vertex[3].v; glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); glEnd(); } //glLoadIdentity(); for (int index = 0; index < 4; index++) { if (!painting[index].inventory) { glPushMatrix(); glTranslatef(painting[index].posx, 0, painting[index].posz); glRotatef(time_elapsed/5,0,1.0,0); glBindTexture(GL_TEXTURE_2D, 1); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glScaled(.5, .5, .1); glCallList(painting[index].id); glPopMatrix(); } } glDisable(GL_TEXTURE_2D); /////////////////////////////////////////// //this is the testing ground for the text// //glPushMatrix(); //tried to seprate the matrix, but that did nothing //glTranslatef(0.0f,0.0f,-1.0f); // Move One Unit Into The Screen glColor3f(1.0f,1.0f,1.0f); glRasterPos2f(-0.2f, 0.22f); // Position The Text On The Screen glPrint("Here's some Text!!"); //glPopMatrix(); //////////////////////////////////////////// glFlush(); return TRUE; // Everything Went OK } now, all the 3d drawing goes to plan, but there's no text. Does anyone have any suggestions?? -steve
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!