Package icyllis.arc3d.compiler.glsl

# Class GLSLCodeGenerator

java.lang.Object
icyllis.arc3d.compiler.CodeGenerator
icyllis.arc3d.compiler.glsl.GLSLCodeGenerator

public final class GLSLCodeGenerator extends CodeGenerator
Standard GLSL code generator for OpenGL 3.3 or above and Vulkan 1.0 or above (Vulkan GLSL).

A GLSL shader is a UTF-8 encoded string. However, our compiler only outputs ASCII characters.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final TargetApi`
  `mOutputTarget`
  `final GLSLVersion`
  `mOutputVersion`

  ### Fields inherited from class icyllis.arc3d.compiler.CodeGenerator

  `mCompiler, mTranslationUnit`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GLSLCodeGenerator(ShaderCompiler compiler, TranslationUnit translationUnit, ShaderCaps shaderCaps)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ByteBuffer`
  `generateCode()`
  Generates the code and returns the pointer value.

  ### Methods inherited from class icyllis.arc3d.compiler.CodeGenerator

  `getContext`

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

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

- ## Field Details

  - ### mOutputTarget

    public final TargetApi mOutputTarget

  - ### mOutputVersion

    public final GLSLVersion mOutputVersion

- ## Constructor Details

  - ### GLSLCodeGenerator

    public GLSLCodeGenerator(@Nonnull ShaderCompiler compiler, @Nonnull TranslationUnit translationUnit, @Nonnull ShaderCaps shaderCaps)

- ## Method Details

  - ### generateCode

    @Nullable public ByteBuffer generateCode()
    Description copied from class: `CodeGenerator`
    Generates the code and returns the pointer value. The code size in bytes is `Buffer.remaining()`. Check errors via `Context.getErrorHandler()`.

    The return value is a direct buffer, see `ByteBuffer.allocateDirect(int)`. A direct buffer wraps an address that points to off-heap memory, i.e. a native pointer. The byte order is `ByteOrder.nativeOrder()` and it's safe to pass the result to OpenGL and Vulkan API. There is no way to free this buffer explicitly, as it is subject to GC.

    Specified by:
      `generateCode` in class `CodeGenerator`
    Returns:
      the generated code, or null if there's an error