diff options
Diffstat (limited to 'gpu/command_buffer')
-rw-r--r-- | gpu/command_buffer/client/gles2_demo.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_demo_c.c | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_demo_c.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_demo_cc.cc | 73 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_demo_cc.h | 3 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_lib.cc | 1 | ||||
-rw-r--r-- | gpu/command_buffer/common/constants.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 2 |
8 files changed, 42 insertions, 48 deletions
diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc index 9b5977e..8992c2c 100644 --- a/gpu/command_buffer/client/gles2_demo.cc +++ b/gpu/command_buffer/client/gles2_demo.cc @@ -83,6 +83,8 @@ bool GLES2Demo::Setup(void* hwnd, int32 size) { transfer_buffer.ptr, transfer_buffer_id)); + GLFromCPPInit(); + return command_buffer.release() != NULL; } @@ -97,8 +99,8 @@ LRESULT CALLBACK WindowProc( PostQuitMessage(0); break; case WM_PAINT: { - GLFromCPPTestFunction(); - GLFromCTestFunction(); + GLFromCPPDraw(); + GLFromCDraw(); // TODO(gman): Not sure how SwapBuffer should be exposed. gles2::GetGLContext()->SwapBuffers(); break; diff --git a/gpu/command_buffer/client/gles2_demo_c.c b/gpu/command_buffer/client/gles2_demo_c.c index abba8b7..aa83b57 100644 --- a/gpu/command_buffer/client/gles2_demo_c.c +++ b/gpu/command_buffer/client/gles2_demo_c.c @@ -8,7 +8,7 @@ #include <GLES2/gl2.h> #include "gpu/command_buffer/client/gles2_demo_c.h" -void GLFromCTestFunction() { +void GLFromCDraw() { // glClear(GL_COLOR_BUFFER_BIT); } diff --git a/gpu/command_buffer/client/gles2_demo_c.h b/gpu/command_buffer/client/gles2_demo_c.h index 3ce07b2..d4d69e9 100644 --- a/gpu/command_buffer/client/gles2_demo_c.h +++ b/gpu/command_buffer/client/gles2_demo_c.h @@ -11,7 +11,7 @@ extern "C" { #endif -void GLFromCTestFunction(); +void GLFromCDraw(); #ifdef __cplusplus } diff --git a/gpu/command_buffer/client/gles2_demo_cc.cc b/gpu/command_buffer/client/gles2_demo_cc.cc index 2544f42..c6beff6 100644 --- a/gpu/command_buffer/client/gles2_demo_cc.cc +++ b/gpu/command_buffer/client/gles2_demo_cc.cc @@ -130,15 +130,43 @@ void InitShaders() { CheckGLError(); } -#define PI 3.1415926535897932384626433832795f +GLuint CreateCheckerboardTexture() { + 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); + return texture; +} + +} // anonymous namespace. + +void GLFromCPPInit() { + glClearColor(0.f, 0.f, .7f, 1.f); + g_texture = CreateCheckerboardTexture(); + InitShaders(); +} + +void GLFromCPPDraw() { + const float kPi = 3.1415926535897932384626433832795f; -void Draw() { // TODO(kbr): base the angle on time rather than on ticks g_angle = (g_angle + 1) % 360; // Rotate about the Z axis GLfloat rot_matrix[16]; - GLfloat cos_angle = cosf(static_cast<GLfloat>(g_angle) * PI / 180.0f); - GLfloat sin_angle = sinf(static_cast<GLfloat>(g_angle) * PI / 180.0f); + GLfloat cos_angle = cosf(static_cast<GLfloat>(g_angle) * kPi / 180.0f); + GLfloat sin_angle = sinf(static_cast<GLfloat>(g_angle) * kPi / 180.0f); // OpenGL matrices are column-major rot_matrix[0] = cos_angle; rot_matrix[1] = sin_angle; @@ -188,40 +216,3 @@ void Draw() { CheckGLError(); glFlush(); } - -GLuint CreateCheckerboardTexture() { - 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); - return texture; -} - -void Init() { - glClearColor(0.f, 0.f, .7f, 1.f); - g_texture = CreateCheckerboardTexture(); - InitShaders(); -} - -} // anonymous namespace. - -void GLFromCPPTestFunction() { - static bool initialized = false; - if (!initialized) { - initialized = true; - Init(); - } - Draw(); -} diff --git a/gpu/command_buffer/client/gles2_demo_cc.h b/gpu/command_buffer/client/gles2_demo_cc.h index ef074e0..158ba43 100644 --- a/gpu/command_buffer/client/gles2_demo_cc.h +++ b/gpu/command_buffer/client/gles2_demo_cc.h @@ -7,7 +7,8 @@ #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_CC_H #define GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_CC_H -void GLFromCPPTestFunction(); +void GLFromCPPInit(); +void GLFromCPPDraw(); #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_CC_H diff --git a/gpu/command_buffer/client/gles2_lib.cc b/gpu/command_buffer/client/gles2_lib.cc index 003a4cc..5753715 100644 --- a/gpu/command_buffer/client/gles2_lib.cc +++ b/gpu/command_buffer/client/gles2_lib.cc @@ -16,6 +16,7 @@ void Initialize() { void Terminate() { gpu::ThreadLocalFree(g_gl_context_key); + g_gl_context_key = 0; } gpu::gles2::GLES2Implementation* GetGLContext() { diff --git a/gpu/command_buffer/common/constants.h b/gpu/command_buffer/common/constants.h index b208153..2359bea 100644 --- a/gpu/command_buffer/common/constants.h +++ b/gpu/command_buffer/common/constants.h @@ -20,6 +20,7 @@ namespace error { kOutOfBounds, kUnknownCommand, kInvalidArguments, + kLostContext, kGenericError }; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index ddfc358..684e579 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -1549,8 +1549,6 @@ void GLES2DecoderImpl::DoLinkProgram(GLuint program) { } }; -// NOTE: If you need to know the results of SwapBuffers (like losing -// the context) then add a new command. Do NOT make SwapBuffers synchronous. void GLES2DecoderImpl::DoSwapBuffers() { #if defined(UNIT_TEST) #elif defined(OS_WIN) |