I get a strange problem with drawing stuff using bgl or blf if I have a material using the wire render setting in the GE. It only happens sometimes, seems to depend on when openGL gets around to rendering that material. I’ve been trying all night to fix it and haven’t made any progress. This affects BGUI as well since it draws using bgl (I’ve tested it). If anyone has any ideas as to how to fix it any help would be appreciated~
An example blend is included cleantest.zip (754 KB)
If you want to try it for yourself: make a scene with one obj, set the material type to wire, and attach the following script to an always sensor.
# open GL stuff # import stand alone modules from bgl import * import blf from bge import logic as logic from bge import render as render scene = logic.getCurrentScene() cont = logic.getCurrentController() owner = cont.owner def init(): """init function - runs once""" # create a new font object, use external ttf file font_path = logic.expandPath('//fonts/arial.ttf') # store the font indice - to use later logic.font_id = blf.load(font_path) scene.post_draw.append(write) def write(): """write on screen""" width = render.getWindowWidth() height = render.getWindowHeight() glMatrixMode(GL_PROJECTION) glPushMatrix() glLoadIdentity() gluOrtho2D(0, width, 0, height) glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() # try drawing a blue rectangle with 50% alpha glColor4f(0.0,0.0,1.0,0.5) # RGBA glRectf(width*0.5,height*0.5,width*0.75,height*0.75) # BLF drawing routine font_id = logic.font_id blf.position(font_id, (width * 0.2), (height * 0.3), 0) blf.size(font_id, 50, 72) # size,res glColor4f(0.0,1.0,0.0,1.0) # RGBA blf.draw(font_id, "some text") if not init in owner or owner["init"] == False: init() owner["init"] = True