Jump to content
  • Advertisement
Sign in to follow this  
nitinjavakid

OpenGL Text Problem

This topic is 4723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have just started with OpenGL programming and am planning to make a 3D window. I wrote the following code: #include<gl/glut.h> void box(float length,float breadth,float thickness) { glBegin(GL_QUAD_STRIP); glVertex3f(0.0,0.0,0.0); glVertex3f(length,0.0,0.0); glVertex3f(0.0,0.0,thickness); glVertex3f(length,0.0,thickness); glVertex3f(0.0,breadth,thickness); glVertex3f(length,breadth,thickness); glVertex3f(0.0,breadth,0.0); glVertex3f(length,breadth,0.0); glVertex3f(0.0,0.0,0.0); glVertex3f(length,0.0,0.0); glEnd(); glBegin(GL_QUADS); glVertex3f(0.0,0.0,thickness); glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,breadth,0.0); glVertex3f(0.0,breadth,thickness); glVertex3f(length,0.0,0.0); glVertex3f(length,0.0,thickness); glVertex3f(length,breadth,thickness); glVertex3f(length,breadth,0.0); glEnd(); } void window(float width, float height) { glColor4f(0.0,1.0,0.1,1.0); box(width,height,0.07); glPushMatrix(); glTranslatef(width-0.1,height-0.1,-0.03); glColor4f(1.0,0,0,0.1); box(0.1,0.1,0.03); glPopMatrix(); glPushMatrix(); glTranslatef(0.1,height-0.1,-0.03); glColor3f(0.0,0.0,1.0); box(width-0.2,0.1,0.03); glPopMatrix(); glPushMatrix(); glTranslatef(0.0,height-0.1,-0.03); glColor3f(0.0,1.0,1.0); box(0.1,0.1,0.03); glPopMatrix(); } void render(void) { glViewport(0, 0, 400, 400); glClearColor(1.0,1.0,1.0,0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glColor4f(0.0,0.0,0.5,0.1); glRotatef(1,1.0,1.0,1.0); glRasterPos3f(0.0,0.0,1.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'N'); glPushMatrix(); glTranslatef(-0.5,-0.5,0.0); window(1.0,1.0); glColor4f(1.0,0.0,0.5,1.0); glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); glPopMatrix(); glutSwapBuffers(); } int main(int argc, char *argv[]) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(400,400); glutCreateWindow("nitin"); glutFullScreen(); glutDisplayFunc(render); glutIdleFunc(render); glutMainLoop(); return 0; } ////////////////////////////////////////////////////// But the problem is the small Text 'N' does not rotate with window as if it is actually embedded on the window.(ie. printed on the window) Plz Help. If i need to learn more things to achieve this plz show me the right path.

Share this post


Link to post
Share on other sites
Advertisement
The function glutBitmapCharacter() renders text as a bitmap onto the pixels of the screen. In other words, it does not support the kind of projection you would like to apply here.

I'd recommend looking at the nehe tutorial lesson #17 as a good place to learn texture mapped 2d fonts. (nehe is hosted right here on gamedev.net)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!