Hello Guest

How to create a Clickable Button?

  • 3 Replies
  • 12429 Views
How to create a Clickable Button?
« on: October 13, 2014, 21:07:31 »
Hello,
I Development a 3D Survival Game(like Minecraft). I like a startMenu with Buttons Example:(Start Game, Options, Exit). I don't know to create a clickable button. And on Youtube I find nothing.
People can help me? Please?
(Sorry, for my bad English i come form Germany(Deutschland). And my English is not prefect)

*

Offline Cornix

  • *****
  • 488
Re: How to create a Clickable Button?
« Reply #1 on: October 14, 2014, 09:18:56 »
This has nothing to do with OpenGL.
OpenGL is used to render primitives. GUI components, like buttons, labels, etc, are all at a much higher level of abstraction. You usually need to program these kinds of things yourself.
One way might be to get the mouse coordinates and check whether they are within a certain area when a mouse button is pressed.

Re: How to create a Clickable Button?
« Reply #2 on: October 14, 2014, 09:31:51 »
ok, thank you!
Do you maybe have an example code for it?

*

Offline abcdef

  • ****
  • 336
Re: How to create a Clickable Button?
« Reply #3 on: October 14, 2014, 10:41:58 »
1) Read up on how to draw 2D objects on the screen using opengl (Plenty of these on the net, port to LWJGL if required)
2) Learn how to read mouse and keyboard events (http://www.lwjgl.com/wiki/index.php?title=LWJGL_Basics_2_(Input))
3) Combine 1 and 2 to build a button

or

Use an existing library

http://twl.l33tlabs.org/
http://nifty-gui.lessvoid.com/