efl

Форк
0
/
ector_main.c 
248 строк · 6.0 Кб
1
/* ECTOR - EFL retained mode drawing library
2
 * Copyright (C) 2014 Cedric Bail
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library;
16
 * if not, see <http://www.gnu.org/licenses/>.
17
 */
18
#ifdef HAVE_CONFIG_H
19
# include "config.h"
20
#endif
21

22
#include <Ector.h>
23
#include "ector_private.h"
24

25
Ector_GL_API GL;
26
int _ector_log_dom_global = 0;
27

28
static int _ector_main_count = 0;
29

30
ECTOR_API int
31
ector_init(void)
32
{
33
   if (EINA_LIKELY(_ector_main_count > 0))
34
     return ++_ector_main_count;
35

36
   eina_init();
37
   efl_object_init();
38

39
   _ector_log_dom_global = eina_log_domain_register("ector", ECTOR_DEFAULT_LOG_COLOR);
40
   if (_ector_log_dom_global < 0)
41
     {
42
        EINA_LOG_ERR("Could not register log domain: ector");
43
        goto on_error;
44
     }
45

46
   _ector_main_count = 1;
47

48
   eina_log_timing(_ector_log_dom_global, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
49
   GL.init = 0;
50

51
   return _ector_main_count;
52

53
 on_error:
54
   efl_object_shutdown();
55
   eina_shutdown();
56

57
   return 0;
58
}
59

60
static void
61
donothing(void)
62
{
63
}
64

65
ECTOR_API Eina_Bool
66
ector_glsym_set(void *(*glsym)(void *lib, const char *name), void *lib)
67
{
68
   Eina_Bool r = EINA_TRUE;
69

70
   if (!glsym) return EINA_FALSE;
71

72
#define ORD(a) do { GL.a = glsym(lib, #a); if (!GL.a) { GL.a = (void*) donothing; r = EINA_FALSE; } } while (0)
73

74
   ORD(glActiveTexture);
75
   ORD(glAttachShader);
76
   ORD(glBindAttribLocation);
77
   ORD(glBindBuffer);
78
   ORD(glBindFramebuffer);
79
   ORD(glBindRenderbuffer);
80
   ORD(glBindTexture);
81
   ORD(glBlendColor);
82
   ORD(glBlendEquation);
83
   ORD(glBlendEquationSeparate);
84
   ORD(glBlendFunc);
85
   ORD(glBlendFuncSeparate);
86
   ORD(glBufferData);
87
   ORD(glBufferSubData);
88
   ORD(glCheckFramebufferStatus);
89
   ORD(glClear);
90
   ORD(glClearColor);
91
   ORD(glClearDepthf);
92
   ORD(glClearStencil);
93
   ORD(glColorMask);
94
   ORD(glCompileShader);
95
   ORD(glCompressedTexImage2D);
96
   ORD(glCompressedTexSubImage2D);
97
   ORD(glCopyTexImage2D);
98
   ORD(glCopyTexSubImage2D);
99
   ORD(glCreateProgram);
100
   ORD(glCreateShader);
101
   ORD(glCullFace);
102
   ORD(glDeleteBuffers);
103
   ORD(glDeleteFramebuffers);
104
   ORD(glDeleteProgram);
105
   ORD(glDeleteRenderbuffers);
106
   ORD(glDeleteShader);
107
   ORD(glDeleteTextures);
108
   ORD(glDepthFunc);
109
   ORD(glDepthMask);
110
   ORD(glDepthRangef);
111
   ORD(glDetachShader);
112
   ORD(glDisable);
113
   ORD(glDisableVertexAttribArray);
114
   ORD(glDrawArrays);
115
   ORD(glDrawElements);
116
   ORD(glEnable);
117
   ORD(glEnableVertexAttribArray);
118
   ORD(glFinish);
119
   ORD(glFlush);
120
   ORD(glFramebufferRenderbuffer);
121
   ORD(glFramebufferTexture2D);
122
   ORD(glFrontFace);
123
   ORD(glGenBuffers);
124
   ORD(glGenerateMipmap);
125
   ORD(glGenFramebuffers);
126
   ORD(glGenRenderbuffers);
127
   ORD(glGenTextures);
128
   ORD(glGetActiveAttrib);
129
   ORD(glGetActiveUniform);
130
   ORD(glGetAttachedShaders);
131
   ORD(glGetAttribLocation);
132
   ORD(glGetBooleanv);
133
   ORD(glGetBufferParameteriv);
134
   ORD(glGetError);
135
   ORD(glGetFloatv);
136
   ORD(glGetFramebufferAttachmentParameteriv);
137
   ORD(glGetIntegerv);
138
   ORD(glGetProgramiv);
139
   ORD(glGetProgramInfoLog);
140
   ORD(glGetProgramBinary);
141
   ORD(glGetRenderbufferParameteriv);
142
   ORD(glGetShaderiv);
143
   ORD(glGetShaderInfoLog);
144
   ORD(glGetShaderPrecisionFormat);
145
   ORD(glGetShaderSource);
146
   ORD(glGetString);
147
   ORD(glGetTexParameterfv);
148
   ORD(glGetTexParameteriv);
149
   ORD(glGetUniformfv);
150
   ORD(glGetUniformiv);
151
   ORD(glGetUniformLocation);
152
   ORD(glGetVertexAttribfv);
153
   ORD(glGetVertexAttribiv);
154
   ORD(glGetVertexAttribPointerv);
155
   ORD(glHint);
156
   ORD(glIsBuffer);
157
   ORD(glIsEnabled);
158
   ORD(glIsFramebuffer);
159
   ORD(glIsProgram);
160
   ORD(glIsRenderbuffer);
161
   ORD(glIsShader);
162
   ORD(glIsTexture);
163
   ORD(glLineWidth);
164
   ORD(glLinkProgram);
165
   ORD(glPixelStorei);
166
   ORD(glPolygonOffset);
167
   ORD(glProgramBinary);
168
   ORD(glProgramParameteri);
169
   ORD(glReadPixels);
170
   ORD(glReleaseShaderCompiler);
171
   ORD(glRenderbufferStorage);
172
   ORD(glSampleCoverage);
173
   ORD(glScissor);
174
   ORD(glShaderBinary);
175
   ORD(glShaderSource);
176
   ORD(glStencilFunc);
177
   ORD(glStencilFuncSeparate);
178
   ORD(glStencilMask);
179
   ORD(glStencilMaskSeparate);
180
   ORD(glStencilOp);
181
   ORD(glStencilOpSeparate);
182
   ORD(glTexImage2D);
183
   ORD(glTexParameterf);
184
   ORD(glTexParameterfv);
185
   ORD(glTexParameteri);
186
   ORD(glTexParameteriv);
187
   ORD(glTexSubImage2D);
188
   ORD(glUniform1f);
189
   ORD(glUniform1fv);
190
   ORD(glUniform1i);
191
   ORD(glUniform1iv);
192
   ORD(glUniform2f);
193
   ORD(glUniform2fv);
194
   ORD(glUniform2i);
195
   ORD(glUniform2iv);
196
   ORD(glUniform3f);
197
   ORD(glUniform3fv);
198
   ORD(glUniform3i);
199
   ORD(glUniform3iv);
200
   ORD(glUniform4f);
201
   ORD(glUniform4fv);
202
   ORD(glUniform4i);
203
   ORD(glUniform4iv);
204
   ORD(glUniformMatrix2fv);
205
   ORD(glUniformMatrix3fv);
206
   ORD(glUniformMatrix4fv);
207
   ORD(glUseProgram);
208
   ORD(glValidateProgram);
209
   ORD(glVertexAttrib1f);
210
   ORD(glVertexAttrib1fv);
211
   ORD(glVertexAttrib2f);
212
   ORD(glVertexAttrib2fv);
213
   ORD(glVertexAttrib3f);
214
   ORD(glVertexAttrib3fv);
215
   ORD(glVertexAttrib4f);
216
   ORD(glVertexAttrib4fv);
217
   ORD(glVertexAttribPointer);
218
   ORD(glViewport);
219

220
   GL.init = r;
221
   return r;
222
}
223

224
ECTOR_API int
225
ector_shutdown(void)
226
{
227
   if (_ector_main_count <= 0)
228
     {
229
        EINA_LOG_ERR("Init count not greater than 0 in shutdown of ector.");
230
        return 0;
231
     }
232

233
   _ector_main_count--;
234
   if (EINA_LIKELY(_ector_main_count > 0))
235
     return _ector_main_count;
236

237
   GL.init = 0;
238
   eina_log_timing(_ector_log_dom_global,
239
                   EINA_LOG_STATE_START,
240
                   EINA_LOG_STATE_SHUTDOWN);
241

242
   efl_object_shutdown();
243

244
   eina_log_domain_unregister(_ector_log_dom_global);
245

246
   eina_shutdown();
247
   return _ector_main_count;
248
}
249

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.