Index: third_party/gles_book_examples/Common/Include/esUtil.h |
=================================================================== |
--- third_party/gles_book_examples/Common/Include/esUtil.h (revision 35503) |
+++ third_party/gles_book_examples/Common/Include/esUtil.h (working copy) |
@@ -21,18 +21,37 @@ |
// Includes |
// |
#include <GLES2/gl2.h> |
+#include <EGL/egl.h> |
#ifdef __cplusplus |
+ |
extern "C" { |
-#endif // __cplusplus |
+#endif |
-#ifndef FALSE |
-#define FALSE 0 |
-#endif // FALSE |
-#ifndef TRUE |
-#define TRUE 1 |
-#endif // TRUE |
+ |
+/// |
+// Macros |
+// |
+#define ESUTIL_API __cdecl |
+#define ESCALLBACK __cdecl |
+ |
+/// 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 |
+// |
+ |
typedef struct |
{ |
GLfloat m[4][4]; |
@@ -48,20 +67,84 @@ |
/// 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 |
// |
-extern void esInitContext ( ESContext *esContext ); |
+void ESUTIL_API 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. |
// |
-extern void esLogMessage ( const char *formatStr, ... ); |
+void ESUTIL_API esLogMessage ( const char *formatStr, ... ); |
// |
/// |
@@ -70,7 +153,7 @@ |
/// \param shaderSrc Shader source string |
/// \return A new shader object on success, 0 on failure |
// |
-extern GLuint esLoadShader ( GLenum type, const char *shaderSrc ); |
+GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc ); |
// |
/// |
@@ -80,7 +163,7 @@ |
/// \param fragShaderSrc Fragment shader source code |
/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure |
// |
-extern GLuint esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ); |
+GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ); |
// |
@@ -94,8 +177,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 |
// |
-extern int esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals, |
- GLfloat **texCoords, GLuint **indices ); |
+int ESUTIL_API 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 |
@@ -108,8 +191,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_TRIANGLES |
// |
-extern int esGenCube ( float scale, GLfloat **vertices, GLfloat **normals, |
- GLfloat **texCoords, GLuint **indices ); |
+int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals, |
+ GLfloat **texCoords, GLuint **indices ); |
// |
/// \brief Loads a 24-bit TGA image from a file |
@@ -118,7 +201,7 @@ |
/// \param height Height of loaded image in pixels |
/// \return Pointer to loaded image. NULL on failure. |
// |
-extern char* esLoadTGA ( char *fileName, int *width, int *height ); |
+char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height ); |
// |
@@ -126,14 +209,14 @@ |
/// \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 |
// |
-extern void esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz); |
+void ESUTIL_API 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 |
// |
-extern void esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz); |
+void ESUTIL_API 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 |
@@ -141,7 +224,7 @@ |
/// \param angle Specifies the angle of rotation, in degrees. |
/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively |
// |
-extern void esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); |
+void ESUTIL_API 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 |
@@ -150,7 +233,7 @@ |
/// \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. |
// |
-extern void esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); |
+void ESUTIL_API 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 |
@@ -160,7 +243,7 @@ |
/// \param nearZ Near plane distance |
/// \param farZ Far plane distance |
// |
-extern void esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ); |
+void ESUTIL_API 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 |
@@ -169,23 +252,23 @@ |
/// \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 |
// |
-extern void esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); |
+void ESUTIL_API 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 |
// |
-extern void esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB); |
+void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB); |
// |
//// \brief return an indentity matrix |
//// \param result returns identity matrix |
// |
-extern void esMatrixLoadIdentity(ESMatrix *result); |
+void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result); |
#ifdef __cplusplus |
} |
-#endif // __cplusplus |
+#endif |
-#endif // ESUTIL_H |
+#endif // ESUTIL_H |