1 /**************************************************************************
3 * Copyright 2013-2014 RAD Game Tools and Valve Software
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
26 // File: vogl_namespaces.h
28 #ifdef VOGL_NAMESPACES_HEADER
30 #define VOGL_SHADER_OBJECT 1
31 #define VOGL_PROGRAM_OBJECT 2
33 //----------------------------------------------------------------------------------------------------------------------
34 // GL namespace enums/table
35 // Important: If you change these enums, be sure to recompile and regenerate all .inc files using voglgen!
36 // Keep this in sync with g_vogl_namespace_names!
37 //----------------------------------------------------------------------------------------------------------------------
40 VOGL_NAMESPACE_UNKNOWN = -2,
41 VOGL_NAMESPACE_INVALID = -1,
42 VOGL_NAMESPACE_FRAMEBUFFERS,
43 VOGL_NAMESPACE_TEXTURES,
44 VOGL_NAMESPACE_RENDER_BUFFERS,
45 VOGL_NAMESPACE_QUERIES,
46 VOGL_NAMESPACE_SAMPLERS,
47 VOGL_NAMESPACE_PROGRAM_ARB,
48 VOGL_NAMESPACE_PROGRAMS,
49 VOGL_NAMESPACE_VERTEX_ARRAYS,
51 VOGL_NAMESPACE_LOCATIONS,
52 VOGL_NAMESPACE_FENCES, // TODO: Is this a alias to syncs?
54 VOGL_NAMESPACE_PIPELINES,
55 VOGL_NAMESPACE_SHADERS,
56 VOGL_NAMESPACE_BUFFERS,
57 VOGL_NAMESPACE_FEEDBACKS,
58 VOGL_NAMESPACE_VERTEX_ARRAYS_APPLE,
59 VOGL_NAMESPACE_FRAGMENT_SHADER_ATI,
60 VOGL_NAMESPACE_GLHANDLEARB,
64 struct vogl_gl_type_to_namespace_t
67 vogl_namespace_t m_namespace;
70 extern const char *g_vogl_namespace_names[VOGL_TOTAL_NAMESPACES];
72 extern const char *vogl_get_namespace_name(vogl_namespace_t namespace_index);
74 // Note that g_vogl_gl_type_to_namespace[]'s size is != VOGL_TOTAL_NAMESPACES, because of namespace aliases.
75 extern vogl_gl_type_to_namespace_t g_vogl_gl_type_to_namespace[];
76 extern const uint g_vogl_gl_type_to_namespace_array_size;
78 extern vogl_namespace_t vogl_find_namespace_from_gl_type(const char *pType);
80 #endif // VOGL_NAMESPACES_HEADER
82 #ifdef VOGL_NAMESPACES_IMPLEMENTATION
84 // Keep this in sync with vogl_namespace_t!
85 const char *g_vogl_namespace_names[VOGL_TOTAL_NAMESPACES] =
103 "vertex_arrays_apple",
104 "fragment_shader_ati",
108 const char *vogl_get_namespace_name(vogl_namespace_t namespace_index)
110 VOGL_ASSERT(namespace_index >= VOGL_NAMESPACE_UNKNOWN);
111 VOGL_ASSERT(namespace_index < VOGL_TOTAL_NAMESPACES);
113 if ((namespace_index == VOGL_NAMESPACE_INVALID) || (namespace_index >= VOGL_TOTAL_NAMESPACES))
115 else if (namespace_index == VOGL_NAMESPACE_UNKNOWN)
118 const char *pName = g_vogl_namespace_names[namespace_index];
122 //----------------------------------------------------------------------------------------------------------------------
123 // GL namespace enums/table
124 //----------------------------------------------------------------------------------------------------------------------
125 vogl_gl_type_to_namespace_t g_vogl_gl_type_to_namespace[] =
127 { "unknown", VOGL_NAMESPACE_UNKNOWN },
128 { "invalid", VOGL_NAMESPACE_INVALID },
129 { "GLframebuffer", VOGL_NAMESPACE_FRAMEBUFFERS },
130 { "GLtexture", VOGL_NAMESPACE_TEXTURES },
131 { "GLrenderbuffer", VOGL_NAMESPACE_RENDER_BUFFERS },
132 { "GLquery", VOGL_NAMESPACE_QUERIES },
133 { "GLsampler", VOGL_NAMESPACE_SAMPLERS },
134 { "GLprogramARB", VOGL_NAMESPACE_PROGRAM_ARB },
135 { "GLprogram", VOGL_NAMESPACE_PROGRAMS },
136 { "GLarray", VOGL_NAMESPACE_VERTEX_ARRAYS },
137 { "GLlist", VOGL_NAMESPACE_LISTS },
138 { "GLlocation", VOGL_NAMESPACE_LOCATIONS },
139 { "GLlocationARB", VOGL_NAMESPACE_LOCATIONS },
140 { "GLfence", VOGL_NAMESPACE_FENCES },
141 { "GLsync", VOGL_NAMESPACE_SYNCS },
142 { "GLpipeline", VOGL_NAMESPACE_PIPELINES },
143 { "GLshader", VOGL_NAMESPACE_SHADERS },
144 { "GLbuffer", VOGL_NAMESPACE_BUFFERS },
145 { "GLfeedback", VOGL_NAMESPACE_FEEDBACKS },
146 { "GLarrayAPPLE", VOGL_NAMESPACE_VERTEX_ARRAYS_APPLE },
147 { "GLfragmentShaderATI", VOGL_NAMESPACE_FRAGMENT_SHADER_ATI },
148 { "GLhandleARB", VOGL_NAMESPACE_GLHANDLEARB },
151 const uint g_vogl_gl_type_to_namespace_array_size = VOGL_ARRAY_SIZE(g_vogl_gl_type_to_namespace);
153 vogl_namespace_t vogl_find_namespace_from_gl_type(const char *pType)
155 for (uint i = 0; i < g_vogl_gl_type_to_namespace_array_size; i++)
156 if (!vogl::vogl_stricmp(g_vogl_gl_type_to_namespace[i].m_pType, pType))
157 return g_vogl_gl_type_to_namespace[i].m_namespace;
159 return VOGL_NAMESPACE_INVALID;
162 #endif // VOGL_NAMESPACES_IMPLEMENTATION