1616
1717package overrungl .opengl ;
1818
19- import org .jetbrains .annotations .Nullable ;
2019import overrungl .OverrunGL ;
2120import overrungl .opengl .amd .GLAMDDebugOutput ;
2221import overrungl .opengl .amd .GLDebugProcAMD ;
@@ -50,38 +49,38 @@ private GLUtil() {
5049 * Detects the best debug output functionality to use and creates a callback that prints information to
5150 * {@link OverrunGL#apiLogger() API Logger}.
5251 * <p>
53- * The callback function is returned as a {@link Arena}, that should be reset to NULL and
52+ * The callback function is allocated with the given {@link Arena} that should be
5453 * {@link Arena#close() closed} when no longer needed, which is often after destroying GL context.
5554 *
55+ * @param arena the arena to allocate the callback
5656 * @param gl the OpenGL context.
5757 * @param flags the OpenGL flags.
5858 * @param func the loading function
59- * @return the arena.
6059 */
61- @ Nullable
62- public static Arena setupDebugMessageCallback (
60+ public static void setupDebugMessageCallback (
61+ Arena arena ,
6362 GL43 gl ,
6463 GLFlags flags ,
6564 GLLoadFunc func
6665 ) {
67- return setupDebugMessageCallback (gl , flags , func , OverrunGL .apiLogger ());
66+ setupDebugMessageCallback (arena , gl , flags , func , OverrunGL .apiLogger ());
6867 }
6968
7069 /**
7170 * Detects the best debug output functionality to use and creates a callback that prints information to the specified
7271 * logger.
7372 * <p>
74- * The callback function is returned as a {@link Arena}, that should be reset to NULL and
73+ * The callback function is allocated with the given {@link Arena} that should be
7574 * {@link Arena#close() closed} when no longer needed, which is often after destroying GL context.
7675 *
76+ * @param arena the arena to allocate the callback
7777 * @param gl the OpenGL context.
7878 * @param flags the OpenGL flags.
7979 * @param func the loading function
8080 * @param logger the output logger.
81- * @return the arena.
8281 */
83- @ Nullable
84- public static Arena setupDebugMessageCallback (
82+ public static void setupDebugMessageCallback (
83+ Arena arena ,
8584 GL43 gl ,
8685 GLFlags flags ,
8786 GLLoadFunc func ,
@@ -93,7 +92,6 @@ public static Arena setupDebugMessageCallback(
9392 } else {
9493 apiLog ("[GL] Using KHR_debug for error logging." );
9594 }
96- var arena = Arena .ofConfined ();
9795 gl .DebugMessageCallback (GLDebugProc .alloc (arena , (source , type , id , severity , _ , message , _ ) -> {
9896 var sb = new StringBuilder (768 );
9997 sb .append ("[OverrunGL] OpenGL debug message\n " );
@@ -121,12 +119,10 @@ public static Arena setupDebugMessageCallback(
121119 gl .Enable (GL_DEBUG_OUTPUT );
122120 }
123121 }
124- return arena ;
125122 }
126123
127124 if (flags .GL_ARB_debug_output ) {
128125 apiLog ("[GL] Using ARB_debug_output for error logging." );
129- var arena = Arena .ofConfined ();
130126 new GLARBDebugOutput (func ).DebugMessageCallbackARB (GLDebugProc .alloc (arena , (source , type , id , severity , _ , message , _ ) -> {
131127 var sb = new StringBuilder (768 );
132128 sb .append ("[OverrunGL] ARB_debug_output message\n " );
@@ -141,12 +137,10 @@ public static Arena setupDebugMessageCallback(
141137 }
142138 logger .accept (sb .toString ());
143139 }), MemorySegment .NULL );
144- return arena ;
145140 }
146141
147142 if (flags .GL_AMD_debug_output ) {
148143 apiLog ("[GL] Using AMD_debug_output for error logging." );
149- var arena = Arena .ofConfined ();
150144 new GLAMDDebugOutput (func ).DebugMessageCallbackAMD (GLDebugProcAMD .alloc (arena , (id , category , severity , _ , message , _ ) -> {
151145 var sb = new StringBuilder (768 );
152146 sb .append ("[OverrunGL] AMD_debug_output message\n " );
@@ -160,11 +154,9 @@ public static Arena setupDebugMessageCallback(
160154 }
161155 logger .accept (sb .toString ());
162156 }), MemorySegment .NULL );
163- return arena ;
164157 }
165158
166159 apiLog ("[GL] No debug output implementation is available." );
167- return null ;
168160 }
169161
170162 private static void printDetail (StringBuilder sb , String type , String message ) {
0 commit comments