GLDrawText()

BlitzMax Forums/OpenGL Module/GLDrawText()

Tom(Posted 2005) [#1]
I'm tinkering with GL again, what OpenGL settings might I be messing with that would cause Max2Ds GLDrawText to draw a black rectangle?


Chris C(Posted 2005) [#2]
try disabling textures, took me a while to figure out!!


skidracer(Posted 2005) [#3]
and if you call glBindTexture restore it afterwards


ckob(Posted 2005) [#4]
im having the same prob tom :P

I dont suppose anyone could provide a little example of what they mean?


Chris C(Posted 2005) [#5]
I usually do all my drawtext's at the end of my loop after
I've drawn everthing with a texture...
glDisable(GL_TEXTURE_2D)
gldrawtext "hello world",20,20
glEnable(GL_TEXTURE_2D)
rem from this point on no texture is bound



marksibly(Posted 2005) [#6]
Hi,

GLDrawText should save/restore any state changes it makes - ie: you shouldn't have to worry about current state etc before using it.

However, there are a lot of states that can affect it and we've probably missed some.

Could you please post some code that produces the black rectangle problem?


ckob(Posted 2005) [#7]
Mark,
I am using terrabits engine and started modifying it so its basically the same one. Most of the changes ive made so far are just getting rid of flushmem and the bglcreatecontext command.


Tom(Posted 2005) [#8]
Partialy fixed, text is white now but it's drawn on a black rectange still. I suspect it's an alpha thing somewhere.

This got my text back to white anyway

glActiveTextureARB(GL_TEXTURE0_ARB)
glClientActiveTextureARB(GL_TEXTURE0_ARB)

The code's pretty complex & messy, involves a fair bit of multitexturing and uses a lot of gl commands. I'll see if I can make a smaller example.


Tom(Posted 2005) [#9]
Ok, bit easier than I thought :)

GLGraphics 800,600,0,0, GL_BACKBUFFER | GL_DEPTHBUFFER
glClearColor(0.5, 0.5, 0.5, 0.0)
While Not KeyHit(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
	GLDrawText "BRL Rock",400,300
	Flip True
Wend



Chris C(Posted 2005) [#10]
lighting effects it too from memory (or used to...)


Tom(Posted 2005) [#11]
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

Fixes it, I was disabling GL_BLEND at the end of my drawing routine, oops!