I'm having a problem with my 3D engine that is written in Java and JOGL. I am using the NeHe texture mapping program as an example and I'm loading his sample png image in my current program. I can load the image just fine, but then all I can see in my world is blue, white, and a dark green.....? My world is very simple right now, just a box that I can fly around in and each side of the box is a diffrent color. I'm attaching the image to a glQuad, and that is the only place currently that loads or draws any textures at all. Anybody else have a simular problem with JOGL...?
thanks in advance,
Post your setup and drawing code. Do you have texturing enabled? Are you using lighting? Can you see the quad at all? If so what color is it? Does it look textured, even if the terxture is wrong? I assume from your description the blue white and green you see are the sides of the box, or is that on the quad? Maybe post a screenshot if you think it would help.
If you have lighting on, try turning it off until you get textures working. Make sure textures are enabled and you are loading the texture into opengl correctly. If you are enabling any opengl state you don't absolutely need, comment that out. If you don't see the quad at all, check the position of the quad and the modelview matrix, also check the winding of the verts. Try turning off backface culling or swaping the winding order. It's pretty easy to draw geometry backwards or in a place you aren't expecting.
Try generating a simple test texture. Fill an array with a single color or maybe a simple pattern. Then load that as your texture. If you can get that working then the problem is in your png loader.
If you can see the quad but it is the wrong color check your texture coords, make sure you are setting them and they make sense. Also check all your opengl texture state, try using default values.
If the quad is drawn and textured, but the texture is wrong, check your texture loading code. Check your unpack alignment settings. Check the pixel format you are using, make sure it matches your data. Some file formats are bgr instead of rgb, if this is the case with yours you'll need to swap the bytes or if your opengl implementation supports it you can use the bgr format.
This is going to sound really stupid, but I'm still really new to openGL. I was enabling texture mapping at the begining of my program and didn't disable it when I was drawing things that were not being texture mapped. Everything that was being drawn using the normal glColor3f functions had texture mapping enabled on them, but no points were specified. So basically, everything was being texture mapped with the one pixel at 0,0 of my default texture. thanks for the reply's guys, JDev