OpenGLES 3.0 Shader Language Specification Change

OpenGLES 3.0 Shader script

300 ES #Version
layout (LOCATION = 0) in vec4 vPosition;
void main ()
{
gl_Position = vPosition;
}
. 1
2
. 3
. 4
. 5
. 6
wherein, # version 300 es declaration of version 3.0 OpenGLES is, 3.0 in and out using the keywords replace attribute and varying, layout keywords directly attribute specifies the location of the script for the property assignment becomes:

GLfloat vVertices[] = {
0.0f, 0.5f, 0.0f,
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, -1.0f, 0.0f,
0.5f, -0.5f, 0.0f,
-0.5f, -0.5f, 0.0f
};

// The first parameter is the location value of the corresponding attribute
glVertexAttribPointer (0,. 3, GL_FLOAT,, GL_FALSE,, 0, vVertices);
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
while the original assignment mode is 2.0:

= glGetAttribLocation positionLoc (Program, "vPosition");
glVertexAttribPointer (positionLoc,. 3, GL_FLOAT,, GL_FALSE,, 0, vVertices);
. 1
2
draw a triangle
drawing a triangle steps: (http://www.amjmh.com/v/)

Create OpenGLES environment (by means of a context object may be created GLSurfaceView);
compile and link shader programs;
specified shader programs, programs for the shader variable assignment;
drawn.

Guess you like

Origin www.cnblogs.com/hyhy904/p/11460277.html