Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Okay so I want to create a main menu which includes several buttons and text fields, is there a built in library for LWJGL or would I use normal Swing and start a thread of the application?

Its a 2D game and I'm simply looking for a way of starting it from a menu rather than having it jump straight into game.

share|improve this question

put on hold as off-topic by Josh Petrie Sep 16 at 20:18

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

    
possible duplicate of Making a HUD/GUI with OpenGL (LWJGL) –  Byte56 Aug 8 '12 at 0:41

2 Answers 2

up vote 2 down vote accepted

As far as I know, there isn't a built in library for LWJGL, but there are several libraries using LWJGL.

I tried NiftyGui and TWL. TWL looks a bit easier and less messy to me, but both libraries need quiet a lot of time to get used to work with (i managed to make some simple UIs with NiftyGui, with TWL we are stuck in the theme creation...).

If you only need buttons, you can make something pretty quick by yourself. But input text boxes (where the player can enter text) require some more work.

My advice would be: Check what you want to do. Do you want a complex or a simple UI. Does it need many different controls (sliders, checkboxes, comboboxes, textfield, multiline textfield, dropdown etc.) or only a few. If you have a complex UI with many menus, settings, editable controls etc. I would look at either TWL or NiftyGui, as both libraries are used by many people and work pretty well (if you set them up correctly). If you only need some basic things like buttons and a text menu, I would implement a basic UI by yourself, as it could take more time getting used to something like TWL or NiftyGui, then implementing the basic things from scratch.

As Peter Taylor pointed out, feng gui could also be an alternative. Though it seems to be discontinued, it seems to have a solid base: http://www.fenggui.org

share|improve this answer
    
FengGUI is another option, although it's a couple of years since I used it so I don't know what state it's currently in. –  Peter Taylor Aug 11 '12 at 8:15
    
Oh yeah, I also read about feng gui, but never tried it, as it seems to be discontinued (last update on page is from 2009). There is a list of alternatives on the feng gui page. I add it to my answer. –  tom van green Aug 13 '12 at 8:42

This might be too late for you, but for the benefit of web searchers, I'll answer:

  1. Create an empty canvas (AWT).

  2. Set the size of the canvas to be equal to the LWJGL Display.

  3. Add the canvas to the Java Swing form. (There's a reason for this).

  4. Set the canvas as parent of the LWJGL Display using Display.setParent(canvasName);. (Remember you might also need to allow the display to be resizable.)

The reason for adding the canvas to the form before setting it as parent of the Display is that, the canvas needs to be drawable so it can be a parent of the the LWGL Display. Otherwise your program will crash with an error that no OpenGL context was found.

This official tutorial is a good reference.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.