Graphics Programs Reference
In-Depth Information
Figure 5-4
.
Using single texture with an object
sampler2D Uniform Variable
Now, take a look at the
shader
code for texturing. The vertex-fragment shader pair
in
Listing 5-6
demonstrates the basics of how 2D texturing is done in a
shader
.
Listing
5-6.
GL TEXTURE/src/com/apress/android/gltexture/GLES20Render-
er.java
private final String _planeVertexShaderCode =
"attribute vec4 aPosition; \n"
+ "attribute vec2 aCoord; \n"
+ "varying vec2 vCoord; \n"
+ "uniform mat4 uMVP; \n"
+ "void main() { \n"
+ " gl_Position = uMVP * aPosition; \n"
+ " vCoord = aCoord; \n"
+ "} \n";
private final String _planeFragmentShaderCode =
"#ifdef GL_FRAGMENT_PRECISION_HIGH \n"
+ "precision highp float; \n"
+ "#else \n"
+ "precision mediump float; \n"

Search WWH ::

Custom Search