Class GLUtil

java.lang.Object
icyllis.arc3d.opengl.GLUtil

public final class GLUtil extends Object
Provides OpenGL utilities.
  • Field Details

  • Constructor Details

    • GLUtil

      public GLUtil()
  • Method Details

    • makeOpenGL

      @Internal public static @Nullable ImmediateContext makeOpenGL()
      Creates a DirectContext for a backend context, using default context options.
      Returns:
      context or null if failed to create
      See Also:
    • makeOpenGL

      @Internal public static @Nullable ImmediateContext makeOpenGL(@NonNull ContextOptions options)
    • makeOpenGL

      public static @Nullable ImmediateContext makeOpenGL(@NonNull Object capabilities, @NonNull ContextOptions options)
      Creates a DirectContext for a backend context, using specified context options.

      Example with GLFW:

      
        public static void main(String[] args) {
            System.setProperty("java.awt.headless", Boolean.TRUE.toString());
            if (!glfwInit()) {
                throw new IllegalStateException();
            }
            // default hints use highest OpenGL version and native API
            glfwDefaultWindowHints();
            long window = glfwCreateWindow(1280, 720, "Example Window", NULL, NULL);
            if (window == NULL) {
                throw new IllegalStateException();
            }
            // you can make a thread a render thread
            glfwMakeContextCurrent(window);
            DirectContext direct = DirectContext.makeOpenGL(
                GL.createCapabilities()
            );
            if (direct == null) {
                throw new IllegalStateException();
            }
            ...
            // destroy and close
            direct.discard();
            direct.unref();
            GL.setCapabilities(null);
            glfwDestroyWindow(window);
            glfwTerminate();
        }
       
      Returns:
      context or null if failed to create
    • findVendor

      public static GLUtil.GLVendor findVendor(String vendorString)
    • findDriver

      public static GLUtil.GLDriver findDriver(GLUtil.GLVendor vendor, String vendorString, String versionString)
    • glFormatToIndex

      public static int glFormatToIndex(int format)
      Lists all supported OpenGL texture formats and converts to table index. 0 is reserved for unsupported formats.
      See Also:
    • glIndexToFormat

      public static int glIndexToFormat(int index)
    • glFormatChannels

      public static int glFormatChannels(int format)
      See Also:
    • glFormatIsSupported

      public static boolean glFormatIsSupported(int format)
      Consistent with glFormatToIndex(int)
    • glFormatCompressionType

      public static int glFormatCompressionType(int format)
      See Also:
    • glFormatBytesPerBlock

      public static int glFormatBytesPerBlock(int format)
    • glFormatDepthBits

      public static int glFormatDepthBits(int format)
    • glFormatStencilBits

      public static int glFormatStencilBits(int format)
    • glFormatIsPackedDepthStencil

      public static boolean glFormatIsPackedDepthStencil(int format)
    • glFormatIsSRGB

      public static boolean glFormatIsSRGB(int format)
    • glFormatIsCompressed

      public static boolean glFormatIsCompressed(int format)
    • glFormatName

      public static String glFormatName(int format)
    • getDebugSource

      public static @NonNull String getDebugSource(int source)
    • getDebugType

      public static @NonNull String getDebugType(int type)
    • getDebugSeverity

      public static @NonNull String getDebugSeverity(int severity)
    • getSourceARB

      public static @NonNull String getSourceARB(int source)
    • getTypeARB

      public static @NonNull String getTypeARB(int type)
    • getSeverityARB

      public static @NonNull String getSeverityARB(int severity)
    • getCategoryAMD

      public static @NonNull String getCategoryAMD(int category)
    • getSeverityAMD

      public static @NonNull String getSeverityAMD(int severity)
    • glCompileShader

      public static int glCompileShader(GLDevice device, int shaderType, ByteBuffer glsl, GlobalResourceCache.Stats stats)
    • glSpecializeShader

      public static int glSpecializeShader(GLDevice device, int shaderType, ByteBuffer spirv, String entryPoint, GlobalResourceCache.Stats stats)
    • handleCompileError

      public static void handleCompileError(org.slf4j.Logger logger, String source, String errors)
    • handleLinkError

      public static void handleLinkError(org.slf4j.Logger logger, String[] headers, String[] sources, String errors)
    • toGLMagFilter

      public static int toGLMagFilter(int filter)
    • toGLMinFilter

      public static int toGLMinFilter(int filter, int mipmapMode)
    • toGLWrapMode

      public static int toGLWrapMode(int addressMode)
    • toGLBlendEquation

      public static int toGLBlendEquation(byte equation)
    • toGLBlendFactor

      public static int toGLBlendFactor(byte factor)
    • toGLCompareFunc

      public static int toGLCompareFunc(byte compareOp)
    • toGLStencilOp

      public static int toGLStencilOp(byte stencilOp)
    • toGLPrimitiveType

      public static int toGLPrimitiveType(byte primitiveType)