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

Re: [pygame] Re: GSoC



On Sat, Jan 22, 2011 at 3:48 PM, Sam Bull <sam.hacking@xxxxxxxx> wrote:
I only know a tiny bit of OpenGL, and I was wondering if anybody who
knows some OpenGL programming could answer a question, to help me
prepare.
       In order for me to produce these widgets in OpenGL, does OpenGL provide
functions to draw 2D shapes onto the screen in front of the 3D view
(like a HUD), or do these have to be drawn in 3D and anchored to the
camera or something?.

Thanks,
Sam Bull
Graphics hardware works by transforming points (vertices) by three matrices (model, view, projection, although OpenGL combines the model and view matrices).  Then, the points are connected by pixels (rasterization).  So yes, change the matrices, and you change how what you see works.


To do a 3D view:

glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(...)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

gluLookAt(...)

#draw world


To do a 2D view:

glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(...) or gluOrtho2D(...)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

#draw HUD


Ian