This is honestly one of the most perplexing bugs I’ve ever faced.
(For reference, I’m using a standard LWJGL/OpenGL set up)
So let me explain what I’m trying to make: a panel. Like the bottom of this image:
http://eportfolio.lagcc.cuny.edu/scholars/doc_sp10/eP_sp10/Gerard_Irizarry/Projects/pastoria_city/images/pkmn_images/battle%20screen%201.JPG
It’s a rectangle with a pretty border. (Two in this image.) Seems simple.
So I’m made a class for these panels. There’s not even any text drawn on them yet, just the border and the 1-colored rectangle to fill the middle
So I started off by making the border. This is accomplished with a texture, and my process of doing this is unimportant. Just know that I bind one texture and draw a bunch of quads from it. I got the border working first. I thought the hard part was over.
But then I tried to draw the colored rectangle that the border frames. And… nothing happened.
As is, here’s what the draw method looked like:
public void draw(){
glColor3f(red, green, blue);
glRecti(x, y, x+length, y+height);
glColor3f(1f, 1f, 1f);
someTexture.bind();
//an implementation for drawing the border which definitely works
}
And… Nothing showed up. I mean, the border was still being drawn correctly, so I’m definitely CALLING the draw() method, but I couldn’t see the 1 color rectangle.
I played around with this for a while. I tried drawing a quad by specifying 4 vertexes, and nothing worked. Then I tried this:
public void draw(){
someTexture.bind();
//an implementation for drawing the border which definitely works
glColor3f(red, green, blue);
glRecti(x, y, x+length, y+height);
glColor3f(1f, 1f, 1f);
}
And I saw something where the rectangle was supposed to be. It was a single-colored rectangle, but it was gray and transparent.
…?
I made a separate Java Project, and drew some rectangles there with no problem. Then a though crosses my mind:
“Am I still drawing a rectangle from a texture?”
So I changed the texture that makes up my border into pure red texture, and sure enough with the second implementation the panel was being filled with pure red. With the first implementation, there was once again no visible box.
So… What gives? How can I just draw a single colored rectangle when I’m also binding sprites? (I think that’s where the problem lies)
I hope I was clear enough.
Thanks