Advertisement

Trouble display things other then bitmaps

Started by March 03, 2002 09:41 PM
5 comments, last by NerdJNerdBird 22 years, 11 months ago
Basically i''m just having trouble displaying things, like fonts and lines. I can display them, but if blending is off they are just completely black and if blending is on you can''t see them at all.
  
	int level = 5;

	glLoadIdentity();
	glTranslatef(-ship.x, -ship.y, -30.0f);
	glColor4f(1.0f,1.0f,1.0f,1.0f);
	glBegin(GL_LINES);							glVertex2d(-level, level);			
		glVertex2d( level, level);					glVertex2d( level, level);					glVertex2d( level, -level);				    glVertex2d( level, -level);						glVertex2d( -level, -level);					glVertex2d( -level, -level);					glVertex2d( -level, level);				glEnd();		

  
With this code that is excatly what happens. A black outline box is displayed but I can hardly see it even when I changed its color to white its still black. If I turn blending on it completley goes away. I''m displaying it directly after everything too
I wish I could explain precisely what the problem is, but it seems there is some problem with using the OpenGL rasterization functions in glPrint() when texturing is enabled. Simply disable texturing before the call to glPrint() and re-enable it afterward (I tested this on your program). Also, the OpenGL superbible recommends staying away from wglUseFontBitmaps() entirely and creating your text from texture-mapped quads instead. It further suggests that you can use the windows GDI to render into a bitmap and put that bitmap on the texture-mapped quad.
Advertisement
If bleding is enabled, check your blending function, ie check what arguments are passed as parameters for glBlendFunc.

And you have to check if lighting is enabled.
If lighting is enabled, try to call glEnable(GL_COLOR_MATERIAL) and glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION) before glColor4f. If it works then you have to reconsider colouring : either disable lighting or enable color material or define normals or whatever.

If you''re using bitmap fonts, you have to call glColor BEFORE glRasterPos.
Aye chromebender I disabled texture mapping and it worked great, thanks! That has been bugging me for the last couple of days.

Vincoof I appreciate the input, I''m not using lighting so it wasn''t a problem :-).
Vincoof, that''s good general advice. I _think_ the problem in this case is the code to display a bitmap font uses the GDI, which doesn''t support alpha-blending.
Hehe. Scroll down the forums and take a gander at my post about timers. It would be extremely appreciated!
Advertisement
Doesn''t support alpha blending ?

Hmm.. do you mean that you can''t blend bitmap fonts ?
IMO you can.
In fact, I''m sure you can because I do it

This topic is closed to new replies.

Advertisement