Skip to content

Commit

Permalink
Add GLES2 2D renderer + Linux display manager
Browse files Browse the repository at this point in the history
First implementation with Linux display manager.

- Add single-threaded mode for EditorResourcePreview (needed for OpenGL).

Co-authored-by: clayjohn <claynjohn@gmail.com>
Co-authored-by: Fabio Alessandrelli <fabio.alessandrelli@gmail.com>
  • Loading branch information
3 people authored and Calinou committed Oct 30, 2021
1 parent d046817 commit e3491a3
Show file tree
Hide file tree
Showing 88 changed files with 41,646 additions and 338 deletions.
22 changes: 22 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ from collections import OrderedDict
# Local
import methods
import glsl_builders
import gles_builders
from platform_methods import run_in_subprocess

# Scan possible build platforms

Expand Down Expand Up @@ -706,6 +708,26 @@ if selected_platform in platform_list:
}
env.Append(BUILDERS=GLSL_BUILDERS)

if not env["platform"] == "server": # FIXME: detect GLES3
env.Append(
BUILDERS={
"GLES3_GLSL": env.Builder(
action=run_in_subprocess(gles_builders.build_gles3_headers),
suffix="glsl.gen.h",
src_suffix=".glsl",
)
}
)
env.Append(
BUILDERS={
"GLES2_GLSL": env.Builder(
action=run_in_subprocess(gles_builders.build_gles2_headers),
suffix="glsl.gen.h",
src_suffix=".glsl",
)
}
)

scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path != None:
CacheDir(scons_cache_path)
Expand Down
19 changes: 19 additions & 0 deletions core/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class OS {
bool restart_on_exit = false;
List<String> restart_commandline;

// for the user interface we keep a record of the current display driver
// so we can retrieve the rendering drivers available
int _display_driver_id = -1;
String _current_rendering_driver_name = "";

protected:
void _set_logger(CompositeLogger *p_logger);

Expand All @@ -81,20 +86,29 @@ class OS {
RENDER_SEPARATE_THREAD
};

enum RenderMainThreadMode {
RENDER_MAIN_THREAD_ONLY,
RENDER_ANY_THREAD,
};

protected:
friend class Main;
// Needed by tests to setup command-line args.
friend int test_main(int argc, char *argv[]);

HasServerFeatureCallback has_server_feature_callback = nullptr;
RenderThreadMode _render_thread_mode = RENDER_THREAD_SAFE;
RenderMainThreadMode _render_main_thread_mode = RENDER_ANY_THREAD;

// Functions used by Main to initialize/deinitialize the OS.
void add_logger(Logger *p_logger);

virtual void initialize() = 0;
virtual void initialize_joypads() = 0;

void set_current_rendering_driver_name(String p_driver_name) { _current_rendering_driver_name = p_driver_name; }
void set_display_driver_id(int p_display_driver_id) { _display_driver_id = p_display_driver_id; }

virtual void set_main_loop(MainLoop *p_main_loop) = 0;
virtual void delete_main_loop() = 0;

Expand All @@ -110,6 +124,9 @@ class OS {

static OS *get_singleton();

String get_current_rendering_driver_name() const { return _current_rendering_driver_name; }
int get_display_driver_id() const { return _display_driver_id; }

void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, Logger::ErrorType p_type = Logger::ERR_ERROR);
void print(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
void printerr(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
Expand Down Expand Up @@ -241,6 +258,8 @@ class OS {
virtual uint64_t get_free_static_memory() const;

RenderThreadMode get_render_thread_mode() const { return _render_thread_mode; }
RenderMainThreadMode get_render_main_thread_mode() const { return _render_main_thread_mode; }
void set_render_main_thread_mode(RenderMainThreadMode p_thread_mode) { _render_main_thread_mode = p_thread_mode; }

virtual String get_locale() const;
String get_locale_language() const;
Expand Down
5 changes: 5 additions & 0 deletions drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ SConscript("winmidi/SCsub")
# Graphics drivers
if env["vulkan"]:
SConscript("vulkan/SCsub")
SConscript("gles2/SCsub")
SConscript("gles_common/SCsub")
SConscript("gl_context/SCsub")
else:
SConscript("dummy/SCsub")

# Core dependencies
SConscript("png/SCsub")
Expand Down
23 changes: 23 additions & 0 deletions drivers/gl_context/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

Import("env")

if env["platform"] in ["haiku", "osx", "windows", "linuxbsd"]:
# Thirdparty source files
thirdparty_dir = "#thirdparty/glad/"
thirdparty_sources = [
"glad.c",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env.Prepend(CPPPATH=[thirdparty_dir])

env.Append(CPPDEFINES=["GLAD_ENABLED"])
env.Append(CPPDEFINES=["GLES_OVER_GL"])

env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources)

# Godot source files
env.add_source_files(env.drivers_sources, "*.cpp")
7 changes: 7 additions & 0 deletions drivers/gles2/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python

Import("env")

env.add_source_files(env.drivers_sources, "*.cpp")

SConscript("shaders/SCsub")
Loading

0 comments on commit e3491a3

Please sign in to comment.