Results 1 to 10 of 10

Thread: Texture not showing up

  1. #1
    Member Newbie
    Join Date
    Mar 2011
    Posts
    48

    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

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2010
    Location
    Brazil, Rio de Janeiro
    Posts
    147

    Re: Texture not showing up

    You need to set up some texture parameters, like

    Code :
    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

  3. #3
    Member Newbie
    Join Date
    Mar 2011
    Posts
    48

    Re: Texture not showing up

    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?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2010
    Location
    Brazil, Rio de Janeiro
    Posts
    147

    Re: Texture not showing up

    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

  5. #5
    Member Newbie
    Join Date
    Mar 2011
    Posts
    48

    Re: Texture not showing up

    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.

  6. #6
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,672

    Re: Texture not showing up

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

  7. #7
    Member Newbie
    Join Date
    Mar 2011
    Posts
    48

    Re: Texture not showing up

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

    I'm new at opengl.

  8. #8
    Member Newbie
    Join Date
    Mar 2011
    Posts
    48

    Re: Texture not showing up

    Awesome got it working alot better now.

  9. #9
    Member Newbie
    Join Date
    Mar 2011
    Posts
    48

    Re: Texture not showing up

    The only problem i have now is:

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

  10. #10
    V-man
    Guest

    Re: Texture not showing up

    Let's do a search in the Wiki for "non power of 2"

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

Similar Threads

  1. Texture not showing
    By BBeck1 in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 06-05-2016, 11:42 AM
  2. glGenerateMipmap is showing no texture
    By NightKn8 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-10-2013, 11:24 PM
  3. Texture not showing
    By shawn619 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-25-2012, 11:54 AM
  4. texture not showing
    By amoskoh in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 10-29-2004, 09:53 AM
  5. showing only part of a texture
    By 409er in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-27-2002, 01:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean