Main Menu

Recent posts

#61
OpenGL / Error when creating window and...
Last post by aerodash - January 22, 2024, 23:33:54
Hello :)

I am trying to do all rendering on a separate thread.
What I am doing right now is the following:
glfwInit();
long handle = glfwCreateWindow(800, 600, "Demo", NULL, NULL);
new Thread(() -> {
  glfwMakeContextCurrent(handle);
  GL.createCapabilities();

  int shader = loadShaders();
  int vao = createVao();

  while (!glfwWindowShouldClose(handle)) {
    glUseProgram(shader);
    glBindVertexArray(vao);
    glDrawArrays(GL_TRIANGLES, 0, 3);

    glfwSwapBuffers(handle);
    glfwPollEvents();
  }
}).start();


With the above code, rendering works as I can see a triangle but the window is not responsive.
When moving or clicking on the window the process would stop responding.
#62
The January release of Area Zero (v0.8.0) is now available for download: https://ephemeraltechnicalarts.com/area-zero

Release Notes:
0.8.0 (01/18/2024)
  1.Ex Cancel routes expanded:
    a. Standing specials can be canceled into any other standing special for 2 blue meters.
    b. Special attacks tuned to accommodate new routes.
  2. Move lists now available for all characters through the pause menu.
  3. Universals established:
    a. Every character has a back + HP command normal.
    b. Every character can chain together their LP, HP and back + HP attacks.
    c. Every character's back + HP can cancel into special or super.
  4. Advanced tutorial mode added; Covers universals, cancels and Hold-to-Cancel feature.
  5. Credits screen added and Patrons are acknowledged.
  6. Richard's attack animations shaded and colored.
  7. Additional animations for Richard and Niven shaded and colored.
#63
That works, thanks.

Good to know about DriftFX.  Currently I'm just using framebuffer reads to put the graphics output into the JavaFX window and it works fine, but if I have time to rewrite the graphics backend of my project, it would be nice to have something more integrated.

