summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-09 00:56:51 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-09 00:56:51 +0000
commit4ad58c3ee09c10358c86990e5a0f51087cc56fef (patch)
tree149237b5cbf9f59cc8bf82996a5444d49e370fde /third_party
parent3a991672550ca9b6f4046ab1232caf8d48d14b23 (diff)
downloadchromium_src-4ad58c3ee09c10358c86990e5a0f51087cc56fef.zip
chromium_src-4ad58c3ee09c10358c86990e5a0f51087cc56fef.tar.gz
chromium_src-4ad58c3ee09c10358c86990e5a0f51087cc56fef.tar.bz2
Added gyp file for examples. Removed unnecessary functions. Added header files for two examples and changed a few function signatures so they can be compiled as static libraries.
BUG=26099 Review URL: http://codereview.chromium.org/527016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35856 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.c177
-rw-r--r--third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.h38
-rw-r--r--third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c71
-rw-r--r--third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.h54
-rw-r--r--third_party/gles_book_examples/Common/Include/esUtil.h135
-rw-r--r--third_party/gles_book_examples/Common/Include/esUtil_win.h38
-rw-r--r--third_party/gles_book_examples/Common/Source/Win32/esUtil_TGA.c3
-rw-r--r--third_party/gles_book_examples/Common/Source/Win32/esUtil_win32.c183
-rw-r--r--third_party/gles_book_examples/Common/Source/esShader.c6
-rw-r--r--third_party/gles_book_examples/Common/Source/esShapes.c11
-rw-r--r--third_party/gles_book_examples/Common/Source/esTransform.c26
-rw-r--r--third_party/gles_book_examples/Common/Source/esUtil.c184
-rw-r--r--third_party/gles_book_examples/README.chromium6
-rw-r--r--third_party/gles_book_examples/gles_book_examples.gyp60
14 files changed, 276 insertions, 716 deletions
diff --git a/third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.c b/third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.c
index 352bfae..6021f687 100644
--- a/third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.c
+++ b/third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.c
@@ -14,70 +14,18 @@
// a minimal vertex/fragment shader. The purpose of this
// example is to demonstrate the basic concepts of
// OpenGL ES 2.0 rendering.
-#include <stdlib.h>
-#include "esUtil.h"
-
-typedef struct
-{
- // Handle to a program object
- GLuint programObject;
-
-} UserData;
-
-///
-// Create a shader object, load the shader source, and
-// compile the shader.
-//
-GLuint LoadShader ( GLenum type, const char *shaderSrc )
-{
- GLuint shader;
- GLint compiled;
-
- // Create the shader object
- shader = glCreateShader ( type );
-
- if ( shader == 0 )
- return 0;
-
- // Load the shader source
- glShaderSource ( shader, 1, &shaderSrc, NULL );
-
- // Compile the shader
- glCompileShader ( shader );
-
- // Check the compile status
- glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );
-
- if ( !compiled )
- {
- GLint infoLen = 0;
-
- glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );
-
- if ( infoLen > 1 )
- {
- char* infoLog = malloc (sizeof(char) * infoLen );
-
- glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
- esLogMessage ( "Error compiling shader:\n%s\n", infoLog );
-
- free ( infoLog );
- }
-
- glDeleteShader ( shader );
- return 0;
- }
- return shader;
+#include "Hello_Triangle.h"
-}
+#include <stdlib.h>
///
// Initialize the shader and program object
//
-int Init ( ESContext *esContext )
+int htInit ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
+ HTUserData *userData = esContext->userData;
+
GLbyte vShaderStr[] =
"attribute vec4 vPosition; \n"
"void main() \n"
@@ -85,62 +33,28 @@ int Init ( ESContext *esContext )
" gl_Position = vPosition; \n"
"} \n";
+ // TODO(alokp): Shaders containing "precision" do not compile.
GLbyte fShaderStr[] =
- "precision mediump float;\n"\
- "void main() \n"
- "{ \n"
- " gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );\n"
- "} \n";
-
- GLuint vertexShader;
- GLuint fragmentShader;
- GLuint programObject;
- GLint linked;
-
- // Load the vertex/fragment shaders
- vertexShader = LoadShader ( GL_VERTEX_SHADER, vShaderStr );
- fragmentShader = LoadShader ( GL_FRAGMENT_SHADER, fShaderStr );
-
- // Create the program object
- programObject = glCreateProgram ( );
-
- if ( programObject == 0 )
- return 0;
-
- glAttachShader ( programObject, vertexShader );
- glAttachShader ( programObject, fragmentShader );
-
- // Bind vPosition to attribute 0
- glBindAttribLocation ( programObject, 0, "vPosition" );
+ "//precision mediump float; \n"
+ "void main() \n"
+ "{ \n"
+ " gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );\n"
+ "} \n";
- // Link the program
- glLinkProgram ( programObject );
+ GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f,
+ -0.5f, -0.5f, 0.0f,
+ 0.5f, -0.5f, 0.0f };
- // Check the link status
- glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );
+ userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
+ if ( userData->programObject == 0 ) return FALSE;
- if ( !linked )
- {
- GLint infoLen = 0;
-
- glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );
-
- if ( infoLen > 1 )
- {
- char* infoLog = malloc (sizeof(char) * infoLen );
-
- glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );
- esLogMessage ( "Error linking program:\n%s\n", infoLog );
-
- free ( infoLog );
- }
-
- glDeleteProgram ( programObject );
- return FALSE;
- }
+ // Bind vPosition to attribute 0
+ glBindAttribLocation ( userData->programObject, 0, "vPosition" );
- // Store the program object
- userData->programObject = programObject;
+ glGenBuffers ( 1, &userData->vbo );
+ glBindBuffer ( GL_ARRAY_BUFFER, userData->vbo );
+ glBufferData ( GL_ARRAY_BUFFER, sizeof(vVertices), NULL, GL_STATIC_DRAW );
+ glBufferSubData ( GL_ARRAY_BUFFER, 0, sizeof(vVertices), vVertices );
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
return TRUE;
@@ -149,13 +63,10 @@ int Init ( ESContext *esContext )
///
// Draw a triangle using the shader pair created in Init()
//
-void Draw ( ESContext *esContext )
+void htDraw ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
- GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f,
- -0.5f, -0.5f, 0.0f,
- 0.5f, -0.5f, 0.0f };
-
+ HTUserData *userData = esContext->userData;
+
// Set the viewport
glViewport ( 0, 0, esContext->width, esContext->height );
@@ -166,29 +77,33 @@ void Draw ( ESContext *esContext )
glUseProgram ( userData->programObject );
// Load the vertex data
- glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices );
+ glBindBuffer ( GL_ARRAY_BUFFER, userData->vbo );
glEnableVertexAttribArray ( 0 );
+ glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, 0 );
glDrawArrays ( GL_TRIANGLES, 0, 3 );
- eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
+ // Nothing is drawn or application crashes without glFlush.
+ // TODO(alokp): glFlush should not be necessary with SwapBuffers().
+ glFlush();
}
-
-int main ( int argc, char *argv[] )
+///
+// Cleanup
+//
+void htShutDown ( ESContext *esContext )
{
- ESContext esContext;
- UserData userData;
-
- esInitContext ( &esContext );
- esContext.userData = &userData;
-
- esCreateWindow ( &esContext, "Hello Triangle", 320, 240, ES_WINDOW_RGB );
-
- if ( !Init ( &esContext ) )
- return 0;
+ HTUserData *userData = esContext->userData;
- esRegisterDrawFunc ( &esContext, Draw );
-
- esMainLoop ( &esContext );
+ // Delete program object
+ if ( userData->programObject != 0 )
+ {
+ glDeleteProgram ( userData->programObject );
+ userData->programObject = 0;
+ }
+ if ( userData->vbo != 0 )
+ {
+ glDeleteBuffers ( 1, &userData->vbo );
+ userData->vbo = 0;
+ }
}
diff --git a/third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.h b/third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.h
new file mode 100644
index 0000000..4e90d2f
--- /dev/null
+++ b/third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle.h
@@ -0,0 +1,38 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+#ifndef HELLO_TRIANGLE_H
+#define HELLO_TRIANGLE_H
+
+#include "esUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+typedef struct
+{
+ // Handle to a program object
+ GLuint programObject;
+ // Handle to vbo object
+ GLuint vbo;
+
+} HTUserData;
+
+extern int htInit ( ESContext *esContext );
+
+extern void htDraw ( ESContext *esContext );
+
+extern void htShutDown ( ESContext *esContext );
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+#endif // HELLO_TRIANGLE_H
diff --git a/third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c b/third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c
index bf06cb8..ad6f188 100644
--- a/third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c
+++ b/third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.c
@@ -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 <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;
+#include "Simple_VertexShader.h"
+#include <stdlib.h>
///
// 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 @@ int Init ( ESContext *esContext )
" 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 @@ int Init ( ESContext *esContext )
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 @@ void Update ( ESContext *esContext, float deltaTime )
///
// 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 @@ void Draw ( ESContext *esContext )
// 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 @@ void ShutDown ( ESContext *esContext )
// 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 );
-}
diff --git a/third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.h b/third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.h
new file mode 100644
index 0000000..e3c8832
--- /dev/null
+++ b/third_party/gles_book_examples/Chapter_8/Simple_VertexShader/Simple_VertexShader.h
@@ -0,0 +1,54 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+#ifndef SIMPLE_VERTEX_SHADER_H
+#define SIMPLE_VERTEX_SHADER_H
+
+#include "esUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+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;
+} SVSUserData;
+
+extern int svsInit ( ESContext *esContext );
+
+extern void svsUpdate ( ESContext *esContext, float deltaTime );
+
+extern void svsDraw ( ESContext *esContext );
+
+extern void svsShutDown ( ESContext *esContext );
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+#endif // SIMPLE_VERTEX_SHADER_H
diff --git a/third_party/gles_book_examples/Common/Include/esUtil.h b/third_party/gles_book_examples/Common/Include/esUtil.h
index f45c27b..a1a72c4 100644
--- a/third_party/gles_book_examples/Common/Include/esUtil.h
+++ b/third_party/gles_book_examples/Common/Include/esUtil.h
@@ -21,36 +21,17 @@
// Includes
//
#include <GLES2/gl2.h>
-#include <EGL/egl.h>
#ifdef __cplusplus
-
extern "C" {
-#endif
-
-
-///
-// Macros
-//
-#define ESUTIL_API __cdecl
-#define ESCALLBACK __cdecl
-
+#endif // __cplusplus
-/// esCreateWindow flag - RGB color buffer
-#define ES_WINDOW_RGB 0
-/// esCreateWindow flag - ALPHA color buffer
-#define ES_WINDOW_ALPHA 1
-/// esCreateWindow flag - depth buffer
-#define ES_WINDOW_DEPTH 2
-/// esCreateWindow flag - stencil buffer
-#define ES_WINDOW_STENCIL 4
-/// esCreateWindow flat - multi-sample buffer
-#define ES_WINDOW_MULTISAMPLE 8
-
-
-///
-// Types
-//
+#ifndef FALSE
+#define FALSE 0
+#endif // FALSE
+#ifndef TRUE
+#define TRUE 1
+#endif // TRUE
typedef struct
{
@@ -67,84 +48,20 @@ typedef struct
/// Window height
GLint height;
-
- /// Window handle
- EGLNativeWindowType hWnd;
-
- /// EGL display
- EGLDisplay eglDisplay;
-
- /// EGL context
- EGLContext eglContext;
-
- /// EGL surface
- EGLSurface eglSurface;
-
- /// Callbacks
- void (ESCALLBACK *drawFunc) ( void* );
- void (ESCALLBACK *keyFunc) ( void*, unsigned char, int, int );
- void (ESCALLBACK *updateFunc) ( void*, float deltaTime );
} ESContext;
-
-///
-// Public Functions
-//
-
//
///
/// \brief Initialize ES framework context. This must be called before calling any other functions.
/// \param esContext Application context
//
-void ESUTIL_API esInitContext ( ESContext *esContext );
+extern void esInitContext ( ESContext *esContext );
//
-/// \brief Create a window with the specified parameters
-/// \param esContext Application context
-/// \param title Name for title bar of window
-/// \param width Width in pixels of window to create
-/// \param height Height in pixels of window to create
-/// \param flags Bitfield for the window creation flags
-/// ES_WINDOW_RGB - specifies that the color buffer should have R,G,B channels
-/// ES_WINDOW_ALPHA - specifies that the color buffer should have alpha
-/// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
-/// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
-/// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
-/// \return GL_TRUE if window creation is succesful, GL_FALSE otherwise
-GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, const char *title, GLint width, GLint height, GLuint flags );
-
-//
-/// \brief Start the main loop for the OpenGL ES application
-/// \param esContext Application context
-//
-void ESUTIL_API esMainLoop ( ESContext *esContext );
-
-//
-/// \brief Register a draw callback function to be used to render each frame
-/// \param esContext Application context
-/// \param drawFunc Draw callback function that will be used to render the scene
-//
-void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) ( ESContext* ) );
-
-//
-/// \brief Register an update callback function to be used to update on each time step
-/// \param esContext Application context
-/// \param updateFunc Update callback function that will be used to render the scene
-//
-void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) );
-
-//
-/// \brief Register an keyboard input processing callback function
-/// \param esContext Application context
-/// \param keyFunc Key callback function for application processing of keyboard input
-//
-void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
- void (ESCALLBACK *drawFunc) ( ESContext*, unsigned char, int, int ) );
-//
/// \brief Log a message to the debug output for the platform
/// \param formatStr Format string for error log.
//
-void ESUTIL_API esLogMessage ( const char *formatStr, ... );
+extern void esLogMessage ( const char *formatStr, ... );
//
///
@@ -153,7 +70,7 @@ void ESUTIL_API esLogMessage ( const char *formatStr, ... );
/// \param shaderSrc Shader source string
/// \return A new shader object on success, 0 on failure
//
-GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc );
+extern GLuint esLoadShader ( GLenum type, const char *shaderSrc );
//
///
@@ -163,7 +80,7 @@ GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc );
/// \param fragShaderSrc Fragment shader source code
/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure
//
-GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc );
+extern GLuint esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc );
//
@@ -177,8 +94,8 @@ GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragSha
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
/// if it is not NULL ) as a GL_TRIANGLE_STRIP
//
-int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
- GLfloat **texCoords, GLuint **indices );
+extern int esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices );
//
/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores
@@ -191,8 +108,8 @@ int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GL
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
/// if it is not NULL ) as a GL_TRIANGLES
//
-int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
- GLfloat **texCoords, GLuint **indices );
+extern int esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices );
//
/// \brief Loads a 24-bit TGA image from a file
@@ -201,7 +118,7 @@ int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
/// \param height Height of loaded image in pixels
/// \return Pointer to loaded image. NULL on failure.
//
-char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height );
+extern char* esLoadTGA ( char *fileName, int *width, int *height );
//
@@ -209,14 +126,14 @@ char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height );
/// \param result Specifies the input matrix. Scaled matrix is returned in result.
/// \param sx, sy, sz Scale factors along the x, y and z axes respectively
//
-void ESUTIL_API esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz);
+extern void esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz);
//
/// \brief multiply matrix specified by result with a translation matrix and return new matrix in result
/// \param result Specifies the input matrix. Translated matrix is returned in result.
/// \param tx, ty, tz Scale factors along the x, y and z axes respectively
//
-void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz);
+extern void esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz);
//
/// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result
@@ -224,7 +141,7 @@ void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz
/// \param angle Specifies the angle of rotation, in degrees.
/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively
//
-void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+extern void esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
//
// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
@@ -233,7 +150,7 @@ void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y,
/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
/// \param nearZ, farZ Distances to the near and far depth clipping planes. Both distances must be positive.
//
-void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
+extern void esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
//
/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
@@ -243,7 +160,7 @@ void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float botto
/// \param nearZ Near plane distance
/// \param farZ Far plane distance
//
-void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ);
+extern void esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ);
//
/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
@@ -252,23 +169,23 @@ void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float
/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
/// \param nearZ, farZ Distances to the near and far depth clipping planes. These values are negative if plane is behind the viewer
//
-void ESUTIL_API esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
+extern void esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
//
/// \brief perform the following operation - result matrix = srcA matrix * srcB matrix
/// \param result Returns multiplied matrix
/// \param srcA, srcB Input matrices to be multiplied
//
-void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB);
+extern void esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB);
//
//// \brief return an indentity matrix
//// \param result returns identity matrix
//
-void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result);
+extern void esMatrixLoadIdentity(ESMatrix *result);
#ifdef __cplusplus
}
-#endif
+#endif // __cplusplus
-#endif // ESUTIL_H \ No newline at end of file
+#endif // ESUTIL_H
diff --git a/third_party/gles_book_examples/Common/Include/esUtil_win.h b/third_party/gles_book_examples/Common/Include/esUtil_win.h
index e76f7b9..d7e4104 100644
--- a/third_party/gles_book_examples/Common/Include/esUtil_win.h
+++ b/third_party/gles_book_examples/Common/Include/esUtil_win.h
@@ -15,41 +15,9 @@
#ifndef ESUTIL_WIN_H
#define ESUTIL_WIN_H
-///
-// Includes
-//
-
#ifdef __cplusplus
-
extern "C" {
-#endif
-
-
-///
-// Macros
-//
-
-///
-// Types
-//
-
-///
-// Public Functions
-//
-
-///
-// WinCreate()
-//
-// Create Win32 instance and window
-//
-GLboolean WinCreate ( ESContext *esContext, const char *title );
-
-///
-// WinLoop()
-//
-// Start main windows loop
-//
-void WinLoop ( ESContext *esContext );
+#endif // __cplusplus
///
// WinTGALoad()
@@ -60,6 +28,6 @@ int WinTGALoad ( const char *fileName, char **buffer, int *width, int *height );
#ifdef __cplusplus
}
-#endif
+#endif // __cplusplus
-#endif // ESUTIL_WIN_H \ No newline at end of file
+#endif // ESUTIL_WIN_H
diff --git a/third_party/gles_book_examples/Common/Source/Win32/esUtil_TGA.c b/third_party/gles_book_examples/Common/Source/Win32/esUtil_TGA.c
index 9d31df8..86a1f320 100644
--- a/third_party/gles_book_examples/Common/Source/Win32/esUtil_TGA.c
+++ b/third_party/gles_book_examples/Common/Source/Win32/esUtil_TGA.c
@@ -12,7 +12,10 @@
//
// This file contains the Win32 implementation of a TGA image loader
+#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
+#endif // WIN32_LEAN_AND_MEAN
+
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/third_party/gles_book_examples/Common/Source/Win32/esUtil_win32.c b/third_party/gles_book_examples/Common/Source/Win32/esUtil_win32.c
deleted file mode 100644
index 73dcaad..0000000
--- a/third_party/gles_book_examples/Common/Source/Win32/esUtil_win32.c
+++ /dev/null
@@ -1,183 +0,0 @@
-//
-// Book: OpenGL(R) ES 2.0 Programming Guide
-// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
-// ISBN-10: 0321502795
-// ISBN-13: 9780321502797
-// Publisher: Addison-Wesley Professional
-// URLs: http://safari.informit.com/9780321563835
-// http://www.opengles-book.com
-//
-
-// esUtil_win32.c
-//
-// This file contains the Win32 implementation of the windowing functions.
-
-
-///
-// Includes
-//
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include "esUtil.h"
-
-//////////////////////////////////////////////////////////////////
-//
-// Private Functions
-//
-//
-
-///
-// ESWindowProc()
-//
-// Main window procedure
-//
-LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
-{
- LRESULT lRet = 1;
-
- switch (uMsg)
- {
- case WM_CREATE:
- break;
-
- case WM_PAINT:
- {
- ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
-
- if ( esContext && esContext->drawFunc )
- esContext->drawFunc ( esContext );
-
- ValidateRect( esContext->hWnd, NULL );
- }
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
- case WM_CHAR:
- {
- POINT point;
- ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
-
- GetCursorPos( &point );
-
- if ( esContext && esContext->keyFunc )
- esContext->keyFunc ( esContext, (unsigned char) wParam,
- (int) point.x, (int) point.y );
-}
- break;
-
- default:
- lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
- break;
- }
-
- return lRet;
-}
-
-//////////////////////////////////////////////////////////////////
-//
-// Public Functions
-//
-//
-
-///
-// WinCreate()
-//
-// Create Win32 instance and window
-//
-GLboolean WinCreate ( ESContext *esContext, const char *title )
-{
- WNDCLASS wndclass = {0};
- DWORD wStyle = 0;
- RECT windowRect;
- HINSTANCE hInstance = GetModuleHandle(NULL);
-
-
- wndclass.style = CS_OWNDC;
- wndclass.lpfnWndProc = (WNDPROC)ESWindowProc;
- wndclass.hInstance = hInstance;
- wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- wndclass.lpszClassName = "opengles2.0";
-
- if (!RegisterClass (&wndclass) )
- return FALSE;
-
- wStyle = WS_VISIBLE | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION;
-
- // Adjust the window rectangle so that the client area has
- // the correct number of pixels
- windowRect.left = 0;
- windowRect.top = 0;
- windowRect.right = esContext->width;
- windowRect.bottom = esContext->height;
-
- AdjustWindowRect ( &windowRect, wStyle, FALSE );
-
-
-
- esContext->hWnd = CreateWindow(
- "opengles2.0",
- title,
- wStyle,
- 0,
- 0,
- windowRect.right - windowRect.left,
- windowRect.bottom - windowRect.top,
- NULL,
- NULL,
- hInstance,
- NULL);
-
- // Set the ESContext* to the GWL_USERDATA so that it is available to the
- // ESWindowProc
- SetWindowLongPtr ( esContext->hWnd, GWL_USERDATA, (LONG) (LONG_PTR) esContext );
-
-
- if ( esContext->hWnd == NULL )
- return GL_FALSE;
-
- ShowWindow ( esContext->hWnd, TRUE );
-
- return GL_TRUE;
-}
-
-///
-// winLoop()
-//
-// Start main windows loop
-//
-void WinLoop ( ESContext *esContext )
-{
- MSG msg = { 0 };
- int done = 0;
- DWORD lastTime = GetTickCount();
-
- while (!done)
- {
- int gotMsg = (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0);
- DWORD curTime = GetTickCount();
- float deltaTime = (float)( curTime - lastTime ) / 1000.0f;
- lastTime = curTime;
-
- if ( gotMsg )
- {
- if (msg.message==WM_QUIT)
- {
- done=1;
- }
- else
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- else
- SendMessage( esContext->hWnd, WM_PAINT, 0, 0 );
-
- // Call update function if registered
- if ( esContext->updateFunc != NULL )
- esContext->updateFunc ( esContext, deltaTime );
- }
-}
diff --git a/third_party/gles_book_examples/Common/Source/esShader.c b/third_party/gles_book_examples/Common/Source/esShader.c
index cdb4bb6..1e5c5e6 100644
--- a/third_party/gles_book_examples/Common/Source/esShader.c
+++ b/third_party/gles_book_examples/Common/Source/esShader.c
@@ -40,7 +40,7 @@
/// \param shaderSrc Shader source string
/// \return A new shader object on success, 0 on failure
//
-GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc )
+GLuint esLoadShader ( GLenum type, const char *shaderSrc )
{
GLuint shader;
GLint compiled;
@@ -93,7 +93,7 @@ GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc )
/// \param fragShaderSrc Fragment shader source code
/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure
//
-GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc )
+GLuint esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc )
{
GLuint vertexShader;
GLuint fragmentShader;
@@ -152,4 +152,4 @@ GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragSha
glDeleteShader ( fragmentShader );
return programObject;
-} \ No newline at end of file
+}
diff --git a/third_party/gles_book_examples/Common/Source/esShapes.c b/third_party/gles_book_examples/Common/Source/esShapes.c
index e659495..ddb75c7 100644
--- a/third_party/gles_book_examples/Common/Source/esShapes.c
+++ b/third_party/gles_book_examples/Common/Source/esShapes.c
@@ -19,6 +19,7 @@
#include "esUtil.h"
#include <stdlib.h>
#include <math.h>
+#include <string.h>
///
// Defines
@@ -50,8 +51,8 @@
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
/// if it is not NULL ) as a GL_TRIANGLE_STRIP
//
-int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
- GLfloat **texCoords, GLuint **indices )
+int esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices )
{
int i;
int j;
@@ -137,8 +138,8 @@ int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GL
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
/// if it is not NULL ) as a GL_TRIANGLE_STRIP
//
-int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
- GLfloat **texCoords, GLuint **indices )
+int esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices )
{
int i;
int numVertices = 24;
@@ -276,4 +277,4 @@ int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
}
return numIndices;
-} \ No newline at end of file
+}
diff --git a/third_party/gles_book_examples/Common/Source/esTransform.c b/third_party/gles_book_examples/Common/Source/esTransform.c
index 587e80b..91eef80 100644
--- a/third_party/gles_book_examples/Common/Source/esTransform.c
+++ b/third_party/gles_book_examples/Common/Source/esTransform.c
@@ -20,11 +20,11 @@
//
#include "esUtil.h"
#include <math.h>
+#include <string.h>
#define PI 3.1415926535897932384626433832795f
-void ESUTIL_API
-esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz)
+void esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz)
{
result->m[0][0] *= sx;
result->m[0][1] *= sx;
@@ -42,8 +42,7 @@ esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz)
result->m[2][3] *= sz;
}
-void ESUTIL_API
-esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz)
+void esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz)
{
result->m[3][0] += (result->m[0][0] * tx + result->m[1][0] * ty + result->m[2][0] * tz);
result->m[3][1] += (result->m[0][1] * tx + result->m[1][1] * ty + result->m[2][1] * tz);
@@ -51,8 +50,7 @@ esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz)
result->m[3][3] += (result->m[0][3] * tx + result->m[1][3] * ty + result->m[2][3] * tz);
}
-void ESUTIL_API
-esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+void esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{
GLfloat sinAngle, cosAngle;
GLfloat mag = sqrtf(x * x + y * y + z * z);
@@ -104,8 +102,7 @@ esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
}
}
-void ESUTIL_API
-esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
+void esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
{
float deltaX = right - left;
float deltaY = top - bottom;
@@ -134,8 +131,7 @@ esFrustum(ESMatrix *result, float left, float right, float bottom, float top, fl
}
-void ESUTIL_API
-esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ)
+void esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ)
{
GLfloat frustumW, frustumH;
@@ -145,8 +141,7 @@ esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float far
esFrustum( result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ );
}
-void ESUTIL_API
-esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
+void esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
{
float deltaX = right - left;
float deltaY = top - bottom;
@@ -168,8 +163,7 @@ esOrtho(ESMatrix *result, float left, float right, float bottom, float top, floa
}
-void ESUTIL_API
-esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB)
+void esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB)
{
ESMatrix tmp;
int i;
@@ -200,8 +194,7 @@ esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB)
}
-void ESUTIL_API
-esMatrixLoadIdentity(ESMatrix *result)
+void esMatrixLoadIdentity(ESMatrix *result)
{
memset(result, 0x0, sizeof(ESMatrix));
result->m[0][0] = 1.0f;
@@ -209,4 +202,3 @@ esMatrixLoadIdentity(ESMatrix *result)
result->m[2][2] = 1.0f;
result->m[3][3] = 1.0f;
}
-
diff --git a/third_party/gles_book_examples/Common/Source/esUtil.c b/third_party/gles_book_examples/Common/Source/esUtil.c
index 99d7b34..7a9c9c5 100644
--- a/third_party/gles_book_examples/Common/Source/esUtil.c
+++ b/third_party/gles_book_examples/Common/Source/esUtil.c
@@ -20,96 +20,21 @@
//
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
#include <GLES2/gl2.h>
-#include <EGL/egl.h>
+
#include "esUtil.h"
#include "esUtil_win.h"
-
-
-
-///
-// CreateEGLContext()
-//
-// Creates an EGL rendering context and all associated elements
-//
-EGLBoolean CreateEGLContext ( EGLNativeWindowType hWnd, EGLDisplay* eglDisplay,
- EGLContext* eglContext, EGLSurface* eglSurface,
- EGLint attribList[])
-{
- EGLint numConfigs;
- EGLint majorVersion;
- EGLint minorVersion;
- EGLDisplay display;
- EGLContext context;
- EGLSurface surface;
- EGLConfig config;
- EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
-
- // Get Display
- display = eglGetDisplay(GetDC(hWnd));
- if ( display == EGL_NO_DISPLAY )
- {
- return EGL_FALSE;
- }
-
- // Initialize EGL
- if ( !eglInitialize(display, &majorVersion, &minorVersion) )
- {
- return EGL_FALSE;
- }
-
- // Get configs
- if ( !eglGetConfigs(display, NULL, 0, &numConfigs) )
- {
- return EGL_FALSE;
- }
-
- // Choose config
- if ( !eglChooseConfig(display, attribList, &config, 1, &numConfigs) )
- {
- return EGL_FALSE;
- }
-
- // Create a surface
- surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL);
- if ( surface == EGL_NO_SURFACE )
- {
- return EGL_FALSE;
- }
-
- // Create a GL context
- context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
- if ( context == EGL_NO_CONTEXT )
- {
- return EGL_FALSE;
- }
-
- // Make the context current
- if ( !eglMakeCurrent(display, surface, surface, context) )
- {
- return EGL_FALSE;
- }
-
- *eglDisplay = display;
- *eglSurface = surface;
- *eglContext = context;
- return EGL_TRUE;
-}
-
-//////////////////////////////////////////////////////////////////
-//
-// Public Functions
-//
-//
-
///
// esInitContext()
//
// Initialize ES utility context. This must be called before calling any other
// functions.
//
-void ESUTIL_API esInitContext ( ESContext *esContext )
+void esInitContext ( ESContext *esContext )
{
if ( esContext != NULL )
{
@@ -118,103 +43,11 @@ void ESUTIL_API esInitContext ( ESContext *esContext )
}
///
-// esCreateWindow()
-//
-// title - name for title bar of window
-// width - width of window to create
-// height - height of window to create
-// flags - bitwise or of window creation flags
-// ES_WINDOW_ALPHA - specifies that the framebuffer should have alpha
-// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
-// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
-// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
-//
-GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, const char* title, GLint width, GLint height, GLuint flags )
-{
- EGLint attribList[] =
- {
- EGL_RED_SIZE, 5,
- EGL_GREEN_SIZE, 6,
- EGL_BLUE_SIZE, 5,
- EGL_ALPHA_SIZE, (flags & ES_WINDOW_ALPHA) ? 8 : EGL_DONT_CARE,
- EGL_DEPTH_SIZE, (flags & ES_WINDOW_DEPTH) ? 8 : EGL_DONT_CARE,
- EGL_STENCIL_SIZE, (flags & ES_WINDOW_STENCIL) ? 8 : EGL_DONT_CARE,
- EGL_SAMPLE_BUFFERS, (flags & ES_WINDOW_MULTISAMPLE) ? 1 : 0,
- EGL_NONE
- };
-
- if ( esContext == NULL )
- {
- return GL_FALSE;
- }
-
- esContext->width = width;
- esContext->height = height;
-
- if ( !WinCreate ( esContext, title) )
- {
- return GL_FALSE;
- }
-
-
- if ( !CreateEGLContext ( esContext->hWnd,
- &esContext->eglDisplay,
- &esContext->eglContext,
- &esContext->eglSurface,
- attribList) )
- {
- return GL_FALSE;
- }
-
-
- return GL_TRUE;
-}
-
-///
-// esMainLoop()
-//
-// Start the main loop for the OpenGL ES application
-//
-void ESUTIL_API esMainLoop ( ESContext *esContext )
-{
- WinLoop ( esContext );
-}
-
-
-///
-// esRegisterDrawFunc()
-//
-void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) (ESContext* ) )
-{
- esContext->drawFunc = drawFunc;
-}
-
-
-///
-// esRegisterUpdateFunc()
-//
-void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) )
-{
- esContext->updateFunc = updateFunc;
-}
-
-
-///
-// esRegisterKeyFunc()
-//
-void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
- void (ESCALLBACK *keyFunc) (ESContext*, unsigned char, int, int ) )
-{
- esContext->keyFunc = keyFunc;
-}
-
-
-///
// esLogMessage()
//
// Log an error message to the debug output for the platform
//
-void ESUTIL_API esLogMessage ( const char *formatStr, ... )
+void esLogMessage ( const char *formatStr, ... )
{
va_list params;
char buf[BUFSIZ];
@@ -227,13 +60,12 @@ void ESUTIL_API esLogMessage ( const char *formatStr, ... )
va_end ( params );
}
-
///
// esLoadTGA()
//
// Loads a 24-bit TGA image from a file
//
-char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height )
+char* esLoadTGA ( char *fileName, int *width, int *height )
{
char *buffer;
@@ -243,4 +75,4 @@ char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height )
}
return NULL;
-} \ No newline at end of file
+}
diff --git a/third_party/gles_book_examples/README.chromium b/third_party/gles_book_examples/README.chromium
index 596356c..38aaad8 100644
--- a/third_party/gles_book_examples/README.chromium
+++ b/third_party/gles_book_examples/README.chromium
@@ -17,5 +17,11 @@ Local Modifications:
- Common/Include/GLES2/*
- Common/Include/KD/*
- Common/Lib/*
+ - Common/Source/esUtil_win32.c
- Lib/*
- *.vcproj, *.sln
+
+ Added header files for individual examples so that they can be compiled as
+ static libraries:
+ - Chapter_2/Hello_Triangle/Hello_Triangle.h
+ - Chapter_8/Simple_VertexShader/Simple_VertexShader.h
diff --git a/third_party/gles_book_examples/gles_book_examples.gyp b/third_party/gles_book_examples/gles_book_examples.gyp
new file mode 100644
index 0000000..96a6673
--- /dev/null
+++ b/third_party/gles_book_examples/gles_book_examples.gyp
@@ -0,0 +1,60 @@
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'es_util',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../../gpu/gpu.gyp:gles2_c_lib',
+ ],
+ 'include_dirs': [
+ 'Common/Include',
+ ],
+ 'all_dependent_settings': {
+ 'include_dirs': [
+ 'Common/Include',
+ ],
+ },
+ 'sources': [
+ 'Common/Include/esUtil.h',
+ 'Common/Include/esUtil_win.h',
+ 'Common/Source/esShader.c',
+ 'Common/Source/esShapes.c',
+ 'Common/Source/esTransform.c',
+ 'Common/Source/esUtil.c',
+ 'Common/Source/Win32/esUtil_TGA.c',
+ ],
+ },
+ {
+ 'target_name': 'hello_triangle',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'es_util',
+ ],
+ 'sources': [
+ 'Chapter_2/Hello_Triangle/Hello_Triangle.c',
+ 'Chapter_2/Hello_Triangle/Hello_Triangle.h',
+ ],
+ },
+ {
+ 'target_name': 'simple_vertex_shader',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'es_util',
+ ],
+ 'sources': [
+ 'Chapter_8/Simple_VertexShader/Simple_VertexShader.c',
+ 'Chapter_8/Simple_VertexShader/Simple_VertexShader.h',
+ ],
+ },
+ ]
+}
+
+# Local Variables:
+# tab-width:2
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=2 shiftwidth=2: