Class ShaderUtil


  • public class ShaderUtil
    extends java.lang.Object
    Shader helper functions.
    • Constructor Summary

      Constructors 
      Constructor Description
      ShaderUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkGLError​(java.lang.String tag, java.lang.String label)
      Checks if we've had an error inside of OpenGL ES, and if so what that error is.
      static int loadGLShader​(java.lang.String tag, Context context, int type, java.lang.String filename)
      Converts a raw text file, saved as a resource, into an OpenGL ES shader.
      private static java.lang.String readShaderFileFromAssets​(Context context, java.lang.String filename)
      Converts a raw shader file into a string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShaderUtil

        public ShaderUtil()
    • Method Detail

      • loadGLShader

        public static int loadGLShader​(java.lang.String tag,
                                       Context context,
                                       int type,
                                       java.lang.String filename)
                                throws java.io.IOException
        Converts a raw text file, saved as a resource, into an OpenGL ES shader.
        Parameters:
        type - The type of shader we will be creating.
        filename - The filename of the asset file about to be turned into a shader.
        Returns:
        The shader object handler.
        Throws:
        java.io.IOException
      • checkGLError

        public static void checkGLError​(java.lang.String tag,
                                        java.lang.String label)
        Checks if we've had an error inside of OpenGL ES, and if so what that error is.
        Parameters:
        label - Label to report in case of error.
        Throws:
        java.lang.RuntimeException - If an OpenGL error is detected.
      • readShaderFileFromAssets

        private static java.lang.String readShaderFileFromAssets​(Context context,
                                                                 java.lang.String filename)
                                                          throws java.io.IOException
        Converts a raw shader file into a string.
        Parameters:
        filename - The filename of the shader file about to be turned into a shader.
        Returns:
        The context of the text file, or null in case of error.
        Throws:
        java.io.IOException