2015-04-03 07:14:56 -07:00
|
|
|
/* ECTOR - EFL retained mode drawing library
|
|
|
|
* Copyright (C) 2014 Cedric Bail
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <Ector.h>
|
|
|
|
#include "ector_private.h"
|
|
|
|
|
2016-01-05 21:31:57 -08:00
|
|
|
Ector_GL_API GL;
|
2015-04-03 07:31:13 -07:00
|
|
|
int _ector_log_dom_global = 0;
|
2015-04-03 07:14:56 -07:00
|
|
|
|
|
|
|
static int _ector_main_count = 0;
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
ector_init(void)
|
|
|
|
{
|
|
|
|
if (EINA_LIKELY(_ector_main_count > 0))
|
|
|
|
return ++_ector_main_count;
|
|
|
|
|
|
|
|
eina_init();
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_object_init();
|
2015-04-03 07:14:56 -07:00
|
|
|
|
2015-04-03 07:31:13 -07:00
|
|
|
_ector_log_dom_global = eina_log_domain_register("ector", ECTOR_DEFAULT_LOG_COLOR);
|
|
|
|
if (_ector_log_dom_global < 0)
|
2015-04-03 07:14:56 -07:00
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Could not register log domain: ector");
|
|
|
|
goto on_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
_ector_main_count = 1;
|
|
|
|
|
2015-04-03 07:31:13 -07:00
|
|
|
eina_log_timing(_ector_log_dom_global, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
|
2016-01-05 21:31:57 -08:00
|
|
|
GL.init = 0;
|
2015-04-03 07:14:56 -07:00
|
|
|
|
|
|
|
return _ector_main_count;
|
|
|
|
|
|
|
|
on_error:
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_object_shutdown();
|
2015-04-03 07:14:56 -07:00
|
|
|
eina_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-16 15:18:23 -08:00
|
|
|
static void
|
|
|
|
donothing(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ector_glsym_set(void *(*glsym)(void *lib, const char *name), void *lib)
|
|
|
|
{
|
|
|
|
Eina_Bool r = EINA_TRUE;
|
|
|
|
|
|
|
|
if (!glsym) return EINA_FALSE;
|
|
|
|
|
|
|
|
#define ORD(a) do { GL.a = glsym(lib, #a); if (!GL.a) { GL.a = (void*) donothing; r = EINA_FALSE; } } while (0)
|
|
|
|
|
|
|
|
ORD(glActiveTexture);
|
|
|
|
ORD(glAttachShader);
|
|
|
|
ORD(glBindAttribLocation);
|
|
|
|
ORD(glBindBuffer);
|
|
|
|
ORD(glBindFramebuffer);
|
|
|
|
ORD(glBindRenderbuffer);
|
|
|
|
ORD(glBindTexture);
|
|
|
|
ORD(glBlendColor);
|
|
|
|
ORD(glBlendEquation);
|
|
|
|
ORD(glBlendEquationSeparate);
|
|
|
|
ORD(glBlendFunc);
|
|
|
|
ORD(glBlendFuncSeparate);
|
|
|
|
ORD(glBufferData);
|
|
|
|
ORD(glBufferSubData);
|
|
|
|
ORD(glCheckFramebufferStatus);
|
|
|
|
ORD(glClear);
|
|
|
|
ORD(glClearColor);
|
|
|
|
ORD(glClearDepthf);
|
|
|
|
ORD(glClearStencil);
|
|
|
|
ORD(glColorMask);
|
|
|
|
ORD(glCompileShader);
|
|
|
|
ORD(glCompressedTexImage2D);
|
|
|
|
ORD(glCompressedTexSubImage2D);
|
|
|
|
ORD(glCopyTexImage2D);
|
|
|
|
ORD(glCopyTexSubImage2D);
|
|
|
|
ORD(glCreateProgram);
|
|
|
|
ORD(glCreateShader);
|
|
|
|
ORD(glCullFace);
|
|
|
|
ORD(glDeleteBuffers);
|
|
|
|
ORD(glDeleteFramebuffers);
|
|
|
|
ORD(glDeleteProgram);
|
|
|
|
ORD(glDeleteRenderbuffers);
|
|
|
|
ORD(glDeleteShader);
|
|
|
|
ORD(glDeleteTextures);
|
|
|
|
ORD(glDepthFunc);
|
|
|
|
ORD(glDepthMask);
|
|
|
|
ORD(glDepthRangef);
|
|
|
|
ORD(glDetachShader);
|
|
|
|
ORD(glDisable);
|
|
|
|
ORD(glDisableVertexAttribArray);
|
|
|
|
ORD(glDrawArrays);
|
|
|
|
ORD(glDrawElements);
|
|
|
|
ORD(glEnable);
|
|
|
|
ORD(glEnableVertexAttribArray);
|
|
|
|
ORD(glFinish);
|
|
|
|
ORD(glFlush);
|
|
|
|
ORD(glFramebufferRenderbuffer);
|
|
|
|
ORD(glFramebufferTexture2D);
|
|
|
|
ORD(glFrontFace);
|
|
|
|
ORD(glGenBuffers);
|
|
|
|
ORD(glGenerateMipmap);
|
|
|
|
ORD(glGenFramebuffers);
|
|
|
|
ORD(glGenRenderbuffers);
|
|
|
|
ORD(glGenTextures);
|
|
|
|
ORD(glGetActiveAttrib);
|
|
|
|
ORD(glGetActiveUniform);
|
|
|
|
ORD(glGetAttachedShaders);
|
|
|
|
ORD(glGetAttribLocation);
|
|
|
|
ORD(glGetBooleanv);
|
|
|
|
ORD(glGetBufferParameteriv);
|
|
|
|
ORD(glGetError);
|
|
|
|
ORD(glGetFloatv);
|
|
|
|
ORD(glGetFramebufferAttachmentParameteriv);
|
|
|
|
ORD(glGetIntegerv);
|
|
|
|
ORD(glGetProgramiv);
|
|
|
|
ORD(glGetProgramInfoLog);
|
|
|
|
ORD(glGetProgramBinary);
|
|
|
|
ORD(glGetRenderbufferParameteriv);
|
|
|
|
ORD(glGetShaderiv);
|
|
|
|
ORD(glGetShaderInfoLog);
|
|
|
|
ORD(glGetShaderPrecisionFormat);
|
|
|
|
ORD(glGetShaderSource);
|
|
|
|
ORD(glGetString);
|
|
|
|
ORD(glGetTexParameterfv);
|
|
|
|
ORD(glGetTexParameteriv);
|
|
|
|
ORD(glGetUniformfv);
|
|
|
|
ORD(glGetUniformiv);
|
|
|
|
ORD(glGetUniformLocation);
|
|
|
|
ORD(glGetVertexAttribfv);
|
|
|
|
ORD(glGetVertexAttribiv);
|
|
|
|
ORD(glGetVertexAttribPointerv);
|
|
|
|
ORD(glHint);
|
|
|
|
ORD(glIsBuffer);
|
|
|
|
ORD(glIsEnabled);
|
|
|
|
ORD(glIsFramebuffer);
|
|
|
|
ORD(glIsProgram);
|
|
|
|
ORD(glIsRenderbuffer);
|
|
|
|
ORD(glIsShader);
|
|
|
|
ORD(glIsTexture);
|
|
|
|
ORD(glLineWidth);
|
|
|
|
ORD(glLinkProgram);
|
|
|
|
ORD(glPixelStorei);
|
|
|
|
ORD(glPolygonOffset);
|
|
|
|
ORD(glProgramBinary);
|
|
|
|
ORD(glProgramParameteri);
|
|
|
|
ORD(glReadPixels);
|
|
|
|
ORD(glReleaseShaderCompiler);
|
|
|
|
ORD(glRenderbufferStorage);
|
|
|
|
ORD(glSampleCoverage);
|
|
|
|
ORD(glScissor);
|
|
|
|
ORD(glShaderBinary);
|
|
|
|
ORD(glShaderSource);
|
|
|
|
ORD(glStencilFunc);
|
|
|
|
ORD(glStencilFuncSeparate);
|
|
|
|
ORD(glStencilMask);
|
|
|
|
ORD(glStencilMaskSeparate);
|
|
|
|
ORD(glStencilOp);
|
|
|
|
ORD(glStencilOpSeparate);
|
|
|
|
ORD(glTexImage2D);
|
|
|
|
ORD(glTexParameterf);
|
|
|
|
ORD(glTexParameterfv);
|
|
|
|
ORD(glTexParameteri);
|
|
|
|
ORD(glTexParameteriv);
|
|
|
|
ORD(glTexSubImage2D);
|
|
|
|
ORD(glUniform1f);
|
|
|
|
ORD(glUniform1fv);
|
|
|
|
ORD(glUniform1i);
|
|
|
|
ORD(glUniform1iv);
|
|
|
|
ORD(glUniform2f);
|
|
|
|
ORD(glUniform2fv);
|
|
|
|
ORD(glUniform2i);
|
|
|
|
ORD(glUniform2iv);
|
|
|
|
ORD(glUniform3f);
|
|
|
|
ORD(glUniform3fv);
|
|
|
|
ORD(glUniform3i);
|
|
|
|
ORD(glUniform3iv);
|
|
|
|
ORD(glUniform4f);
|
|
|
|
ORD(glUniform4fv);
|
|
|
|
ORD(glUniform4i);
|
|
|
|
ORD(glUniform4iv);
|
|
|
|
ORD(glUniformMatrix2fv);
|
|
|
|
ORD(glUniformMatrix3fv);
|
|
|
|
ORD(glUniformMatrix4fv);
|
|
|
|
ORD(glUseProgram);
|
|
|
|
ORD(glValidateProgram);
|
|
|
|
ORD(glVertexAttrib1f);
|
|
|
|
ORD(glVertexAttrib1fv);
|
|
|
|
ORD(glVertexAttrib2f);
|
|
|
|
ORD(glVertexAttrib2fv);
|
|
|
|
ORD(glVertexAttrib3f);
|
|
|
|
ORD(glVertexAttrib3fv);
|
|
|
|
ORD(glVertexAttrib4f);
|
|
|
|
ORD(glVertexAttrib4fv);
|
|
|
|
ORD(glVertexAttribPointer);
|
|
|
|
ORD(glViewport);
|
|
|
|
|
2016-01-05 21:31:57 -08:00
|
|
|
GL.init = r;
|
2015-12-16 15:18:23 -08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-04-03 07:14:56 -07:00
|
|
|
EAPI int
|
|
|
|
ector_shutdown(void)
|
|
|
|
{
|
|
|
|
if (_ector_main_count <= 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Init count not greater than 0 in shutdown of ector.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_ector_main_count--;
|
|
|
|
if (EINA_LIKELY(_ector_main_count > 0))
|
|
|
|
return _ector_main_count;
|
|
|
|
|
2016-01-05 21:31:57 -08:00
|
|
|
GL.init = 0;
|
2015-04-03 07:31:13 -07:00
|
|
|
eina_log_timing(_ector_log_dom_global,
|
2015-04-03 07:14:56 -07:00
|
|
|
EINA_LOG_STATE_START,
|
|
|
|
EINA_LOG_STATE_SHUTDOWN);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_object_shutdown();
|
2015-04-03 07:14:56 -07:00
|
|
|
|
2015-04-03 07:31:13 -07:00
|
|
|
eina_log_domain_unregister(_ector_log_dom_global);
|
2015-04-03 07:14:56 -07:00
|
|
|
|
|
|
|
eina_shutdown();
|
|
|
|
return _ector_main_count;
|
|
|
|
}
|