1212 *
1313 * The above copyright notice and this permission notice shall be included in all
1414 * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
1523 */
1624
1725package overrungl .vulkan ;
1826
27+ import org .lwjgl .system .Configuration ;
1928import overrungl .util .MemoryStack ;
2029import overrungl .util .MemoryUtil ;
2130
@@ -36,15 +45,24 @@ public final class VK {
3645 private VK () {
3746 }
3847
39- /// Loads necessary functions for Vulkan to create [VkInstance] with the given loading function .
48+ /// Loads Vulkan with LWJGL 3 .
4049 ///
41- /// @param func a function that returns an address of a Vulkan function specified with the given name. this can be `GLFW::glfwGetInstanceProcAddress`
50+ /// @param func unused
4251 public static void create (VKLoadFunc func ) {
43- if (loadFunc != null ) {
44- throw new IllegalStateException ("Vulkan has already been created." );
52+ create ();
53+ }
54+
55+ /// Loads Vulkan with LWJGL 3.
56+ ///
57+ /// @since 0.3.0
58+ public static void create () {
59+ if (Configuration .VULKAN_EXPLICIT_INIT .get (false )) {
60+ org .lwjgl .vulkan .VK .create ();
4561 }
46- loadFunc = func ;
47- globalCommands = new GlobalCommands (func );
62+ loadFunc = (_ , name ) ->
63+ MemorySegment .ofAddress (org .lwjgl .vulkan .VK .getFunctionProvider ()
64+ .getFunctionAddress (Objects .requireNonNull (MemoryUtil .nativeString (name ))));
65+ globalCommands = new GlobalCommands (loadFunc );
4866 }
4967
5068 /// Removes loaded functions.
0 commit comments