diff --git a/platform/frt/.clang-format b/platform/frt/.clang-format new file mode 100644 index 000000000..22505aca5 --- /dev/null +++ b/platform/frt/.clang-format @@ -0,0 +1,100 @@ +#### Quick patch adapting 3.9.1 for 3.5 (debian jessie) +#### (no SortIncludes regardless) +--- +BasedOnStyle: LLVM +# Commented out parameters are those with the same value as base LLVM style +# We can uncomment them if we want to change their value, or enforce the +# chosen value in case the base style changes (initial sync: Clang 3.9.1). +... +Language: Cpp +AccessModifierOffset: -4 +####AlignAfterOpenBracket: DontAlign +# AlignConsecutiveAssignments: false +# AlignConsecutiveDeclarations: false +# AlignEscapedNewlinesLeft: false +# AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +# AllowShortBlocksOnASingleLine: false +###AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: true +# AllowShortLoopsOnASingleLine: false +# AlwaysBreakAfterDefinitionReturnType: None +# AlwaysBreakAfterReturnType: None +# AlwaysBreakBeforeMultilineStrings: false +# AlwaysBreakTemplateDeclarations: false +# BinPackArguments: true +# BinPackParameters: true +# BraceWrapping: +# AfterClass: false +# AfterControlStatement: false +# AfterEnum: false +# AfterFunction: false +# AfterNamespace: false +# AfterObjCDeclaration: false +# AfterStruct: false +# AfterUnion: false +# BeforeCatch: false +# BeforeElse: false +# IndentBraces: false +# BreakBeforeBinaryOperators: None +# BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: false +# BreakConstructorInitializersBeforeComma: false +# BreakAfterJavaFieldAnnotations: false +# BreakStringLiterals: true +ColumnLimit: 0 +# CommentPragmas: '^ IWYU pragma:' +# ConstructorInitializerAllOnOneLineOrOnePerLine: false +# ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +# DerivePointerAlignment: false +# DisableFormat: false +# ExperimentalAutoDetectBinPacking: false +# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +####IncludeCategories: +#### - Regex: '".*"' +#### Priority: 1 +#### - Regex: '^<.*\.h>' +#### Priority: 2 +#### - Regex: '^<.*' +#### Priority: 3 +# IncludeIsMainRegex: '$' +IndentCaseLabels: true +IndentWidth: 4 +# IndentWrappedFunctionNames: false +# JavaScriptQuotes: Leave +# JavaScriptWrapImports: true +# KeepEmptyLinesAtTheStartOfBlocks: true +# MacroBlockBegin: '' +# MacroBlockEnd: '' +# MaxEmptyLinesToKeep: 1 +# NamespaceIndentation: None +####ObjCBlockIndentWidth: 4 +# ObjCSpaceAfterProperty: false +# ObjCSpaceBeforeProtocolList: true +# PenaltyBreakBeforeFirstCallParameter: 19 +# PenaltyBreakComment: 300 +# PenaltyBreakFirstLessLess: 120 +# PenaltyBreakString: 1000 +# PenaltyExcessCharacter: 1000000 +# PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +# ReflowComments: true +####SortIncludes: true +# SpaceAfterCStyleCast: false +# SpaceBeforeAssignmentOperators: true +# SpaceBeforeParens: ControlStatements +# SpaceInEmptyParentheses: false +# SpacesBeforeTrailingComments: 1 +# SpacesInAngles: false +# SpacesInContainerLiterals: true +# SpacesInCStyleCastParentheses: false +# SpacesInParentheses: false +# SpacesInSquareBrackets: false +Standard: Cpp03 +TabWidth: 4 +UseTab: Always +... diff --git a/platform/frt/.gitignore b/platform/frt/.gitignore new file mode 100644 index 000000000..27ebfbe6a --- /dev/null +++ b/platform/frt/.gitignore @@ -0,0 +1,8 @@ +*.o +*.swp +*.pyc +*.bin +a.out +logo.h +*.gen.* +private/ diff --git a/platform/frt/.travis.yml b/platform/frt/.travis.yml new file mode 100644 index 000000000..9e61d58a3 --- /dev/null +++ b/platform/frt/.travis.yml @@ -0,0 +1,20 @@ +dist: trusty +sudo: false +language: cpp +os: + - linux +addons: + apt: + packages: + - build-essential + - scons + - pkg-config + - libx11-dev + - libgles2-mesa-dev + - libasound2-dev + - libfreetype6-dev + - libudev-dev + - libpng12-dev + - zlib1g-dev +script: + - make ci diff --git a/platform/frt/CREDITS.txt b/platform/frt/CREDITS.txt new file mode 100644 index 000000000..dd14255e0 --- /dev/null +++ b/platform/frt/CREDITS.txt @@ -0,0 +1,21 @@ +Some code has been imported (almost) verbatim. See import/* from details. + +The file os_frt.cpp has been written taking the Godot code base as a reference +(mostly platform/os_x11.cpp). + +For other contributions, here is a snippet of the git history of FRT: + +============================================================================== + +commit a85b77e41ccc08f0e90fa958052c3ca551f6f37f +Author: pacoSan +Date: Wed Oct 16 20:01:41 2019 -0600 + + kmsdrm + +commit f438afc7c5f12a991a5c37534aeec547972ef080 +Author: Fabio Alessandrelli +Date: Wed Sep 20 21:29:08 2017 +0200 + + Add joystick support for RPI + diff --git a/platform/frt/LICENSE.txt b/platform/frt/LICENSE.txt new file mode 100644 index 000000000..d65da5e6b --- /dev/null +++ b/platform/frt/LICENSE.txt @@ -0,0 +1,21 @@ +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. diff --git a/platform/frt/LICENSE_GODOT.txt b/platform/frt/LICENSE_GODOT.txt new file mode 100644 index 000000000..c290de091 --- /dev/null +++ b/platform/frt/LICENSE_GODOT.txt @@ -0,0 +1,28 @@ + GODOT ENGINE + http://www.godotengine.org + +************************************************************************ + + Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. + Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) + + 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. + +************************************************************************ diff --git a/platform/frt/Local.mk b/platform/frt/Local.mk new file mode 100644 index 000000000..dfc1c9c57 --- /dev/null +++ b/platform/frt/Local.mk @@ -0,0 +1,11 @@ +all: + @echo + @echo FRT is not meant to be compiled stand alone out of the box. + @echo You need to put it in the \"platform\" directory of godot and use + @echo scons as usual. + @echo + @echo For example, from the main top level godot directory, type: + @echo + @echo " " scons platform=frt target=release tools=no frt_arch=pi3 + @echo + @echo diff --git a/platform/frt/Makefile b/platform/frt/Makefile new file mode 100644 index 000000000..cda1c603c --- /dev/null +++ b/platform/frt/Makefile @@ -0,0 +1,16 @@ +# Makefile + +CLANG_FORMAT = clang-format-3.5 + +include Local.mk + +clean: + rm -f *.o dl/*.gen.* import/*.o + +format: + $(CLANG_FORMAT) -i *.cpp *.h bits/*.h import/*.h porting/*.cpp + +ci: + git clone -b 3.0-gles2 --depth=1 https://github.com/efornara/godot + ln -s `pwd` godot/platform/frt + ( cd godot ; scons platform=frt target=release warnings=no builtin_freetype=yes builtin_libpng=yes builtin_zlib=yes module_openssl_enabled=no module_websocket_enabled=no tools=no frt_arch=pc ) diff --git a/platform/frt/README.md b/platform/frt/README.md new file mode 100644 index 000000000..0e19938db --- /dev/null +++ b/platform/frt/README.md @@ -0,0 +1,72 @@ +FRT 1.x +======= + +patreon: efornaralabs +https://github.com/efornara/frt +https://github.com/efornara/frt/tree/1.x - 265ddf153c3350b10c4b4c1fd08ddf6cfb67be91 + +FRT +=== + +[Godot](https://godotengine.org) is a full 2D and 3D game engine with editor. + +FRT is a Godot "platform" targeting single board computers. In plain English, +you can export a Godot game to most of them by using FRT binaries, *as long as +the game has been designed with the limitation of the hardware in mind*. + +## When (not) to use FRT + +Godot comes with a generic X11 platform that works very well on Pis, as long +as you enable the experimental OpenGL driver (not needed on a Pi 4, not +recommended on Pi 0-1). + +So, in general, if you are only interested in exporting games for Pis starting +from the Pi 2, your best option is probably to compile an ARM export template +yourself starting from the official Godot source code. + +## How to use FRT + +Precompiled versions of FRT can be found here: + + + +And instructions of how to export a game from the Godot editor running on your +PC [here](doc/Usage.md). + +If you have come across an FRT game and it is running on the console, you can +press *Win+Q* to close it. + +This is the list of meta (Win) keys recognized by FRT when running on +the console (i.e. non on X11): + +| Meta | Action | +| :---: | :--- | +| *Q* | *Quit* | +| F | Toggle fullscreen | +| W | Change window gravity | +| K | Grab / ungrab the keyboard | +| M | Grab / ungrab the mouse | +| Return | Mouse Left Button (virtual mouse) | +| Cursor Keys | Mouse Motion (virtual mouse) | + +The virtual mouse keys are available only if a keyboard is found, but a +mouse is not. + +## User Info + +- [ReleaseNotes](doc/ReleaseNotes.md) +- [Usage](doc/Usage.md) +- [Environment](doc/Environment.md) +- [Extensions](doc/Extensions.md) +- [Bugs](doc/Bugs.md) + +## Hardware Info + +- [Utgard](doc/Utgard.md) +- [VC4](doc/VC4.md) +- [VC6](doc/VC6.md) + +## Developer Info + +- [Compile](doc/Compile.md) +- [Porting](doc/Porting.md) diff --git a/platform/frt/SCsub b/platform/frt/SCsub new file mode 100644 index 000000000..34d5884e2 --- /dev/null +++ b/platform/frt/SCsub @@ -0,0 +1,28 @@ +#! /usr/bin/env python + +Import('env') + +import sys +dl_path = './dl' +sys.path.append(dl_path) +import procdl +sys.path.remove(dl_path) + +env.Append(BUILDERS={'DLH': env.Builder(action=procdl.build_h_action, suffix='.gen.h', src_suffix='.dl')}) +env.Append(BUILDERS={'DLCPP': env.Builder(action=procdl.build_cpp_action, suffix='.gen.cpp', src_suffix='.dl')}) + +for dl in Glob('dl/*.dl'): + env.DLH(str(dl)) + env.DLCPP(str(dl)) +for libname in ['gles2', 'gles3']: + env.Depends('platform_config.h', 'dl/' + libname + '.gen.h') + +frt_env = env.Clone() +import os +if os.path.isfile('/opt/vc/include/bcm_host.h'): + frt_env.Append(CCFLAGS=["-I/opt/vc/include/"]) + +if os.path.isfile('/usr/include/libdrm/drm.h'): + frt_env.Append(CCFLAGS=["-I/usr/include/libdrm"]) + +frt_env.Program('#bin/godot', ['godot_frt.cpp', 'os_frt.cpp', 'frt_options.cpp'] + env['FRT_MODULES']) diff --git a/platform/frt/bits/egl_base_context.h b/platform/frt/bits/egl_base_context.h new file mode 100644 index 000000000..97f5fd538 --- /dev/null +++ b/platform/frt/bits/egl_base_context.h @@ -0,0 +1,116 @@ +// egl_base_context.h +/* + * 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 "dl/egl.gen.h" + +namespace frt { + +class EGLBaseContext { +private: + void build_attr_list(EGLint *attr_list) { + App *app = App::instance(); + int n = 0; + const int color_size = app->get_int_param("color_size"); + attr_list[n++] = EGL_RED_SIZE; + attr_list[n++] = color_size; + attr_list[n++] = EGL_GREEN_SIZE; + attr_list[n++] = color_size; + attr_list[n++] = EGL_BLUE_SIZE; + attr_list[n++] = color_size; + const int alpha_size = app->get_int_param("alpha_size"); + attr_list[n++] = EGL_ALPHA_SIZE; + attr_list[n++] = alpha_size >= 0 ? alpha_size : EGL_DONT_CARE; + const int depth_size = app->get_int_param("depth_size"); + attr_list[n++] = EGL_DEPTH_SIZE; + attr_list[n++] = depth_size >= 0 ? depth_size : EGL_DONT_CARE; + if (app->get_bool_param("multisample")) { + attr_list[n++] = EGL_SAMPLE_BUFFERS; + attr_list[n++] = 1; + } + attr_list[n++] = EGL_SURFACE_TYPE; + attr_list[n++] = EGL_WINDOW_BIT; + attr_list[n++] = EGL_NONE; + } + +protected: + EGLDisplay display; + EGLContext context; + EGLSurface surface; + EGLConfig config; + +public: + void init(int version, EGLNativeDisplayType display_id = EGL_DEFAULT_DISPLAY) { + static EGLint attr_list[32]; + static const EGLint ctx_attrs[] = { + EGL_CONTEXT_CLIENT_VERSION, version, + EGL_NONE + }; + EGLBoolean result; + EGLint num_config; + display = eglGetDisplay(display_id); + if (display == EGL_NO_DISPLAY) + fatal("eglGetDisplay failed."); + result = eglInitialize(display, 0, 0); + if (result == EGL_FALSE) + fatal("eglInitialize failed."); + build_attr_list(attr_list); + result = eglChooseConfig(display, attr_list, &config, 1, &num_config); + if (result == EGL_FALSE) + fatal("eglChooseConfig failed."); + result = eglBindAPI(EGL_OPENGL_ES_API); + if (result == EGL_FALSE) + fatal("eglBindAPI failed."); + context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctx_attrs); + if (context == EGL_NO_CONTEXT) + fatal("eglCreateContext failed."); + }; + void create_simple_surface(EGLNativeWindowType window_id) { + surface = eglCreateWindowSurface(display, config, window_id, 0); + if (surface == EGL_NO_SURFACE) + fatal("eglCreateWindowSurface failed."); + } + void cleanup() { + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(display, context); + eglTerminate(display); + } + void destroy_surface() { + eglDestroySurface(display, surface); + } + void make_current() { + eglMakeCurrent(display, surface, surface, context); + } + void release_current() { + eglMakeCurrent(display, 0, 0, 0); + } + void swap_buffers() { + eglSwapBuffers(display, surface); + } + void swap_interval(int interval) { + eglSwapInterval(display, interval); + } +}; + +} // namespace frt diff --git a/platform/frt/bits/frt_app_impl.h b/platform/frt/bits/frt_app_impl.h new file mode 100644 index 000000000..417641341 --- /dev/null +++ b/platform/frt/bits/frt_app_impl.h @@ -0,0 +1,114 @@ +// frt_app_impl.h +/* + * 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 +#include +#include +#include + +namespace frt { + +void fatal(const char *format, ...) { + va_list ap; + va_start(ap, format); + fprintf(stderr, "frt: "); + vfprintf(stderr, format, ap); + fprintf(stderr, "\n"); + va_end(ap); + exit(1); +} + +void App::register_(Module *module) { + if (nm >= max_modules) + return; + m[nm++] = module; +} + +Module *App::get(const char *id) const { + for (int i = 0; i < nm; i++) + if (!strcmp(id, m[i]->get_id())) + return m[i]; + return 0; +} + +Module *App::probe(const char *ids[]) { + for (int i = 0; ids[i]; i++) { + Module *module = get(ids[i]); + if (module && module->probe()) + return module; + } + return 0; +} + +Module *App::probe_single() { + if (nm != 1) + return 0; + if (!m[0]->probe()) + return 0; + return m[0]; +} + +void **App::get_context(const char *key) { + for (int i = 0; i < nc; i++) + if (!strcmp(key, c[i].key)) + return &c[i].value; + if (nc >= max_contexts) + return 0; + c[nc].key = key; + c[nc].value = 0; + return &c[nc++].value; +} + +void App::add_dispatcher(EventDispatcher *dispatcher) { + if (nd >= max_dispatchers) + return; + d[nd++] = dispatcher; +} + +void App::remove_dispatcher(EventDispatcher *dispatcher) { + int i; + for (i = 0; i < nd; i++) + if (d[i] == dispatcher) + break; + if (i == nd) + return; + nd--; + for (; i < nd; i++) + d[i] = d[i + 1]; +} + +void App::dispatch_events() { + for (int i = 0; i < nd; i++) + d[i]->dispatch_events(); +} + +App *App::instance() { + static App *a = 0; + if (!a) + a = new App(); + return a; +} + +} // namespace frt diff --git a/platform/frt/bits/frt_load_gles.h b/platform/frt/bits/frt_load_gles.h new file mode 100644 index 000000000..3a9a187ba --- /dev/null +++ b/platform/frt/bits/frt_load_gles.h @@ -0,0 +1,58 @@ +// frt_load_gles.h +/* + * 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. + */ + +// on pi, skip EGL/GLESv2 in /opt/vc/lib +static const char *lib(const char *s) { +#if defined(__arm__) || defined(__aarch64__) + static char buf[64]; // large enough + strcpy(buf, "/opt/vc/lib/"); + strcat(buf, s); + if (access(buf, R_OK) != 0) + return s; +#if defined(__arm__) + strcpy(buf, "/usr/lib/arm-linux-gnueabihf/"); +#else + strcpy(buf, "/usr/lib/aarch64-linux-gnu/"); +#endif + strcat(buf, s); + return buf; +#else // !pi + return s; +#endif +} + +#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")); +} diff --git a/platform/frt/bits/linux_input.h b/platform/frt/bits/linux_input.h new file mode 100644 index 000000000..7feb956f5 --- /dev/null +++ b/platform/frt/bits/linux_input.h @@ -0,0 +1,169 @@ +// linux_input.h +/* + * 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 +#include +#include + +#include +#include +#include +#include + +namespace frt { + +static const char *dev_input_id_dir = "/dev/input/by-id"; + +enum KeyValue { KV_Released, + KV_Pressed, + KV_Repeated }; + +class LinuxInput { +private: + int fd; + bool grabbed; + bool find_by_name(char *buf, int size, const char *name) { + const char *s_name = "N: Name=\""; + const char *s_handlers = "H: Handlers="; + const char *s_event = "event"; + FILE *f = fopen("/proc/bus/input/devices", "r"); + if (!f) + return false; + char s[1024]; + bool found = false; + int state = 0, nn = strlen(name), ns; + while (fgets(s, sizeof(s), f) && !found) { + switch (state) { + case 0: + if (!strncmp(s_name, s, strlen(s_name))) { + ns = strlen(s); + if (((int)(ns - strlen(s_name) - strlen("\"\n")) == nn) + && !memcmp(&s[strlen(s_name)], name, nn)) + state = 1; + } + break; + case 1: + if (!strncmp(s_handlers, s, strlen(s_handlers))) { + state = 0; + char *event = strstr(s, s_event); + if (!event) + break; + int id = atoi(event + strlen(s_event)); + snprintf(buf, size, "/dev/input/event%d", id); + found = true; + } + break; + } + } + fclose(f); + return found; + } + bool open_file(const char *file_name) { + fd = ::open(file_name, O_RDONLY | O_NONBLOCK); + if (fd == -1) + return false; + return true; + } + bool parse_dir(const char *pattern, char *buf, int size) { + bool found = false; + DIR *dirp = opendir(dev_input_id_dir); + if (!dirp) + return false; + while (1) { + struct dirent *dp; + if (!(dp = readdir(dirp))) + break; + const char *id = dp->d_name; + if (strstr(id, pattern)) { + snprintf(buf, size, "%s/%s", dev_input_id_dir, id); + buf[size - 1] = '\0'; + found = true; + break; + } + } + closedir(dirp); + return found; + } + bool open_by_id_substr(const char *substr) { + char buf[512]; + if (!parse_dir(substr, buf, sizeof(buf))) + return false; + return open_file(buf); + } + +protected: + LinuxInput() + : fd(-1), grabbed(false) {} + bool open(const char *env_tag, const char *substr) { + char *id = getenv(env_tag); + if (id) { + char buf[512]; + const char *s = 0; + if (id[0] == '/') + s = id; + else if (find_by_name(buf, sizeof(buf), id)) + s = buf; + if (s) + return open_file(s); + } else { + return open_by_id_substr(substr); + } + return false; + } + bool grab(bool grab, int wait_ms) { + /* + HACK to let other clients get release keys at startup + TODO: better handling + */ + if (this->grabbed == grab) + return true; + usleep(wait_ms * 1000); + if (ioctl(fd, EVIOCGRAB, grab ? 1 : 0)) + return false; + this->grabbed = grab; + return true; + } + void close() { + if (fd != -1) { + ::close(fd); + fd = -1; + } + } + bool poll() { + input_event events[64]; + while (1) { + int bytes = read(fd, events, sizeof(events)); + if (bytes <= 0) + return false; + int n = bytes / sizeof(input_event); + for (int i = 0; i < n; i++) + handle(events[i]); + } + } + // LinuxInput + virtual void handle(const input_event &ev) = 0; +}; + +} // namespace frt diff --git a/platform/frt/bits/mouse_virtual.h b/platform/frt/bits/mouse_virtual.h new file mode 100644 index 000000000..4a34b0631 --- /dev/null +++ b/platform/frt/bits/mouse_virtual.h @@ -0,0 +1,110 @@ +// mouse_virtual.h +/* + * 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 "../import/gdkeys.h" + +namespace frt { + +class MouseVirtual : public Mouse, public EventDispatcher { +private: + static const int speed = 2; + Handler *h; + Vec2 size; + Vec2 pos; + struct { + bool up; + bool down; + bool left; + bool right; + } st; + +public: + MouseVirtual() + : h(0) { + st.up = false; + st.down = false; + st.left = false; + st.right = false; + } + // Module + const char *get_id() const { return "mouse_virtual"; } + bool probe() { + App::instance()->add_dispatcher(this); + return true; + } + void cleanup() { + App::instance()->remove_dispatcher(this); + } + bool handle_meta(int gd_code, bool pressed) { + switch (gd_code) { + case GD_KEY_UP: + st.up = pressed; + break; + case GD_KEY_DOWN: + st.down = pressed; + break; + case GD_KEY_LEFT: + st.left = pressed; + break; + case GD_KEY_RIGHT: + st.right = pressed; + break; + case GD_KEY_RETURN: + if (h) + h->handle_mouse_button(Left, pressed); + break; + default: + return false; + } + return true; + } + // EventDispatcher + void dispatch_events() { + if (!st.up && !st.down && !st.left && !st.right) + return; + if (st.up) + pos.y -= speed; + if (st.down) + pos.y += speed; + if (st.left) + pos.x -= speed; + if (st.right) + pos.x += speed; + if (h) + h->handle_mouse_motion(pos); + } + // Mouse + Vec2 get_pos() const { return pos; } + void set_size(Vec2 size) { + this->size = size; + pos.x = size.x - 1; + pos.y = size.y - 1; + } + void set_handler(Handler *handler) { + h = handler; + } +}; + +} // namespace frt diff --git a/platform/frt/bits/x11.h b/platform/frt/bits/x11.h new file mode 100644 index 000000000..bf220157b --- /dev/null +++ b/platform/frt/bits/x11.h @@ -0,0 +1,191 @@ +// x11.h +/* + * 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 + +#include "dl/x11.gen.h" + +namespace frt { + +class X11Context; + +struct X11User { +private: + friend class X11Context; + X11Context *ctx; + EventHandler *h; + long mask; + const int *types; + bool valid; + X11User() + : valid(false) {} + +public: + inline Display *get_display(); + inline Window create_window(int width, int height, const char *title); + inline void get_event(XEvent &ev); + inline void release(); +}; + +class X11Context : public EventDispatcher { +private: + friend struct X11User; + static const int max_users = 10; + X11User users[max_users]; + int n_users; + bool create_window; + Display *display; + Window window; + XEvent ev; + long current_mask; + long server_mask; + X11Context() + : n_users(0), create_window(true), display(0), window(0), current_mask(0), server_mask(0) { + display = XOpenDisplay(NULL); + } + virtual ~X11Context() { + if (!display) + return; + if (window) + XDestroyWindow(display, window); + XCloseDisplay(display); + } + Window create(int width, int height, const char *title) { + bool undecorated = getenv("FRT_X11_UNDECORATED"); + Window root = DefaultRootWindow(display); + XSetWindowAttributes swa; + window = XCreateWindow(display, root, 0, 0, + width, height, 0, CopyFromParent, + InputOutput, CopyFromParent, 0, &swa); + XSizeHints sh; + sh.min_width = width; + sh.min_height = height; + sh.max_width = width; + sh.max_height = height; + sh.flags = PMinSize | PMaxSize; + if (undecorated) { + sh.x = 0; + sh.y = 0; + sh.flags |= PPosition; + } + XSetWMNormalHints(display, window, &sh); + XMapWindow(display, window); + XStoreName(display, window, title); + if (undecorated) { + Atom motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False); + long hints[5] = { 2, 0, 0, 0, 0 }; + XChangeProperty(display, window, motif_wm_hints, motif_wm_hints, 32, PropModeReplace, (unsigned char *)hints, 5); + } + XFlush(display); + return window; + } + X11User *acquire_(long mask, const int *types, EventHandler *handler, bool window_owner) { + for (int i = 0; i < max_users; i++) { + if (users[i].valid) + continue; + n_users++; + users[i].valid = true; + users[i].ctx = this; + users[i].mask = mask; + users[i].types = types; + users[i].h = handler; + if (window_owner) + create_window = false; + current_mask |= users[i].mask; + return &users[i]; + } + return 0; + } + void release(X11User *u) { + u->valid = false; + if (--n_users == 0) { + App *app = App::instance(); + app->remove_dispatcher(this); + delete this; + X11Context **ctx = (X11Context **)app->get_context("x11"); + *ctx = 0; + } + } + // EventDispatcher + void dispatch_events() { + if (create_window && !window) + create(100, 100, FRT_WINDOW_TITLE); + if (current_mask != server_mask) { + XSelectInput(display, window, current_mask); + server_mask = current_mask; + } + while (XPending(display)) { + XNextEvent(display, &ev); + int i; + for (i = 0; i < max_users; i++) { + if (!users[i].valid || !users[i].types) + continue; + const int *t = users[i].types; + for (int j = 0; t[j] != 0; j++) { + if (t[j] == ev.type) { + if (users[i].h) + users[i].h->handle_event(); + } + } + } + } + } + + /* + Unfortunately, no RAII since users are driven by probe/cleanup. + Be careful: no safeguards here! + */ +public: + static X11User *acquire(long mask, const int *types, EventHandler *handler, bool window_owner = false) { + App *app = App::instance(); + X11Context **ctx = (X11Context **)app->get_context("x11"); + if (!*ctx) { + if (!frt_load_x11("libX11.so.6")) + return 0; + *ctx = new X11Context(); + app->add_dispatcher(*ctx); + } + return (*ctx)->acquire_(mask, types, handler, window_owner); + } +}; + +inline Display *X11User::get_display() { + return ctx->display; +} + +inline Window X11User::create_window(int width, int height, const char *title) { + return ctx->create(width, height, title); +} + +inline void X11User::get_event(XEvent &ev) { + ev = ctx->ev; +} + +inline void X11User::release() { + if (valid) + ctx->release(this); +} + +} // namespace frt diff --git a/platform/frt/detect.py b/platform/frt/detect.py new file mode 100644 index 000000000..05b18f7ad --- /dev/null +++ b/platform/frt/detect.py @@ -0,0 +1,207 @@ + +import os +import sys + + +import version + +if version.major > 2: + yes = True + no = False +else: + yes = 'yes' + no = 'no' + + +def has_wrapper_for(lib): + + if version.major == 2: + return False + if version.minor > 2: + return True + return False + + +def is_active(): + + return True + + +def get_name(): + + return 'FRT' + + +def can_build(): + + if os.name != 'posix': + return False + return True + + +def get_opts(): + + if version.major > 2: + from SCons.Variables import BoolVariable + else: + def BoolVariable(a,b,c): return (a,b,c) + + return [ + ('frt_arch', 'Architecture (no/arm32v6/arm32v7/arm64v8)', 'no'), + ('frt_cross', 'Cross compilation (no/auto/)', 'no'), + BoolVariable('use_llvm', 'Use llvm compiler', no), + BoolVariable('use_lto', 'Use link time optimization', no), + BoolVariable('use_static_cpp', 'Link libgcc and libstdc++ statically', yes), + BoolVariable('pulseaudio', 'Detect and use pulseaudio', yes), + ] + + +def get_flags(): + + return [ + ('tools', no), + ] + +def check(env, key): + + if not (key in env): + return False + if version.major > 2: + return env[key] + else: + return env[key] == 'yes' + +def configure(env): + + import methods + + env.Append(CPPPATH=['#platform/frt']) + + if check(env, 'use_llvm'): + if 'clang++' not in env['CXX']: + env['CC'] = 'clang' + env['CXX'] = 'clang++' + env['LD'] = 'clang++' + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env.extra_suffix += '.llvm' + + if check(env, 'use_lto'): + if check(env, 'use_llvm'): + env.Append(CCFLAGS=['-flto=thin']) + env.Append(LINKFLAGS=['-fuse-ld=lld', '-flto=thin']) + env['AR'] = 'llvm-ar' + env['RANLIB'] = 'llvm-ranlib' + else: + env.Append(CCFLAGS=['-flto']) + env.Append(LINKFLAGS=['-flto']) + env.extra_suffix += '.lto' + + if env['frt_cross'] != 'no': + if env['frt_cross'] == 'auto': + triple = { + 'arm32v7': 'arm-linux-gnueabihf', + 'arm64v8': 'aarch64-linux-gnu', + }[env['frt_arch']] + else: + triple = env['frt_cross'] + if check(env, 'use_llvm'): + env.Append(CCFLAGS=['-target', triple]) + env.Append(LINKFLAGS=['-target', triple]) + else: + env['CC'] = triple + '-gcc' + env['CXX'] = triple + '-g++' + pkg_config = triple + '-pkg-config' + else: + pkg_config = 'pkg-config' + + env.Append(CCFLAGS=['-pipe']) + env.Append(LINKFLAGS=['-pipe']) + + if os.system(pkg_config + ' --exists alsa') == 0: + print('Enabling ALSA') + env.Append(CPPFLAGS=['-DALSA_ENABLED']) + if has_wrapper_for('alsa'): + env['alsa'] = True + else: + env.ParseConfig(pkg_config + ' alsa --cflags --libs') + else: + print('ALSA libraries not found, disabling driver') + + if check(env, 'pulseaudio'): + if os.system(pkg_config + ' --exists libpulse') == 0: + print('Enabling PulseAudio') + env.Append(CPPDEFINES=['PULSEAUDIO_ENABLED']) + if version.major == 2: + env.ParseConfig(pkg_config + ' --cflags --libs libpulse-simple') + elif has_wrapper_for('libpulse'): + env.ParseConfig(pkg_config + ' --cflags libpulse') + else: + env.ParseConfig(pkg_config + ' --cflags --libs libpulse') + else: + print('PulseAudio libraries not found, disabling driver') + + # pkg-config returns 0 when the lib exists... + found_udev = not os.system(pkg_config + ' --exists libudev') + if found_udev: + print('Enabling udev support') + env.Append(CPPFLAGS=['-DUDEV_ENABLED']) + if has_wrapper_for('udev'): + env.Append(FRT_MODULES=['include/libudev-so_wrap.c']) + else: + env.ParseConfig(pkg_config + ' libudev --cflags --libs') + env.Append(CPPFLAGS=['-DJOYDEV_ENABLED']) + env.Append(FRT_MODULES=['include/joypad_linux.cpp']) + 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': + env.Append(CCFLAGS=['-O3', '-DDEBUG_ENABLED']) + elif env['target'] == 'debug': + env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + if env['target'].startswith('release'): + if version.major == 2 or (version.major == 3 and version.minor == 0): + env.Append(CCFLAGS=['-ffast-math']) + + if env['frt_arch'] == 'arm32v6': + env.Append(CCFLAGS=['-march=armv6', '-mfpu=vfp', '-mfloat-abi=hard']) + env.extra_suffix += '.arm32v6' + elif env['frt_arch'] == 'arm32v7': + env.Append(CCFLAGS=['-march=armv7-a', '-mfpu=neon-vfpv4', '-mfloat-abi=hard']) + env.extra_suffix += '.arm32v7' + elif env['frt_arch'] == 'arm64v8': + env.Append(CCFLAGS=['-march=armv8-a']) + env.extra_suffix += '.arm64v8' + + env.Append(CFLAGS=['-std=gnu11']) # for libwebp (maybe more in the future) + env.Append(CPPFLAGS=['-DFRT_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_ENABLED']) + env.Append(LIBS=['pthread']) + if env['frt_arch'] == 'arm32v6' and version.major == 3 and version.minor >= 4: # TODO find out exact combination + env.Append(LIBS=['atomic']) + + 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=['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']) diff --git a/platform/frt/dl/bcm.dl b/platform/frt/dl/bcm.dl new file mode 100644 index 000000000..7c44d6645 --- /dev/null +++ b/platform/frt/dl/bcm.dl @@ -0,0 +1,41 @@ +// bcm.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 + +typedef void (*___bcm_host_init___)(); +typedef int32_t (*___graphics_get_display_size___)(const uint16_t display_number, uint32_t *width, uint32_t *height); +typedef DISPMANX_DISPLAY_HANDLE_T (*___vc_dispmanx_display_open___)(uint32_t device); +typedef int (*___vc_dispmanx_display_close___)(DISPMANX_DISPLAY_HANDLE_T display); +typedef DISPMANX_RESOURCE_HANDLE_T (*___vc_dispmanx_resource_create___)(VC_IMAGE_TYPE_T type, uint32_t width, uint32_t height, uint32_t *native_image_handle); +typedef int (*___vc_dispmanx_resource_write_data___)(DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, void * src_address, const VC_RECT_T * rect); +typedef int (*___vc_dispmanx_resource_delete___)(DISPMANX_RESOURCE_HANDLE_T res); +typedef int (*___vc_dispmanx_rect_set___)(VC_RECT_T *rect, uint32_t x_offset, uint32_t y_offset, uint32_t width, uint32_t height); +typedef DISPMANX_ELEMENT_HANDLE_T (*___vc_dispmanx_element_add___)(DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display, int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection, VC_DISPMANX_ALPHA_T *alpha, DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform); +typedef int (*___vc_dispmanx_element_remove___)(DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element); +typedef int (*___vc_dispmanx_element_change_attributes___)(DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element, uint32_t change_flags, int32_t layer, uint8_t opacity, const VC_RECT_T *dest_rect, const VC_RECT_T *src_rect, DISPMANX_RESOURCE_HANDLE_T mask, DISPMANX_TRANSFORM_T transform); +typedef DISPMANX_UPDATE_HANDLE_T (*___vc_dispmanx_update_start___)(int32_t priority); +typedef int (*___vc_dispmanx_update_submit_sync___)(DISPMANX_UPDATE_HANDLE_T update); +typedef int (*___vc_dispmanx_update_submit___)(DISPMANX_UPDATE_HANDLE_T update, DISPMANX_CALLBACK_FUNC_T cb_func, void *cb_arg); diff --git a/platform/frt/dl/drm.dl b/platform/frt/dl/drm.dl new file mode 100644 index 000000000..1bde76a68 --- /dev/null +++ b/platform/frt/dl/drm.dl @@ -0,0 +1,39 @@ +// drm.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 +#include + +typedef int (*___drmModeAddFB___)(int fd, uint32_t width, uint32_t height, uint8_t depth, uint8_t bpp, uint32_t pitch, uint32_t bo_handle, uint32_t *buf_id); +typedef int (*___drmModeSetCrtc___)(int fd, uint32_t crtcId, uint32_t bufferId, uint32_t x, uint32_t y, uint32_t *connectors, int count, drmModeModeInfoPtr mode); +typedef int (*___drmModeRmFB___)(int fd, uint32_t bufferId); +typedef void (*___drmModeFreeCrtc___)(drmModeCrtcPtr ptr); +typedef drmModeResPtr (*___drmModeGetResources___)(int fd); +typedef drmModeConnectorPtr (*___drmModeGetConnector___)(int fd, uint32_t connectorId); +typedef drmModeEncoderPtr (*___drmModeGetEncoder___)(int fd, uint32_t encoder_id); +typedef drmModeCrtcPtr (*___drmModeGetCrtc___)(int fd, uint32_t crtcId); +typedef void (*___drmModeFreeEncoder___)(drmModeEncoderPtr ptr); +typedef void (*___drmModeFreeConnector___)(drmModeConnectorPtr ptr); +typedef void (*___drmModeFreeResources___)(drmModeResPtr ptr); diff --git a/platform/frt/dl/egl.dl b/platform/frt/dl/egl.dl new file mode 100644 index 000000000..573665e8e --- /dev/null +++ b/platform/frt/dl/egl.dl @@ -0,0 +1,42 @@ +// egl.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 + +typedef EGLContext (*___eglCreateContext___)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +typedef EGLBoolean (*___eglChooseConfig___)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLBoolean (*___eglGetConfigs___)(EGLDisplay dpy, EGLConfig * configs, EGLint config_size, EGLint * num_config); +typedef EGLBoolean (*___eglGetConfigAttrib___)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value); +typedef EGLSurface (*___eglCreateWindowSurface___)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +typedef EGLBoolean (*___eglDestroyContext___)(EGLDisplay dpy, EGLContext ctx); +typedef EGLBoolean (*___eglDestroySurface___)(EGLDisplay dpy, EGLSurface surface); +typedef EGLDisplay (*___eglGetDisplay___)(EGLNativeDisplayType display_id); +typedef EGLBoolean (*___eglInitialize___)(EGLDisplay dpy, EGLint *major, EGLint *minor); +typedef EGLBoolean (*___eglMakeCurrent___)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +typedef EGLBoolean (*___eglSwapBuffers___)(EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (*___eglTerminate___)(EGLDisplay dpy); +typedef EGLBoolean (*___eglSwapInterval___)(EGLDisplay dpy, EGLint interval); +typedef EGLBoolean (*___eglBindAPI___)(EGLenum api); +typedef EGLint (*___eglGetError___)(); diff --git a/platform/frt/dl/gbm.dl b/platform/frt/dl/gbm.dl new file mode 100644 index 000000000..61a3ce92f --- /dev/null +++ b/platform/frt/dl/gbm.dl @@ -0,0 +1,36 @@ +// gbm.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 +#include + +typedef struct gbm_bo *(*___gbm_surface_lock_front_buffer___)(struct gbm_surface *surface); +typedef union gbm_bo_handle (*___gbm_bo_get_handle___)(struct gbm_bo *bo); +typedef uint32_t (*___gbm_bo_get_stride___)(struct gbm_bo *bo); +typedef void (*___gbm_surface_release_buffer___)(struct gbm_surface *surface, struct gbm_bo *bo); +typedef void (*___gbm_surface_destroy___)(struct gbm_surface *surface); +typedef void (*___gbm_device_destroy___)(struct gbm_device *gbm); +typedef struct gbm_device *(*___gbm_create_device___)(int fd); +typedef struct gbm_surface *(*___gbm_surface_create___)(struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t flags); diff --git a/platform/frt/dl/gles2.dl b/platform/frt/dl/gles2.dl new file mode 100644 index 000000000..2677ac682 --- /dev/null +++ b/platform/frt/dl/gles2.dl @@ -0,0 +1,171 @@ +// gles2.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 + +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 (*___glRenderbufferStorageMultisample___)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); diff --git a/platform/frt/dl/gles3.dl b/platform/frt/dl/gles3.dl new file mode 100644 index 000000000..507d64e20 --- /dev/null +++ b/platform/frt/dl/gles3.dl @@ -0,0 +1,273 @@ +// 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 + +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); diff --git a/platform/frt/dl/minidl.sh b/platform/frt/dl/minidl.sh new file mode 100755 index 000000000..5cf24a349 --- /dev/null +++ b/platform/frt/dl/minidl.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +for filename in $* ; do + echo -n "Processing $filename... " + libname=`basename "$filename" .dl` + grep '^#include' <"$libname.dl" >"$libname.gen.h" + echo >>"$libname.gen.h" \ + "static inline bool frt_load_$libname(const char *) { return true; }" + rm -f "$libname.gen.cpp" + echo "done." +done diff --git a/platform/frt/dl/procdl.py b/platform/frt/dl/procdl.py new file mode 100755 index 000000000..ce33f264a --- /dev/null +++ b/platform/frt/dl/procdl.py @@ -0,0 +1,141 @@ +#! /usr/bin/python + +# procdl.py +# +# FRT - A Godot platform targeting single board computers +# Copyright (c) 2017 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. +# + +import re + +def parse_dl(dl, suffix): + libname = 'unnamed' + head = '' + symbols = [] + types = [] + includes = [] + f_dl = open(dl, 'r') + for line in f_dl.readlines(): + line = line.replace('\n', '') + if libname == 'unnamed': + m = re.search(r'^//\s*(.*)\.dl\s*$', line) + if m: + libname = m.group(1) + head += '// ' + libname + suffix + head += ' - File generated by procdl.py - DO NOT EDIT\n' + continue + m = re.search(r'^.*___(.*)___.*$', line) + if not m: + if re.search(r'^#include', line): + includes.append(line) + else: + head += line + '\n' + continue + s = m.group(1) + symbols.append(s) + ls = libname + '_' + s + types.append(line.replace('___' + s + '___', 'FRT_FN_' + ls)) + f_dl.close() + return (libname, head, symbols, types, includes) + +def build_h(dl, h): + libname, head, symbols, types, includes = parse_dl(dl, '.gen.h') + f = open(h, 'w') + f.write(head) + def out(s=None): + if s: + f.write(s) + f.write('\n') + out('#ifndef FRT_DL_SKIP') + for s in includes: + out(s) + out() + for s in types: + out(s) + out() + for s in symbols: + ls = libname + '_' + s + out('#define ' + s + ' frt_fn_' + ls) + out() + for s in symbols: + ls = libname + '_' + s + out('extern FRT_FN_' + ls + ' frt_fn_' + ls + ';') + out() + out('#endif') + out('extern bool frt_load_' + libname + '(const char *filename);') + f.close() + +def build_cpp(dl, cpp): + libname, head, symbols, types, includes = parse_dl(dl, '.gen.cpp') + f = open(cpp, 'w') + f.write(head) + assignments = '' + for s in symbols: + ls = libname + '_' + s + assignments += 'FRT_FN_' + ls + ' frt_fn_' + ls + ' = 0;\n' + resolutions = '' + for s in symbols: + ls = libname + '_' + s + resolutions += '\tfrt_fn_' + ls + ' = (FRT_FN_' + ls + ')' + resolutions += 'dlsym(lib, "' + s + '");\n' + f.write("""\ +#include "%(libname)s.gen.h" + +#include + +#include + +static void *lib = 0; + +%(assignments)s + +bool frt_load_%(libname)s(const char *filename) { + if (lib) + return true; + lib = dlopen(filename, RTLD_LAZY); + if (!lib) { + fprintf(stderr, "frt: dlopen failed for '%%s'.\\n", filename); + return false; + } +%(resolutions)s + return true; +} +""" % { + 'libname': libname, + 'assignments': assignments[:-1], + 'resolutions': resolutions[:-1] + }) + f.close() + +def build_cpp_action(target, source, env): + build_cpp(str(source[0]), str(target[0])) + +def build_h_action(target, source, env): + build_h(str(source[0]), str(target[0])) + +if __name__ == '__main__': + import sys + for s in sys.argv[1:]: + sys.stdout.write('Processing ' + s + '... ') + build_cpp(s, s.replace('.dl', '.gen.cpp')) + build_h(s, s.replace('.dl', '.gen.h')) + sys.stdout.write('done.\n') diff --git a/platform/frt/dl/x11.dl b/platform/frt/dl/x11.dl new file mode 100644 index 000000000..848648fc7 --- /dev/null +++ b/platform/frt/dl/x11.dl @@ -0,0 +1,45 @@ +// x11.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 +#include + +typedef Display *(*___XOpenDisplay___)(_Xconst char *); +typedef int (*___XCloseDisplay___)(Display *); +typedef Window (*___XCreateWindow___)(Display *, Window, int, int, unsigned int, unsigned int, unsigned int, int, unsigned int, Visual *, unsigned long, XSetWindowAttributes *); +typedef int (*___XDestroyWindow___)(Display *, Window); +typedef int (*___XMapWindow___)(Display *, Window); +typedef int (*___XStoreName___)(Display *, Window, _Xconst char *); +typedef int (*___XFlush___)(Display *); +typedef int (*___XSelectInput___)(Display *, Window, long); +typedef int (*___XPending___)(Display *); +typedef int (*___XNextEvent___)(Display *, XEvent *); +typedef int (*___XPeekEvent___)(Display *, XEvent *); +typedef int (*___XWarpPointer___)(Display *, Window, Window, int, int, unsigned int, unsigned int, int, int); +typedef int (*___XLookupString___)(XKeyEvent *, char *, int, KeySym *, XComposeStatus *); +typedef void (*___XSetWMNormalHints___)(Display *, Window, XSizeHints *); +typedef Atom (*___XInternAtom___)(Display *, _Xconst char *, Bool); +typedef Status (*___XSetWMProtocols___)(Display *, Window, Atom *, int); +typedef int (*___XChangeProperty___)(Display *, Window, Atom, Atom, int, int, _Xconst unsigned char *, int); diff --git a/platform/frt/doc/Bugs.md b/platform/frt/doc/Bugs.md new file mode 100644 index 000000000..92f1a077d --- /dev/null +++ b/platform/frt/doc/Bugs.md @@ -0,0 +1,38 @@ +Bugs +==== + +When reading the list of known bugs below, please keep this in mind: + +- FRT has been written with the idea of treating SBCs as cheap and open game + consoles, so some features you can find on the official Godot x11 platform, + like cut and paste, drag and drop, or more in general proper desktop + integration, are out of scope for FRT. + +- Apart from the now deprecated 3.0-gles2 version, most of the code, and the + rendering code in particular, is unpatched from the official Godot codebase. + However, the code-path used is roughly the one used on mobile phones. If you + find a bug, check upstream with similar bugs on phones with a similar SoC to + the one used in your board. + +- There are different code-paths within FRT, so it can behave differently on + different hardware and even on different configurations of the same + hardware. + +- Major refactoring work in the FRT codebase is on hold until Godot 4.0 + reaches beta / release candidate stage. + +## Common + +- No proper fullscreen support + +## Module: `video_bcm` + +- Might panic the kernel if 3D is used in Godot 3.2 + +## Module: `video_kmsdms` and `video_fbdev` + +- No mouse pointer + +## Module: `keyboard_linux_input` + +- Might provide the wrong key presses on some layouts diff --git a/platform/frt/doc/Compile.md b/platform/frt/doc/Compile.md new file mode 100644 index 000000000..6aba7120b --- /dev/null +++ b/platform/frt/doc/Compile.md @@ -0,0 +1,158 @@ +Compile +======= + +To compile the Godot templates on a Pi, start from the official +3.1-stable source tarball: + + + +These packages should be enough: + + $ sudo apt-get install build-essential scons pkg-config libx11-dev libgles2-mesa-dev libasound2-dev libfreetype6-dev libudev-dev libpng12-dev zlib1g-dev clang + +## Compile Godot (X11) + +To compile the official X11 platform, this is, in theory, what you should do: + + $ cd ~/godot-3.1-stable + $ scons platform=x11 target=release tools=no -j 4 + +In practice, it is better to give the compiler some flags to better target +the CPU of the Pi, and especially its FPU. + +For example (Pi 2/3): + + $ scons platform=x11 target=release tools=no CCFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access" -j 4 + +Or (Pi 1/Zero): + + $ scons platform=x11 target=release tools=no CCFLAGS="-mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -mlittle-endian -munaligned-access" -j 4 + +You might need to use clang on some versions of debian. If so, add: + + use_llvm=yes + +You might also need to disable some modules, for example: + + module_webm_enabled=no + +See `release.sh` for the options that are used to generate the official +FRT release binaries, keeping in mind that they are generated on a +debian jessie chroot environment (gcc 4.9.2, so there is no need to use clang) +and that SSL is disabled (so you might want to omit the relevant options if +you want to enable it). + +## Compile Godot (FRT) + +FRT can be compiled against the Godot engine source as it is. + +However there are some optional patches that you might want to apply +to the engine. See the `patches` directory. FRT release binaries are +generated applying the patches. + +Go to the platform directory and clone this repository: + + $ cd ~/godot-3.1-stable + $ cd platform + $ git clone https://github.com/efornara/frt + +From the main directory, you now have a new "platform" available: + + $ cd ~/godot-3.1-stable + $ scons platform=frt target=release frt_arch=pi3 -j 4 + +Unlike the X11 platform, FRT disables tools by default and preselect +some CPU-specific options according to frt\_arch. + +When compiling on a real Pi, using an external Hard Disk is +strongly advised: everything is faster and more reliable, and you can +enable a swap partition without stressing the Memory Card. +Swap is hardly used, especially if you start Raspbian without the GUI, +but enabling it allows you to use `-j 4` and leave the compilation +unattended. + +Compiling godot-3.1-stable + FRT from scratch on a non-overclocked +Pi 3 running Raspbian jessie should take about one hour. + +## Compile Godot (FRT) to run on a PC + +On some Linux systems, FRT can run on a desktop. This can be useful +to test the ES 2.0 rendering pipeline directly on a PC. +Intel IGPs are known to work. +Just repeat the steps above from your Linux PC and build FRT without +setting the architecture: + + $ scons platform=frt target=release -j 8 + +## Cross compile (QEMU) + +These are a few notes on how to cross-compile FRT on a PC running debian +stable (stretch). A standard armv7 debian is used as a target. See +below on tips on using Raspbian as a target. + +There might be better ways, and compilation is quite slow +(around 5 hours to compile godot-2.1.4-stable from scratch on a, +quite slow, Acer C7 C710-2847). + +The official FRT release binaries are not cross-compiled. They are generated +on a Pi. + +Familiarity with the Linux environment is assumed. +Notes based on + + +Install debootstrap and qemu: + + [host] # apt-get install binfmt-support qemu qemu-user-static debootstrap + +Download and install the base system: + + [host] # cd /opt + [host] # mkdir arm7hf + [host] # qemu-debootstrap --arch armhf jessie arm7hf http://deb.debian.org/debian + +Mount the proc filesystem: + + [host] # mount -t proc proc /opt/arm7hf/proc + +Chroot into the system and create a user (with uid/gid matching your main +user on the host; no action should be required if your main user is the +first user created): + + [host] # LC_ALL=C chroot /opt/arm7hf bash + [chroot] # adduser user + ... + +Install the needed packages: + + [chroot] # apt-get update + [chroot] # apt-get upgrade -y + [chroot] # apt-get install -y build-essential scons pkg-config libx11-dev libgles2-mesa-dev libasound2-dev libfreetype6-dev libudev-dev libpng12-dev zlib1g-dev + +From another terminal, and using your main user on the host (note the `$` +prompt), clone the Godot and FRT repositories: + + [host] $ cd /opt/arm7hf/home/user + [host] $ git clone https://github.com/efornara/godot 3.0-gles2 + [host] $ cd 3.0-gles2/platform + [host] $ git clone https://github.com/efornara/frt + +Back on the chroot environment, compile Godot: + + [chroot] # su - user + [chroot] $ cd 3.0-gles2 + [chroot] $ nice scons platform=frt target=release frt_arch=arm7hf module_webm_enabled=no builtin_freetype=yes -j 2 + ... + +### Raspbian + +- Download the Raspbian keyring and use it with qemu-debootstrap + +- Check the chroot `/etc/apt/source.list` after debootstrap, and reset it +to the Raspbian repository if needed. + +### BCM + +- Download the raspberry firmware to compile BCM support. Only the +include directory (`/opt/vc/include`) is needed as the libraries are +dynamically loaded. diff --git a/platform/frt/doc/Environment.md b/platform/frt/doc/Environment.md new file mode 100644 index 000000000..74104d0bc --- /dev/null +++ b/platform/frt/doc/Environment.md @@ -0,0 +1,68 @@ +Environment +=========== + +Environment variables can be passed to FRT like this: + + export FRT_KMSDRM_DEVICE=/dev/dri/renderD128 + frt_096_216_pi2.bin -path ~/mygame + +Or like this: + + FRT_KMSDRM_DEVICE=/dev/dri/renderD128 frt_096_216_pi2.bin -path ~/mygame + +In most cases, you shouldn't need to set environment variables to use FRT. + +## `FRT_X11_UNDECORATED` + +Ask the window manager not to decorate the window, and force its position +to be at 0,0. + +Work around the lack of fullscreen support in the X11 module. Intended to be +used together with --resolution (or -r for Godot 2). + +## `FRT_KEYBOARD_ID` and `FRT_MOUSE_ID` + +If FRT fails to select the correct device for your keyboard and/or your mouse, +you can force it to by specifying either the full path of the device, or its +name as seen by the input bus. For example, to find out which name to use, you +can use the following command: + + grep Name= /proc/bus/input/devices + +`FRT_KEYBOARD_ID` can also be used to let FRT open a "virtual keyboard". For +example (GPIOnext): + + FRT_KEYBOARD_ID="GPIOnext Keyboard" + +or (Adafruit-Retrogame): + + FRT_KEYBOARD_ID=retrogame + +These variables are not relevant under X11. + +## `FRT_KMSDRM_DEVICE` + +Selection of the dri card to use is done by an heuristic tuned for the +Pis. For other devices, you might have to select it manually. For +example: + + FRT_KMSDRM_DEVICE=/dev/dri/renderD128 + +## `FRT_MODULES` + +This should be used as a last resort and only if you know what you are doing. +Forcing a module that cannot run is likely to result in FRT just crashing. + +To override which modules are loaded by FRT, use the following pattern: + + FRT_MODULES=