PDA

View Full Version : Texture not showing up



CoolBeanJ
03-19-2011, 08:24 PM
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

McLeary
03-19-2011, 08:32 PM
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

CoolBeanJ
03-19-2011, 08:50 PM
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?

McLeary
03-19-2011, 09:12 PM
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

CoolBeanJ
03-19-2011, 09:19 PM
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.

Alfonse Reinheart
03-19-2011, 09:20 PM
I don't see any code setting up the texture environment.

CoolBeanJ
03-19-2011, 09:32 PM
Could you point me in the direction of where to do that?

I'm new at opengl.

CoolBeanJ
03-19-2011, 10:36 PM
Awesome got it working alot better now.

CoolBeanJ
03-20-2011, 01:02 AM
The only problem i have now is:

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

V-man
03-20-2011, 06:36 AM
Let's do a search in the Wiki for "non power of 2"

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