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;
|
|
|
|
|
ector: Rename EAPI macro to ECTOR_API in Ector library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12226
2021-01-01 12:31:37 -08:00
|
|
|
ECTOR_API int
|
2015-04-03 07:14:56 -07:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
ector: Rename EAPI macro to ECTOR_API in Ector library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12226
2021-01-01 12:31:37 -08:00
|
|
|
ECTOR_API Eina_Bool
|
2015-12-16 15:18:23 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
ector: Rename EAPI macro to ECTOR_API in Ector library
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, woohyun, jptiz, lucas
Reviewed By: vtorri
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12226
2021-01-01 12:31:37 -08:00
|
|
|
ECTOR_API int
|
2015-04-03 07:14:56 -07:00
|
|
|
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;
|
|
|
|
}
|