View Full Version : Understanding OpenGL 3 textures

12-23-2014, 02:52 PM
I recently began adventuring into the world of OpenGL 3.3 coming from a background of limited knowledge of OpenGL 1.1. I understand basic texture loading and usage, however, I can't seem to figure out how to use the texture in my shader. I know it may sound like a stupid question, but I can't find any resources on how to actually use them. Can somebody give me or link me to an example usage of a GL_TEXTURE_2D texture in a GLSL 3.3 shader?

12-23-2014, 11:56 PM

the basics are still the same ...
- you create a texture
- you fill it with your texture data
- you bind it ..
now 2 new thinks come along:
- you create a "sampler2d" variable in your shader
- you populate the value of it

somthing like:

glActiveTexture( GL_TEXTURE0 );
glBindTexture ( GL_TEXTURE_2D, textureId );
glUniform1i ( samplerLoc, 0 );

in the shader its like

uniform sampler2D mytexture;