Jump to content
  • Advertisement
Sign in to follow this  
Skol

OpenGL Binding textures through render pass w/ Python

This topic is 4420 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm new. Wasn't sure if I should go to beginner forum or opengl forum, but this seems right. I'm using pyogl, and made a rendering pass that looks like this:
for sectors in geometry.keys():
     for triangles in geometry[sectors]:
          glBegin(GL_TRIANGLES)
               for vertices in triangles:
                    glTexCoord2f(vertices[3],vertices[4])
                    glVertex3f(vertices[0],vertices[1],vertices[2])
           glEnd()

...which I'm very proud of (I'm new ;)) I'm assuming that glBindTexture binds the texture to each successive triangle, but I'm wondering if calling that method in this rendering pass (forever and ever) is unnecessary, and, if so, what can I do? Right now my geometry data looks like this: {"sector name":[[(x,y,z,u,v),(x,y,z,u,v),(x,y,z,u,v)][...]]} if the sector name becomes a texture, is that too much overhead, as glBindTexture will still be applied each loop? Or is this all dandy, and can I make the code:
for sectors in geometry.keys():
     for triangles in geometry[sectors]:
          glBindTexture(GL_TEXTURE_2D,data[0])
          glBegin(GL_TRIANGLES)
          for vertices in triangles:
               glTexCoord2f(vertices[3],vertices[4])
               glVertex3f(vertices[0],vertices[1],vertices[2])
          glEnd()

(geometry now looking like {"yada":[[texture,(x,y,z,u,v)...][...]]} )

Share this post


Link to post
Share on other sites
Advertisement
OpenGL is a state machine and whatever state you set (such as the currently bound texture) will stay that way until you change it. So bind the texture once and render everything that will use that texture, then bind the next texture and render everything which uses that one, etc.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!