I want to create an OpenGL application which could show 2D text on the screen, which have to use a font.
I should like to do this without GLUT, and with pure OpenGL in Win32, so I have no glut function.
At the moment I use wglUseFontBitmaps method, and it displays the text fine and in the right font.
But when the beginning of the text becomes to much to the left (and only the beginning should disappear), the whole string disappears!
I don’t know what kind of thing I could do now, I hope someone could help me with my problem.
Thanks in advance,
Complete source (which has some unused functions because I use it as a default OpenGL start source) in attachments.
Also compiled version in attachments (so you could see the thing what’s going wrong)
Could you not just post some of the relevant drawing code rather than expecting very busy people to trawl around your source looking for your problem.
Oh… yes of course, here it is:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
static float f = 0;
f-=.0005f; // maybe you have to change this speed, but I used this because my computer isn't very fast
glColor3f(1.0f, 0.0f, 0.0f);
char* fmt = "Hello World, My name is Dennis";
vsprintf(text, fmt, ap);
glListBase(base - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
init (Initialize fonts):
base = glGenLists(96);
font = CreateFont(-12,
HFONT oldfont = (HFONT)SelectObject(g.hdc, font);
wglUseFontBitmaps(g.hdc, 32, 96, base);
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations