I'm new to OpenGL and I've been playing with LWJGL, and now Slick (since it provides some utilities for loading textures).
I was experiencing a very strange issue in my project, and I was able to reproduce it by slightly modifying the sample code from here:
http://lwjgl.org/wiki/index.php?title=Slick-Util_Library_-_Part_1_-_Loading_Images_for_LWJGL
Here's the code which produces the error:
http://pastie.org/5179268
The important changes are:
- line 81 (to specify a 16x16 solid red png)
- lines 113-193 (to draw a 100x100 white rectangle)
Here's the really strange thing.
- If I disable the texture loading (init()), skip drawing the texture, and go straight to drawing the white rectangle, I get what I expect: A white rectangle in the upper left corner. This is what it looks like: http://i.imgur.com/t4D8n.png
(Modified code here, which the texture loading/drawing disabled: http://pastie.org/5179294.)
- If I keep the texture loading/drawing, and then try to draw the same white rectangle, it draws a red rectangle instead.
So with this code http://pastie.org/5179268, I get this: http://i.imgur.com/bU5pp.png
- If I repeat step 2 with a 16x16 solid blue png, I get same result, except everything is blue instead of red.
Sample images:
blue - http://i.imgur.com/VjgR1.png
red - http://i.imgur.com/7DVqj.png
Anyone know why this is happening? It seems like some global state is being tainted, but I have no idea how to reset, clean, or avoid it. I've been banging my head against this for days, so any ideas would be greatly appreciated.
Thanks!