Cleanups and fixed compile for frt.

This commit is contained in:
Relintai 2022-03-27 13:48:18 +02:00
parent 09742a48b6
commit 53efe58c4f
9 changed files with 39 additions and 2352 deletions

View File

@ -45,14 +45,7 @@ static const char *lib(const char *s) {
#define FRT_DL_SKIP
#include "dl/gles2.gen.h"
#if FRT_GLES_VERSION == 3
#include "dl/gles3.gen.h"
#endif
static bool frt_load_gles(int version) {
#if FRT_GLES_VERSION == 3
if (version == 3)
return frt_load_gles3(lib("libGLESv2.so.2"));
#endif
return frt_load_gles2(lib("libGLESv2.so.2"));
}

View File

@ -82,6 +82,7 @@ def configure(env):
env['CC'] = 'clang'
env['CXX'] = 'clang++'
env['LD'] = 'clang++'
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
env.extra_suffix += '.llvm'
@ -94,6 +95,7 @@ def configure(env):
else:
env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto'])
env.extra_suffix += '.lto'
if env['frt_cross'] != 'no':
@ -154,15 +156,6 @@ def configure(env):
else:
print('libudev development libraries not found, disabling udev support')
if version.major == 2:
if version.minor == 1 and version.patch >=4:
gen_suffix = 'glsl.gen.h'
else:
gen_suffix = 'glsl.h'
env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix=gen_suffix, src_suffix='.glsl')})
env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix=gen_suffix, src_suffix='.glsl')})
env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix=gen_suffix, src_suffix='.glsl')})
if env['target'] == 'release':
env.Append(CCFLAGS=['-O3', '-fomit-frame-pointer'])
elif env['target'] == 'release_debug':
@ -192,16 +185,15 @@ def configure(env):
env.Append(FRT_MODULES=['envprobe.cpp'])
env.Append(FRT_MODULES=['video_fbdev.cpp', 'keyboard_linux_input.cpp', 'mouse_linux_input.cpp'])
env.Append(FRT_MODULES=['video_x11.cpp', 'keyboard_x11.cpp', 'mouse_x11.cpp'])
if version.major >= 3:
env.Append(FRT_MODULES=['import/key_mapping_x11_3.cpp'])
else:
env.Append(FRT_MODULES=['import/key_mapping_x11_2.cpp'])
env.Append(FRT_MODULES=['import/key_mapping_x11_3.cpp'])
env.Append(FRT_MODULES=['dl/x11.gen.cpp', 'dl/egl.gen.cpp'])
if os.path.isfile('/opt/vc/include/bcm_host.h'):
env.Append(FRT_MODULES=['video_bcm.cpp', 'dl/bcm.gen.cpp'])
if os.path.isfile('/usr/include/gbm.h'):
env.Append(FRT_MODULES=['video_kmsdrm.cpp', 'dl/gbm.gen.cpp', 'dl/drm.gen.cpp'])
env.Append(FRT_MODULES=['dl/gles2.gen.cpp'])
if version.major >= 3:
env.Append(FRT_MODULES=['dl/gles3.gen.cpp'])
env.Append(LIBS=['dl'])

View File

