LWJGL Rendering problem

Hello everyone! I am trying to learn LWJGL (OpenGL) and i have encountered a problem:
I am trying to make an editor for a Tilebased Map, so i want to make a menu that will open when i right-click any tile.

Check this images:

http://uploadimage.ro/images/23180354201860657379.png

http://uploadimage.ro/images/60472711453550609877.png

As you can see, when i render the menu (the black square that is on top of tiles), the grid doesn’t render anymore… I mean, it renders, but in black (the grid isn’t made from lines, is made of quads rendered with a transparent texture).

What can i do?

EDIT: The menu is rendered using this code:

glColor3f(0f, .5f, 0f);
		glBegin(GL_QUADS);
		    glVertex2f(x, y);
		    glVertex2f(x + width, y);
		    glVertex2f(x + width, y + height);
		    glVertex2f(x, y + height);
		glEnd();
		
		for(int i=0 ; i < buttons.size(); i++) {
			((Button) buttons.get(i)).renderButton();
		}

I’m not 100% sure, but I think that calling:

glColor3f(1f, 1f, 1f);

before drawing the grid should fix that…

I don’t need to use color in drawing of grids. They are textured quads.
Anyway, thanks for reply.

Also, i think that the problem is in the shader, because if you look closely, you can see that the green tiles get darker.


glEnable(GL_BLEND); 
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

They are getting darker because when you get to them in the code, the green shades of the texture are being drawn darker, as you set glColor3f(0f, .5f, 0f);

-0.5 being the green, no red or blue is drawn, thus the red textured grids are not drawn. glColour also affects the way textures are drawn… this can be useful for certain purposes such as 2d lighting systems etc.

It’s pretty likely that adding that code will make sure that the grid is drawn again…

I LOVE YOU! Thanks!

Textured surfaces are multiplied by the current color. Be sure to reset the color to white to ensure that your texture is rendered correctly! :wink:

Is there any way to use textures on the tiles and use normal colors (not textures) on menu? HOW? :expressionless:

glBindTexture(GL_TEXTURE_2D, ); That would unbind the texture, meaning only glColor is taken into consideration. glDisable(GL_TEXTURE_2D); also works but you have to enable it again. I just leave it enabled and unbind it instead.

Forgot the 0 in there: glBindTexture(GL_TEXTURE_2D, 0) :wink:


Keyboard kb = laptop.getKeyboard();
if(kb.isReliable()){
    kb.getMaker().giveNobelPrice(NobelPrizes.PEACE_PRIZE, "Prevented me from going to war with said maker");
}

Uh oh, watch out you’ve got some dead code in there :wink: :stuck_out_tongue: ;D

Don’t worry, the it’ll be optimized away anyway.