From 7fef91e70964fd1862b61f6be1b595e0ab66fe45 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 19 Oct 2024 20:28:54 +0200 Subject: [PATCH 1/4] renderer/ShaderProgram: Fix compiler warning --- renderer/ShaderProgram.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renderer/ShaderProgram.h b/renderer/ShaderProgram.h index 90ce5acb1..3bdb52293 100644 --- a/renderer/ShaderProgram.h +++ b/renderer/ShaderProgram.h @@ -67,7 +67,7 @@ struct VertexBuffer { initialData, bufferType); - for (GLint i{}; i < attribs.size(); i++) { + for (std::size_t i{}; i < attribs.size(); i++) { dglEnableVertexAttribArray(i); dglVertexAttribPointer(i, attribs[i].size, From 2c7a0e98a82b749f6476e64226d05b4b59ffd5cf Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 19 Oct 2024 20:43:21 +0200 Subject: [PATCH 2/4] renderer/HardwareOpenGL: Fix compiler warnings --- renderer/HardwareOpenGL.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/renderer/HardwareOpenGL.cpp b/renderer/HardwareOpenGL.cpp index fac46c4eb..0056ca572 100644 --- a/renderer/HardwareOpenGL.cpp +++ b/renderer/HardwareOpenGL.cpp @@ -1683,10 +1683,6 @@ void rend_DrawSpecialLine(g3Point *p0, g3Point *p1) { // Takes a screenshot of the current frame and puts it into the handle passed std::unique_ptr rend_Screenshot() { - uint16_t *dest_data; - uint32_t *temp_data; - - int total = gpu_state.screen_width * gpu_state.screen_height; auto result = std::make_unique(gpu_state.screen_width, gpu_state.screen_height, PixelDataFormat::RGBA32, true); if (!result || result->getData() == nullptr) { @@ -1712,8 +1708,8 @@ void rend_Screenshot(int bm_handle) { uint16_t* dest_data = bm_data(bm_handle, 0); - for (int i = 0; i < h; i++) { - for (int t = 0; t < w; t++) { + for (std::size_t i = 0; i < h; i++) { + for (std::size_t t = 0; t < w; t++) { uint32_t spix = temp_data[i * w + t]; int r = spix & 0xff; From 19c7611ce58969902c94b14152443e6ccbe657b6 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 19 Oct 2024 23:23:19 +0200 Subject: [PATCH 3/4] renderer/HardwareOpenGL: Use mem_rmalloc instead of mem_malloc --- renderer/HardwareOpenGL.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/renderer/HardwareOpenGL.cpp b/renderer/HardwareOpenGL.cpp index 0056ca572..0fbff8f45 100644 --- a/renderer/HardwareOpenGL.cpp +++ b/renderer/HardwareOpenGL.cpp @@ -268,9 +268,9 @@ int opengl_MakeTextureObject(int tn) { int opengl_InitCache() { - OpenGL_bitmap_remap = (uint16_t *)mem_malloc(MAX_BITMAPS * 2); + OpenGL_bitmap_remap = mem_rmalloc(MAX_BITMAPS); ASSERT(OpenGL_bitmap_remap); - OpenGL_lightmap_remap = (uint16_t *)mem_malloc(MAX_LIGHTMAPS * 2); + OpenGL_lightmap_remap = mem_rmalloc(MAX_LIGHTMAPS); ASSERT(OpenGL_lightmap_remap); OpenGL_bitmap_states = mem_rmalloc(MAX_BITMAPS); @@ -573,9 +573,9 @@ int opengl_Init(oeApplication *app, renderer_preferred_state *pref_state) { opengl_InitCache(); if (OpenGL_packed_pixels) { - opengl_packed_Upload_data = (uint16_t *)mem_malloc(2048 * 2048 * 2); - opengl_packed_Translate_table = (uint16_t *)mem_malloc(65536 * 2); - opengl_packed_4444_translate_table = (uint16_t *)mem_malloc(65536 * 2); + opengl_packed_Upload_data = mem_rmalloc(2048 * 2048); + opengl_packed_Translate_table = mem_rmalloc(65536); + opengl_packed_4444_translate_table = mem_rmalloc(65536); ASSERT(opengl_packed_Upload_data); ASSERT(opengl_packed_Translate_table); @@ -620,9 +620,9 @@ int opengl_Init(oeApplication *app, renderer_preferred_state *pref_state) { opengl_packed_4444_translate_table[i] = INTEL_INT(pix); } } else { - opengl_Upload_data = (uint32_t *)mem_malloc(2048 * 2048 * 4); - opengl_Translate_table = (uint32_t *)mem_malloc(65536 * 4); - opengl_4444_translate_table = (uint32_t *)mem_malloc(65536 * 4); + opengl_Upload_data = mem_rmalloc(2048 * 2048); + opengl_Translate_table = mem_rmalloc(65536); + opengl_4444_translate_table = mem_rmalloc(65536); ASSERT(opengl_Upload_data); ASSERT(opengl_Translate_table); From 9a536021aaa72eaba07d822d8240be52a069327f Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sun, 20 Oct 2024 00:04:13 +0200 Subject: [PATCH 4/4] renderer/HardwareBaseGPU: Fix compiler warnings --- renderer/HardwareBaseGPU.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/renderer/HardwareBaseGPU.cpp b/renderer/HardwareBaseGPU.cpp index 812f5955a..fda7d4075 100644 --- a/renderer/HardwareBaseGPU.cpp +++ b/renderer/HardwareBaseGPU.cpp @@ -284,25 +284,12 @@ void rend_DrawChunkedBitmap(chunked_bitmap *chunk, int x, int y, uint8_t alpha) int piece_w = bm_w(bm_array[0], 0); int piece_h = bm_h(bm_array[0], 0); int screen_w, screen_h; - int i, t; rend_SetZBufferState(0); rend_GetProjectionParameters(&screen_w, &screen_h); - for (i = 0; i < h; i++) { - for (t = 0; t < w; t++) { + for (int i = 0; i < h; i++) { + for (int t = 0; t < w; t++) { int dx = x + (piece_w * t); int dy = y + (piece_h * i); - int dw, dh; - if ((dx + piece_w) > screen_w) - dw = piece_w - ((dx + piece_w) - screen_w); - else - dw = piece_w; - if ((dy + piece_h) > screen_h) - dh = piece_h - ((dy + piece_h) - screen_h); - else - dh = piece_h; - - float u2 = (float)dw / (float)piece_w; - float v2 = (float)dh / (float)piece_h; rend_DrawSimpleBitmap(bm_array[i * w + t], dx, dy); } }