Game Development Reference
In-Depth Information
glGetProgramInfoLog(Program, 1024, &Len, Error);
LOGE(Error);
exit(-1);
}
glValidateProgram(Program);
glGetProgramiv(Program, GL_VALIDATE_STATUS, &ShaderStatus);
if (ShaderStatus != GL_TRUE) {
LOGE("Error: Failed to validate GLSL program\n");
exit(-1);
}
// Enable the program
glUseProgram(Program);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
// Setup the Projection matrix
Persp(Proj, 70.0f, 0.1f, 200.0f);
// Retrieve our uniforms
iProj = glGetUniformLocation(Program, "Proj");
iModel = glGetUniformLocation(Program, "Model");
// Basic GL setup
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable ( GL_CULL_FACE);
glCullFace ( GL_BACK);
return GL_TRUE;
}
Initialization is the first step and it is performed only once. Next, you'll tackle rendering.
Scene Rendering
Scene rendering is performed multiple times when a frame is to be drawn. Listing 4-12
defines the Display C++ function.
Listing 4-12. Scene Rendering
void Display(int time) {
// Clear the screen
glClear ( GL_COLOR_BUFFER_BIT);
float Model[4][4];
memset(Model, 0, sizeof(Model));
 
Search WWH ::




Custom Search