From ce4be40407f13f745f4d7f1569e5625e9878b026 Mon Sep 17 00:00:00 2001 From: Alberto Torres Date: Tue, 21 Jan 2025 20:13:24 +0100 Subject: [PATCH] Render: Set 1-byte texture alignment. Make `blank_texture` transparent. --- src/graphics/render.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/graphics/render.nim b/src/graphics/render.nim index 5fc67f3..bbfa023 100644 --- a/src/graphics/render.nim +++ b/src/graphics/render.nim @@ -125,6 +125,9 @@ proc initialize*(self: RenderManager) = glEnable(GL_CULL_FACE) glCullFace(GL_BACK) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) + # For uploading byte-packed textures. TODO: Does WebGL 2 ignore this? + glPixelStorei(GL_UNPACK_ALIGNMENT, 1) + glPixelStorei(GL_PACK_ALIGNMENT, 1) self.bg_mesh = newMesh(self.engine, "_bg_mesh", common_attributes={vertex}) self.bg_mesh.load_from_va_ia(@[-1'f32, -1, -1, 3, -1, -1, -1, 3, -1]) self.bg_mesh.radius = Inf @@ -132,9 +135,9 @@ proc initialize*(self: RenderManager) = self.no_material = self.engine.newSolidMaterial("_no_material", vec4(1,0,1,1)); self.camera_render_ubo = self.newUBO("CameraRenderUniform", CameraRenderUniform, 1) # since this is a ref, it won't be destroyed until it's used - let zero = newArrRef[uint8](3) + let zero = newArrRef[uint8](4) zero.fill 0 - self.blank_texture = self.engine.newTexture("",1,1,1,RGB_u8,pixels=zero.to float32) + self.blank_texture = self.engine.newTexture("",1,1,1,RGBA_u8,pixels=zero.to float32) self.initialized = true for fun in self.queue: try: