LWJGL Forum

Programming => OpenGL => Topic started by: IceReaper on October 13, 2016, 07:46:45

Title: Usage without GLFW?
Post by: IceReaper on October 13, 2016, 07:46:45
Currently using the nightly version from the download page.
Is there any way to get the OpenGL renderer working without using GLFW at all?
When using "GL.createCapabilities();" i get "There is no OpenGL context current in the current thread."
After some googling i found some posts about "GLContext.createFromCurrent();" but that class does not exist anymore as it seems.
Basically i want to archive to implement off-screen rendering, to mix OpenGL rendered output with JavaFX.
Or is there any other way currently to archive this?
Title: Re: Usage without GLFW?
Post by: Kai on October 13, 2016, 09:08:31
You need to have _some_ provider for an OpenGL context. LWJGL 3 itself does not create an OpenGL context by itself.
This is what GLFW does. The new GL.createCapabilities() is basically the old GLContext.createFromCurrent(). Neither of which do create an OpenGL context, but _assume_ that an OpenGL context is current in the calling thread, and then obtain the OpenGL functions from them.
The easiest thing to do is to still use GLFW but not making the window visible.
Title: Re: Usage without GLFW?
Post by: Cornix on October 13, 2016, 14:04:15
Why would you need LWJGL with JavaFX? As far as I understood JavaFX already uses OpenGL itself and exposes most of the OpenGL functionality to the user.
Title: Re: Usage without GLFW?
Post by: IceReaper on October 14, 2016, 08:04:28
Using a hidden GLFW window is the way i am currently going. However its somewhat ugly, as thats the only thing i need glfw for.

The currently LWJGL + JavaFX combination is due to the way im planning to build my game project. It relies highly on modability without the need to touch the java souce. In the case above i'm using JavaFX to render a WebView over the OpenGL output (copied into a WritableImage). The WebView is my implementation for an easy modable UI. It handles user input, is scriptable, is responsive, and can communicate with the attached Ui class to get data from the Game, or to send Input events to the Game. No more building/rebuilding bitmap fonts, or other black magic.

I tried a bunch of UI libraries, but nothing satisfied me. Thats when i came up with the webkit / WebView implementation idea. Its also the most easy way to implement and tweak Uis i can currently think of.
Title: Re: Usage without GLFW?
Post by: Kai on October 14, 2016, 08:56:35
Using an offscreen/hidden GLFW window is the preferred way to go.
Once GLFW supports creating OpenGL contexts from existing visuals/windows (https://github.com/glfw/glfw/issues/25) you could probably create an OpenGL context associated with your webkit/WebView/JavaFX window/component.