Share error code to string of jgl

This commit is contained in:
Martin Pernollet 2022-03-17 10:35:01 +01:00
parent 260480beb9
commit 7de96cc620
2 changed files with 37 additions and 32 deletions

View File

@ -122,37 +122,7 @@ public abstract class gl_object {
public void gl_error(int error, String s) { public void gl_error(int error, String s) {
if (debug) { if (debug) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = errorCodeToString("jGL Error (", error, "): " + s);
sb.append("jGL Error (");
switch (error) {
case GL.GL_NO_ERROR:
sb.append("GL_NO_ERROR");
break;
case GL.GL_INVALID_VALUE:
sb.append("GL_INVALID_VALUE");
break;
case GL.GL_INVALID_ENUM:
sb.append("GL_INVALID_ENUM");
break;
case GL.GL_INVALID_OPERATION:
sb.append("GL_INVALID_OPERATION");
break;
case GL.GL_STACK_OVERFLOW:
sb.append("GL_STACK_OVERFLOW");
break;
case GL.GL_STACK_UNDERFLOW:
sb.append("GL_STACK_UNDERFLOW");
break;
case GL.GL_OUT_OF_MEMORY:
sb.append("GL_OUT_OF_MEMORY");
break;
default:
sb.append("unknown");
break;
}
// System.out.println("): " + s);
sb.append("): " + s);
if (throwExceptionOnGLError) { if (throwExceptionOnGLError) {
throw new RuntimeException(sb.toString()); throw new RuntimeException(sb.toString());
@ -165,6 +135,41 @@ public abstract class gl_object {
} }
} }
public static StringBuffer errorCodeToString(String prefix, int error, String suffix) {
StringBuffer sb = new StringBuffer();
sb.append(prefix);
switch (error) {
case GL.GL_NO_ERROR:
sb.append("GL_NO_ERROR");
break;
case GL.GL_INVALID_VALUE:
sb.append("GL_INVALID_VALUE");
break;
case GL.GL_INVALID_ENUM:
sb.append("GL_INVALID_ENUM");
break;
case GL.GL_INVALID_OPERATION:
sb.append("GL_INVALID_OPERATION");
break;
case GL.GL_STACK_OVERFLOW:
sb.append("GL_STACK_OVERFLOW");
break;
case GL.GL_STACK_UNDERFLOW:
sb.append("GL_STACK_UNDERFLOW");
break;
case GL.GL_OUT_OF_MEMORY:
sb.append("GL_OUT_OF_MEMORY");
break;
default:
sb.append("unknown");
break;
}
// System.out.println("): " + s);
sb.append(suffix);
return sb;
}
public void setThrowExceptionOnGLError(boolean status) { public void setThrowExceptionOnGLError(boolean status) {
this.throwExceptionOnGLError = status; this.throwExceptionOnGLError = status;
} }

View File

@ -19,7 +19,7 @@ import org.jzy3d.plot3d.rendering.view.View;
public class ITTest_AxisLabelRotateLayout extends ITTest{ public class ITTest_AxisLabelRotateLayout extends ITTest{
public static void main(String[] args) { public static void main(String[] args) {
open(new ITTest_AxisLabelRotateLayout().whenAxisLabelOrientationNotHorizontal(WT.Native_AWT, HiDPI.OFF)); open(new ITTest_AxisLabelRotateLayout().whenAxisLabelOrientationNotHorizontal(WT.Native_AWT, HiDPI.ON));
} }
@Test @Test