I'm a beginner using OpenGL v3.3 on C# with SharpGL. I have a simple scene with a Skybox and some OBJ Models. Both the skybox and models have multiple textures. Currently what I do is that I load all the textures used in the scene into different texture units at once program launch and then while rendering each element in the scene I just change a uniform variable to reflect the correct texture unit and render the vertices. Doing this could get me into trouble if there are more textures in my scene than texture units on the GPU, so I'm not sure if this is the right approach.

I would like to know what the standard practice for such a scenario. Do you just (re)load the texture for each element into say fixed texture unit 0 on every draw call or what?


2 Answers 2


I'll post the answer as the question is related to my previous misunderstanding of how textures and texture units work.

  1. You can load as many Textures as you want into the OpenGL memory, all assigned to Texture Unit #0. OpenGL always returns a new handle for each of these textures.
  2. When applying the texture, you just have to bind to the appropriate handle via glBindTexture() and set the sampler to 0
  3. For most cases you don't need to use the other texture units, it's only really required when you want to blend more than one texture on the fly.

are you drawing your texture in the back buffer for updates but still storing the texture?

if the texture was destroyed from memory thin it will have to be reloaded in to the back buffer

are you changing the texture to a new texture?

draw the texture in to the back buffer so on next update there texture will update thin remove old texture from memory

  • \$\begingroup\$ I store the texture and don't change it. I don't have to change the scene elements so the textures are constant. I only load them into memory ONCE (reading to bitmap .. etc) and assign a texture unit for each. After that during the "draw" call I just switch between the texture units using a sampler uniform variable. I just want to know if this is the "usual" way of doing is since I am limited by the number of texture units available? What if there are more textures required, is it acceptable load it during the draw call? \$\endgroup\$
    – Sredni
    Commented Apr 18, 2015 at 1:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .