pull in DerelictGL3 and load it

This commit is contained in:
Josh Holtrop 2020-08-03 16:53:22 -04:00
parent 56c20c4a36
commit 3f4a8709b5
7 changed files with 26 additions and 2 deletions

9
.gitmodules vendored
View File

@ -4,3 +4,12 @@
[submodule "libs/glcxx"] [submodule "libs/glcxx"]
path = libs/glcxx path = libs/glcxx
url = git://github.com/holtrop/glcxx.git url = git://github.com/holtrop/glcxx.git
[submodule "libs/DerelictGL3"]
path = libs/DerelictGL3
url = git://github.com/DerelictOrg/DerelictGL3
[submodule "libs/DerelictGLFW3"]
path = libs/DerelictGLFW3
url = git://github.com/DerelictOrg/DerelictGLFW3
[submodule "libs/DerelictUtil"]
path = libs/DerelictUtil
url = git://github.com/DerelictOrg/DerelictUtil

View File

@ -6,9 +6,9 @@ end
build do build do
main_env = Rscons::Environment.new do |env| main_env = Rscons::Environment.new do |env|
env["sources"] = glob("src/**/*.{c,d}") env["sources"] = glob("src/**/*.{c,d}", "libs/Derelict*/**/*.d")
env["CCFLAGS"] += %w[-Wall] env["CCFLAGS"] += %w[-Wall]
env["D_IMPORT_PATH"] += glob("src/**") env["D_IMPORT_PATH"] += glob("src/**", "libs/Derelict*/source")
env["DFLAGS"] += %w[-Wall] env["DFLAGS"] += %w[-Wall]
env["LIBS"] += %w[X11 GLX] env["LIBS"] += %w[X11 GLX]
env.Program("jes", "${sources}") env.Program("jes", "${sources}")

1
libs/DerelictGL3 Submodule

@ -0,0 +1 @@
Subproject commit e1197a6c5f644a8c4a2f132de03d5c979490690c

1
libs/DerelictGLFW3 Submodule

@ -0,0 +1 @@
Subproject commit 09b9680cc8b40e20a48b2c008907cc749254aced

1
libs/DerelictUtil Submodule

@ -0,0 +1 @@
Subproject commit 8dda33953e05e228a8a0459954023de2c0b375b5

View File

@ -4,11 +4,15 @@ static import jtk.event;
static import jtk.timer; static import jtk.timer;
static import jtk.window; static import jtk.window;
import derelict.opengl;
private extern(C) bool jtk_init(); private extern(C) bool jtk_init();
private extern(C) void jtk_quit(); private extern(C) void jtk_quit();
bool init() bool init()
{ {
DerelictGL3.load();
if (!jtk_init()) if (!jtk_init())
{ {
return false; return false;

View File

@ -3,6 +3,8 @@ module jtk.window;
import std.string; import std.string;
import core.sync.mutex; import core.sync.mutex;
import derelict.opengl;
private extern(C) bool jtk_window_create(ulong * window); private extern(C) bool jtk_window_create(ulong * window);
private extern(C) void jtk_window_swap_buffers(ulong window); private extern(C) void jtk_window_swap_buffers(ulong window);
private extern(C) void jtk_window_close(ulong window); private extern(C) void jtk_window_close(ulong window);
@ -14,6 +16,7 @@ class Window
{ {
private static Window[ulong] windows_by_id; private static Window[ulong] windows_by_id;
private static Mutex windows_by_id_mutex; private static Mutex windows_by_id_mutex;
private static bool derelict_reloaded;
private ulong m_window; private ulong m_window;
this() this()
@ -22,6 +25,11 @@ class Window
{ {
/* TODO */ /* TODO */
} }
if (!derelict_reloaded)
{
DerelictGL3.reload();
derelict_reloaded = true;
}
synchronized(windows_by_id_mutex) synchronized(windows_by_id_mutex)
{ {
windows_by_id[m_window] = this; windows_by_id[m_window] = this;