[Tutor] Re: Tutor digest, Vol 1 #1397 - 3 msgs

Noah Luken nluken@earthlink.net
Sun, 03 Feb 2002 15:58:23 -0500

Hi everyone,

I've been puzzling out python and opengl and trying to convert some of 
nehe's opengl tutorials to python, but I'm running into problems.  I've 
subscribed and written to the pyopengl list about a week or so ago with a 
question regarding GLU routines and nurbs, but haven't heard from 
anyone.  That question is *really* specific, and so I'm hesitant to post it 

The question for this group is a little less specific.  I'm trying to 
translate, as closely as possible, nehe's 13th tutorial:
http://nehe.gamedev.net/tutorials/lesson13.asp, which covers using 
bitmapped fonts.  Rather than using the standard GLUT routines (which 
provide pretty limited numbers and kinds of fonts) I wanted to use 
OpenGL.WGL.wglUseFontBitmaps(), win32ui, and win32com to convert fonts on 
my system to opengl-usable bitmaps.

the basic question is about the definition of the hDC, handles, and so on.

### begin code snippet...
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.WGL import *
from wxPython.wx import *  # don't know if all these are necessary
import win32ui, win32con   # not sure if win32con is needed
hDC = win32ui.CreateDC()  # could also be CreateDCFromHandle()
base = []
props = {"name":"Courier New",\

def BuildFont():
     global hDC, base
     base = glGenLists(96)
     font = win32ui.CreateFont(props)
     oldfont = hDC.SelectObject(font)
     SelectObject(hDC, oldfont)
the problems in the interactive shell are these:

 >>> oldfont = hDC.SelectObject(font)
Traceback (most recent call last):
   File "<pyshell#28>", line 1, in ?
     oldfont = hDC.SelectObject(font)
win32ui: Select font object failed

 >>> wglUseFontBitmaps(hDC,32,96,base)
Traceback (most recent call last):
   File "<pyshell#27>", line 1, in ?
TypeError: an integer is required

I might be getting in over my head here, trying to understand the 
intricacies of the drawing contexts and so forth.  I'm just trying to 
get  this simplest case (truetype fonts in opengl with python) to work.
Any help, references, emails of gurus, etc. would be mightily appreciated.

thanks everyone,
noah luken