From 7265089f7c32e3e438012156d241b7d39c3fa5cd Mon Sep 17 00:00:00 2001 From: Dendy Date: Wed, 14 Dec 2022 04:09:27 +0100 Subject: [PATCH] Change fade rects color. Implement float setColor --- src/MainMenu/Renderer.zig | 3 ++- src/Renderer.zig | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/MainMenu/Renderer.zig b/src/MainMenu/Renderer.zig index 9fc0fc0..547bc0b 100644 --- a/src/MainMenu/Renderer.zig +++ b/src/MainMenu/Renderer.zig @@ -99,7 +99,8 @@ pub fn render(self: Self, main_menu: MainMenu) void { self.renderer.fillRectangleEx(x - 25, 10, width + 50, height + 50, skew); } - self.renderer.setColor(0, 0, 0, 127); + // TODO: Set the Color depending on the Main Menu color + self.renderer.setColorF(0.91, 0.85, 0.65, 0.50); self.renderer.fillRectangleEx(-150, 0, @divTrunc(wsize.width, 3), wsize.height, skew); self.renderer.fillRectangleEx(@intCast(i32, screen_width) - 300, 0, @divTrunc(wsize.width, 3), wsize.height, skew); } diff --git a/src/Renderer.zig b/src/Renderer.zig index ebef8b0..f3b147d 100644 --- a/src/Renderer.zig +++ b/src/Renderer.zig @@ -25,7 +25,6 @@ fn glGetProcAddress(p: []const u8, proc: [:0]const u8) ?*const anyopaque { return sdl.c.SDL_GL_GetProcAddress(@ptrCast([*c]const u8, proc)); } - pub fn init() !Self { try sdl.init(.{ .video = true, .audio = true, .events = true }); @@ -51,7 +50,6 @@ pub fn init() !Self { const proc: []const u8 = undefined; try gl.loadExtensions(proc, glGetProcAddress); - // Shader stuff var mvp_loc: u32 = undefined; //var color_loc: u32 = undefined; @@ -127,7 +125,6 @@ pub fn render(self: *Self) void { // Clear the vbo, this really shouldn't be necessary as the index is set to zero, // but otherwise it leads to bugs self.vbo = .{0.0} ** max_objects; - } pub fn deinit(self: *Self) void { @@ -137,7 +134,11 @@ pub fn deinit(self: *Self) void { sdl.gl.deleteContext(self.context); } -pub fn setColor(self: *Self, r: u8, g: i32, b: i32, a: i32) void { +pub fn setColorF(self: *Self, r: f32, g: f32, b: f32, a: f32) void { + self.*.color = .{ r, g, b, a }; +} + +pub fn setColor(self: *Self, r: i32, g: i32, b: i32, a: i32) void { self.*.color = .{ @intToFloat(f32, r) / 255.0, @intToFloat(f32, g) / 255.0,