add wasigl
This commit is contained in:
parent
b2ea5eae5e
commit
5367c60328
25
build.zig
25
build.zig
|
|
@ -205,8 +205,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
|
||||||
if (options.rmodels) {
|
if (options.rmodels) {
|
||||||
try c_source_files.append("src/rmodels.c");
|
try c_source_files.append("src/rmodels.c");
|
||||||
}
|
}
|
||||||
raylib_mod.addCMacro("SUPPORT_MODULE_RAUDIO", &.{@as(u8, @intFromBool(options.raudio)) + 0x30});
|
const raudio_enabled = options.raudio and options.platform != .wasigl;
|
||||||
if (options.raudio) {
|
raylib_mod.addCMacro("SUPPORT_MODULE_RAUDIO", &.{@as(u8, @intFromBool(raudio_enabled)) + 0x30});
|
||||||
|
if (raudio_enabled) {
|
||||||
try c_source_files.append("src/raudio.c");
|
try c_source_files.append("src/raudio.c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,6 +362,12 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
|
||||||
raylib_mod.addCMacro(OpenglVersion.gl_soft.toCMacroStr(), "");
|
raylib_mod.addCMacro(OpenglVersion.gl_soft.toCMacroStr(), "");
|
||||||
raylib_mod.addCMacro("PLATFORM_MEMORY", "");
|
raylib_mod.addCMacro("PLATFORM_MEMORY", "");
|
||||||
},
|
},
|
||||||
|
.wasigl => {
|
||||||
|
raylib_mod.addCMacro("PLATFORM_WASIGL", "");
|
||||||
|
raylib_mod.addCMacro("GRAPHICS_API_OPENGL_ES2", "");
|
||||||
|
raylib_mod.addIncludePath(b.path("src/external/glfw/include"));
|
||||||
|
raylib.import_symbols = true;
|
||||||
|
},
|
||||||
.win32 => {
|
.win32 => {
|
||||||
if (target.result.os.tag != .windows) {
|
if (target.result.os.tag != .windows) {
|
||||||
@panic("Target is not supported with this platform");
|
@panic("Target is not supported with this platform");
|
||||||
|
|
@ -573,17 +580,7 @@ pub const LinuxDisplayBackend = enum {
|
||||||
Both,
|
Both,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const PlatformBackend = enum {
|
pub const PlatformBackend = enum { glfw, rgfw, sdl, sdl2, sdl3, memory, win32, drm, android, wasigl };
|
||||||
glfw,
|
|
||||||
rgfw,
|
|
||||||
sdl,
|
|
||||||
sdl2,
|
|
||||||
sdl3,
|
|
||||||
memory,
|
|
||||||
win32,
|
|
||||||
drm,
|
|
||||||
android,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn translateCMod(
|
fn translateCMod(
|
||||||
comptime header: []const u8,
|
comptime header: []const u8,
|
||||||
|
|
@ -687,6 +684,7 @@ fn addExamples(
|
||||||
}
|
}
|
||||||
if (std.mem.eql(u8, filename, "raylib_opengl_interop")) {
|
if (std.mem.eql(u8, filename, "raylib_opengl_interop")) {
|
||||||
if (platform == .drm) continue;
|
if (platform == .drm) continue;
|
||||||
|
if (platform == .wasigl) continue;
|
||||||
if (target.result.os.tag == .macos) continue;
|
if (target.result.os.tag == .macos) continue;
|
||||||
exe_mod.addIncludePath(b.path("src/external"));
|
exe_mod.addIncludePath(b.path("src/external"));
|
||||||
}
|
}
|
||||||
|
|
@ -794,4 +792,3 @@ fn waylandGenerate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -578,6 +578,14 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WASIGL)
|
||||||
|
WASI_SDK ?= /opt/wasi-sdk
|
||||||
|
CC = $(WASI_SDK)/bin/clang
|
||||||
|
AR = $(WASI_SDK)/bin/llvm-ar
|
||||||
|
LDFLAGS += -Wl,--allow-undefined
|
||||||
|
CFLAGS += -DPLATFORM_WASIGL -DGRAPHICS_API_OPENGL_ES2
|
||||||
|
endif
|
||||||
|
|
||||||
# Define library paths containing required libs: LDFLAGS
|
# Define library paths containing required libs: LDFLAGS
|
||||||
# NOTE: This is only required for dynamic library generation
|
# NOTE: This is only required for dynamic library generation
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
1
src/platforms/rcore_wasigl.c
Normal file
1
src/platforms/rcore_wasigl.c
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "./rcore_desktop_glfw.c"
|
||||||
|
|
@ -33,6 +33,8 @@
|
||||||
* - Android (ARM, ARM64)
|
* - Android (ARM, ARM64)
|
||||||
* > PLATFORM_MEMORY
|
* > PLATFORM_MEMORY
|
||||||
* - Memory framebuffer output, using software renderer, no OS required
|
* - Memory framebuffer output, using software renderer, no OS required
|
||||||
|
* > PLATFORM_WASIGL
|
||||||
|
* - WASM that imports GL/GLFW from host
|
||||||
*
|
*
|
||||||
* CONFIGURATION:
|
* CONFIGURATION:
|
||||||
* #define SUPPORT_CAMERA_SYSTEM 1
|
* #define SUPPORT_CAMERA_SYSTEM 1
|
||||||
|
|
@ -528,6 +530,8 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
|
||||||
#include "platforms/rcore_android.c"
|
#include "platforms/rcore_android.c"
|
||||||
#elif defined(PLATFORM_MEMORY)
|
#elif defined(PLATFORM_MEMORY)
|
||||||
#include "platforms/rcore_memory.c"
|
#include "platforms/rcore_memory.c"
|
||||||
|
#elif defined(PLATFORM_WASIGL)
|
||||||
|
#include "platforms/rcore_wasigl.c"
|
||||||
#else
|
#else
|
||||||
// TODO: Include your custom platform backend!
|
// TODO: Include your custom platform backend!
|
||||||
// i.e software rendering backend or console backend!
|
// i.e software rendering backend or console backend!
|
||||||
|
|
|
||||||
|
|
@ -883,7 +883,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
|
||||||
// NOTE: OpenGL ES 2.0 can be enabled on Desktop platforms,
|
// NOTE: OpenGL ES 2.0 can be enabled on Desktop platforms,
|
||||||
// in that case, functions are loaded from a custom glad for OpenGL ES 2.0
|
// in that case, functions are loaded from a custom glad for OpenGL ES 2.0
|
||||||
// TODO: OpenGL ES 2.0 support shouldn't be platform-dependent, neither require GLAD
|
// TODO: OpenGL ES 2.0 support shouldn't be platform-dependent, neither require GLAD
|
||||||
#if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL)
|
#if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL) || defined(PLATFORM_WASIGL)
|
||||||
#define GLAD_GLES2_IMPLEMENTATION
|
#define GLAD_GLES2_IMPLEMENTATION
|
||||||
#include "external/glad_gles2.h"
|
#include "external/glad_gles2.h"
|
||||||
#else
|
#else
|
||||||
|
|
@ -2484,7 +2484,7 @@ void rlLoadExtensions(void *loader)
|
||||||
|
|
||||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL)
|
#if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL) || defined(PLATFORM_WASIGL)
|
||||||
// TODO: Support GLAD loader for OpenGL ES 3.0
|
// TODO: Support GLAD loader for OpenGL ES 3.0
|
||||||
if (gladLoadGLES2((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL ES2.0 functions");
|
if (gladLoadGLES2((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL ES2.0 functions");
|
||||||
else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL ES 2.0 loaded successfully");
|
else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL ES 2.0 loaded successfully");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user