From 25872b257d9eba9f34bb05d5854eea2297b657c4 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Sat, 29 Jan 2022 22:52:51 +0800 Subject: [PATCH] io: make ClearColor and FogColor Vec4f instead of 3 --- cmd/main.go | 3 ++- internal/io/io.go | 3 ++- internal/render/render_world.go | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index ed2ddbb..ca4181e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -52,7 +52,8 @@ func main() { game := game.NewGame() game.Init(win) - gio.ClearColor = itype.Vec3f{0.6, 0.8, 1.0} + gio.ClearColor = itype.Vec4f{0.6, 0.8, 1.0, 1.0} + gio.FogColor = itype.Vec4f{0.6, 0.8, 1.0, 1.0} gl.ClearColor(0.6, 0.8, 1.0, 1) gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) win.SwapBuffers() diff --git a/internal/io/io.go b/internal/io/io.go index ec6b4d9..b0565df 100644 --- a/internal/io/io.go +++ b/internal/io/io.go @@ -5,7 +5,8 @@ import "edgaru089.ml/go/gl01/internal/util/itype" var ( DisplaySize itype.Vec2i // Size of the window viewport in pixels. - ClearColor itype.Vec3f // Clear color of the renderer. + ClearColor itype.Vec4f // Clear color of the renderer. + FogColor itype.Vec4f // Color of the fog. Changes if the player is e.g. under water // Directions are not always normalized. ViewPos, ViewDir itype.Vec3d // Position and Direction of the player view. diff --git a/internal/render/render_world.go b/internal/render/render_world.go index 1574af7..003ebc2 100644 --- a/internal/render/render_world.go +++ b/internal/render/render_world.go @@ -252,14 +252,14 @@ func (r *WorldRenderer) Render(world *world.World, view *View) { // 3. Render the actual output with deferred lighting gl.BindFramebuffer(gl.FRAMEBUFFER, r.output.fbo) - gl.ClearColor(io.ClearColor[0], io.ClearColor[1], io.ClearColor[2], 1) + gl.ClearColor(io.ClearColor[0], io.ClearColor[1], io.ClearColor[2], io.ClearColor[3]) gl.Clear(gl.COLOR_BUFFER_BIT) gl.Disable(gl.DEPTH_TEST) r.lighting.shader.UseProgram() r.lighting.shader.BindTextures() r.lighting.shader.SetUniformMat4("lightspace", lightspace) r.lighting.shader.SetUniformVec3f("viewPos", view.EyePos) - r.lighting.shader.SetUniformVec4f("fogColor", itype.Vec4f{0.6, 0.8, 1.0, 1.0}) + r.lighting.shader.SetUniformVec4f("fogColor", io.FogColor) r.lighting.shader.SetUniformVec3f("sun", normalSun) DrawScreenQuad() @@ -278,7 +278,7 @@ func (r *WorldRenderer) Render(world *world.World, view *View) { r.water.shader.SetUniformMat4("view", view.View()) r.water.shader.SetUniformMat4("projection", view.Perspective()) r.water.shader.SetUniformVec3f("viewPos", view.EyePos) - r.water.shader.SetUniformVec4f("fogColor", itype.Vec4f{0.6, 0.8, 1.0, 1.0}) + r.water.shader.SetUniformVec4f("fogColor", io.FogColor) r.water.shader.SetUniformVec3f("sun", normalSun) r.water.shader.SetUniformFloat("alpha", alpha)