Instanced rendering of 2D textured quads

Robert Kent <[email protected]> Fri, 13 Dec 2013 12:50:15 +0000
Newsgroups gmane.comp.python.opengl.user
Message-ID <CED0B305.1F44%[email protected]>
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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk

_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users