I did D3D for a "long" time now and am somewhat new to OpenGL (still at the basics)
What i am trying to do is:
> Load texture1, Load texture2
> Bind texture1 to texture unit 0, render some geometry
> Bind texture2 to texture unit 0, render some geometry
In short it doenst work as expected. The result is, that both geometry is rendered with texture2 on it. So i looked up the docs and they were stating:
So I spent some time on trial and erroring around and finally I activated texture unit 1 before loading texture 2 which yields the correct result if I bind at rendering texture1 to tex unit 0 and texture2 to tex uint 1. Binding both textures to tex unit 0 will render the geometry only with texture1.
Actually this feels like the instand I call glTexImage* when having bound a texture to a certain tex uint (texture2 at 0) the the data I loaded before that (texture1 at 0) gets discarded?
I'm not quite sure what that would mean. Is it ture, that I need to spend a tex uint for each texture??? I cannot believe that, this would suggest that my graphics card has a 96 (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) textures max limit (no way).
so here some snippets on how I (initially inteded to) do the loading and rendereing (both geometry gets rendered with texture2 on it):
glGenTextures (1, &tex); glBindTexture (cfg.GetBindFlag (), tex); glTexStorage2D(tex, cfg.GetMipLevel (), cfg.GetTextureFormat (), cfg.GetWidth (), cfg.GetHeight ()); glTexImage2D (cfg.GetBindFlag (), cfg.GetMipLevel (), cfg.GetTextureFormat (), cfg.GetWidth (), cfg.GetHeight (), 0, cfg.GetDataFormat (), cfg.GetDataType (), initdata);
glActiveTexture (_TexUnit); // _TexUnit is asserted as GL_TEXTURE0 + _TexUnitIndex glBindTexture (resource->GetBindFlag (), resource->GetGLID ()); // resource::_GLID is corresponds to names of texture1 and texture 2 glUniform1i (_Location, _TexUnitIndex); // _Location is the uniform sampler bindpoint in the shader, _TexUnitIndex is 0 in both rendering events _Sampler->Bind (_TexUnitIndex);
I actually conclude that I have to have missed something, the question is what? Hopefully some of you can point me a diretion.