Graphics Programs Reference
In-Depth Information
float[] pointVFA = {
0.1f,0.1f,0.0f,
-0.1f,0.1f,0.0f,
-0.1f,-0.1f,0.0f,
0.1f,-0.1f,0.0f
};
ByteBuffer pointVBB =
ByteBuffer.allocateDirect(pointVFA.length * 4);
pointVBB.order(ByteOrder.nativeOrder());
_pointVFB = pointVBB.asFloatBuffer();
_pointVFB.put(pointVFA);
_pointVFB.position(0);
Using this code, we create a FloatBuffer ( _pointVFB ) to represent four points
in each quadrant shown in Figure 3-6 . After making a few additional changes to this
class, you can render these points on OpenGL surface ( Figure 3-10 ) .
Figure 3-10 . GL POINT ADVANCED
Replace the vertex shader code with lines given in Listing 3-18 . This code demon-
strates that we can also supply inputs to vertex shaders “externally,” instead of direc-
tly defining and writing data to gl_Position variable.
Listing 3-18. GLPOINTADVANCED/src/com/apress/android/glpointadvanced/
GLES20Renderer.java
 
 
 
 
Search WWH ::




Custom Search