Package icyllis.arc3d.opengl

# Class GLUtil

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

public final class GLUtil extends Object
Provides OpenGL utilities.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `GLUtil.GLDriver`
  Known drivers.
  `static enum`
  `GLUtil.GLVendor`
  Known vendors.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `LAST_COLOR_FORMAT_INDEX`
  `static final int`
  `LAST_FORMAT_INDEX`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GLUtil()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static GLUtil.GLDriver`
  `findDriver(GLUtil.GLVendor vendor, String vendorString, String versionString)`
  `static GLUtil.GLVendor`
  `findVendor(String vendorString)`
  `static String`
  `getCategoryAMD(int category)`
  `static String`
  `getDebugSeverity(int severity)`
  `static String`
  `getDebugSource(int source)`
  `static String`
  `getDebugType(int type)`
  `static String`
  `getSeverityAMD(int severity)`
  `static String`
  `getSeverityARB(int severity)`
  `static String`
  `getSourceARB(int source)`
  `static String`
  `getTypeARB(int type)`
  `static int`
  `glCompileShader(GLDevice device, int shaderType, ByteBuffer glsl, SharedResourceCache.Stats stats)`
  `static int`
  `glFormatBytesPerBlock(int format)`
  `static int`
  `glFormatChannels(int format)`
  `static int`
  `glFormatCompressionType(int format)`
  `static int`
  `glFormatDepthBits(int format)`
  `static boolean`
  `glFormatIsCompressed(int format)`
  `static boolean`
  `glFormatIsPackedDepthStencil(int format)`
  `static boolean`
  `glFormatIsSRGB(int format)`
  `static boolean`
  `glFormatIsSupported(int format)`
  Consistent with `glFormatToIndex(int)`
  `static String`
  `glFormatName(int format)`
  `static int`
  `glFormatStencilBits(int format)`
  `static int`
  `glFormatToIndex(int format)`
  Lists all supported OpenGL texture formats and converts to table index.
  `static int`
  `glIndexToFormat(int index)`
  Reverse of `glFormatToIndex(int)`.
  `static int`
  `glSpecializeShader(GLDevice device, int shaderType, ByteBuffer spirv, String entryPoint, SharedResourceCache.Stats stats)`
  `static void`
  `handleCompileError(org.slf4j.Logger logger, String source, String errors)`
  `static void`
  `handleLinkError(org.slf4j.Logger logger, String[] headers, String[] sources, String errors)`
  `static ImmediateContext`
  `makeOpenGL()`
  Creates a DirectContext for a backend context, using default context options.
  `static ImmediateContext`
  `makeOpenGL(ContextOptions options)`
  `static ImmediateContext`
  `makeOpenGL(Object capabilities, ContextOptions options)`
  Creates a DirectContext for a backend context, using specified context options.
  `static int`
  `toGLBlendEquation(byte equation)`
  `static int`
  `toGLBlendFactor(byte factor)`
  `static int`
  `toGLCompareFunc(byte compareOp)`
  `static int`
  `toGLMagFilter(int filter)`
  `static int`
  `toGLMinFilter(int filter, int mipmapMode)`
  `static int`
  `toGLPrimitiveType(byte primitiveType)`
  `static int`
  `toGLStencilOp(byte stencilOp)`
  `static int`
  `toGLWrapMode(int addressMode)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### LAST_COLOR_FORMAT_INDEX

    public static final int LAST_COLOR_FORMAT_INDEX
    See Also:
      - `glFormatToIndex(int)`
      - Constant Field Values

  - ### LAST_FORMAT_INDEX

    public static final int LAST_FORMAT_INDEX
    See Also:
      - `glFormatToIndex(int)`
      - Constant Field Values

- ## 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(ContextOptions)`

  - ### 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(int)`

  - ### glIndexToFormat

    public static int glIndexToFormat(int index)
    Reverse of `glFormatToIndex(int)`.

  - ### glFormatChannels

    public static int glFormatChannels(int format)
    See Also:
      - `Color.COLOR_CHANNEL_FLAGS_RGBA`

  - ### glFormatIsSupported

    public static boolean glFormatIsSupported(int format)
    Consistent with `glFormatToIndex(int)`

  - ### glFormatCompressionType

    public static int glFormatCompressionType(int format)
    See Also:
      - `ColorInfo.COMPRESSION_NONE`

  - ### 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)