Texture not showing up

Hi i’ve been trying to get this texture to display on this quad for a long time and could use some help.

I’ve debuged the code and the pixel array seems to contain the right set. it is set up as red byte, green byte, blue byte, alpha byte.

If anyone can tell me what i’ve done wrong that would be great as i’m not sure what the problem is.
Thanks

You need to set up some texture parameters, like


glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

Take a look at glTextParameter

Thanks!

Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);

Displays nothing.

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

No change

Anything i might be doing wrong?

Did you set the four parameters?

Did your second code is your display function? If so, you are generating a new texture every frame. You need to generate the texture once and just bind it before any draw calls

The second lot of code is called a few times on each frame.

Are the parameterf commands ment to go in the init I just added them before the glTexImage2D.

I don’t see any code setting up the texture environment.

Could you point me in the direction of where to do that?

I’m new at opengl.

Awesome got it working alot better now.

The only problem i have now is:

How do i deal with texture which are not power of 2?

Let’s do a search in the Wiki for “non power of 2”

http://www.opengl.org/wiki/NPOT_Texture