For anyone else finding this, here's a bit more about what discovered with regards to the relationship between LWJGL, JavaFX, and MacOS:


  • * MacOS requires that all windowing operations happen on the first thread created.  This affects both JavaFX and the GLFW library that LWJGL uses to create windows and graphics contexts.  It gets tricky because both libraries need to be able to use that single thread for all of their windowing-related calls.
  • * JavaFX seems to manage this using some native code that ensures that the JavaFX application thread IS the first thread (so when that Java thread is "started" it's really just running within that first thread).  I'm not 100% sure this is correct, but it's the explanation most consistent with my testing and debugging efforts.
  • * Using -xStartOnFirstThread solves the problem for GLFW by making the Java main() method run on the first thread, but messes up JavaFX as it's no longer able to put the JavaFX application thread on the main thread.
  • * The solution is to NOT use xStartOnFirstThread and use glfw_async, as spasi suggested. I'm not sure entirely how this works, but I'm guessing that, like JavaFX, it has a way of injecting GLFW calls into the first thread.  In addition, my program waits until JavaFX is initialized to start the GLFW thread (which may or may not matter).
  • * An alternative that I had just got working before I saw spasi's response is to put all GLFW calls on the JavaFX application thread, i.e. by putting them in Platform.runLater.  If you do this, then you don't nee to use glfw_async.  Once you have a handle for the GLFW context, that handle can be safely used for most graphics commands on any thread (so the JavaFX thread won't be blocked by graphics operations).  I'm going with spasi's solution though, rather than this, as it also solves other threading issues I encountered.
#64
Lightweight Java Gaming Library / Re: LWJGL + JavaFX + MacOS
Last post by spasi - January 12, 2024, 18:40:36
Hey Michael,

Without -XstartOnFirstThread, you must use the async GLFW implementation for macOS. You can do that with Configuration.GLFW_LIBRARY_NAME.set("glfw_async"). This will let you use GLFW from a secondary thread.

I'm not sure how it's going to work with JavaFX though. I've given up on trying to support any kind of integration between JavaFX and GLFW and haven't tested such a configuration. The recommended solution, which doesn't require any interaction with GLFW, is DriftFX: https://github.com/eclipse-efx/efxclipse-drift
#65
I've also now tried updating to LWJGL 3.3.3.  With the latest version of LWJGL, it now seems that if -XstartOnFirstThread is used, JavaFX ALWAYS hangs / fails to launch the window, regardless of initialization order or thread (main vs. non-main).  However, if -XstartOnFirstThread is not used, glfwInit() crashes the program (even when called on the main thread).
#66
Lightweight Java Gaming Library / LWJGL + JavaFX + MacOS
Last post by Michael Tetzlaff - January 11, 2024, 23:31:50
Hi, I'm trying to get a project running on MacOS that uses LWJGL and JavaFX.  (This project has run successfully on MacOS a number of years ago, but I haven't tested it in several years, and significant development on the project has happened since then.)

I am currently trying this with LWJGL 3.0.0 and JavaFX 17 (version 17.0.2 from org.openjfx in Maven).  I was previously using LWJGL 3.0.0b and JavaFX 11 (11.0.2).

I am using the XstartOnFirstThread VM argument.  I am running LWJGL / GLFW on the main thread, and launching JavaFX in a separate thread.  I only need LWJGL for offscreen rendering; I'm not trying to create a visible window or poll events.

The basic problem is that it seems that between GLFW and JavaFX, whichever one I initialize second hangs forever on initialization. 

For instance, if I try the following, JavaFX launches fine, but glfwInit() hangs and never returns:

        log.info("Starting JavaFX UI");
        new Thread(() -> kintsugi3d.builder.javafx.MainApplication.launchWrapper("")).start();

        try
        {
            Thread.sleep(5000L);
        }
        catch (InterruptedException e)
        {
            throw new RuntimeException(e);
        }

        if ( glfwInit() != true )
        {
            throw new GLFWException("Unable to initialize GLFW.");
        }

        // finish initializing GLFW, never gets here


(The sleep for 5 seconds is excessive, but just wanted a quick hack to be relatively certain it wasn't a race condition.)

On the other hand, if I use the following code, glfwInit() returns successfully, but my JavaFX application is never created (presumably hanging somewhere in internal JavaFX code):

        if ( glfwInit() != true )
        {
            throw new GLFWException("Unable to initialize GLFW.");
        }


        log.info("Starting JavaFX UI");
        new Thread(() -> kintsugi3d.builder.javafx.MainApplication.launchWrapper("")).start();

        try
        {
            Thread.sleep(5000L);
        }
        catch (InterruptedException e)
        {
            throw new RuntimeException(e);
        }

        // finish initializing GLFW


Any help getting this to work, or even which way is most likely expected to work, would be appreciated.  As I said before, I'm pretty sure I got this to work in the past, but that was before a lot of additional development happened, and probably on different versions of Java/JavaFX/LWJGL/MacOS.
#67
LWJGL Documentation / Questions about Struct and Str...
Last post by p3dr0n - January 05, 2024, 23:40:08
Hello, everyone. I'm new here. I was kinda forced to create an account today because I found nothing that could help me with this thing.
I tried searching for tutorials, articles and videos but found nothing.
My problem regards implementing my own Struct<T> to use a StructBuffer<T>, as you might have guessed.
I got somewhere thanks to Netbeans complaints about methods I had to implement.


class Vertex extends Struct<Vertex> {
  public float x, y, z;
  public float u, v;
  
  protected Vertex(long l, ByteBuffer bb) {
    super(l, bb);
  }
  
  @Override
  protected Vertex create(long l, ByteBuffer bb) {
    // I really have no idea what to do here. Maybe read from bb using l?
    // Or use l to allocate something, but how?
  }

  @Override
  public int sizeof() {
    return 5 * Float.BYTES; // this makes sense
  }
}


I also don't have a glue if I need to do anything other than implementing Struct<Vertex>.create to get going.
Sorry to take your time and thank you for it. I also apologize for any misuse inside the forum.

Edit: Forgot to mention that I'm using lwjgl 3.3.3
Edit2: I just noted that there was a better "area" to post this. Sorry again...

#68
Lightweight Java Gaming Library / Re: Indie Fighting Game using ...
Last post by cpope9141 - December 20, 2023, 17:09:23
The December release of Area Zero (v0.7.0) is now available at www.EphemeralTechnicalArts.com !

Release Notes 0.7.0 (12/19/2023)
  -Tutorial mode added that covers all the basics:
    -Basic movements, dashing and running.
    -Blocking
    -Normal attacks
    -Evading
    -Grab and grab escape
    -Taunting
    -Special, EX special and super attacks.
  -Finished art assets for all of Richard's and Niven's special and super attacks.
  -Variant of Corporate HQ: Parking Garage (Night) added with unique background music.
  -Fixed audio bug in Violet's projectiles
  -Reset controller bindings on disconnect so that keyboard may be used as a fall back.
#69
Lightweight Java Gaming Library / Having program with OpenGL Fun...
Last post by Cordeku - December 19, 2023, 06:33:45
The function is createCapabilities();

I got a script from my friend and idk if Its required but I think it is so im a little scared.

TLDR: Fixed.
#70
Lightweight Java Gaming Library / LWJGL On Macos
Last post by joecqr - December 08, 2023, 22:15:02
Hello everyone,

I'm trying to compile a shader on macos but im getting some errors, I think this has to do that macos doen't support openpl, i saw in the system settings, it actually uses metal.
Im getting this error when i try to compile the shader
Error: vertex shader compilation failed
ERROR: 0:1: '' :  version '330' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:3: 'layout' : syntax error: syntax error


i saw there is lib called bgfx, but im not sure how to use it.

Is it possible to compile shader on mac that uses metal instead of opengl?

Thanks!