summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-06 07:25:06 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-06 07:25:06 +0000
commit28a9a4b27d7d64b97e108d16512d5ec28fbbf768 (patch)
treef6b46f28f5e50dc53bfda14174c88f019504fd39
parent5d0cd830169f76e9f7fdc8b7ce8235d9ee5dd8a9 (diff)
downloadchromium_src-28a9a4b27d7d64b97e108d16512d5ec28fbbf768.zip
chromium_src-28a9a4b27d7d64b97e108d16512d5ec28fbbf768.tar.gz
chromium_src-28a9a4b27d7d64b97e108d16512d5ec28fbbf768.tar.bz2
Reland a portion of r215672.
The goal is to delete third_party/gles2_book. This patch deletes all known references. BUG=98130 TBR=apatrick@chromium.org Review URL: https://chromiumcodereview.appspot.com/22299002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215832 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/all.gyp1
-rw-r--r--gpu/demos/DEPS3
-rw-r--r--gpu/demos/compressed_textures/compressed_textures.cc380
-rw-r--r--gpu/demos/demos.gyp213
-rw-r--r--gpu/demos/gles2_book/demo_hello_triangle.cc35
-rw-r--r--gpu/demos/gles2_book/demo_mip_map_2d.cc33
-rw-r--r--gpu/demos/gles2_book/demo_simple_texture_2d.cc34
-rw-r--r--gpu/demos/gles2_book/demo_simple_texture_cubemap.cc32
-rw-r--r--gpu/demos/gles2_book/demo_simple_vertex_shader.cc37
-rw-r--r--gpu/demos/gles2_book/demo_stencil_test.cc32
-rw-r--r--gpu/demos/gles2_book/demo_texture_wrap.cc33
-rw-r--r--gpu/demos/gles2_book/example.h91
-rw-r--r--gpu/demos/occlusion_query/occlusion_query.cc312
13 files changed, 0 insertions, 1236 deletions
diff --git a/build/all.gyp b/build/all.gyp
index a10e93d..865bb18 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -148,7 +148,6 @@
'../sandbox/sandbox.gyp:*',
'../third_party/angle_dx11/src/build_angle.gyp:*',
'../third_party/bspatch/bspatch.gyp:*',
- '../third_party/gles2_book/gles2_book.gyp:*',
],
}, {
'dependencies': [
diff --git a/gpu/demos/DEPS b/gpu/demos/DEPS
deleted file mode 100644
index 8684e76..0000000
--- a/gpu/demos/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+third_party/gles2_book",
-]
diff --git a/gpu/demos/compressed_textures/compressed_textures.cc b/gpu/demos/compressed_textures/compressed_textures.cc
deleted file mode 100644
index d2b1ec8..0000000
--- a/gpu/demos/compressed_textures/compressed_textures.cc
+++ /dev/null
@@ -1,380 +0,0 @@
-// Copyright (c) 2011 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.
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <GLES2/gl2extchromium.h>
-#include <math.h>
-#include <stdio.h>
-#include <string>
-
-// Some tests for compressed textures.
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-
-namespace gpu {
-namespace demos {
-
-namespace {
-
-int g_frameCount = 0;
-int g_textureIndex = 0;
-int g_numTextures = 1;
-GLuint g_textures[5];
-int g_textureLoc = -1;
-GLuint g_programObject = 0;
-GLuint g_vbo = 0;
-
-void CheckGLError(const char* func_name, int line_no) {
-#ifndef NDEBUG
- GLenum error = GL_NO_ERROR;
- while ((error = glGetError()) != GL_NO_ERROR) {
- fprintf(stderr, "GL ERROR in %s at line %d : 0x%04x\n",
- func_name, line_no, error);
- }
-#endif
-}
-
-GLuint LoadShader(GLenum type, const char* shaderSrc) {
- CheckGLError("LoadShader", __LINE__);
- GLuint 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
- GLint value = 0;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &value);
- if (value == 0) {
- char buffer[1024];
- GLsizei length = 0;
- glGetShaderInfoLog(shader, sizeof(buffer), &length, buffer);
- std::string log(buffer, length);
- fprintf(stderr, "Error compiling shader: %s\n", log.c_str());
- glDeleteShader(shader);
- return 0;
- }
- return shader;
-}
-
-void InitShaders() {
- static const char* vShaderStr =
- "attribute vec2 g_Position;\n"
- "varying vec2 texCoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(g_Position.x, g_Position.y, 0.0, 1.0);\n"
- " texCoord = g_Position * vec2(0.5) + vec2(0.5);\n"
- "}\n";
- static const char* fShaderStr =
- "precision mediump float;"
- "uniform sampler2D tex;\n"
- "varying vec2 texCoord;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(tex, texCoord);\n"
- "}\n";
-
- CheckGLError("InitShaders", __LINE__);
- GLuint vertexShader = LoadShader(GL_VERTEX_SHADER, vShaderStr);
- GLuint fragmentShader = LoadShader(GL_FRAGMENT_SHADER, fShaderStr);
- // Create the program object
- GLuint programObject = glCreateProgram();
- if (programObject == 0) {
- fprintf(stderr, "Creating program failed\n");
- return;
- }
- glAttachShader(programObject, vertexShader);
- glAttachShader(programObject, fragmentShader);
- // Bind g_Position to attribute 0
- glBindAttribLocation(programObject, 0, "g_Position");
- // Link the program
- glLinkProgram(programObject);
- // Check the link status
- GLint linked = 0;
- glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
- if (linked == 0) {
- char buffer[1024];
- GLsizei length = 0;
- glGetProgramInfoLog(programObject, sizeof(buffer), &length, buffer);
- std::string log(buffer, length);
- fprintf(stderr, "Error linking program: %s\n", log.c_str());
- glDeleteProgram(programObject);
- return;
- }
- g_programObject = programObject;
- g_textureLoc = glGetUniformLocation(g_programObject, "tex");
- glGenBuffers(1, &g_vbo);
- glBindBuffer(GL_ARRAY_BUFFER, g_vbo);
- static float vertices[] = {
- 1.0f, 1.0f,
- -1.0f, 1.0f,
- -1.0f, -1.0f,
- 1.0f, 1.0f,
- -1.0f, -1.0f,
- 1.0f, -1.0f
- };
- glBufferData(GL_ARRAY_BUFFER,
- sizeof(vertices),
- vertices,
- GL_STATIC_DRAW);
- CheckGLError("InitShaders", __LINE__);
-}
-
-GLuint CreateCheckerboardTexture() {
- CheckGLError("CreateCheckerboardTexture", __LINE__);
- static unsigned char pixels[] = {
- 255, 255, 255,
- 0, 0, 0,
- 0, 0, 0,
- 255, 255, 255,
- };
- GLuint texture;
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE,
- pixels);
- CheckGLError("CreateCheckerboardTexture", __LINE__);
- return texture;
-}
-
-GLuint CreateCompressedTexture(
- const void* data,
- GLsizeiptr size,
- GLenum format,
- GLint width,
- GLint height) {
- GLuint texture;
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glCompressedTexImage2D(
- GL_TEXTURE_2D, 0, format, width, height, 0, size, data);
- CheckGLError("CreateCompressedTxture", __LINE__);
- return texture;
-}
-
-GLuint LoadDXT1RGBTexture() {
- static unsigned char data[] = {
- 0x00, 0xd0, 0x00, 0xef, 0x00, 0xaa, 0x95, 0xd5,
- 0x00, 0x90, 0x57, 0xff, 0x00, 0xaa, 0xff, 0x55,
- 0x00, 0x88, 0x99, 0xff, 0x00, 0xaa, 0xff, 0x55,
- 0x20, 0xb8, 0xe4, 0xf6, 0x00, 0xaa, 0x5b, 0x5d,
- 0x21, 0x09, 0xe6, 0x27, 0x15, 0x15, 0x15, 0x15,
- 0xd7, 0xbd, 0xff, 0xff, 0x56, 0x16, 0x16, 0x56,
- 0x00, 0x00, 0xff, 0xff, 0x55, 0x00, 0x00, 0x55,
- 0xe0, 0x08, 0xa9, 0x2f, 0x51, 0x58, 0x56, 0x54,
- 0xff, 0x07, 0x15, 0x09, 0x40, 0x6a, 0xd5, 0xd5,
- 0xd7, 0xbd, 0xff, 0xff, 0x56, 0x16, 0x16, 0x16,
- 0x91, 0x08, 0xff, 0xff, 0x55, 0xff, 0x00, 0x03,
- 0xfe, 0x07, 0x5b, 0x09, 0x01, 0xa9, 0x55, 0xff,
- 0x0d, 0x10, 0x18, 0xe8, 0xea, 0x15, 0x95, 0x55,
- 0x08, 0x88, 0x3c, 0xe7, 0x55, 0x55, 0xff, 0x00,
- 0x10, 0x20, 0x18, 0xe8, 0xa8, 0x54, 0x56, 0x55,
- 0x1f, 0x78, 0x15, 0xf8, 0x00, 0xaa, 0x55, 0x55,
- };
- return CreateCompressedTexture(
- data, sizeof(data), GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 16, 16);
-}
-
-GLuint LoadDXT1RGBATexture() {
- static unsigned char data[] = {
- 0xff, 0xff, 0x90, 0xee, 0x00, 0xaa, 0xff, 0x55,
- 0x53, 0xde, 0xdd, 0xff, 0x55, 0x55, 0x00, 0xff,
- 0xc9, 0xb4, 0xdd, 0xff, 0x55, 0x55, 0xaa, 0xff,
- 0x6f, 0xee, 0xdd, 0xff, 0x55, 0x55, 0xa8, 0x03,
- 0x60, 0xa3, 0xa5, 0xe5, 0x55, 0x55, 0xaa, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff,
- 0x80, 0xab, 0xc2, 0xc4, 0xff, 0x55, 0xaa, 0xff,
- 0x60, 0x9b, 0xa5, 0xe5, 0x57, 0x56, 0xaa, 0x00,
- 0x1f, 0xbf, 0xff, 0xf7, 0x55, 0x55, 0xaa, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff,
- 0xfe, 0xbe, 0x7e, 0xdf, 0xff, 0xaa, 0x55, 0x00,
- 0xfe, 0xbe, 0xff, 0xf7, 0x54, 0x56, 0xaa, 0x00,
- 0xfa, 0x4c, 0x7e, 0x9e, 0x55, 0xaa, 0x00, 0x00,
- 0xbb, 0x2c, 0x98, 0x54, 0xff, 0xff, 0x55, 0xaa,
- 0xfa, 0x4c, 0x7e, 0x9e, 0x55, 0xaa, 0x00, 0x00,
- 0xfa, 0x4c, 0x7e, 0x9e, 0x55, 0xaa, 0x00, 0x00,
- };
- return CreateCompressedTexture(
- data, sizeof(data), GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 16, 16);
-}
-
-GLuint LoadDXT3RGBATexture() {
- static unsigned char data[] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xa3, 0x22, 0x03, 0x03, 0x55, 0xff, 0xaa, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0xcf, 0x7c, 0xc3, 0x12, 0x55, 0x55, 0x55, 0x54,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0x83, 0x1a, 0x03, 0x03, 0x55, 0xff, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff,
- 0xcf, 0x7c, 0xc3, 0x12, 0x55, 0x55, 0x55, 0x54,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xc3, 0x59, 0x63, 0x32, 0x55, 0xff, 0xaa, 0x00,
- 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00,
- 0x8f, 0x94, 0x03, 0x4a, 0x54, 0x94, 0x94, 0x54,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
- 0xa3, 0x59, 0x43, 0x2a, 0x55, 0xff, 0xaa, 0x00,
- 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
- 0xaf, 0x84, 0x03, 0x42, 0x54, 0x55, 0x55, 0x55,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xc3, 0xa0, 0x83, 0x71, 0x55, 0xff, 0xaa, 0x00,
- 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40,
- 0x0f, 0xb4, 0x43, 0x81, 0x54, 0x94, 0x94, 0x94,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xc3, 0xa0, 0x83, 0x69, 0x55, 0xff, 0xaa, 0x00,
- 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xc3, 0xa0, 0x83, 0x69, 0x55, 0xfd, 0xaa, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x23, 0xd0, 0xa3, 0xb0, 0x55, 0xff, 0xaa, 0x00,
- 0x00, 0x40, 0x00, 0x40, 0xff, 0xff, 0xff, 0xff,
- 0xf0, 0xc3, 0x43, 0xc0, 0x94, 0x94, 0x55, 0x55,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x23, 0xd0, 0xa3, 0xb0, 0x55, 0xff, 0xaa, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x23, 0xd0, 0xa3, 0xb0, 0x55, 0xff, 0xaa, 0x00,
- };
- return CreateCompressedTexture(
- data, sizeof(data), GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 16, 16);
-}
-
-GLuint LoadDXT5RGBATexture() {
- static unsigned char data[] = {
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x72, 0xdd, 0x03, 0x92, 0x2d, 0x2d, 0x2d, 0x2d,
- 0x04, 0xfb, 0xff, 0xff, 0xff, 0x49, 0x02, 0xdb,
- 0x97, 0xf6, 0x32, 0xcd, 0xc0, 0xc0, 0x7b, 0xc0,
- 0xfb, 0xff, 0x49, 0x92, 0x24, 0x00, 0x60, 0xdb,
- 0x11, 0xcd, 0x67, 0x82, 0x78, 0x78, 0x5e, 0x78,
- 0x04, 0xfb, 0xff, 0xff, 0xff, 0xf9, 0x8f, 0xff,
- 0x2e, 0xac, 0xc4, 0x71, 0x15, 0x15, 0x15, 0x14,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x72, 0xdd, 0x03, 0x92, 0x2d, 0x2d, 0x2d, 0x2d,
- 0x04, 0x43, 0xb0, 0x0d, 0x3b, 0xb0, 0x03, 0xdb,
- 0xb8, 0xf6, 0xd5, 0xd5, 0x60, 0x60, 0x60, 0x60,
- 0xfb, 0x00, 0x49, 0x02, 0x00, 0x00, 0x90, 0x24,
- 0xb0, 0xbc, 0x26, 0x7a, 0x78, 0x78, 0x78, 0x78,
- 0x04, 0xf7, 0xf8, 0x9f, 0xff, 0xf9, 0x9f, 0xff,
- 0x0e, 0xac, 0x83, 0x69, 0x34, 0x35, 0x35, 0x35,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x72, 0xdd, 0x03, 0x92, 0x2d, 0x2d, 0x2d, 0x2d,
- 0x04, 0x43, 0xb0, 0x0d, 0x3b, 0xb0, 0x03, 0x3b,
- 0xb8, 0xf6, 0xd5, 0xd5, 0x60, 0x60, 0x60, 0x60,
- 0xfb, 0xff, 0xb6, 0x0d, 0x00, 0x49, 0x92, 0x24,
- 0x11, 0xcd, 0x67, 0x82, 0x78, 0x5e, 0x78, 0x78,
- 0xea, 0xff, 0x4a, 0xd2, 0x24, 0x49, 0x92, 0x24,
- 0x0e, 0xac, 0xc4, 0x71, 0x15, 0x15, 0x15, 0x15,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x72, 0xdd, 0x03, 0x92, 0x2d, 0x2d, 0x2d, 0x2d,
- 0xfd, 0x00, 0x49, 0x9c, 0xc4, 0x00, 0x00, 0x00,
- 0xb8, 0xf6, 0x53, 0xcd, 0xe0, 0xe0, 0x7f, 0xe0,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xf1, 0xcc, 0x46, 0x82, 0x78, 0x78, 0x78, 0x78,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0e, 0xac, 0xc4, 0x71, 0x15, 0x15, 0x15, 0x15,
- };
- return CreateCompressedTexture(
- data, sizeof(data), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 16, 16);
-}
-
-} // anonymous namespace.
-
-static int stInit(ESContext *esContext) {
- CheckGLError("GLFromCPPInit", __LINE__);
- g_textures[0] = CreateCheckerboardTexture();
- glClearColor(0.f, 0.f, .7f, 1.f);
- const char* extensions =
- reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
- if (strstr(extensions, "GL_EXT_texture_compression_dxt1")) {
- g_textures[g_numTextures++] = LoadDXT1RGBTexture();
- g_textures[g_numTextures++] = LoadDXT1RGBATexture();
- }
- if (strstr(extensions, "GL_CHROMIUM_texture_compression_dxt3")) {
- g_textures[g_numTextures++] = LoadDXT3RGBATexture();
- }
- if (strstr(extensions, "GL_CHROMIUM_texture_compression_dxt5")) {
- g_textures[g_numTextures++] = LoadDXT5RGBATexture();
- }
- InitShaders();
- CheckGLError("GLFromCPPInit", __LINE__);
- return 1;
-}
-
-static void stDraw (ESContext *esContext) {
- CheckGLError("GLFromCPPDraw", __LINE__);
-
- g_frameCount++;
- if (g_frameCount > 60)
- {
- g_frameCount = 0;
- g_textureIndex = (g_textureIndex + 1) % g_numTextures;
- }
-
- glViewport(0, 0, esContext->width, esContext->height);
- // Clear the color buffer
- glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- CheckGLError("GLFromCPPDraw", __LINE__);
- // Use the program object
- glUseProgram(g_programObject);
- CheckGLError("GLFromCPPDraw", __LINE__);
-
- // Load the vertex data
- glBindBuffer(GL_ARRAY_BUFFER, g_vbo);
- glEnableVertexAttribArray(0);
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
- CheckGLError("GLFromCPPDraw", __LINE__);
- // Bind the texture to texture unit 0
- glBindTexture(GL_TEXTURE_2D, g_textures[g_textureIndex]);
- CheckGLError("GLFromCPPDraw", __LINE__);
- // Point the uniform sampler to texture unit 0
- glUniform1i(g_textureLoc, 0);
- CheckGLError("GLFromCPPDraw", __LINE__);
- glDrawArrays(GL_TRIANGLES, 0, 6);
- CheckGLError("GLFromCPPDraw", __LINE__);
- glFlush();
-}
-
-static void stShutDown (ESContext *esContext) {
-}
-
-struct STUserData {
- int dummy;
-};
-
-class CompressedTextureTest : public gles2_book::Example<STUserData> {
- public:
- CompressedTextureTest() {
- RegisterCallbacks(stInit, NULL, stDraw, stShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Compressed Texture Test";
- }
-
- bool IsAnimated() {
- return true;
- }
-};
-
-Demo* CreateDemo() {
- return new CompressedTextureTest();
-}
-
-} // namespace demos
-} // namespace gpu
-
-
diff --git a/gpu/demos/demos.gyp b/gpu/demos/demos.gyp
index e716bf7..5b89759 100644
--- a/gpu/demos/demos.gyp
+++ b/gpu/demos/demos.gyp
@@ -73,21 +73,14 @@
'include_dirs': [
'../..',
'../../ppapi/lib/gl/include',
- '../../third_party/gles2_book/Common/Include',
],
'sources': [
'framework/pepper.cc',
- '../../third_party/gles2_book/Common/Include/esUtil.h',
- '../../third_party/gles2_book/Common/Source/esShader.c',
- '../../third_party/gles2_book/Common/Source/esShapes.c',
- '../../third_party/gles2_book/Common/Source/esTransform.c',
- '../../third_party/gles2_book/Common/Source/esUtil.c',
],
'direct_dependent_settings': {
'include_dirs': [
'../..',
'../../ppapi/lib/gl/include',
- '../../third_party/gles2_book/Common/Include',
],
'run_as': {
'conditions': [
@@ -121,211 +114,5 @@
],
},
},
- {
- 'target_name': 'hello_triangle_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:hello_triangle',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/demo_hello_triangle.cc',
- ],
- },
- {
- 'target_name': 'mip_map_2d_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:mip_map_2d',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/demo_mip_map_2d.cc',
- ],
- },
- {
- 'target_name': 'simple_texture_2d_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:simple_texture_2d',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/demo_simple_texture_2d.cc',
- ],
- },
- {
- 'target_name': 'simple_texture_cubemap_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:simple_texture_cubemap',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/demo_simple_texture_cubemap.cc',
- ],
- },
- {
- 'target_name': 'simple_vertex_shader_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:simple_vertex_shader',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/demo_simple_vertex_shader.cc',
- ],
- },
- {
- 'target_name': 'stencil_test_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:stencil_test',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/demo_stencil_test.cc',
- ],
- },
- {
- 'target_name': 'texture_wrap_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:texture_wrap',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/demo_texture_wrap.cc',
- ],
- },
- {
- 'target_name': 'compressed_textures_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:es_util',
- ],
- 'sources': [
- 'compressed_textures/compressed_textures.cc',
- ],
- },
- {
- 'target_name': 'occlusion_query_exe',
- 'type': 'executable',
- 'dependencies': [
- 'gpu_demo_framework_exe',
- '../../third_party/gles2_book/gles2_book.gyp:es_util',
- ],
- 'defines': [
- 'GL_GLEXT_PROTOTYPES',
- ],
- 'sources': [
- 'occlusion_query/occlusion_query.cc',
- ],
- },
- ],
- 'conditions': [
- ['enable_pepper_demos==1', {
- 'targets': [
- {
- 'target_name': 'hello_triangle_ppapi',
- 'type': 'loadable_module',
- 'variables': { 'chromium_code': 0, },
- 'dependencies': [ 'gpu_demo_framework_ppapi', ],
- 'sources': [
- '<@(ppp_entrypoints_sources)',
- 'gles2_book/example.h',
- 'gles2_book/demo_hello_triangle.cc',
- '../../third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.c',
- '../../third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.h',
- ],
- },
- {
- 'target_name': 'mip_map_2d_ppapi',
- 'type': 'loadable_module',
- 'variables': { 'chromium_code': 0, },
- 'dependencies': [ 'gpu_demo_framework_ppapi', ],
- 'sources': [
- '<@(ppp_entrypoints_sources)',
- 'gles2_book/example.h',
- 'gles2_book/demo_mip_map_2d.cc',
- '../../third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.c',
- '../../third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.h',
- ],
- },
- {
- 'target_name': 'simple_texture_2d_ppapi',
- 'type': 'loadable_module',
- 'variables': { 'chromium_code': 0, },
- 'dependencies': [ 'gpu_demo_framework_ppapi', ],
- 'sources': [
- '<@(ppp_entrypoints_sources)',
- 'gles2_book/example.h',
- 'gles2_book/demo_simple_texture_2d.cc',
- '../../third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.c',
- '../../third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.h',
- ],
- },
- {
- 'target_name': 'simple_texture_cubemap_ppapi',
- 'type': 'loadable_module',
- 'variables': { 'chromium_code': 0, },
- 'dependencies': [ 'gpu_demo_framework_ppapi', ],
- 'sources': [
- '<@(ppp_entrypoints_sources)',
- 'gles2_book/example.h',
- 'gles2_book/demo_simple_texture_cubemap.cc',
- '../../third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c',
- '../../third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h',
- ],
- },
- {
- 'target_name': 'simple_vertex_shader_ppapi',
- 'type': 'loadable_module',
- 'variables': { 'chromium_code': 0, },
- 'dependencies': [ 'gpu_demo_framework_ppapi', ],
- 'sources': [
- '<@(ppp_entrypoints_sources)',
- 'gles2_book/example.h',
- 'gles2_book/demo_simple_vertex_shader.cc',
- '../../third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c',
- '../../third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.h',
- ],
- },
- {
- 'target_name': 'stencil_test_ppapi',
- 'type': 'loadable_module',
- 'variables': { 'chromium_code': 0, },
- 'dependencies': [ 'gpu_demo_framework_ppapi', ],
- 'sources': [
- '<@(ppp_entrypoints_sources)',
- 'gles2_book/example.h',
- 'gles2_book/demo_stencil_test.cc',
- '../../third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c',
- '../../third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h',
- ],
- },
- {
- 'target_name': 'texture_wrap_ppapi',
- 'type': 'loadable_module',
- 'variables': { 'chromium_code': 0, },
- 'dependencies': [ 'gpu_demo_framework_ppapi', ],
- 'sources': [
- '<@(ppp_entrypoints_sources)',
- 'gles2_book/example.h',
- 'gles2_book/demo_texture_wrap.cc',
- '../../third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.c',
- '../../third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.h',
- ],
- },
- ],
- }],
],
}
diff --git a/gpu/demos/gles2_book/demo_hello_triangle.cc b/gpu/demos/gles2_book/demo_hello_triangle.cc
deleted file mode 100644
index 806a0dd..0000000
--- a/gpu/demos/gles2_book/demo_hello_triangle.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2010 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.
-
-// This is a simple example that draws a single triangle with
-// a minimal vertex/fragment shader. The purpose of this
-// example is to demonstrate the basic concepts of
-// OpenGL ES 2.0 rendering.
-
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-#include "third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.h"
-
-namespace gpu {
-namespace demos {
-
-namespace gles2_book {
-class HelloTriangle : public Example<HTUserData> {
- public:
- HelloTriangle() {
- RegisterCallbacks(htInit, NULL, htDraw, htShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Hello Triangle";
- }
-};
-} // namespace gles2_book
-
-Demo* CreateDemo() {
- return new gles2_book::HelloTriangle();
-}
-
-} // namespace demos
-} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_mip_map_2d.cc b/gpu/demos/gles2_book/demo_mip_map_2d.cc
deleted file mode 100644
index fcb5c3b..0000000
--- a/gpu/demos/gles2_book/demo_mip_map_2d.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2010 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.
-
-// This is a simple example that demonstrates generating a mipmap chain
-// and rendering with it.
-
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-#include "third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.h"
-
-namespace gpu {
-namespace demos {
-
-namespace gles2_book {
-class MipMap2D : public Example<MMUserData> {
- public:
- MipMap2D() {
- RegisterCallbacks(mmInit, NULL, mmDraw, mmShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Mip-Map 2D";
- }
-};
-} // namespace gles2_book
-
-Demo* CreateDemo() {
- return new gles2_book::MipMap2D();
-}
-
-} // namespace demos
-} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_simple_texture_2d.cc b/gpu/demos/gles2_book/demo_simple_texture_2d.cc
deleted file mode 100644
index 3f4eff6..0000000
--- a/gpu/demos/gles2_book/demo_simple_texture_2d.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2010 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.
-
-// This is a simple example that draws a quad with a 2D
-// texture image. The purpose of this example is to demonstrate
-// the basics of 2D texturing.
-
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-#include "third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.h"
-
-namespace gpu {
-namespace demos {
-
-namespace gles2_book {
-class SimpleTexture2D : public Example<STUserData> {
- public:
- SimpleTexture2D() {
- RegisterCallbacks(stInit, NULL, stDraw, stShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Simple Texture 2D";
- }
-};
-} // namespace gles2_book
-
-Demo* CreateDemo() {
- return new gles2_book::SimpleTexture2D();
-}
-
-} // namespace demos
-} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc b/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc
deleted file mode 100644
index 6db525b..0000000
--- a/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2010 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.
-
-// This is a simple example that draws a sphere with a cubemap image applied.
-
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-#include "third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h"
-
-namespace gpu {
-namespace demos {
-
-namespace gles2_book {
-class SimpleTextureCubemap : public Example<STCUserData> {
- public:
- SimpleTextureCubemap() {
- RegisterCallbacks(stcInit, NULL, stcDraw, stcShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Simple Texture Cubemap";
- }
-};
-} // namespace gles2_book
-
-Demo* CreateDemo() {
- return new gles2_book::SimpleTextureCubemap();
-}
-
-} // namespace demos
-} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_simple_vertex_shader.cc b/gpu/demos/gles2_book/demo_simple_vertex_shader.cc
deleted file mode 100644
index 0f8b72e..0000000
--- a/gpu/demos/gles2_book/demo_simple_vertex_shader.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2010 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.
-
-// This is a simple example that draws a rotating cube in perspective
-// using a vertex shader to transform the object.
-
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-#include "third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.h"
-
-namespace gpu {
-namespace demos {
-
-namespace gles2_book {
-class SimpleVertexShader : public Example<SVSUserData> {
- public:
- SimpleVertexShader() {
- RegisterCallbacks(svsInit, svsUpdate, svsDraw, svsShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Simple Vertex Shader";
- }
-
- virtual bool IsAnimated() {
- return true;
- }
-};
-} // namespace gles2_book
-
-Demo* CreateDemo() {
- return new gles2_book::SimpleVertexShader();
-}
-
-} // namespace demos
-} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_stencil_test.cc b/gpu/demos/gles2_book/demo_stencil_test.cc
deleted file mode 100644
index 66be791..0000000
--- a/gpu/demos/gles2_book/demo_stencil_test.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2010 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.
-
-// This example shows various stencil buffer operations.
-
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-#include "third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h"
-
-namespace gpu {
-namespace demos {
-
-namespace gles2_book {
-class StencilTest : public Example<STUserData> {
- public:
- StencilTest() {
- RegisterCallbacks(stInit, NULL, stDraw, stShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Stencil Test";
- }
-};
-} // namespace gles2_book
-
-Demo* CreateDemo() {
- return new gles2_book::StencilTest();
-}
-
-} // namespace demos
-} // namespace gpu
diff --git a/gpu/demos/gles2_book/demo_texture_wrap.cc b/gpu/demos/gles2_book/demo_texture_wrap.cc
deleted file mode 100644
index a3fb3ba..0000000
--- a/gpu/demos/gles2_book/demo_texture_wrap.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2010 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.
-
-// This is an example that demonstrates the three texture
-// wrap modes available on 2D textures.
-
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-#include "third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.h"
-
-namespace gpu {
-namespace demos {
-
-namespace gles2_book {
-class TextureWrap : public Example<TWUserData> {
- public:
- TextureWrap() {
- RegisterCallbacks(twInit, NULL, twDraw, twShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Texture Wrap";
- }
-};
-} // namespace gles2_book
-
-Demo* CreateDemo() {
- return new gles2_book::TextureWrap();
-}
-
-} // namespace demos
-} // namespace gpu
diff --git a/gpu/demos/gles2_book/example.h b/gpu/demos/gles2_book/example.h
deleted file mode 100644
index 0eaf1a4..0000000
--- a/gpu/demos/gles2_book/example.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2006-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.
-
-// Base class for OpenGL ES 2.0 book examples.
-
-#ifndef GPU_DEMOS_GLES2_BOOK_EXAMPLE_H_
-#define GPU_DEMOS_GLES2_BOOK_EXAMPLE_H_
-
-#include <cassert>
-#include <cstring>
-
-#include "gpu/demos/framework/demo.h"
-#include "third_party/gles2_book/Common/Include/esUtil.h"
-
-namespace gpu {
-namespace demos {
-namespace gles2_book {
-
-typedef int InitFunc(ESContext* context);
-typedef void UpdateFunc(ESContext* context, float elapsed_sec);
-typedef void DrawFunc(ESContext* context);
-typedef void ShutDownFunc(ESContext* context);
-
-// The examples taken from OpenGL 2.0 ES book follow a well-defined pattern.
-// They all use one ESContext that holds a reference to a custom UserData.
-// Each example provides four functions:
-// 1. InitFunc to initialize OpenGL state and custom UserData
-// 2. UpdateFunc is called before drawing each frame to update animation etc.
-// 3. DrawFunc is called to do the actual frame rendering
-// 4. ShutDownFunc is called when program terminates
-// This class encapsulates this pattern to make it easier to write classes
-// for each example.
-template <typename UserData>
-class Example : public gpu::demos::Demo {
- public:
- Example()
- : init_func_(NULL),
- update_func_(NULL),
- draw_func_(NULL),
- shut_down_func_(NULL) {
- esInitContext(&context_);
- memset(&user_data_, 0, sizeof(UserData));
- context_.userData = &user_data_;
- }
- virtual ~Example() {
- shut_down_func_(&context_);
- }
-
- virtual bool InitGL() {
- // Note that update_func is optional.
- assert(init_func_ && draw_func_ && shut_down_func_);
-
- if (!init_func_(&context_)) return false;
- return true;
- }
-
- protected:
- void RegisterCallbacks(InitFunc* init_func,
- UpdateFunc* update_func,
- DrawFunc* draw_func,
- ShutDownFunc* shut_down_func) {
- init_func_ = init_func;
- update_func_ = update_func;
- draw_func_ = draw_func;
- shut_down_func_ = shut_down_func;
- }
-
- virtual void Render(float elapsed_sec) {
- context_.width = width();
- context_.height = height();
-
- if (update_func_) update_func_(&context_, elapsed_sec);
- draw_func_(&context_);
- }
-
- private:
- ESContext context_;
- UserData user_data_;
-
- // Callback functions.
- InitFunc* init_func_;
- UpdateFunc* update_func_;
- DrawFunc* draw_func_;
- ShutDownFunc* shut_down_func_;
-};
-
-} // namespace gles2_book
-} // namespace demos
-} // namespace gpu
-#endif // GPU_DEMOS_GLES2_BOOK_EXAMPLE_H_
diff --git a/gpu/demos/occlusion_query/occlusion_query.cc b/gpu/demos/occlusion_query/occlusion_query.cc
deleted file mode 100644
index 4cab2e8..0000000
--- a/gpu/demos/occlusion_query/occlusion_query.cc
+++ /dev/null
@@ -1,312 +0,0 @@
-// Copyright (c) 2012 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.
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <math.h>
-#include <stdio.h>
-#include <string>
-
-// Some tests for occlusion queries.
-#include "gpu/demos/framework/demo_factory.h"
-#include "gpu/demos/gles2_book/example.h"
-
-namespace gpu {
-namespace demos {
-
-namespace {
-
-class OcclusionQueryTest;
-
-struct STUserData {
- OcclusionQueryTest* demo;
-};
-
-class OcclusionQueryTest : public gles2_book::Example<STUserData> {
- public:
- OcclusionQueryTest()
- : elasped_sec_(0),
- program_(0),
- matrix_loc_(0),
- color_loc_(0),
- vbo_(0),
- query_(0),
- clock_(0),
- last_query_status_(0) {
- test_ = this;
- RegisterCallbacks(stInit, stUpdate, stDraw, stShutDown);
- }
-
- const wchar_t* Title() const {
- return L"Occlusion Query Test";
- }
-
- bool IsAnimated() {
- return true;
- }
-
- private:
- int Init(ESContext* esContext);
- void Update(ESContext* esContext, float elapsed_sec);
- void Draw(ESContext* esContext);
- void ShutDown(ESContext* esContext);
-
- void InitShaders();
- void DrawRect(float x, float z, float scale, float* color);
-
- static int stInit(ESContext* esContext) {
- static_cast<STUserData*>(esContext->userData)->demo = test_;
- test_ = NULL;
- return static_cast<STUserData*>(esContext->userData)->demo->Init(esContext);
- }
-
- static void stUpdate (ESContext* esContext, float elapsed_sec) {
- static_cast<STUserData*>(esContext->userData)->demo->Update(
- esContext, elapsed_sec);
- }
-
- static void stShutDown (ESContext* esContext) {
- static_cast<STUserData*>(esContext->userData)->demo->ShutDown(
- esContext);
- }
-
- static void stDraw (ESContext* esContext) {
- static_cast<STUserData*>(esContext->userData)->demo->Draw(
- esContext);
- }
-
- // This is the test being created. Because the GLES2 book's framework
- // has no way to pass anything into the init funciton this is a hacky
- // workaround.
- static OcclusionQueryTest* test_;
-
- float elasped_sec_;
- GLuint program_;
- GLint matrix_loc_;
- GLint color_loc_;
- GLuint vbo_;
- GLuint query_;
- float clock_;
- GLuint last_query_status_;
-
- static float red_[4];
- static float green_[4];
- static float blue_[4];
-};
-
-OcclusionQueryTest* OcclusionQueryTest::test_;
-float OcclusionQueryTest::red_[4] = { 1, 0, 0, 1, };
-float OcclusionQueryTest::green_[4] = { 0, 1, 0, 1, };
-float OcclusionQueryTest::blue_[4] = { 0, 0, 1, 1, };
-
-void CheckGLError(const char* func_name, int line_no) {
-#ifndef NDEBUG
- GLenum error = GL_NO_ERROR;
- while ((error = glGetError()) != GL_NO_ERROR) {
- fprintf(stderr, "GL ERROR in %s at line %d : 0x%04x\n",
- func_name, line_no, error);
- }
-#endif
-}
-
-GLuint LoadShader(GLenum type, const char* shaderSrc) {
- CheckGLError("LoadShader", __LINE__);
- GLuint 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
- GLint value = 0;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &value);
- if (value == 0) {
- char buffer[1024];
- GLsizei length = 0;
- glGetShaderInfoLog(shader, sizeof(buffer), &length, buffer);
- std::string log(buffer, length);
- fprintf(stderr, "Error compiling shader: %s\n", log.c_str());
- glDeleteShader(shader);
- return 0;
- }
- return shader;
-}
-
-void OcclusionQueryTest::InitShaders() {
- static const char* v_shader_str =
- "uniform mat4 worldMatrix;\n"
- "attribute vec3 g_Position;\n"
- "void main()\n"
- "{\n"
- " gl_Position = worldMatrix *\n"
- " vec4(g_Position.x, g_Position.y, g_Position.z, 1.0);\n"
- "}\n";
- static const char* f_shader_str =
- "precision mediump float;"
- "uniform vec4 color;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = color;\n"
- "}\n";
-
- CheckGLError("InitShaders", __LINE__);
- GLuint vertex_shader = LoadShader(GL_VERTEX_SHADER, v_shader_str);
- GLuint fragment_shader = LoadShader(GL_FRAGMENT_SHADER, f_shader_str);
- // Create the program object
- GLuint program = glCreateProgram();
- if (program == 0) {
- fprintf(stderr, "Creating program failed\n");
- return;
- }
- glAttachShader(program, vertex_shader);
- glAttachShader(program, fragment_shader);
- // Bind g_Position to attribute 0
- glBindAttribLocation(program, 0, "g_Position");
- // Link the program
- glLinkProgram(program);
- // Check the link status
- GLint linked = 0;
- glGetProgramiv(program, GL_LINK_STATUS, &linked);
- if (linked == 0) {
- char buffer[1024];
- GLsizei length = 0;
- glGetProgramInfoLog(program, sizeof(buffer), &length, buffer);
- std::string log(buffer, length);
- fprintf(stderr, "Error linking program: %s\n", log.c_str());
- glDeleteProgram(program);
- return;
- }
- program_ = program;
- matrix_loc_ = glGetUniformLocation(program_, "worldMatrix");
- color_loc_ = glGetUniformLocation(program_, "color");
- glGenBuffers(1, &vbo_);
- glBindBuffer(GL_ARRAY_BUFFER, vbo_);
- static float vertices[] = {
- 1, 1, 0.0,
- -1, 1, 0.0,
- -1, -1, 0.0,
- 1, 1, 0.0,
- -1, -1, 0.0,
- 1, -1, 0.0,
- };
- glBufferData(GL_ARRAY_BUFFER,
- sizeof(vertices),
- NULL,
- GL_STATIC_DRAW);
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
- CheckGLError("InitShaders", __LINE__);
-
- glGenQueriesEXT(1, &query_);
- glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query_);
- glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
- CheckGLError("InitShaders", __LINE__);
-}
-
-} // anonymous namespace.
-
-int OcclusionQueryTest::Init(ESContext* esContext) {
- CheckGLError("GLFromCPPInit", __LINE__);
- glClearColor(0.0f, 0.1f, 0.2f, 1.0f);
- InitShaders();
- CheckGLError("GLFromCPPInit", __LINE__);
- return 1;
-}
-
-void OcclusionQueryTest::Update(ESContext* esContext, float elapsed_sec) {
- elasped_sec_ = elapsed_sec;
-}
-
-static void SetMatrix(float x, float z, float scale, float* matrix) {
- matrix[0] = scale;
- matrix[1] = 0.0f;
- matrix[2] = 0.0f;
- matrix[3] = 0.0f;
-
- matrix[4] = 0.0f;
- matrix[5] = scale;
- matrix[6] = 0.0f;
- matrix[7] = 0.0f;
-
- matrix[8] = 0.0f;
- matrix[9] = 0.0f;
- matrix[10] = scale;
- matrix[11] = 0.0f;
-
- matrix[12] = x;
- matrix[13] = 0.0f;
- matrix[14] = z;
- matrix[15] = 1.0f;
-}
-
-void OcclusionQueryTest::DrawRect(float x, float z, float scale, float* color) {
- GLfloat matrix[16];
-
- SetMatrix(x, z, scale, matrix);
-
- // Set up the model matrix
- glUniformMatrix4fv(matrix_loc_, 1, GL_FALSE, matrix);
-
- glUniform4fv(color_loc_, 1, color);
- CheckGLError("GLFromCPPDraw", __LINE__);
-
- glDrawArrays(GL_TRIANGLES, 0, 6);
- CheckGLError("GLFromCPPDraw", __LINE__);
-}
-
-void OcclusionQueryTest::Draw(ESContext* esContext) {
- CheckGLError("GLFromCPPDraw", __LINE__);
- clock_ += elasped_sec_;
-
- // Note: the viewport is automatically set up to cover the entire Canvas.
- // Clear the color buffer
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glEnable(GL_DEPTH_TEST);
- CheckGLError("GLFromCPPDraw", __LINE__);
- // Use the program object
- glUseProgram(program_);
- CheckGLError("GLFromCPPDraw", __LINE__);
-
- // Load the vertex data
- glBindBuffer(GL_ARRAY_BUFFER, vbo_);
- glEnableVertexAttribArray(0);
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
- CheckGLError("GLFromCPPDraw", __LINE__);
-
- DrawRect(sinf(clock_), 0.0f, 0.50f,
- last_query_status_ ? green_ : red_);
-
- bool started_query = false;
- GLuint result = 0;
- glGetQueryObjectuivEXT(query_, GL_QUERY_RESULT_AVAILABLE_EXT, &result);
- CheckGLError("GLFromCPPDraw", __LINE__);
- if (result) {
- glGetQueryObjectuivEXT(query_, GL_QUERY_RESULT_EXT, &last_query_status_);
- CheckGLError("GLFromCPPDraw", __LINE__);
- glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query_);
- CheckGLError("GLFromCPPDraw", __LINE__);
- started_query = true;
- }
-
- DrawRect(-0.125f, 0.1f, 0.25f, blue_);
-
- if (started_query) {
- glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
- CheckGLError("GLFromCPPDraw", __LINE__);
- }
-
- glFlush();
-}
-
-void OcclusionQueryTest::ShutDown(ESContext* esContext) {
-}
-
-Demo* CreateDemo() {
- return new OcclusionQueryTest();
-}
-
-} // namespace demos
-} // namespace gpu
-
-