root/OpenSceneGraph/trunk/src/osg/GLStaticLibrary.cpp @ 13041

Revision 13041, 6.6 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 * Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
3 * Copyright (C) 2004-2005 Nathan Cournia
4 * Copyright (C) 2008 Zebra Imaging
5 *
6 * This application is open source and may be redistributed and/or modified
7 * freely and without restriction, both in commercial and non commercial
8 * applications, as long as this copyright notice is maintained.
9 *
10 * This application is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *
14*/
15
16/* file:        src/osg/GLStaticLibrary.cpp
17 * author:      Alok Priyadarshi 2010-04-27
18*/
19
20#include "GLStaticLibrary.h"
21#include <osg/GL>
22#include <osg/Notify>
23
24#include <map>
25#include <string>
26
27// This file is intended for GL static linking only.
28#if defined(OSG_GL_LIBRARY_STATIC)
29
30using namespace osg;
31
32namespace {
33typedef void (*GLProc)(void);
34typedef std::map<std::string, GLProc> GLProcAddressMap;
35static bool sProcAddressInitialized = false;
36static GLProcAddressMap sProcAddressMap;
37
38#define ADD_FUNCTION(FunctionName) sProcAddressMap[#FunctionName] = reinterpret_cast<GLProc>(&FunctionName);
39
40void initGLES2ProcAddress()
41{
42    ADD_FUNCTION(glActiveTexture)
43    ADD_FUNCTION(glAttachShader)
44    ADD_FUNCTION(glBindAttribLocation)
45    ADD_FUNCTION(glBindBuffer)
46    ADD_FUNCTION(glBindFramebuffer)
47    ADD_FUNCTION(glBindRenderbuffer)
48    ADD_FUNCTION(glBindTexture)
49    ADD_FUNCTION(glBlendColor)
50    ADD_FUNCTION(glBlendEquation)
51    ADD_FUNCTION(glBlendEquationSeparate)
52    ADD_FUNCTION(glBlendFunc)
53    ADD_FUNCTION(glBlendFuncSeparate)
54    ADD_FUNCTION(glBufferData)
55    ADD_FUNCTION(glBufferSubData)
56    ADD_FUNCTION(glCheckFramebufferStatus)
57    ADD_FUNCTION(glClear)
58    ADD_FUNCTION(glClearColor)
59    ADD_FUNCTION(glClearDepthf)
60    ADD_FUNCTION(glClearStencil)
61    ADD_FUNCTION(glColorMask)
62    ADD_FUNCTION(glCompileShader)
63    ADD_FUNCTION(glCompressedTexImage2D)
64    ADD_FUNCTION(glCompressedTexSubImage2D)
65    ADD_FUNCTION(glCopyTexImage2D)
66    ADD_FUNCTION(glCopyTexSubImage2D)
67    ADD_FUNCTION(glCreateProgram)
68    ADD_FUNCTION(glCreateShader)
69    ADD_FUNCTION(glCullFace)
70    ADD_FUNCTION(glDeleteBuffers)
71    ADD_FUNCTION(glDeleteFramebuffers)
72    ADD_FUNCTION(glDeleteProgram)
73    ADD_FUNCTION(glDeleteRenderbuffers)
74    ADD_FUNCTION(glDeleteShader)
75    ADD_FUNCTION(glDeleteTextures)
76    ADD_FUNCTION(glDepthFunc)
77    ADD_FUNCTION(glDepthMask)
78    ADD_FUNCTION(glDepthRangef)
79    ADD_FUNCTION(glDetachShader)
80    ADD_FUNCTION(glDisable)
81    ADD_FUNCTION(glDisableVertexAttribArray)
82    ADD_FUNCTION(glDrawArrays)
83    ADD_FUNCTION(glDrawElements)
84    ADD_FUNCTION(glEnable)
85    ADD_FUNCTION(glEnableVertexAttribArray)
86    ADD_FUNCTION(glFinish)
87    ADD_FUNCTION(glFlush)
88    ADD_FUNCTION(glFramebufferRenderbuffer)
89    ADD_FUNCTION(glFramebufferTexture2D)
90    ADD_FUNCTION(glFrontFace)
91    ADD_FUNCTION(glGenBuffers)
92    ADD_FUNCTION(glGenerateMipmap)
93    ADD_FUNCTION(glGenFramebuffers)
94    ADD_FUNCTION(glGenRenderbuffers)
95    ADD_FUNCTION(glGenTextures)
96    ADD_FUNCTION(glGetActiveAttrib)
97    ADD_FUNCTION(glGetActiveUniform)
98    ADD_FUNCTION(glGetAttachedShaders)
99    ADD_FUNCTION(glGetAttribLocation)
100    ADD_FUNCTION(glGetBooleanv)
101    ADD_FUNCTION(glGetBufferParameteriv)
102    ADD_FUNCTION(glGetError)
103    ADD_FUNCTION(glGetFloatv)
104    ADD_FUNCTION(glGetFramebufferAttachmentParameteriv)
105    ADD_FUNCTION(glGetIntegerv)
106    ADD_FUNCTION(glGetProgramiv)
107    ADD_FUNCTION(glGetProgramInfoLog)
108    ADD_FUNCTION(glGetRenderbufferParameteriv)
109    ADD_FUNCTION(glGetShaderiv)
110    ADD_FUNCTION(glGetShaderInfoLog)
111    ADD_FUNCTION(glGetShaderPrecisionFormat)
112    ADD_FUNCTION(glGetShaderSource)
113    ADD_FUNCTION(glGetString)
114    ADD_FUNCTION(glGetTexParameterfv)
115    ADD_FUNCTION(glGetTexParameteriv)
116    ADD_FUNCTION(glGetUniformfv)
117    ADD_FUNCTION(glGetUniformiv)
118    ADD_FUNCTION(glGetUniformLocation)
119    ADD_FUNCTION(glGetVertexAttribfv)
120    ADD_FUNCTION(glGetVertexAttribiv)
121    ADD_FUNCTION(glGetVertexAttribPointerv)
122    ADD_FUNCTION(glHint)
123    ADD_FUNCTION(glIsBuffer)
124    ADD_FUNCTION(glIsEnabled)
125    ADD_FUNCTION(glIsFramebuffer)
126    ADD_FUNCTION(glIsProgram)
127    ADD_FUNCTION(glIsRenderbuffer)
128    ADD_FUNCTION(glIsShader)
129    ADD_FUNCTION(glIsTexture)
130    ADD_FUNCTION(glLineWidth)
131    ADD_FUNCTION(glLinkProgram)
132    ADD_FUNCTION(glPixelStorei)
133    ADD_FUNCTION(glPolygonOffset)
134    ADD_FUNCTION(glReadPixels)
135    ADD_FUNCTION(glReleaseShaderCompiler)
136    ADD_FUNCTION(glRenderbufferStorage)
137    ADD_FUNCTION(glSampleCoverage)
138    ADD_FUNCTION(glScissor)
139    ADD_FUNCTION(glShaderBinary)
140    ADD_FUNCTION(glShaderSource)
141    ADD_FUNCTION(glStencilFunc)
142    ADD_FUNCTION(glStencilFuncSeparate)
143    ADD_FUNCTION(glStencilMask)
144    ADD_FUNCTION(glStencilMaskSeparate)
145    ADD_FUNCTION(glStencilOp)
146    ADD_FUNCTION(glStencilOpSeparate)
147    ADD_FUNCTION(glTexImage2D)
148    ADD_FUNCTION(glTexParameterf)
149    ADD_FUNCTION(glTexParameterfv)
150    ADD_FUNCTION(glTexParameteri)
151    ADD_FUNCTION(glTexParameteriv)
152    ADD_FUNCTION(glTexSubImage2D)
153    ADD_FUNCTION(glUniform1f)
154    ADD_FUNCTION(glUniform1fv)
155    ADD_FUNCTION(glUniform1i)
156    ADD_FUNCTION(glUniform1iv)
157    ADD_FUNCTION(glUniform2f)
158    ADD_FUNCTION(glUniform2fv)
159    ADD_FUNCTION(glUniform2i)
160    ADD_FUNCTION(glUniform2iv)
161    ADD_FUNCTION(glUniform3f)
162    ADD_FUNCTION(glUniform3fv)
163    ADD_FUNCTION(glUniform3i)
164    ADD_FUNCTION(glUniform3iv)
165    ADD_FUNCTION(glUniform4f)
166    ADD_FUNCTION(glUniform4fv)
167    ADD_FUNCTION(glUniform4i)
168    ADD_FUNCTION(glUniform4iv)
169    ADD_FUNCTION(glUniformMatrix2fv)
170    ADD_FUNCTION(glUniformMatrix3fv)
171    ADD_FUNCTION(glUniformMatrix4fv)
172    ADD_FUNCTION(glUseProgram)
173    ADD_FUNCTION(glValidateProgram)
174    ADD_FUNCTION(glVertexAttrib1f)
175    ADD_FUNCTION(glVertexAttrib1fv)
176    ADD_FUNCTION(glVertexAttrib2f)
177    ADD_FUNCTION(glVertexAttrib2fv)
178    ADD_FUNCTION(glVertexAttrib3f)
179    ADD_FUNCTION(glVertexAttrib3fv)
180    ADD_FUNCTION(glVertexAttrib4f)
181    ADD_FUNCTION(glVertexAttrib4fv)
182    ADD_FUNCTION(glVertexAttribPointer)
183    ADD_FUNCTION(glViewport)
184}
185
186void initProcAddress()
187{
188#if defined(OSG_GLES2_AVAILABLE)
189    initGLES2ProcAddress();
190#else
191    OSG_NOTICE << "initProcAddress() not implemented for static GL lib yet." << std::endl;
192#endif
193}
194
195// namespace
196
197void* GLStaticLibrary::getProcAddress(const char* procName)
198{
199    // TODO(alokp): Add a mutex around sProcAddressInitialized.
200    if (!sProcAddressInitialized)
201    {
202        initProcAddress();
203        sProcAddressInitialized = true;
204    }
205
206    GLProcAddressMap::const_iterator iter = sProcAddressMap.find(procName);
207    return iter != sProcAddressMap.end() ? reinterpret_cast<void*>(iter->second) : 0;
208}
209
210#endif  // OSG_GLES2_LIBRARY_STATIC
Note: See TracBrowser for help on using the browser.