Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Sprite won't display with it's texture

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    2

    Sprite won't display with it's texture

    Hey there.

    It's been three days, other people tried to help me (on another forum), but it was no use.
    What I have is:

    A sprite & image class. You can use them in following way:

    Code :
    Image test_img("image.png");
    Sprite test_spr(5.0f,25.0f,test_img);
    test_spr.Draw();

    Sprite that should display along with it's texture. Instead, after I do this:

    Code :
    gl_FragColor = texture2D(mytexture,UV_coord) * color;

    in my fragment shader, gl_FragColor's RGBA is always 0.0. (So actual output after test_spr.Draw is nothing. When I add gl_FragColor[3] = 1.0 to the fragment shader, I get a black rectangle of the x, y, width and height it was supposed to be)
    I have checked and it's not a problem with color uniform (which takes it's values correctly).

    Also, I've used glGetError() everywhere I could - with no errors being reported.
    And also I've checked UV coordinates - they're 100% correct.

    There's not much left I could do... Therefore I post both classes in two separate links:

    Image class.

    http://pastebin.com/KwVtV1kn

    Sprite class.

    http://pastebin.com/ERW1qBTm


    Please help, because I've lost hope already.

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    456
    One problem I can see is that you're using:
    Code :
    [COLOR=#000000][FONT=Consolas]glUniform2i[/FONT][/COLOR][COLOR=#008000][FONT=Consolas]([/FONT][/COLOR][COLOR=#000000][FONT=Consolas]uniform_myTexture,[/FONT][/COLOR][COLOR=#0000DD][FONT=Consolas]0[/FONT][/COLOR][COLOR=#000000][FONT=Consolas],[/FONT][/COLOR][COLOR=#0000DD][FONT=Consolas]0[/FONT][/COLOR][COLOR=#008000][FONT=Consolas])[/FONT][/COLOR][COLOR=#008080][FONT=Consolas];[/FONT][/COLOR]
    Which should be:
    Code :
    [COLOR=#000000][FONT=Consolas]glUniform1i[/FONT][/COLOR][COLOR=#008000][FONT=Consolas]([/FONT][/COLOR][COLOR=#000000][FONT=Consolas]uniform_myTexture,[/FONT][/COLOR][COLOR=#0000DD][FONT=Consolas]0[/FONT][/COLOR][COLOR=#008000][FONT=Consolas])[/FONT][/COLOR][COLOR=#008080][FONT=Consolas];[/FONT][/COLOR]
    Perhaps that is causing another uniform to be overwritten or something.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    2
    Yep, I've spotted that few hours before and changed it to glUniform1i(uniform_myTexture,0);. (It was producing an error being given to me by glGetError)

    But still, it didn't help.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •