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 @Nullable public static 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 @Nullable public static ImmediateContext makeOpenGL(@Nonnull ContextOptions options)
    • makeOpenGL

      @Nullable public static 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

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

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

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

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

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

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

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

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

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

      public static int glSpecializeShader(GLDevice device, int shaderType, ByteBuffer spirv, String entryPoint, SharedResourceCache.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)