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 // TODO(alokp): This will need to be thread-safe if we build gles2 as a | |
16 // shared library. | |
17 static const struct PPB_OpenGLES2_Dev* g_gles2_interface = NULL; | |
18 | |
19 #if __GNUC__ >= 4 | |
20 #define PP_TLS __thread | |
21 #elif defined(_MSC_VER) | |
22 #define PP_TLS __declspec(thread) | |
apatrick_chromium
2010/12/16 22:46:00
This probably isn't an issue for NaCl but perhaps
alokp
2010/12/20 17:24:40
I guess I will have to do the same then. There is
| |
23 #else | |
24 #error "Thread-local storage not supported" | |
25 #endif | |
26 // TODO(alokp): Make sure PP_TLS works on all supported platforms. | |
27 static PP_TLS PP_Resource g_current_context = 0; | |
28 | |
29 GLboolean GL_APIENTRY glInitializePPAPI( | |
11 PPB_GetInterface get_browser_interface) { | 30 PPB_GetInterface get_browser_interface) { |
12 return 0; | 31 if (!g_gles2_interface) { |
32 g_gles2_interface = get_browser_interface(PPB_OPENGLES2_DEV_INTERFACE); | |
33 } | |
34 return g_gles2_interface ? GL_TRUE : GL_FALSE; | |
13 } | 35 } |
14 | 36 |
15 int GL_APIENTRY glTerminatePPAPI() { | 37 GLboolean GL_APIENTRY glTerminatePPAPI() { |
16 return 0; | 38 g_gles2_interface = NULL; |
39 return GL_TRUE; | |
17 } | 40 } |
18 | 41 |
19 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { | 42 void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { |
43 g_current_context = context; | |
20 } | 44 } |
21 | 45 |
22 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { | 46 PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { |
23 return 0; | 47 return g_current_context; |
24 } | 48 } |
25 | 49 |
26 const struct PPB_OpenGLES_Dev* GL_APIENTRY glGetInterfacePPAPI() { | 50 const struct PPB_OpenGLES2_Dev* GL_APIENTRY glGetInterfacePPAPI() { |
27 return g_gles2_interface; | 51 return g_gles2_interface; |
28 } | 52 } |
29 | 53 |
OLD | NEW |