Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c

Issue 527016: Added gyp file for examples. Removed unnecessary functions. Added header file... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c
===================================================================
--- third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c (revision 35821)
+++ third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c (working copy)
@@ -13,38 +13,16 @@
// This is a simple example that draws a rotating cube in perspective
// using a vertex shader to transform the object
//
+
+#include "Simple_VertexShader.h"
#include <stdlib.h>
-#include "esUtil.h"
-typedef struct
-{
- // Handle to a program object
- GLuint programObject;
-
- // Attribute locations
- GLint positionLoc;
-
- // Uniform locations
- GLint mvpLoc;
-
- // Vertex daata
- GLfloat *vertices;
- GLuint *indices;
- int numIndices;
-
- // Rotation angle
- GLfloat angle;
-
- // MVP matrix
- ESMatrix mvpMatrix;
-} UserData;
-
///
// Initialize the shader and program object
//
-int Init ( ESContext *esContext )
+int svsInit ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
+ SVSUserData *userData = esContext->userData;
GLbyte vShaderStr[] =
"uniform mat4 u_mvpMatrix; \n"
"attribute vec4 a_position; \n"
@@ -53,8 +31,9 @@
" gl_Position = u_mvpMatrix * a_position; \n"
"} \n";
+ // TODO(alokp): Shaders containing "precision" do not compile.
GLbyte fShaderStr[] =
- "precision mediump float; \n"
+ "//precision mediump float; \n"
"void main() \n"
"{ \n"
" gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); \n"
@@ -80,13 +59,12 @@
return TRUE;
}
-
///
// Update MVP matrix based on time
//
-void Update ( ESContext *esContext, float deltaTime )
+void svsUpdate ( ESContext *esContext, float deltaTime )
{
- UserData *userData = (UserData*) esContext->userData;
+ SVSUserData *userData = (SVSUserData*) esContext->userData;
ESMatrix perspective;
ESMatrix modelview;
float aspect;
@@ -120,9 +98,9 @@
///
// Draw a triangle using the shader pair created in Init()
//
-void Draw ( ESContext *esContext )
+void svsDraw ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
+ SVSUserData *userData = esContext->userData;
// Set the viewport
glViewport ( 0, 0, esContext->width, esContext->height );
@@ -147,15 +125,16 @@
// Draw the cube
glDrawElements ( GL_TRIANGLES, userData->numIndices, GL_UNSIGNED_INT, userData->indices );
- eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
+ // TODO(alokp): glFlush should not be necessary with SwapBuffers.
+ glFlush();
}
///
// Cleanup
//
-void ShutDown ( ESContext *esContext )
+void svsShutDown ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
+ SVSUserData *userData = esContext->userData;
if ( userData->vertices != NULL )
{
@@ -170,25 +149,3 @@
// Delete program object
glDeleteProgram ( userData->programObject );
}
-
-
-int main ( int argc, char *argv[] )
-{
- ESContext esContext;
- UserData userData;
-
- esInitContext ( &esContext );
- esContext.userData = &userData;
-
- esCreateWindow ( &esContext, "Simple Texture 2D", 320, 240, ES_WINDOW_RGB );
-
- if ( !Init ( &esContext ) )
- return 0;
-
- esRegisterDrawFunc ( &esContext, Draw );
- esRegisterUpdateFunc ( &esContext, Update );
-
- esMainLoop ( &esContext );
-
- ShutDown ( &esContext );
-}

Powered by Google App Engine
This is Rietveld 408576698