[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] win32ui?



On 9/14/06, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
> Where is the "win32ui" module that PyOpenGl seems to require?

Brian Fisher wrote:
What is it that your code is trying to do when it is using that module?


It's in my font-rendering-in-OpenGL code, which is based off the Python version of the tutorial at:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13


The code there doesn't use Pygame at all, and is incomprehensible to me:

def BuildFont ():
	global base

	wgldc = wglGetCurrentDC ()
	hDC = win32ui.CreateDCFromHandle (wgldc)


base = glGenLists(96); # // Storage For 96 Characters

# CreateFont () takes a python dictionary to specify the requested font properties. font_properties = { "name" : "Courier New",
"width" : 0 ,
"height" : -24,
"weight" : 800
}
font = win32ui.CreateFont (font_properties)
# // Selects The Font We Want
oldfont = hDC.SelectObject (font)
# // Builds 96 Characters Starting At Character 32
wglUseFontBitmaps (wgldc, 32, 96, base)
# // reset the font
hDC.SelectObject (oldfont)


Or rather, I can tell it's building a set of 96 drawing lists using a font, but it's using this mysterious win32ui module to get the "drawing context," which apparently has to be of type "long." It doesn't accept pygame or the screen-surface or a Pygame-loaded font object as the "drawing context," so it's opaque to me.

I'm able to get OpenGL to draw rectangles on the screen in ortho mode, but can't get text to display since I can't load a font in the manner that seems to be needed.

Kris