Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LWJGL Rendering problem  (Read 1633 times)
0 Members and 1 Guest are viewing this topic.
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Posted 2012-05-29 18:37:41 »

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:



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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
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();
      }

Getting a project done is by far the most hard thing in game development.
Offline Ciaran54

Junior Member


Medals: 4



« Reply #1 - Posted 2012-05-29 18:56:57 »

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

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


before drawing the grid should fix that...
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #2 - Posted 2012-05-29 19:03:23 »

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

1  
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.

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

Getting a project done is by far the most hard thing in game development.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ciaran54

Junior Member


Medals: 4



« Reply #3 - Posted 2012-05-29 19:24:57 »

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...
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #4 - Posted 2012-05-29 19:29:16 »

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!

Getting a project done is by far the most hard thing in game development.
Offline theagentd
« Reply #5 - Posted 2012-05-30 16:32:41 »

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

Myomyomyo.
Offline marcuiulian13

Senior Member


Medals: 5
Exp: 3 years



« Reply #6 - Posted 2012-06-02 00:36:10 »

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

Getting a project done is by far the most hard thing in game development.
Offline theagentd
« Reply #7 - Posted 2012-06-02 04:53:46 »

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.

Myomyomyo.
Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #8 - Posted 2012-06-02 05:26:10 »

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

Offline theagentd
« Reply #9 - Posted 2012-06-02 09:36:43 »

Forgot the 0 in there: glBindTexture(GL_TEXTURE_2D, 0) Wink
1  
2  
3  
4  
Keyboard kb = laptop.getKeyboard();
if(kb.isReliable()){
    kb.getMaker().giveNobelPrice(NobelPrizes.PEACE_PRIZE, "Prevented me from going to war with said maker");
}

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #10 - Posted 2012-06-02 11:16:19 »

Forgot the 0 in there: glBindTexture(GL_TEXTURE_2D, 0) Wink
1  
2  
3  
4  
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 Tongue Grin

Offline theagentd
« Reply #11 - Posted 2012-06-02 11:35:15 »

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

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!