@ -1,273 +0,0 @@
// gles3.dl
/*
* FRT - A Godot platform targeting single board computers
* Copyright (c) 2017-2019 Emanuele Fornara
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GLES3/gl3.h>
typedef void (*___glActiveTexture___)(GLenum texture);
typedef void (*___glAttachShader___)(GLuint program, GLuint shader);
typedef void (*___glBindAttribLocation___)(GLuint program, GLuint index, const GLchar *name);
typedef void (*___glBindBuffer___)(GLenum target, GLuint buffer);
typedef void (*___glBindFramebuffer___)(GLenum target, GLuint framebuffer);
typedef void (*___glBindRenderbuffer___)(GLenum target, GLuint renderbuffer);
typedef void (*___glBindTexture___)(GLenum target, GLuint texture);
typedef void (*___glBlendColor___)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void (*___glBlendEquation___)(GLenum mode);
typedef void (*___glBlendEquationSeparate___)(GLenum modeRGB, GLenum modeAlpha);
typedef void (*___glBlendFunc___)(GLenum sfactor, GLenum dfactor);
typedef void (*___glBlendFuncSeparate___)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
typedef void (*___glBufferData___)(GLenum target, GLsizeiptr size, const void *data, GLenum usage);
typedef void (*___glBufferSubData___)(GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
typedef GLenum (*___glCheckFramebufferStatus___)(GLenum target);
typedef void (*___glClear___)(GLbitfield mask);
typedef void (*___glClearColor___)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void (*___glClearDepthf___)(GLfloat d);
typedef void (*___glClearStencil___)(GLint s);
typedef void (*___glColorMask___)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
typedef void (*___glCompileShader___)(GLuint shader);
typedef void (*___glCompressedTexImage2D___)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
typedef void (*___glCompressedTexSubImage2D___)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
typedef void (*___glCopyTexImage2D___)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
typedef void (*___glCopyTexSubImage2D___)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
typedef GLuint (*___glCreateProgram___)();
typedef GLuint (*___glCreateShader___)(GLenum type);
typedef void (*___glCullFace___)(GLenum mode);
typedef void (*___glDeleteBuffers___)(GLsizei n, const GLuint *buffers);
typedef void (*___glDeleteFramebuffers___)(GLsizei n, const GLuint *framebuffers);
typedef void (*___glDeleteProgram___)(GLuint program);
typedef void (*___glDeleteRenderbuffers___)(GLsizei n, const GLuint *renderbuffers);
typedef void (*___glDeleteShader___)(GLuint shader);
typedef void (*___glDeleteTextures___)(GLsizei n, const GLuint *textures);
typedef void (*___glDepthFunc___)(GLenum func);
typedef void (*___glDepthMask___)(GLboolean flag);
typedef void (*___glDepthRangef___)(GLfloat n, GLfloat f);
typedef void (*___glDetachShader___)(GLuint program, GLuint shader);
typedef void (*___glDisable___)(GLenum cap);
typedef void (*___glDisableVertexAttribArray___)(GLuint index);
typedef void (*___glDrawArrays___)(GLenum mode, GLint first, GLsizei count);
typedef void (*___glDrawElements___)(GLenum mode, GLsizei count, GLenum type, const void *indices);
typedef void (*___glEnable___)(GLenum cap);
typedef void (*___glEnableVertexAttribArray___)(GLuint index);
typedef void (*___glFinish___)();
typedef void (*___glFlush___)();
typedef void (*___glFramebufferRenderbuffer___)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (*___glFramebufferTexture2D___)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (*___glFrontFace___)(GLenum mode);
typedef void (*___glGenBuffers___)(GLsizei n, GLuint *buffers);
typedef void (*___glGenerateMipmap___)(GLenum target);
typedef void (*___glGenFramebuffers___)(GLsizei n, GLuint *framebuffers);
typedef void (*___glGenRenderbuffers___)(GLsizei n, GLuint *renderbuffers);
typedef void (*___glGenTextures___)(GLsizei n, GLuint *textures);
typedef void (*___glGetActiveAttrib___)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
typedef void (*___glGetActiveUniform___)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
typedef void (*___glGetAttachedShaders___)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
typedef GLint (*___glGetAttribLocation___)(GLuint program, const GLchar *name);
typedef void (*___glGetBooleanv___)(GLenum pname, GLboolean *data);
typedef void (*___glGetBufferParameteriv___)(GLenum target, GLenum pname, GLint *params);
typedef GLenum (*___glGetError___)();
typedef void (*___glGetFloatv___)(GLenum pname, GLfloat *data);
typedef void (*___glGetFramebufferAttachmentParameteriv___)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
typedef void (*___glGetIntegerv___)(GLenum pname, GLint *data);
typedef void (*___glGetProgramiv___)(GLuint program, GLenum pname, GLint *params);
typedef void (*___glGetProgramInfoLog___)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef void (*___glGetRenderbufferParameteriv___)(GLenum target, GLenum pname, GLint *params);
typedef void (*___glGetShaderiv___)(GLuint shader, GLenum pname, GLint *params);
typedef void (*___glGetShaderInfoLog___)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef void (*___glGetShaderPrecisionFormat___)(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
typedef void (*___glGetShaderSource___)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
typedef const GLubyte * (*___glGetString___)(GLenum name);
typedef void (*___glGetTexParameterfv___)(GLenum target, GLenum pname, GLfloat *params);
typedef void (*___glGetTexParameteriv___)(GLenum target, GLenum pname, GLint *params);
typedef void (*___glGetUniformfv___)(GLuint program, GLint location, GLfloat *params);
typedef void (*___glGetUniformiv___)(GLuint program, GLint location, GLint *params);
typedef GLint (*___glGetUniformLocation___)(GLuint program, const GLchar *name);
typedef void (*___glGetVertexAttribfv___)(GLuint index, GLenum pname, GLfloat *params);
typedef void (*___glGetVertexAttribiv___)(GLuint index, GLenum pname, GLint *params);
typedef void (*___glGetVertexAttribPointerv___)(GLuint index, GLenum pname, void **pointer);
typedef void (*___glHint___)(GLenum target, GLenum mode);
typedef GLboolean (*___glIsBuffer___)(GLuint buffer);
typedef GLboolean (*___glIsEnabled___)(GLenum cap);
typedef GLboolean (*___glIsFramebuffer___)(GLuint framebuffer);
typedef GLboolean (*___glIsProgram___)(GLuint program);
typedef GLboolean (*___glIsRenderbuffer___)(GLuint renderbuffer);
typedef GLboolean (*___glIsShader___)(GLuint shader);
typedef GLboolean (*___glIsTexture___)(GLuint texture);
typedef void (*___glLineWidth___)(GLfloat width);
typedef void (*___glLinkProgram___)(GLuint program);
typedef void (*___glPixelStorei___)(GLenum pname, GLint param);
typedef void (*___glPolygonOffset___)(GLfloat factor, GLfloat units);
typedef void (*___glReadPixels___)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
typedef void (*___glReleaseShaderCompiler___)();
typedef void (*___glRenderbufferStorage___)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (*___glSampleCoverage___)(GLfloat value, GLboolean invert);
typedef void (*___glScissor___)(GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (*___glShaderBinary___)(GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);
typedef void (*___glShaderSource___)(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
typedef void (*___glStencilFunc___)(GLenum func, GLint ref, GLuint mask);
typedef void (*___glStencilFuncSeparate___)(GLenum face, GLenum func, GLint ref, GLuint mask);
typedef void (*___glStencilMask___)(GLuint mask);
typedef void (*___glStencilMaskSeparate___)(GLenum face, GLuint mask);
typedef void (*___glStencilOp___)(GLenum fail, GLenum zfail, GLenum zpass);
typedef void (*___glStencilOpSeparate___)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
typedef void (*___glTexImage2D___)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
typedef void (*___glTexParameterf___)(GLenum target, GLenum pname, GLfloat param);
typedef void (*___glTexParameterfv___)(GLenum target, GLenum pname, const GLfloat *params);
typedef void (*___glTexParameteri___)(GLenum target, GLenum pname, GLint param);
typedef void (*___glTexParameteriv___)(GLenum target, GLenum pname, const GLint *params);
typedef void (*___glTexSubImage2D___)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
typedef void (*___glUniform1f___)(GLint location, GLfloat v0);
typedef void (*___glUniform1fv___)(GLint location, GLsizei count, const GLfloat *value);
typedef void (*___glUniform1i___)(GLint location, GLint v0);
typedef void (*___glUniform1iv___)(GLint location, GLsizei count, const GLint *value);
typedef void (*___glUniform2f___)(GLint location, GLfloat v0, GLfloat v1);
typedef void (*___glUniform2fv___)(GLint location, GLsizei count, const GLfloat *value);
typedef void (*___glUniform2i___)(GLint location, GLint v0, GLint v1);
typedef void (*___glUniform2iv___)(GLint location, GLsizei count, const GLint *value);
typedef void (*___glUniform3f___)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
typedef void (*___glUniform3fv___)(GLint location, GLsizei count, const GLfloat *value);
typedef void (*___glUniform3i___)(GLint location, GLint v0, GLint v1, GLint v2);
typedef void (*___glUniform3iv___)(GLint location, GLsizei count, const GLint *value);
typedef void (*___glUniform4f___)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
typedef void (*___glUniform4fv___)(GLint location, GLsizei count, const GLfloat *value);
typedef void (*___glUniform4i___)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
typedef void (*___glUniform4iv___)(GLint location, GLsizei count, const GLint *value);
typedef void (*___glUniformMatrix2fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUniformMatrix3fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUniformMatrix4fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUseProgram___)(GLuint program);
typedef void (*___glValidateProgram___)(GLuint program);
typedef void (*___glVertexAttrib1f___)(GLuint index, GLfloat x);
typedef void (*___glVertexAttrib1fv___)(GLuint index, const GLfloat *v);
typedef void (*___glVertexAttrib2f___)(GLuint index, GLfloat x, GLfloat y);
typedef void (*___glVertexAttrib2fv___)(GLuint index, const GLfloat *v);
typedef void (*___glVertexAttrib3f___)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
typedef void (*___glVertexAttrib3fv___)(GLuint index, const GLfloat *v);
typedef void (*___glVertexAttrib4f___)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
typedef void (*___glVertexAttrib4fv___)(GLuint index, const GLfloat *v);
typedef void (*___glVertexAttribPointer___)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
typedef void (*___glViewport___)(GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (*___glReadBuffer___)(GLenum src);
typedef void (*___glDrawRangeElements___)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);
typedef void (*___glTexImage3D___)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
typedef void (*___glTexSubImage3D___)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
typedef void (*___glCopyTexSubImage3D___)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (*___glCompressedTexImage3D___)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
typedef void (*___glCompressedTexSubImage3D___)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
typedef void (*___glGenQueries___)(GLsizei n, GLuint *ids);
typedef void (*___glDeleteQueries___)(GLsizei n, const GLuint *ids);
typedef GLboolean (*___glIsQuery___)(GLuint id);
typedef void (*___glBeginQuery___)(GLenum target, GLuint id);
typedef void (*___glEndQuery___)(GLenum target);
typedef void (*___glGetQueryiv___)(GLenum target, GLenum pname, GLint *params);
typedef void (*___glGetQueryObjectuiv___)(GLuint id, GLenum pname, GLuint *params);
typedef GLboolean (*___glUnmapBuffer___)(GLenum target);
typedef void (*___glGetBufferPointerv___)(GLenum target, GLenum pname, void **params);
typedef void (*___glDrawBuffers___)(GLsizei n, const GLenum *bufs);
typedef void (*___glUniformMatrix2x3fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUniformMatrix3x2fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUniformMatrix2x4fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUniformMatrix4x2fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUniformMatrix3x4fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glUniformMatrix4x3fv___)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (*___glBlitFramebuffer___)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
typedef void (*___glRenderbufferStorageMultisample___)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (*___glFramebufferTextureLayer___)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
typedef void * (*___glMapBufferRange___)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
typedef void (*___glFlushMappedBufferRange___)(GLenum target, GLintptr offset, GLsizeiptr length);
typedef void (*___glBindVertexArray___)(GLuint array);
typedef void (*___glDeleteVertexArrays___)(GLsizei n, const GLuint *arrays);
typedef void (*___glGenVertexArrays___)(GLsizei n, GLuint *arrays);
typedef GLboolean (*___glIsVertexArray___)(GLuint array);
typedef void (*___glGetIntegeri_v___)(GLenum target, GLuint index, GLint *data);
typedef void (*___glBeginTransformFeedback___)(GLenum primitiveMode);
typedef void (*___glEndTransformFeedback___)();
typedef void (*___glBindBufferRange___)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
typedef void (*___glBindBufferBase___)(GLenum target, GLuint index, GLuint buffer);
typedef void (*___glTransformFeedbackVaryings___)(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);
typedef void (*___glGetTransformFeedbackVarying___)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
typedef void (*___glVertexAttribIPointer___)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);
typedef void (*___glGetVertexAttribIiv___)(GLuint index, GLenum pname, GLint *params);
typedef void (*___glGetVertexAttribIuiv___)(GLuint index, GLenum pname, GLuint *params);
typedef void (*___glVertexAttribI4i___)(GLuint index, GLint x, GLint y, GLint z, GLint w);
typedef void (*___glVertexAttribI4ui___)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
typedef void (*___glVertexAttribI4iv___)(GLuint index, const GLint *v);
typedef void (*___glVertexAttribI4uiv___)(GLuint index, const GLuint *v);
typedef void (*___glGetUniformuiv___)(GLuint program, GLint location, GLuint *params);
typedef GLint (*___glGetFragDataLocation___)(GLuint program, const GLchar *name);
typedef void (*___glUniform1ui___)(GLint location, GLuint v0);
typedef void (*___glUniform2ui___)(GLint location, GLuint v0, GLuint v1);
typedef void (*___glUniform3ui___)(GLint location, GLuint v0, GLuint v1, GLuint v2);
typedef void (*___glUniform4ui___)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
typedef void (*___glUniform1uiv___)(GLint location, GLsizei count, const GLuint *value);
typedef void (*___glUniform2uiv___)(GLint location, GLsizei count, const GLuint *value);
typedef void (*___glUniform3uiv___)(GLint location, GLsizei count, const GLuint *value);
typedef void (*___glUniform4uiv___)(GLint location, GLsizei count, const GLuint *value);
typedef void (*___glClearBufferiv___)(GLenum buffer, GLint drawbuffer, const GLint *value);
typedef void (*___glClearBufferuiv___)(GLenum buffer, GLint drawbuffer, const GLuint *value);
typedef void (*___glClearBufferfv___)(GLenum buffer, GLint drawbuffer, const GLfloat *value);
typedef void (*___glClearBufferfi___)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
typedef const GLubyte * (*___glGetStringi___)(GLenum name, GLuint index);
typedef void (*___glCopyBufferSubData___)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
typedef void (*___glGetUniformIndices___)(GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices);
typedef void (*___glGetActiveUniformsiv___)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
typedef GLuint (*___glGetUniformBlockIndex___)(GLuint program, const GLchar *uniformBlockName);
typedef void (*___glGetActiveUniformBlockiv___)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
typedef void (*___glGetActiveUniformBlockName___)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
typedef void (*___glUniformBlockBinding___)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
typedef void (*___glDrawArraysInstanced___)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
typedef void (*___glDrawElementsInstanced___)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount);
typedef GLsync (*___glFenceSync___)(GLenum condition, GLbitfield flags);
typedef GLboolean (*___glIsSync___)(GLsync sync);
typedef void (*___glDeleteSync___)(GLsync sync);
typedef GLenum (*___glClientWaitSync___)(GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (*___glWaitSync___)(GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (*___glGetInteger64v___)(GLenum pname, GLint64 *data);
typedef void (*___glGetSynciv___)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
typedef void (*___glGetInteger64i_v___)(GLenum target, GLuint index, GLint64 *data);
typedef void (*___glGetBufferParameteri64v___)(GLenum target, GLenum pname, GLint64 *params);
typedef void (*___glGenSamplers___)(GLsizei count, GLuint *samplers);
typedef void (*___glDeleteSamplers___)(GLsizei count, const GLuint *samplers);
typedef GLboolean (*___glIsSampler___)(GLuint sampler);
typedef void (*___glBindSampler___)(GLuint unit, GLuint sampler);
typedef void (*___glSamplerParameteri___)(GLuint sampler, GLenum pname, GLint param);
typedef void (*___glSamplerParameteriv___)(GLuint sampler, GLenum pname, const GLint *param);
typedef void (*___glSamplerParameterf___)(GLuint sampler, GLenum pname, GLfloat param);
typedef void (*___glSamplerParameterfv___)(GLuint sampler, GLenum pname, const GLfloat *param);
typedef void (*___glGetSamplerParameteriv___)(GLuint sampler, GLenum pname, GLint *params);
typedef void (*___glGetSamplerParameterfv___)(GLuint sampler, GLenum pname, GLfloat *params);
typedef void (*___glVertexAttribDivisor___)(GLuint index, GLuint divisor);
typedef void (*___glBindTransformFeedback___)(GLenum target, GLuint id);
typedef void (*___glDeleteTransformFeedbacks___)(GLsizei n, const GLuint *ids);
typedef void (*___glGenTransformFeedbacks___)(GLsizei n, GLuint *ids);
typedef GLboolean (*___glIsTransformFeedback___)(GLuint id);
typedef void (*___glPauseTransformFeedback___)();
typedef void (*___glResumeTransformFeedback___)();
typedef void (*___glGetProgramBinary___)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
typedef void (*___glProgramBinary___)(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
typedef void (*___glProgramParameteri___)(GLuint program, GLenum pname, GLint value);
typedef void (*___glInvalidateFramebuffer___)(GLenum target, GLsizei numAttachments, const GLenum *attachments);
typedef void (*___glInvalidateSubFramebuffer___)(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (*___glTexStorage2D___)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (*___glTexStorage3D___)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
typedef void (*___glGetInternalformativ___)(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);

View File

@ -26,7 +26,7 @@
#ifndef FRT_H
#define FRT_H
#define FRT_WINDOW_TITLE "Godot / FRT"
#define FRT_WINDOW_TITLE "Pandemonium / FRT"
#define FRT_VERSION "1.1.0"
#include <stdint.h>
@ -238,8 +238,7 @@ struct InputModifierState {
#ifdef FRT_TEST
#define FRT_GLES_VERSION 2
#else
#include "core/version.h"
#define FRT_GLES_VERSION VERSION_MAJOR
#define FRT_GLES_VERSION 2
#endif // FRT_TEST
#endif // FRT_H

File diff suppressed because it is too large Load Diff

View File

@ -27,9 +27,9 @@
#define FRT_MOCK_GODOT_INPUT_MODIFIER_STATE
#else
#include "core/version.h"
#if VERSION_MAJOR == 3
#define FRT_MOCK_GODOT_INPUT_MODIFIER_STATE
#endif
#include "core/os/input_event.h"
#endif

View File

@ -27,9 +27,9 @@
#define FRT_MOCK_GODOT_INPUT_MODIFIER_STATE
#else
#include "core/version.h"
#if VERSION_MAJOR == 3
#define FRT_MOCK_GODOT_INPUT_MODIFIER_STATE
#endif
#include "core/os/input_event.h"
#endif

View File

@ -47,146 +47,11 @@
#include "core/print_string.h"
#define VIDEO_DRIVER_GLES2 0
#define VIDEO_DRIVER_GLES3 1
#if VERSION_MAJOR == 2
#define VIDEO_DRIVER_COUNT 1
#include "platform/x11/joystick_linux.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "servers/audio/audio_server_sw.h"
#include "servers/audio/sample_manager_sw.h"
#include "servers/spatial_sound/spatial_sound_server_sw.h"
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "servers/physics_server.h"
#include "servers/physics/physics_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "drivers/gles2/rasterizer_gles2.h"
static int event_id = 0;
class InputModifierStateSetter {
private:
InputModifierState &mod;
public:
InputModifierStateSetter(InputModifierState &m)
: mod(m) {}
void set_shift(bool v) { mod.shift = v; }
void set_control(bool v) { mod.control = v; }
void set_alt(bool v) { mod.alt = v; }
void set_metakey(bool v) { mod.meta = v; }
};
class InputEventKeySetter : public InputModifierStateSetter {
private:
InputEvent &event;
public:
InputEventKeySetter(InputEvent &ev)
: InputModifierStateSetter(ev.key.mod), event(ev) {
event.type = InputEvent::KEY;
event.device = 0;
}
void set_pressed(bool v) { event.key.pressed = v; }
void set_scancode(uint32_t v) { event.key.scancode = v; }
void set_unicode(uint32_t v) { event.key.unicode = v; }
void set_echo(bool v) { event.key.echo = v; }
};
class InputEventMouseMotionSetter : public InputModifierStateSetter {
private:
InputEvent &event;
public:
InputEventMouseMotionSetter(InputEvent &ev)
: InputModifierStateSetter(ev.mouse_motion.mod), event(ev) {
event.type = InputEvent::MOUSE_MOTION;
event.device = 0;
}
void set_button_mask(int v) { event.mouse_motion.button_mask = v; }
void set_position(const Vector2 &v) {
event.mouse_motion.x = v.x;
event.mouse_motion.y = v.y;
}
void set_global_position(const Vector2 &v) {
event.mouse_motion.global_x = v.x;
event.mouse_motion.global_y = v.y;
}
void set_speed(const Vector2 &v) {
event.mouse_motion.speed_x = v.x;
event.mouse_motion.speed_y = v.y;
}
void set_relative(const Vector2 &v) {
event.mouse_motion.relative_x = v.x;
event.mouse_motion.relative_y = v.y;
}
};
class InputEventMouseButtonSetter : public InputModifierStateSetter {
private:
InputEvent &event;
public:
InputEventMouseButtonSetter(InputEvent &ev)
: InputModifierStateSetter(ev.mouse_button.mod), event(ev) {
event.type = InputEvent::MOUSE_BUTTON;
event.device = 0;
}
void set_button_mask(int v) { event.mouse_button.button_mask = v; }
void set_position(const Vector2 &v) {
event.mouse_button.x = v.x;
event.mouse_button.y = v.y;
}
void set_global_position(const Vector2 &v) {
event.mouse_button.global_x = v.x;
event.mouse_button.global_y = v.y;
}
void set_pressed(bool v) { event.mouse_button.pressed = v; }
void set_button_index(int v) { event.mouse_button.button_index = v; }
void set_doubleclick(bool v) { event.mouse_button.doubleclick = v; }
};
class InputModifierRef {
private:
InputModifierStateSetter setter;
public:
InputModifierRef(InputModifierStateSetter &s)
: setter(s) {}
InputModifierStateSetter *operator->() { return &setter; }
};
template <typename T>
class InputEventRef {
private:
InputEvent event;
T setter;
InputModifierRef mod;
public:
InputEventRef()
: setter(event), mod(setter) { event.ID = ++event_id; };
void instance() {}
operator InputEvent() { return event; }
operator InputModifierRef() { return mod; }
T *operator->() { return &setter; }
};
#define INPUT_MODIFIER_REF InputModifierRef
#define INPUT_EVENT_REF(t) InputEventRef<t##Setter>
#include "core/globals.h"
#define PROJECT_SETTINGS \
Globals *project_settings = Globals::get_singleton();
#elif VERSION_MAJOR == 3
#define VIDEO_DRIVER_COUNT 2
#include "platform/x11/joypad_linux.h"
#include "drivers/gles3/rasterizer_gles3.h"
#define FRT_DL_SKIP
//#define FRT_DL_SKIP
#include "drivers/gles2/rasterizer_gles2.h"
typedef AudioDriverManager AudioDriverManagerSW;
typedef AudioDriver AudioDriverSW;
@ -203,10 +68,6 @@ typedef AudioDriver AudioDriverSW;
#define PROJECT_SETTINGS \
ProjectSettings *project_settings = ProjectSettings::get_singleton();
#else
#error "unhandled godot version"
#endif
#include "frt.h"
#include "bits/mouse_virtual.h"
@ -290,15 +151,6 @@ private:
MouseMode mouse_mode;
int mouse_state;
bool grab;
#if VERSION_MAJOR == 2
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
Rasterizer *rasterizer;
AudioServerSW *audio_server;
SampleManagerMallocSW *sample_manager;
SpatialSoundServerSW *spatial_sound_server;
SpatialSound2DServerSW *spatial_sound_2d_server;
#endif
int event_id;
InputDefault *input;
#ifdef JOYDEV_ENABLED
@ -311,10 +163,7 @@ public:
int get_video_driver_count() const { return VIDEO_DRIVER_COUNT; }
int get_current_video_driver() const { return current_video_driver; }
const char *get_video_driver_name(int driver) const {
if (driver == VIDEO_DRIVER_GLES3)
return "GLES3";
else
return "GLES2";
return "GLES2";
}
OS::VideoMode get_default_video_mode() const {
return OS::VideoMode(screen_size.x, screen_size.y, true, false, true);
@ -328,11 +177,9 @@ public:
return driver_->get_name();
}
bool _check_internal_feature_support(const String &feature) {
if (current_video_driver == VIDEO_DRIVER_GLES3 && feature == "etc2")
return true;
return feature == "pc" || feature == "etc";
}
#if VERSION_MAJOR >= 3
String get_config_path() const {
if (has_environment("XDG_CONFIG_HOME"))
return get_environment("XDG_CONFIG_HOME");
@ -354,7 +201,7 @@ public:
return get_environment("HOME").plus_file(".cache");
return get_config_path();
}
#endif
void extract_resource_fatal(const char *msg) {
fatal("failed extracting resource '%s': %s.",
extract_resource_name, msg);
@ -428,39 +275,24 @@ public:
bool exit_on_shiftenter() {
return exit_on_shiftenter_param->value.u.b;
}
#if VERSION_MAJOR == 2
void
#else
Error
#endif
initialize(const VideoMode &desired, int video_driver, int audio_driver) {
Error initialize(const VideoMode &desired, int video_driver, int audio_driver) {
get_project_frt_params();
extract_resource_if_requested();
args = OS::get_singleton()->get_cmdline_args();
current_videomode = desired;
main_loop = 0;
Vec2 view(current_videomode.width, current_videomode.height);
int gl_version = video_driver == VIDEO_DRIVER_GLES3 ? 3 : 2;
int gl_version = video_driver == 2;
context_gl = env->video->create_the_gl_context(gl_version, view);
context_gl->initialize();
#if VERSION_MAJOR == 2
rasterizer = memnew(RasterizerGLES2);
visual_server = memnew(VisualServerRaster(rasterizer));
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE)
visual_server = memnew(VisualServerWrapMT(
visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
#else
if (video_driver == VIDEO_DRIVER_GLES3) {
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
current_video_driver = VIDEO_DRIVER_GLES3;
} else {
RasterizerGLES2::register_config();
RasterizerGLES2::make_current();
current_video_driver = VIDEO_DRIVER_GLES2;
}
RasterizerGLES2::register_config();
RasterizerGLES2::make_current();
current_video_driver = VIDEO_DRIVER_GLES2;
visual_server = memnew(VisualServerRaster);
#endif
// TODO: Audio Module
AudioDriverManagerSW::get_driver(audio_driver)->set_singleton();
audio_driver_index = audio_driver;
@ -476,65 +308,31 @@ public:
}
}
}
#if VERSION_MAJOR == 2
sample_manager = memnew(SampleManagerMallocSW);
audio_server = memnew(AudioServerSW(sample_manager));
audio_server->init();
spatial_sound_server = memnew(SpatialSoundServerSW);
spatial_sound_server->init();
spatial_sound_2d_server = memnew(SpatialSound2DServerSW);
spatial_sound_2d_server->init();
ERR_FAIL_COND(!visual_server);
#else
if (!visual_server)
return FAILED;
#endif
visual_server->init();
#if VERSION_MAJOR == 2
physics_server = memnew(PhysicsServerSW);
physics_server->init();
physics_2d_server = memnew(Physics2DServerSW);
physics_2d_server->init();
#endif
input = memnew(InputDefault);
#ifdef JOYDEV_ENABLED
joystick = memnew(joystick_linux(input));
#endif
last_click = 0;
#if VERSION_MAJOR == 2
_ensure_data_dir();
#else
#if VERSION_MINOR < 3
_ensure_user_data_dir();
#endif
return OK;
#endif
}
void finalize() {
if (main_loop)
memdelete(main_loop);
main_loop = NULL;
#if VERSION_MAJOR == 2
spatial_sound_server->finish();
memdelete(spatial_sound_server);
spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);
memdelete(sample_manager);
audio_server->finish();
memdelete(audio_server);
visual_server->finish();
#else // VERSION_MAJOR == 3
for (int i = 0; i < get_audio_driver_count(); i++)
AudioDriverManager::get_driver(i)->finish();
#endif
memdelete(visual_server);
#if VERSION_MAJOR == 2
memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);
physics_2d_server->finish();
memdelete(physics_2d_server);
#endif
#ifdef JOYDEV_ENABLED
memdelete(joystick);
#endif
@ -570,17 +368,14 @@ public:
input->set_main_loop(main_loop);
}
bool can_draw() const { return true; };
String get_name()
#if (VERSION_MAJOR == 3) && (VERSION_MINOR >= 2)
const
#endif
{ return "FRT"; }
String get_name() const { return "FRT"; }
void move_window_to_foreground() {}
void set_cursor_shape(CursorShape shape) {}
void set_custom_mouse_cursor(const RES&, OS::CursorShape, const Vector2&) {}
void release_rendering_thread() { context_gl->release_current(); }
void make_rendering_thread() { context_gl->make_current(); }
void swap_buffers() { context_gl->swap_buffers(); }
uint32_t unicode_fallback(int gd_code, bool pressed,
const InputModifierState &st) {
if (st.alt || st.control || st.meta || !pressed)
@ -591,6 +386,7 @@ public:
return gd_code;
return 0;
}
void get_key_modifier_state(INPUT_MODIFIER_REF mod,
InputModifierState *st = 0) {
InputModifierState state;
@ -609,6 +405,7 @@ public:
if (st)
*st = state;
}
void process_keyboard_event(int key, bool pressed, uint32_t unicode, bool echo) {
INPUT_EVENT_REF(InputEventKey) k;
k.instance();
@ -759,11 +556,7 @@ public:
while (app->is_running()) {
app->dispatch_events();
#ifdef JOYDEV_ENABLED
#if VERSION_MAJOR == 2
event_id = joystick->process_joysticks(event_id);
#else
joystick->process_joypads();
#endif
#endif
if (Main::iteration() == true)
break;

View File

@ -31,15 +31,8 @@
#define FRT_DL_SKIP
#include "dl/gles2.gen.h"
#if FRT_GLES_VERSION == 3
#include "dl/gles3.gen.h"
#endif
static bool frt_load_gles(int version) {
#if FRT_GLES_VERSION == 3
if (version == 3)
return frt_load_gles3("libGLESv2.so.2");
#endif
return frt_load_gles2("libGLESv2.so.2");
}