Skip to content

Commit

Permalink
Fix building frt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Relintai committed Jul 21, 2024
1 parent c01fe31 commit 7c9b9c8
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 1 deletion.
1 change: 1 addition & 0 deletions platform/frt/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env.Append(BUILDERS={'DLCPP': env.Builder(action=procdl.build_cpp_action, suffix
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')

Expand Down
12 changes: 12 additions & 0 deletions platform/frt/bits/frt_load_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ static const char *lib(const char *s) {
#define FRT_DL_SKIP
#include "dl/gles2.gen.h"

#ifndef GLES3_DISABLED
#if FRT_GLES_VERSION == 3
#include "dl/gles3.gen.h"
#endif
#endif

static bool frt_load_gles(int version) {
#ifndef GLES3_DISABLED
#if FRT_GLES_VERSION == 3
if (version == 3)
return frt_load_gles3(lib("libGLESv2.so.2"));
#endif
#endif
return frt_load_gles2(lib("libGLESv2.so.2"));
}
3 changes: 3 additions & 0 deletions platform/frt/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,7 @@ def configure(env):

env.Append(FRT_MODULES=['dl/gles2.gen.cpp'])

if not env["disable_gles3"]:
env.Append(FRT_MODULES=['dl/gles3.gen.cpp'])

env.Append(LIBS=['dl'])
273 changes: 273 additions & 0 deletions platform/frt/dl/gles3.dl

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions platform/frt/frt.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,13 @@ struct InputModifierState {
#ifdef FRT_TEST
#define FRT_GLES_VERSION 2
#else

#ifndef GLES3_DISABLED
#define FRT_GLES_VERSION 3
#else
#define FRT_GLES_VERSION 2
#endif

#endif // FRT_TEST

#endif // FRT_H
42 changes: 41 additions & 1 deletion platform/frt/os_frt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,25 @@
#include "servers/rendering/rendering_server_raster.h"
#include "servers/rendering_server.h"

#ifndef GLES3_DISABLED
#define VIDEO_DRIVER_GLES2 0
#define VIDEO_DRIVER_GLES3 1
#define VIDEO_DRIVER_COUNT 2
#else
#define VIDEO_DRIVER_GLES2 0
#define VIDEO_DRIVER_COUNT 1
#endif

#include "platform/x11/joypad_linux.h"

// #define FRT_DL_SKIP
#ifndef GLES3_DISABLED
#include "drivers/gles3/rasterizer_gles3.h"
#endif

#define FRT_DL_SKIP
#include "drivers/gles2/rasterizer_gles2.h"


typedef AudioDriverManager AudioDriverManagerSW;
typedef AudioDriver AudioDriverSW;
#define set_mouse_pos set_mouse_position
Expand Down Expand Up @@ -194,7 +206,14 @@ class OS_FRT : public OS_Unix, public Runnable {
int get_video_driver_count() const { return VIDEO_DRIVER_COUNT; }
int get_current_video_driver() const { return current_video_driver; }
const char *get_video_driver_name(int driver) const {
#ifndef GLES3_DISABLED
if (driver == VIDEO_DRIVER_GLES3)
return "GLES3";
else
return "GLES2";
#else
return "GLES2";
#endif
}
OS::VideoMode get_default_video_mode() const {
return OS::VideoMode(screen_size.x, screen_size.y, true, false, true);
Expand All @@ -208,6 +227,10 @@ class OS_FRT : public OS_Unix, public Runnable {
return driver_->get_name();
}
bool _check_internal_feature_support(const String &feature) {
#ifndef GLES3_DISABLED
if (current_video_driver == VIDEO_DRIVER_GLES3 && feature == "etc2")
return true;
#endif
return feature == "pc" || feature == "etc";
}

Expand Down Expand Up @@ -314,13 +337,30 @@ class OS_FRT : public OS_Unix, public Runnable {
current_videomode = desired;
main_loop = 0;
Vec2 view(current_videomode.width, current_videomode.height);
#ifndef GLES3_DISABLED
int gl_version = video_driver == VIDEO_DRIVER_GLES3 ? 3 : 2;
#else
int gl_version = video_driver == 2;
#endif
context_gl = env->video->create_the_gl_context(gl_version, view);
context_gl->initialize();


#ifndef GLES3_DISABLED
if (video_driver == VIDEO_DRIVER_GLES3) {
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
current_video_driver = VIDEO_DRIVER_GLES3;
} else {
RasterizerGLES2::register_config();
RasterizerGLES2::make_current();
current_video_driver = VIDEO_DRIVER_GLES2;
}
#else
RasterizerGLES2::register_config();
RasterizerGLES2::make_current();
current_video_driver = VIDEO_DRIVER_GLES2;
#endif

rendering_server = memnew(RenderingServerRaster);

Expand Down
14 changes: 14 additions & 0 deletions platform/frt/video_fbdev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,21 @@
#define FRT_DL_SKIP
#include "dl/gles2.gen.h"

#ifndef GLES3_DISABLED

#if FRT_GLES_VERSION == 3
#include "dl/gles3.gen.h"
#endif

#endif

static bool frt_load_gles(int version) {
#ifndef GLES3_DISABLED
#if FRT_GLES_VERSION == 3
if (version == 3)
return frt_load_gles3("libGLESv2.so.2");
#endif
#endif
return frt_load_gles2("libGLESv2.so.2");
}

Expand Down

0 comments on commit 7c9b9c8

Please sign in to comment.