OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" | 5 #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" |
6 | 6 |
7 static const struct PPB_OpenGLES_Dev* g_gles2_interface; | 7 #ifndef GL_FALSE |
| 8 #define GL_FALSE 0 |
| 9 #endif // GL_FALSE |
8 | 10 |
9 int GL_APIENTRY glInitializePPAPI( | 11 #ifndef GL_TRUE |
10 PP_Module module, | 12 #define GL_TRUE 1 |
| 13 #endif // GL_TRUE |
| 14 |
| 15 #if defined(__GNUC__) && !defined(__APPLE__) |
| 16 #define PP_TLS __thread |
| 17 #elif defined(_MSC_VER) |
| 18 #define PP_TLS __declspec(thread) |
| 19 #else |
| 20 // TODO(alokp): Fix all other platforms. |
| 21 #define PP_TLS |
| 22 #endif |
| 23 |
| 24 // TODO(alokp): This will need to be thread-safe if we build gles2 as a |
| 25 // shared library. |
| 26 static const struct PPB_OpenGLES2_Dev* g_gles2_interface = NULL; |
| 27 |
| 28 // TODO(alokp): Make sure PP_TLS works on all supported platforms. |
| 29 static PP_TLS PP_Resource g_current_context = 0; |
| 30 |
| 31 GLboolean GL_APIENTRY glInitializePPAPI( |
11 PPB_GetInterface get_browser_interface) { | 32 PPB_GetInterface get_browser_interface) { |
12 return 0; | 33 if (!g_gles2_interface) { |
| 34 g_gles2_interface = get_browser_interface(PPB_OPENGLES2_DEV_INTERFACE); |
| 35 } |
| 36 return g_gles2_interface ? GL_TRUE : GL_FALSE; |
13 } | 37 } |
14 | 38 |
15 int GL_APIENTRY glTerminatePPAPI() { | 39 GLboolean GL_APIENTRY glTerminatePPAPI() { |
16 return 0; | 40 g_gles2_interface = NULL; |
| 41 return GL_TRUE; |
17 } | 42 } |
18 | 43 |
19 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { | 44 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { |
| 45 g_current_context = context; |
20 } | 46 } |
21 | 47 |
22 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { | 48 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { |
23 return 0; | 49 return g_current_context; |
24 } | 50 } |
25 | 51 |
26 const struct PPB_OpenGLES_Dev* GL_APIENTRY glGetInterfacePPAPI() { | 52 const struct PPB_OpenGLES2_Dev* GL_APIENTRY glGetInterfacePPAPI() { |
27 return g_gles2_interface; | 53 return g_gles2_interface; |
28 } | 54 } |
29 | 55 |
OLD | NEW |