Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OperateWithMainMatrix(ESContext* esContext, GLfloat offsetX, GLfloat offsetY, GLfloat offsetZ) {
- UserData *userData = (UserData*) esContext->userData;
- ESMatrix modelview;
- ESMatrix perspective;
- //Manipulation with matrix
- ...
- glVertexAttribPointer(userData->positionLoc, 3, GL_FLOAT, GL_FALSE, 0, cubeFaces);
- //in cubeFaces coordinates verticles cube
- glVertexAttribPointer(userData->normalLoc, 3, GL_FLOAT, GL_FALSE, 0, cubeFaces);
- //for normals (use in fragment shaider for textures)
- glEnableVertexAttribArray(userData->positionLoc);
- glEnableVertexAttribArray(userData->normalLoc);
- // Load the MVP matrix
- glUniformMatrix4fv(userData->mvpLoc, 1, GL_FALSE,
- (GLfloat*)&userData->mvpMatrix.m[0][0]);
- //Bind base map
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_CUBE_MAP, userData->baseMapTexId);
- //Set the base map sampler to texture unit to 0
- glUniform1i(userData->baseMapLoc, 0);
- // Draw the cube
- glDrawArrays(GL_TRIANGLES, 0, 36);
- }
- void Draw(ESContext *esContext)
- {
- UserData *userData = esContext->userData;
- // Set the viewport
- glViewport(0, 0, esContext->width, esContext->height);
- // Clear the color buffer
- glClear(GL_COLOR_BUFFER_BIT);
- // Use the program object
- glUseProgram(userData->programObject);
- OperateWithMainMatrix(esContext, 0.0f, 0.0f, 0.0f);
- eglSwapBuffers(esContext->eglDisplay, esContext->eglSurface);
- }
- void Draw(ESContext *esContext)
- { ...
- // Use the program object
- glUseProgram(userData->programObject);
- OperateWithMainMatrix(esContext, 2.0f, 0.0f, 0.0f);
- OperateWithMainMatrix(esContext, 1.0f, 0.0f, 0.0f);
- OperateWithMainMatrix(esContext, 0.0f, 0.0f, 0.0f);
- OperateWithMainMatrix(esContext, -1.0f, 0.0f, 0.0f);
- OperateWithMainMatrix(esContext, -2.0f, 0.0f, 0.0f);
- eglSwapBuffers(esContext->eglDisplay, esContext->eglSurface);
- }
Add Comment
Please, Sign In to add comment