2
* Copyright (c) 2002-2008 LWJGL Project
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
12
* * Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
16
* * Neither the name of 'LWJGL' nor the names of
17
* its contributors may be used to endorse or promote products derived
18
* from this software without specific prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
package org.lwjgl.opengl;
34
import org.lwjgl.PointerWrapperAbstract;
37
* Instances of this class are needed to use the callback functionality of the ARB_debug_output extension.
38
* A debug context must be current before creating instances of this class. Users of this class may provide
39
* implementations of the {@code Handler} interface to receive notifications. The same {@code Handler}
40
* instance may be used by different contexts but it is not recommended. Handler notifications are synchronized.
44
public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
46
/** Severity levels. */
47
private static final int
48
GL_DEBUG_SEVERITY_HIGH_ARB = 0x9146,
49
GL_DEBUG_SEVERITY_MEDIUM_ARB = 0x9147,
50
GL_DEBUG_SEVERITY_LOW_ARB = 0x9148;
53
private static final int
54
GL_DEBUG_SOURCE_API_ARB = 0x8246,
55
GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB = 0x8247,
56
GL_DEBUG_SOURCE_SHADER_COMPILER_ARB = 0x8248,
57
GL_DEBUG_SOURCE_THIRD_PARTY_ARB = 0x8249,
58
GL_DEBUG_SOURCE_APPLICATION_ARB = 0x824A,
59
GL_DEBUG_SOURCE_OTHER_ARB = 0x824B;
62
private static final int
63
GL_DEBUG_TYPE_ERROR_ARB = 0x824C,
64
GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB = 0x824D,
65
GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB = 0x824E,
66
GL_DEBUG_TYPE_PORTABILITY_ARB = 0x824F,
67
GL_DEBUG_TYPE_PERFORMANCE_ARB = 0x8250,
68
GL_DEBUG_TYPE_OTHER_ARB = 0x8251;
70
private static final long CALLBACK_POINTER;
75
// Call reflectively so that we can compile this class for the Generator.
76
pointer = (Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugOutputCallbackARB").invoke(null);
77
} catch (Exception e) {
80
CALLBACK_POINTER = pointer;
83
private final Handler handler;
86
* Creates an ARBDebugOutputCallback with a default callback handler.
87
* The default handler will simply print the message on System.err.
89
public ARBDebugOutputCallback() {
91
public void handleMessage(final int source, final int type, final int id, final int severity, final String message) {
92
System.err.println("[LWJGL] ARB_debug_output message");
93
System.err.println("\tID: " + id);
97
case GL_DEBUG_SOURCE_API_ARB:
100
case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
101
description = "WINDOW SYSTEM";
103
case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
104
description = "SHADER COMPILER";
106
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
107
description = "THIRD PARTY";
109
case GL_DEBUG_SOURCE_APPLICATION_ARB:
110
description = "APPLICATION";
112
case GL_DEBUG_SOURCE_OTHER_ARB:
113
description = "OTHER";
116
description = "Unknown (" + Integer.toHexString(source) + ")";
118
System.err.println("\tSource: " + description);
121
case GL_DEBUG_TYPE_ERROR_ARB:
122
description = "ERROR";
124
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
125
description = "DEPRECATED BEHAVIOR";
127
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
128
description = "UNDEFINED BEHAVIOR";
130
case GL_DEBUG_TYPE_PORTABILITY_ARB:
131
description = "PORTABILITY";
133
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
134
description = "PERFORMANCE";
136
case GL_DEBUG_TYPE_OTHER_ARB:
137
description = "OTHER";
140
description = "Unknown (" + Integer.toHexString(source) + ")";
142
System.err.println("\tType: " + description);
144
switch ( severity ) {
145
case GL_DEBUG_SEVERITY_HIGH_ARB:
146
description = "HIGH";
148
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
149
description = "MEDIUM";
151
case GL_DEBUG_SEVERITY_LOW_ARB:
155
description = "Unknown (" + Integer.toHexString(source) + ")";
157
System.err.println("\tSeverity: " + description);
159
System.err.println("\tMessage: " + message);
165
* Creates an ARBDebugOutputCallback with the specified callback handler.
166
* The handler's {@code handleMessage} method will be called whenever
167
* debug output is generated by the GL.
169
* @param handler the callback handler
171
public ARBDebugOutputCallback(final Handler handler) {
172
super(CALLBACK_POINTER);
174
this.handler = handler;
177
Handler getHandler() {
181
/** Implementations of this interface can be used to receive ARB_debug_output notifications. */
182
public interface Handler {
185
* This method will be called when an ARB_debug_output message is generated.
187
* @param id the message ID
188
* @param source the message source
189
* @param type the message type
190
* @param severity the message severity
191
* @param message the string representation of the message.
193
void handleMessage(int source, int type, int id, int severity, String message);
b'\\ No newline at end of file'