Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (775)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
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  
  LWJGUI - Application GUI Solution for LWJGL3  (Read 2428 times)
0 Members and 1 Guest are viewing this topic.
Offline orange451

JGO Kernel


Medals: 444
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Posted 2018-07-10 11:58:15 »

This is a project I've been working on off-and-on for the last couple months. I wanted to create a simple user-interface system that worked with LWJGL3 for my projects, but none existed. I wanted to keep it simple and designed similarly to JavaFX to reduce the overhead of learning another UI system.

Repository (Contains source, compiled version, and examples)

Features:
LayoutsControlsPanesMisc
VBoxButtonStackPaneLabel
HBoxCheckBoxSplitPaneFont
BorderPaneRadioButtonScrollPaneImage
GridPaneSegmentedButtonTabPaneImageView
MenuBarOpenGLPane
ContextMenuBlurPane
TextArea
CodeArea
ToolBar

Images:




Simple use-case example:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
package test;

import static org.lwjgl.glfw.GLFW.glfwInit;
import static org.lwjgl.glfw.GLFW.glfwTerminate;

import java.io.IOException;

import org.lwjgl.glfw.GLFW;

import lwjgui.LWJGUI;
import lwjgui.LWJGUIUtil;
import lwjgui.scene.Scene;
import lwjgui.scene.Window;
import lwjgui.scene.control.Label;
import lwjgui.scene.layout.StackPane;

public class HelloWorld {
   public static final int WIDTH   = 320;
   public static final int HEIGHT  = 240;

   public static void main(String[] args) throws IOException {
      if ( !glfwInit() )
         throw new IllegalStateException("Unable to initialize GLFW");

      // Create a standard opengl 3.2 window. You can do this yourself.
      long window = LWJGUIUtil.createOpenGLCoreWindow("Hello World", WIDTH, HEIGHT, true, false);
     
      // Initialize lwjgui for this window
      Window lwjguiWindow = LWJGUI.initialize(window);
     
      // Add some components
      addComponents(lwjguiWindow.getScene());
     
      // Game Loop
      while (!GLFW.glfwWindowShouldClose(window)) {
         // Render GUI
         LWJGUI.render();
      }
     
      // Stop GLFW
      glfwTerminate();
   }

   private static void addComponents(Scene scene) {
      // Create a simple pane
      StackPane pane = new StackPane();
     
      // Set the pane as the scenes root
      scene.setRoot(pane);
     
      // Put a label in the pane
      pane.getChildren().add(new Label("Hello World!"));
   }
}


If there's any questions on how to use this I will gladly answer them.

CSS Styling is not yet supported. It is planned for the future, but I want to work on core functionality first.

Caveats:
  • Deprecated OpenGL (OpenGL 2) is not fully supported
  • This is designed to work with a standard render-loop setup. LWJGUI does not handle your render loop for you.
  • LWJGUI's render method will loop through every initialized window, set the current context to it, and begin drawing it's UI elements. There is a convenience method to hook your own manual drawing at the start of a window draw inside the Window class. See OpenGLExample.java. After drawing it will swap the buffers unless you set the flag to false.

First Recon. A java made online first person shooter!
Offline KaiHH

JGO Kernel


Medals: 636



« Reply #1 - Posted 2018-07-11 07:12:54 »

It'd be absolutely fantastic if it was API-compatible with Swing (modulo package names) so that one could use WindowBuilder to design the GUI graphically and then just change some package names (so that your classes will be used instead of Swing's) and voilĂ .
Offline orange451

JGO Kernel


Medals: 444
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #2 - Posted 2018-07-11 13:49:49 »

That's what I was going for, but with JavaFX. I preserved the same package and class names.

First Recon. A java made online first person shooter!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SHC
« Reply #3 - Posted 2018-07-11 14:19:00 »

@KaiHH But what is wrong with Gluon Scene Builder? I think it is more easy to use than the Swing GUI Builder.

Offline princec

« JGO Spiffy Duke »


Medals: 1059
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2018-07-11 14:53:55 »

Yep, the Gluon scene builder is a nice tool. But it is rather geared towards JavaFX.

Cas Smiley

Offline lacombej

Junior Devvie


Medals: 12
Projects: 1



« Reply #5 - Posted 2018-07-17 15:46:06 »

Really cool project. I'm gonna clone and take a deeper look at it but from what I've seen it looks really interesting. I've been working on a UI on my own but I'd rather contribute to an existing UI library if you need any help.

I made a topic here of what I worked on: http://www.java-gaming.org/topics/abstract-user-interface-implementation-with-lwjgl/38729/view.html
There's also LEGUI which I think might interest you: http://www.java-gaming.org/topics/legui-gui-library-for-lwjgl/38565/view.html
Offline orange451

JGO Kernel


Medals: 444
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #6 - Posted 2018-07-19 00:13:50 »

Update log of the last few days:

- Fixed issue where text of length 0 would crash under the new version of LWJGL
- Added ability to set whether LWJGUI will automatically call swap buffers after drawing (default is true)
- Added setGraphic() method to MenuItem
- Implemented Toolbar
- Increased Performance of node positioning (especially SplitPane)

First Recon. A java made online first person shooter!
Offline Spasi
« Reply #7 - Posted 2018-07-19 23:05:58 »

- Fixed issue where text of length 0 would crash under the new version of LWJGL

Thanks, this has been fixed in 3.1.7 snapshot 10.
Offline orange451

JGO Kernel


Medals: 444
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #8 - Posted 2018-07-26 00:04:32 »

Updates from the last few days:
  • Linked icon sizes in Labeled Objects to the text size
  • Text Boxes will force their size to a tab pane if they are too large
  • Rewrote event system to be lambda friendly (All old event code you wrote must be updated)
  • Implemented MouseClick event
  • Implemented Mouse icon for Split Pane Dividers
  • Implemented editable field in TextInputControl objects
  • Implemented a setFlipY() method in OpenGLPane

Also started using this library to work on another one of my projects:

First Recon. A java made online first person shooter!
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1869 views)
2018-06-10 19:43:48

EgonOlsen (1901 views)
2018-06-10 19:43:44

EgonOlsen (1258 views)
2018-06-10 19:43:20

DesertCoockie (1703 views)
2018-05-13 18:23:11

nelsongames (1378 views)
2018-04-24 18:15:36

nelsongames (2002 views)
2018-04-24 18:14:32

ivj94 (2753 views)
2018-03-24 14:47:39

ivj94 (1955 views)
2018-03-24 14:46:31

ivj94 (3045 views)
2018-03-24 14:43:53

Solater (1090 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!