I am newbie to OpenGL and I am trying to create a simple application that contains a viewport,3d model and display some text. I never used glut window and would like to use MFC window for the above functionality. The viewport and 3d model work fine but the given text is not being displayed. I have tested glutWindow based application in which the text display works. Since I dont want to use glutwindow in my application I avoided the following lines
glutInit(&argc, argv);
glutInitWindowSize (window_width, window_height);
glutInitWindowPosition (window_X_position, window_Y_position);
glutInitDisplayMode (GLUT_RGB);
glutCreateWindow (window_title);
glutDisplayFunc (display);
Only using MFC and OpenGL I have to display the text.
method 1:
/* glPushMatrix();
glRotatef( -25.0f, 0.0f, 1.0f, 0.0f );
glTranslatef( -2.5f, -0.7f, 0.0f );
lListBase( m_TextID );
glCallLists( 20, GL_UNSIGNED_BYTE, (const GLvoid*)"welcome" );
glPopMatrix();*/
method 2 :
void renderstring2d(char string[], float r, float g, float b, float x, float y)
{
glColor3f(r, g, b);
glRasterPos2f(x, y);
for(unsigned int i = 0; i < strlen(string); i++)
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, string[i]);
}
method 3 :
void renderstring3d(char string[], float r, float g, float b, float x, float y, float z)
{
glDisable(GL_LIGHTING);
glColor3f(r, g, b);
glRasterPos3f(x, y, z);
for(unsigned int i = 0; i < strlen(string); i++)
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, string[i]);
}
I tried all of the above methods and failed. Please help me to display text in OpenGL within an MFC application.
x
,y
,z
in yourrenderstring
functions? Better post the code that calls theserenderstring
functions to figure out. – elimad