I just start to learn the OpenGL. I was confused by the Image and texture.
OpenGL Programming Guide
book. First we have vertex data and image data. We can use the image data as the texture or not. When not use as the texture. It's only can be use a background of the scene right. right
?) In terms of OpenGL an image is an array of pixel data in RAM. You can for instance load a smiley.tga in RAM using standard C functions, that would be an image. A texture is when the imagedata is loaded in video memory by OpenGL. This can be done like this:
GLuint *texID;
glGenTextures(1, (GLuint*)&texID);
glBindTexture(GL_TEXTURE_2D, texID);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, imagedata);
After the image has been loaded into video memory, the original imagedata in RAM can be free()ed. The texture can now be used by OpenGL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With