Skip to content

Commit

Permalink
Merge pull request DescentDevelopers#636 from sebholt/renderer_fixes
Browse files Browse the repository at this point in the history
Fix some compiler warnings in the renderer
  • Loading branch information
Lgt2x authored Oct 20, 2024
2 parents 652e31f + 9a53602 commit 33edddd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
17 changes: 2 additions & 15 deletions renderer/HardwareBaseGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
24 changes: 10 additions & 14 deletions renderer/HardwareOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t>(MAX_BITMAPS);
ASSERT(OpenGL_bitmap_remap);
OpenGL_lightmap_remap = (uint16_t *)mem_malloc(MAX_LIGHTMAPS * 2);
OpenGL_lightmap_remap = mem_rmalloc<uint16_t>(MAX_LIGHTMAPS);
ASSERT(OpenGL_lightmap_remap);

OpenGL_bitmap_states = mem_rmalloc<uint8_t>(MAX_BITMAPS);
Expand Down Expand Up @@ -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<uint16_t>(2048 * 2048);
opengl_packed_Translate_table = mem_rmalloc<uint16_t>(65536);
opengl_packed_4444_translate_table = mem_rmalloc<uint16_t>(65536);

ASSERT(opengl_packed_Upload_data);
ASSERT(opengl_packed_Translate_table);
Expand Down Expand Up @@ -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<uint32_t>(2048 * 2048);
opengl_Translate_table = mem_rmalloc<uint32_t>(65536);
opengl_4444_translate_table = mem_rmalloc<uint32_t>(65536);

ASSERT(opengl_Upload_data);
ASSERT(opengl_Translate_table);
Expand Down Expand Up @@ -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<NewBitmap> 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<NewBitmap>(gpu_state.screen_width, gpu_state.screen_height, PixelDataFormat::RGBA32, true);

if (!result || result->getData() == nullptr) {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion renderer/ShaderProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 33edddd

Please sign in to comment.