JIm's picture

texture mapping example question

As you will likely deduce, I am very new to OpenGL. I just completed my first (2D) project in the XNA arena and have decided that moving to OpenGL might be a better technology. Another similar post response suggested that OpenGL was a little more work than XNA and, I suspect the responder might be a master of the understatement :-) Anyway, I compiled the TextureMapping sample and it ran just fine. I then changed the code to reference a different image file and now all it displays is a white rectangle. I am assuming that the problem may be with the following four lines of sample code but, since I have been unable to find any examples explaining just what the parameters actually mean, I can't be too sure.

GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-0.6f, -0.4f);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(0.6f, -0.4f);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(0.6f, 0.4f);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-0.6f, 0.4f);

Can anyone tell me what might be the issue or, better yet, point me in a direction where I might find a tutorial in which no OpenGL knowledge is presumed? Thanks


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

The OpenGL wiki is a good in-depth resource: http://www.opengl.org/wiki/Texture_Mapping

Quote:

I then changed the code to reference a different image file and now all it displays is a white rectangle.

Call GL.GetError() once you load the texture and see what it returns. A white texture can mean one of two things:

  • an error occurred while loading the texture (e.g. using an image with non-power-of-two size on a card that doesn't support NPOT textures)
  • the texture was loaded correctly but texture mapping is not enabled