Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5446 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

How exactly do bind texture, gentexture work, and glTexImage2D work? my thoughts right now is that gentexture tells opengl how many textures are going to be uploaded and what array you are going to use to index the textures. Once you upload the textures using glTexImage2d they are stored in memory. I thought that glbind would just tell opengl what texture you want to use in memory. It doesn''t seem to work this way. If i have an array of tiles with different textures i have to use the glTexImage2D before every draw for every tile. Peole say you only have to use that command once per texture. Now i don''t sort my tiles by texture or anything for that matter. I just draw the array. When people say don''t use the glteximage2d in every tile do they mean sort the array by texture and then for each texture draw the tiles with that texture and draw the next tiles that have the same texture and so on?

Share this post

Link to post
Share on other sites
glGenTextures gives you "handles" for unique texture objects. You can then bind these texture objects to a specific target (e.g. GL_TEXTURE_2D). Each target can have only one texture object bound to it at a time, and all texture-related calls affect the currently bound target.

So what you really need to be calling repeatedly is glBindTexture, not glTexImage2D. Otherwise, how are you telling OpenGL which texture to use?

Anyway, what people mean is that rather than creating a separate texture per tile, you should pack multiple tiles into a single texture, and use texture coordinates to access them.

Share this post

Link to post
Share on other sites

  • 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!