Created
April 14, 2016 13:23
-
-
Save framundo/cea3bbb6f8570872036acc9ad9682791 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Shaders { | |
| public static final String COLOR_VERTEX_SHADER = | |
| "uniform mat4 uMVPMatrix;\n" + | |
| "attribute vec4 vPosition;\n" + | |
| "void main() {\n" + | |
| " gl_Position = uMVPMatrix * vPosition;\n" + | |
| " gl_PointSize = 10.0;\n" + | |
| "}"; | |
| public static final String COLOR_FRAGMENT_SHADER = | |
| "precision mediump float;\n" + | |
| "uniform vec4 vColor;\n" + | |
| "void main() {\n" + | |
| " gl_FragColor = vColor;\n" + | |
| "}"; | |
| public static int loadShader(int type, String shaderCode){ | |
| // create a vertex shader type (GLES20.GL_VERTEX_SHADER) | |
| // or a fragment shader type (GLES20.GL_FRAGMENT_SHADER) | |
| int shader = GLES20.glCreateShader(type); | |
| // add the source code to the shader and compile it | |
| GLES20.glShaderSource(shader, shaderCode); | |
| GLES20.glCompileShader(shader); | |
| return shader; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment