[PyOpenGL-Users] Instanced rendering of 2D textured quads
Brought to you by:
mcfletch
From: Robert K. <r.e...@du...> - 2013-12-13 12:50:29
|
Hi Guys, I've been trying to get my head around instanced rendering and failing. Currently I have the following: glPushMatrix() glMatrixMode(GL_MODELVIEW) glLoadIdentity() glEnable(GL_TEXTURE_2D) glBindTexture(GL_TEXTURE_2D, fbo.texture()) path=path.transformed(transform) for i, (vertices, codes) in enumerate(path.iter_segments()): if not len(vertices): continue x,y=vertices[-2:] glBegin(GL_QUADS) glTexCoord2f(0, 1); glVertex2f(x, y+height) glTexCoord2f(0, 0); glVertex2f(x, y) glTexCoord2f(1, 0); glVertex2f(x+width, y) glTexCoord2f(1, 1); glVertex2f(x+width, y+height) glEnd() if i==10000: break glDisable(GL_TEXTURE_2D) glPopMatrix() As you can see, this iteratively renders a texture from a frame buffer object (fbo) on to a quad of fixed size. The only variable here is the (x,y) position of the quad. I'm guessing that to render this using glDrawArraysInstanced I'm going to have to load the quad vertices into one VBO, the position vertices ((x,y) only, no z) into another and use a shader to apply the texture. I've tried multiple ways of doing this with result varying from blank windows, screwed up geometry for other elements, seg faults and machine crashes... all in all not a success! I'm wondering if anyone has an example of doing this (or can point me to one). I would really appreciate any help and/or suggestions you can give. Thanks, Rob The University of Dundee is a registered Scottish Charity, No: SC015096 |