Hello all, I’m new to the boards and new to OF.
I’ve been trying to learn some OF /openGL and encountered a problem along the way. When writing along with NeHe’s lesson #7 I didn’t want to go through all the code that was presented to be used for loading an image and instead used OF’s:
ofImage img; img.loadImage("test.bmp");
This way of loading an image seems much simpler and that’s exactly what OF is for right?
The tutorial then made a texture out of the image using this code:
glGenTextures(3, &texture); //first texture glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);
The last line of code describes a ‘TextureImage’.
Ofcourse I didn’t have a ‘TextureImage’ because I Loaded my image in a different way so I thougth I would alter the code like this:
glTexImage2D(GL_TEXTURE_2D, 0, 3, img.getWidth(),img.getHeight(),0,GL_RGB,GL_UNSIGNED_BYTE,img.getPixels());
The program does run like this but instead of seeing the right image/texture it shows a picture of what seems like evenly scattered pixels, almost as if the array with pixels is being fed to the glTexImage2D function but he doesn’t know how to place it right.
Now I could just use the code from the NeHe tutorial to load the image but I just don’t fully understand what all the code lines do… and I’de rather not type 50 lines of code without understanding what they’re about.
Hope anyone can help me!