Package icyllis.arc3d.opengl
Class GLUtil
java.lang.Object
icyllis.arc3d.opengl.GLUtil
Provides OpenGL utilities.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Known drivers.static enum
Known vendors. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 withglFormatToIndex(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 ofglFormatToIndex(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
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)
-
Field Details
-
LAST_COLOR_FORMAT_INDEX
public static final int LAST_COLOR_FORMAT_INDEX- See Also:
-
LAST_FORMAT_INDEX
public static final int LAST_FORMAT_INDEX- See Also:
-
-
Constructor Details
-
GLUtil
public GLUtil()
-
-
Method Details
-
makeOpenGL
Creates a DirectContext for a backend context, using default context options.- Returns:
- context or null if failed to create
- See Also:
-
makeOpenGL
-
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
-
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) Reverse ofglFormatToIndex(int)
. -
glFormatChannels
public static int glFormatChannels(int format) - See Also:
-
glFormatIsSupported
public static boolean glFormatIsSupported(int format) Consistent withglFormatToIndex(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
-
getDebugSource
-
getDebugType
-
getDebugSeverity
-
getSourceARB
-
getTypeARB
-
getSeverityARB
-
getCategoryAMD
-
getSeverityAMD
-
handleCompileError
-
handleLinkError
-
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)
-