View Full Version : having a problem with fonts and abusive transparency-layers

02-26-2014, 10:17 AM
so basically, what I'm doing is taking advantage of depth testing...
but what happens is the textured display lists for the font's characters don't want to draw correctly:
they draw as non-textured quads until they're layered, and draw properly when they're supposed to be hidden

my GUI system is an advanced logic system that only processes and draws what's needed,
instead of having to go through everything. (the GUI manages itself, basically)
(yes, that means it uses the CPU)
^ I intend to port this to a shader in the next development

the fonts were just recently added, and the drawing system could be a bit better... (ignoring the drawing data that's hidden)

anyways... here's the code:

for lid in layer:


#print 'layer[%i]:'%lid
#print '%i stack layers:'%(sl+1)
for sid in l.stack: #the hash order shold already order as 0+ (0 being the BG, [-1] the FG)
#reverse the order (draw FG first at highest point then draw BG(s) behind FG)


#print ' stack[%i] - %i primitives:'%(n,len(sprimitives))
for spname in sprimitives:
#print ' "%s"'%spname
p=sprimitives[spname] #localize the primitive for easy reference
if p.isTri: __GL.glBegin(__GL.GL_TRIANGLES); __GL.glVertex3fv(p.v1+[d]); __GL.glVertex3fv(p.v2+[d]); __GL.glVertex3fv(p.v3+[d]); __GL.glEnd()
else: __GL.glBegin(__GL.GL_QUADS); __GL.glVertex3fv(p.v1+[d]); __GL.glVertex3fv(p.v2+[d]); __GL.glVertex3fv(p.v3+[d]); __GL.glVertex3fv(p.v4+[d]); __GL.glEnd()


#print ' font[%i] - %i strings:'%(oid,len(strings))
for ssname in sstrings:
#print ' "%s"'%sname
s=sstrings[ssname] #localize
if s.enabled:

xpos = 0.0
for list,w,h in s.lists:
if list!=None:
#print (s.x+xpos,s.y)



#print '%i ovarlay/font layers:'%len(l.overlay)
for oid in l.overlay:
#print ' overlay[%i] - %i primitives:'%(oid,len(oprimitives))
for opname in oprimitives:
#print ' "%s"'%opname
p=oprimitives[opname] #localize the primitive for easy reference
if p.isTri: __GL.glBegin(__GL.GL_TRIANGLES); __GL.glVertex2fv(p.v1); __GL.glVertex2fv(p.v2); __GL.glVertex2fv(p.v3); __GL.glEnd()
else: __GL.glBegin(__GL.GL_QUADS); __GL.glVertex2fv(p.v1); __GL.glVertex2fv(p.v2); __GL.glVertex2fv(p.v3); __GL.glVertex2fv(p.v4); __GL.glEnd()


#print ' font[%i] - %i strings:'%(oid,len(strings))
for osname in ostrings:
#print ' "%s"'%sname
s=ostrings[osname] #localize
if s.enabled:

xpos = 0.0
for list,w,h in s.lists:
if list!=None:
#print (s.x+xpos,s.y)



#for debugging: (draw the active HitDefs)
global showHitDefs,Widgets
if showHitDefs:
for wname in Widgets:
if HD.enabled:
x=HD.x; y=HD.y; X=HD.X; Y=HD.Y
__GL.glColor3f(1 if W.event.hasFocus else 0,1,0) #hitdef will be yellow if focused on
__GL.glVertex2f(x,y); __GL.glVertex2f(X,y)
__GL.glVertex2f(X,Y); __GL.glVertex2f(x,Y)

this is just what draws everything...

if you need the layer classes and initialization info (font display list generation),
let me know and I'll post it. ;)

the layer classes are for tracking the polygons (and now text) to be drawn.
the stack layer is drawn from top to bottom (this abuses transparency with depth testing)
the overlay layer draws over the stack layer and blends everything normally.

there used to be a font layer (seen in my previous screenshots of my program),
but for my 3rd time redoing the fonts system, the fonts got pushed to draw with the polygons.

why did I go through all this hastle of designing my own manager?
because the GL feedback buffer needs you to calculate everything twice,
where my system only needs you to calculate everything once.

I think I have noticed one thing though...
notice that overlain text by that one selection box that says "Grid",
it's supposed to say "Normals"...
but notice how the "No" doesn't display and the "rm" is slightly cut off by the button?
(I actually just noticed this)
that would be an issue with where d2 is used in the code I posted...
each letter is translated upward by .5 on the Z axis... oops

I'll post a screenshot when I fix that...
(just needs a translation before-hand)

but I'm posting about the black boxes that are supposed to be the characters...
those should be displaying their textures... >_>

and yes, I follow screen (W,H,D) standards (X,Y,Z) instead of (X,Z,Y) like most people do... (including MineCraft)
(the Depth buffer, is called the ZBuffer, not the YBuffer... get your facts straight people) lol

02-26-2014, 10:23 AM
I more than called exactly what would happen:

so... any ideas??

02-26-2014, 10:26 AM
YES I have an idea... and that is that I am an idiot >.<


ugh... why do I need to ask my questions to figure out my answers... >.<
why can't I just figure out my answers w/o asking my questions... >.<