summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 16:32:01 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 16:32:01 +0000
commit46180e667bcc6e943e5b54e083c4809cce5ccad0 (patch)
treeb4243fea1e88353b794e46ed12f78f8fcd1ab575 /third_party
parent48f65dde6736a55e4ab588491fcc0ec1987d7f29 (diff)
downloadchromium_src-46180e667bcc6e943e5b54e083c4809cce5ccad0.zip
chromium_src-46180e667bcc6e943e5b54e083c4809cce5ccad0.tar.gz
chromium_src-46180e667bcc6e943e5b54e083c4809cce5ccad0.tar.bz2
Added cubemap demo.
BUG=26099 Review URL: http://codereview.chromium.org/549063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36356 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c57
-rw-r--r--third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h49
-rw-r--r--third_party/gles2_book/gles2_book.gyp11
3 files changed, 67 insertions, 50 deletions
diff --git a/third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c b/third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c
index 5eb13a6..597982a 100644
--- a/third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c
+++ b/third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c
@@ -13,27 +13,7 @@
// This is a simple example that draws a sphere with a cubemap image applied.
//
#include <stdlib.h>
-#include "esUtil.h"
-
-typedef struct
-{
- // Handle to a program object
- GLuint programObject;
-
- // Attribute locations
- GLint positionLoc;
- GLint normalLoc;
-
- // Sampler location
- GLint samplerLoc;
-
- // Texture handle
- GLuint textureId;
-
- // Vertex data
- int numIndices;
- GLuint vboIds[3];
-} UserData;
+#include "Simple_TextureCubemap.h"
///
// Create a simple cubemap with a 1x1 face with a different
@@ -100,9 +80,9 @@ static GLuint CreateSimpleTextureCubemap( )
///
// Initialize the shader and program object
//
-int Init ( ESContext *esContext )
+int stcInit ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
+ STCUserData *userData = esContext->userData;
int numSlices = 20;
int numVertices = ( (numSlices / 2) + 1 ) * ( numSlices + 1 );
GLfloat *vertices = NULL;
@@ -167,9 +147,9 @@ int Init ( ESContext *esContext )
///
// Draw a triangle using the shader pair created in Init()
//
-void Draw ( ESContext *esContext )
+void stcDraw ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
+ STCUserData *userData = esContext->userData;
// Set the viewport
glViewport ( 0, 0, esContext->width, esContext->height );
@@ -203,16 +183,14 @@ void Draw ( ESContext *esContext )
glDrawElements ( GL_TRIANGLES, userData->numIndices,
GL_UNSIGNED_SHORT, 0 );
-
- eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
}
///
// Cleanup
//
-void ShutDown ( ESContext *esContext )
+void stcShutDown ( ESContext *esContext )
{
- UserData *userData = esContext->userData;
+ STCUserData *userData = esContext->userData;
// Delete texture object
glDeleteTextures ( 1, &userData->textureId );
@@ -223,24 +201,3 @@ void ShutDown ( ESContext *esContext )
// Delete vertex buffer objects
glDeleteBuffers ( 3, userData->vboIds );
}
-
-
-int main ( int argc, char *argv[] )
-{
- ESContext esContext;
- UserData userData;
-
- esInitContext ( &esContext );
- esContext.userData = &userData;
-
- esCreateWindow ( &esContext, "Simple Texture Cubemap", 320, 240, ES_WINDOW_RGB );
-
- if ( !Init ( &esContext ) )
- return 0;
-
- esRegisterDrawFunc ( &esContext, Draw );
-
- esMainLoop ( &esContext );
-
- ShutDown ( &esContext );
-}
diff --git a/third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h b/third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h
new file mode 100644
index 0000000..3169f97
--- /dev/null
+++ b/third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h
@@ -0,0 +1,49 @@
+//
+// 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_TEXTURE_CUBEMAP_H
+#define SIMPLE_TEXTURE_CUBEMAP_H
+
+#include "esUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+typedef struct
+{
+ // Handle to a program object
+ GLuint programObject;
+
+ // Attribute locations
+ GLint positionLoc;
+ GLint normalLoc;
+
+ // Sampler location
+ GLint samplerLoc;
+
+ // Texture handle
+ GLuint textureId;
+
+ // Vertex data
+ int numIndices;
+ GLuint vboIds[3];
+} STCUserData;
+
+extern int stcInit ( ESContext *esContext );
+
+extern void stcDraw ( ESContext *esContext );
+
+extern void stcShutDown ( ESContext *esContext );
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+#endif // SIMPLE_TEXTURE_CUBEMAP_H
diff --git a/third_party/gles2_book/gles2_book.gyp b/third_party/gles2_book/gles2_book.gyp
index b71b5e1..667fbb5 100644
--- a/third_party/gles2_book/gles2_book.gyp
+++ b/third_party/gles2_book/gles2_book.gyp
@@ -62,6 +62,17 @@
],
},
{
+ 'target_name': 'simple_texture_cubemap',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'es_util',
+ ],
+ 'sources': [
+ 'Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c',
+ 'Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h',
+ ],
+ },
+ {
'target_name': 'simple_vertex_shader',
'type': 'static_library',
'dependencies': [