PDA

View Full Version : Sprite won't display with it's texture



kamac496
07-05-2012, 05:45 AM
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:


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:


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.

Dan Bartlett
07-05-2012, 07:45 AM
One problem I can see is that you're using:

glUniform2i(uniform_myTexture,0,0);
Which should be:

glUniform1i(uniform_myTexture,0);
Perhaps that is causing another uniform to be overwritten or something.

kamac496
07-05-2012, 07:57 AM
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. :(