PDA

View Full Version : How to make decals



lavalamp
03-13-2002, 11:05 AM
I'm working on a charting tool in VB.
On a bar chart, I want to put the Y-value on the surface of the bar. The user can pick any font they want, so I do not have any pre-loaded font textures. My workaround is to do a DrawText call to a picturebox, then create a texture off it's hDC. Anway, when I try to alpha blend using dst_color/src_color, the text is not there. I've seen the pixels go into the texture buffer, so I know there are there. Here's some code...

Call glColor4f(1#, 1#, 1#, 1#)
Call glEnable(GL_TEXTURE_2D)
Call glGenTextures(1, aTex(0))
Call glBindTexture(GL_TEXTURE_2D, aTex(0))
Call glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
Call glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
Call glTexImage2D(GL_TEXTURE_2D, 0, 4, rText.Right, rText.Bottom, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, vByte(0, 0, 0))
Call glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR)
Call glEnable(GL_BLEND)
Call glDisable(GL_COLOR_MATERIAL)
glBegin GL_QUADS
Call glTexCoord2d(0#, 0#)
Call glVertex3f(lLeft, 0, z)
Call glTexCoord2d(1#, 0#)
Call glVertex3f(lLeft + lInc, 0, z)
Call glTexCoord2d(1#, 1#)
Call glVertex3f(lLeft + lInc, lH, z)
Call glTexCoord2d(0#, 1#)
Call glVertex3f(lLeft, lH, z)
glEnd

Note: right now, z is actually slightly in front of the surface, so I get a transparent plane - shouldn't the text be visible?. This code is inside a procedure which is called within a glNewList...glEndlist. vByte() is the texture, 0,x,y to 2,x,y = colors - 3,x,y = alpha value (0 for non-black, 1 for black)

thanks for any help