3 Комити

Аутор SHA1 Порука Датум
  Jeffery Myers 6141489b00
Fixes casting warnings with RGFW platform. (#4534) пре 3 недеља
  listeria e494c545b8
raymath: fix C++ operator overloads (#4535) пре 3 недеља
  HaxSam a9aa6b4988
[build.zig] improve build system for zig (#4531) пре 3 недеља
3 измењених фајлова са 34 додато и 27 уклоњено
  1. +21
    -14
      build.zig
  2. +8
    -8
      src/platforms/rcore_desktop_rgfw.c
  3. +5
    -5
      src/raymath.h

+ 21
- 14
build.zig Прегледај датотеку

@ -12,8 +12,6 @@ comptime {
}
fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void {
raylib.defineCMacro("PLATFORM_DESKTOP", null);
switch (platform) {
.glfw => raylib.defineCMacro("PLATFORM_DESKTOP_GLFW", null),
.rgfw => raylib.defineCMacro("PLATFORM_DESKTOP_RGFW", null),
@ -58,6 +56,7 @@ const config_h_flags = outer: {
var lines = std.mem.tokenizeScalar(u8, config_h, '\n');
while (lines.next()) |line| {
if (!std.mem.containsAtLeast(u8, line, 1, "SUPPORT")) continue;
if (std.mem.containsAtLeast(u8, line, 1, "MODULE")) continue;
if (std.mem.startsWith(u8, line, "//")) continue;
if (std.mem.startsWith(u8, line, "#if")) continue;
@ -94,10 +93,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
});
}
// Sets a flag indiciating the use of a custom `config.h`
try raylib_flags_arr.append("-DEXTERNAL_CONFIG_FLAGS");
if (options.config.len > 0) {
// Sets a flag indiciating the use of a custom `config.h`
try raylib_flags_arr.append("-DEXTERNAL_CONFIG_FLAGS");
// Splits a space-separated list of config flags into multiple flags
//
// Note: This means certain flags like `-x c++` won't be processed properly.
@ -126,6 +124,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
// Otherwise, append default value from config.h to compile flags
try raylib_flags_arr.append(flag);
}
} else {
// Set default config if no custome config got set
try raylib_flags_arr.appendSlice(&config_h_flags);
}
const raylib = if (options.shared)
@ -150,26 +151,32 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
var c_source_files = try std.ArrayList([]const u8).initCapacity(b.allocator, 2);
c_source_files.appendSliceAssumeCapacity(&.{ "src/rcore.c", "src/utils.c" });
if (options.raudio) {
try c_source_files.append("src/raudio.c");
}
if (options.rmodels) {
try c_source_files.append("src/rmodels.c");
}
if (options.rshapes) {
try c_source_files.append("src/rshapes.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RSHAPES");
}
if (options.rtextures) {
try c_source_files.append("src/rtextures.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXTURES");
}
if (options.rtext) {
try c_source_files.append("src/rtext.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXT");
}
if (options.rtextures) {
try c_source_files.append("src/rtextures.c");
if (options.rmodels) {
try c_source_files.append("src/rmodels.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RMODELS");
}
if (options.raudio) {
try c_source_files.append("src/raudio.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RAUDIO");
}
if (options.opengl_version != .auto) {
raylib.defineCMacro(options.opengl_version.toCMacroStr(), null);
}
raylib.addIncludePath(b.path("src/platforms"));
switch (target.result.os.tag) {
.windows => {
try c_source_files.append("src/rglfw.c");
@ -329,7 +336,7 @@ pub const Options = struct {
const defaults = Options{};
fn getOptions(b: *std.Build) Options {
pub fn getOptions(b: *std.Build) Options {
return .{
.platform = b.option(PlatformBackend, "platform", "Choose the platform backedn for desktop target") orelse defaults.platform,
.raudio = b.option(bool, "raudio", "Compile with audio support") orelse defaults.raudio,

+ 8
- 8
src/platforms/rcore_desktop_rgfw.c Прегледај датотеку

@ -587,7 +587,7 @@ Vector2 GetMonitorPosition(int monitor)
{
RGFW_monitor *mons = RGFW_getMonitors();
return (Vector2){mons[monitor].rect.x, mons[monitor].rect.y};
return (Vector2){p">(float)mons[monitor].rect.x, (float)mons[monitor].rect.y};
}
// Get selected monitor width (currently used by monitor)
@ -611,7 +611,7 @@ int GetMonitorPhysicalWidth(int monitor)
{
RGFW_monitor* mons = RGFW_getMonitors();
return mons[monitor].physW;
return p">(int)mons[monitor].physW;
}
// Get selected monitor physical height in millimetres
@ -619,7 +619,7 @@ int GetMonitorPhysicalHeight(int monitor)
{
RGFW_monitor *mons = RGFW_getMonitors();
return mons[monitor].physH;
return p">(int)mons[monitor].physH;
}
// Get selected monitor refresh rate
@ -640,7 +640,7 @@ const char *GetMonitorName(int monitor)
// Get window position XY on monitor
Vector2 GetWindowPosition(void)
{
return (Vector2){ platform.window->r.x, platform.window->r.y };
return (Vector2){ p">(float)platform.window->r.x, (float)platform.window->r.y };
}
// Get window scale DPI factor for current monitor
@ -654,7 +654,7 @@ Vector2 GetWindowScaleDPI(void)
// Set clipboard text content
void SetClipboardText(const char *text)
{
RGFW_writeClipboard(text, strlen(text));
RGFW_writeClipboard(text, p">(u32)strlen(text));
}
// Get clipboard text content
@ -947,7 +947,7 @@ void PollInputEvents(void)
case RGFW_quit: CORE.Window.shouldClose = true; break;
case RGFW_dnd: // Dropped file
{
for (kt">int i = 0; i < event->droppedFilesCount; i++)
for (n">u32 i = 0; i < event->droppedFilesCount; i++)
{
if (CORE.Window.dropFileCount == 0)
{
@ -1031,7 +1031,7 @@ void PollInputEvents(void)
{
if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown))
{
CORE.Input.Mouse.currentWheelMove.y = event->scroll;
CORE.Input.Mouse.currentWheelMove.y = p">(float)event->scroll;
break;
}
@ -1050,7 +1050,7 @@ void PollInputEvents(void)
if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown))
{
CORE.Input.Mouse.currentWheelMove.y = event->scroll;
CORE.Input.Mouse.currentWheelMove.y = p">(float)event->scroll;
break;
}

+ 5
- 5
src/raymath.h Прегледај датотеку

@ -2656,7 +2656,7 @@ inline Vector2 operator * (const Vector2& lhs, const Matrix& rhs)
return Vector2Transform(lhs, rhs);
}
inline const Vector2& operator -= (Vector2& lhs, const Matrix& rhs)
inline const Vector2& operator *= (Vector2& lhs, const Matrix& rhs)
{
lhs = Vector2Transform(lhs, rhs);
return lhs;
@ -2669,7 +2669,7 @@ inline Vector2 operator / (const Vector2& lhs, const float& rhs)
inline const Vector2& operator /= (Vector2& lhs, const float& rhs)
{
lhs = Vector2Scale(lhs, rhs);
lhs = Vector2Scale(lhs, mf">1.0f / rhs);
return lhs;
}
@ -2750,7 +2750,7 @@ inline Vector3 operator * (const Vector3& lhs, const Matrix& rhs)
return Vector3Transform(lhs, rhs);
}
inline const Vector3& operator -= (Vector3& lhs, const Matrix& rhs)
inline const Vector3& operator *= (Vector3& lhs, const Matrix& rhs)
{
lhs = Vector3Transform(lhs, rhs);
return lhs;
@ -2763,7 +2763,7 @@ inline Vector3 operator / (const Vector3& lhs, const float& rhs)
inline const Vector3& operator /= (Vector3& lhs, const float& rhs)
{
lhs = Vector3Scale(lhs, rhs);
lhs = Vector3Scale(lhs, mf">1.0f / rhs);
return lhs;
}
@ -2847,7 +2847,7 @@ inline Vector4 operator / (const Vector4& lhs, const float& rhs)
inline const Vector4& operator /= (Vector4& lhs, const float& rhs)
{
lhs = Vector4Scale(lhs, rhs);
lhs = Vector4Scale(lhs, mf">1.0f / rhs);
return lhs;
}

Loading…
Откажи
Сачувај