Re: [PyOpenGL-Users] VBO help and performance
Brought to you by:
mcfletch
|
From: Ian M. <geo...@gm...> - 2010-05-07 03:29:21
|
If your game is 2D, there will be no distortions with a Ortho matrix. Plus,
you'll be able to use actual screen pixel coordinates, like PyGame, (if you
use that) but it's not flipped. You can set your characters at z = 0, and
the foreground and background at 1 and -1.
Personally, I don't know how well OpenGL handles very small floats. My
guess would be a truncation. In any case, the Z-buffer doesn't have a
resolution fine enough to handle that except under very specific
circumstances (like your near plane is 0.00001 and your far plane is
0.00003. I don't recommend that.
The essentials of my 2D view class system, for Ortho projections. You clear
screen, use .set_view(), and draw:
class glLibInternal_glLibView():
def __init__(self,rect):
self.rect = list(rect)
self.x = rect[0]
self.y = rect[1]
self.width = rect[2]
self.height = rect[3]
self.size = [rect[2],rect[3]]
class glLibView2D(glLibInternal_glLibView):
def __init__(self,rect):
glLibInternal_glLibView.__init__(self,rect)
def set_view(self):
glViewport(*self.rect)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(self.rect[0],self.rect[0]+self.rect[2],self.rect[1],self.rect[1]+self.rect[3])
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
Ian
|