diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 21:32:20 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 21:32:20 +0000 |
commit | cb79b334b49795a96034749007d3104e3b7740aa (patch) | |
tree | 28ccf42ac462bc22c3ebc494c175e6385d9515fa /third_party | |
parent | eb003245da4a579090d1e9bdee891587db451d4c (diff) | |
download | chromium_src-cb79b334b49795a96034749007d3104e3b7740aa.zip chromium_src-cb79b334b49795a96034749007d3104e3b7740aa.tar.gz chromium_src-cb79b334b49795a96034749007d3104e3b7740aa.tar.bz2 |
Added stencil-test demo.
PS: I have not moved the repeated code to the base class for this demo because this is the last one I intend to submit before starting to port the demos to pepper. I will refactor all the demos to eliminate repeating code in light of pepper framework.
BUG=26099
TEST=Run stencil_test executable. You should see four different-colored quads.
Review URL: http://codereview.chromium.org/545092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36410 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c | 54 | ||||
-rw-r--r-- | third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h | 45 | ||||
-rw-r--r-- | third_party/gles2_book/gles2_book.gyp | 11 |
3 files changed, 63 insertions, 47 deletions
diff --git a/third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c b/third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c index 28091903..b884e8d 100644 --- a/third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c +++ b/third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c @@ -14,30 +14,14 @@ // operations. // #include <stdlib.h> -#include "esUtil.h" - -typedef struct -{ - // Handle to a program object - GLuint programObject; - - // Attribute locations - GLint positionLoc; - - // Uniform locations - GLint colorLoc; - - // Vertex buffer object handles - GLuint vboIds[2]; - -} UserData; +#include "Stencil_Test.h" /// // Initialize the shader and program object // -int Init ( ESContext *esContext ) +int stInit ( ESContext *esContext ) { - UserData *userData = esContext->userData; + STUserData *userData = esContext->userData; GLbyte vShaderStr[] = "attribute vec4 a_position; \n" "void main() \n" @@ -122,12 +106,12 @@ int Init ( ESContext *esContext ) // Initialize the stencil buffer values, and then use those // values to control rendering // -void Draw ( ESContext *esContext ) +void stDraw ( ESContext *esContext ) { int i; GLubyte *offset = NULL; - UserData *userData = esContext->userData; + STUserData *userData = esContext->userData; #define NumTests 4 GLfloat colors[NumTests][4] = { @@ -251,16 +235,14 @@ void Draw ( ESContext *esContext ) glUniform4fv( userData->colorLoc, 1, colors[i] ); glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, offset ); } - - eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); } /// // Cleanup // -void ShutDown ( ESContext *esContext ) +void stShutDown ( ESContext *esContext ) { - UserData *userData = esContext->userData; + STUserData *userData = esContext->userData; // Delete program object glDeleteProgram ( userData->programObject ); @@ -268,25 +250,3 @@ void ShutDown ( ESContext *esContext ) // Delete vertex buffer objects glDeleteBuffers ( 2, userData->vboIds ); } - - -int main ( int argc, char *argv[] ) -{ - ESContext esContext; - UserData userData; - - esInitContext ( &esContext ); - esContext.userData = &userData; - - esCreateWindow ( &esContext, "Stencil Test", 320, 240, - ES_WINDOW_RGB | ES_WINDOW_DEPTH | ES_WINDOW_STENCIL ); - - if ( !Init ( &esContext ) ) - return 0; - - esRegisterDrawFunc ( &esContext, Draw ); - - esMainLoop ( &esContext ); - - ShutDown ( &esContext ); -} diff --git a/third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h b/third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h new file mode 100644 index 0000000..ff6bff9 --- /dev/null +++ b/third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h @@ -0,0 +1,45 @@ +// +// 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 STENCIL_TEST_H +#define STENCIL_TEST_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 colorLoc; + + // Vertex buffer object handles + GLuint vboIds[2]; + +} STUserData; + +extern int stInit ( ESContext *esContext ); + +extern void stDraw ( ESContext *esContext ); + +extern void stShutDown ( ESContext *esContext ); + +#ifdef __cplusplus +} +#endif // __cplusplus +#endif // STENCIL_TEST_H diff --git a/third_party/gles2_book/gles2_book.gyp b/third_party/gles2_book/gles2_book.gyp index e4975dc..97b351f 100644 --- a/third_party/gles2_book/gles2_book.gyp +++ b/third_party/gles2_book/gles2_book.gyp @@ -84,6 +84,17 @@ ], }, { + 'target_name': 'stencil_test', + 'type': 'static_library', + 'dependencies': [ + 'es_util', + ], + 'sources': [ + 'Chapter_11/Stencil_Test/Stencil_Test.c', + 'Chapter_11/Stencil_Test/Stencil_Test.h', + ], + }, + { 'target_name': 'texture_wrap', 'type': 'static_library', 'dependencies': [ |