diff --git a/impl/gs_graphics_impl.h b/impl/gs_graphics_impl.h index 3be0b48..8fa167d 100644 --- a/impl/gs_graphics_impl.h +++ b/impl/gs_graphics_impl.h @@ -803,7 +803,7 @@ gs_graphics_uniform_create_impl(const gs_graphics_uniform_desc_t* desc) gsgl_data_t* ogl = (gsgl_data_t*)gs_subsystem(graphics)->user_data; // Assert if data isn't named - if (desc->name == NULL) { + if (*desc->name == 0) { gs_println("Warning: Uniform must be named for OpenGL."); return gs_handle_invalid(gs_graphics_uniform_t); } @@ -920,7 +920,7 @@ gs_graphics_storage_buffer_create_impl(const gs_graphics_storage_buffer_desc_t* gs_handle(gs_graphics_storage_buffer_t) hndl = gs_default_val(); gsgl_storage_buffer_t sbo = gs_default_val(); - if (desc->name == NULL) { + if (*desc->name == 0) { gs_println("Warning: Storage buffer must be named for Opengl."); } @@ -1282,14 +1282,14 @@ gs_graphics_texture_desc_query(gs_handle(gs_graphics_texture_t) hndl, gs_graphic gsgl_texture_t* tex = gs_slot_array_getp(ogl->textures, hndl.id); // Read back pixels - if (out->data && out->read.width && out->read.height) + if (out->read.width && out->read.height) { uint32_t type = gsgl_texture_format_to_gl_data_type(tex->desc.format); uint32_t format = gsgl_texture_format_to_gl_texture_format(tex->desc.format); CHECK_GL_CORE( - glActiveTexture(GL_TEXTURE0); - glGetTextureSubImage(tex->id, 0, out->read.x, out->read.y, 0, out->read.width, out->read.height, 1, format, type, out->read.size, out->data); - ); + glActiveTexture(GL_TEXTURE0); + glGetTextureSubImage(tex->id, 0, out->read.x, out->read.y, 0, out->read.width, out->read.height, 1, format, type, out->read.size, out->data); + ); } *out = tex->desc; @@ -1373,7 +1373,6 @@ gs_graphics_index_buffer_update_impl(gs_handle(gs_graphics_index_buffer_t) hndl, int32_t glusage = gsgl_buffer_usage_to_gl_enum(desc->usage); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer); switch (desc->update.type) { -l: case GS_GRAPHICS_BUFFER_UPDATE_SUBDATA: glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, desc->update.offset, desc->size, desc->data); break; default: glBufferData(GL_ELEMENT_ARRAY_BUFFER, desc->size, desc->data, glusage); break; } @@ -1994,14 +1993,11 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb) // Construct temp name, concat with base name + uniform field name char name[256] = gs_default_val(); memcpy(name, ul->name, 64); - if (u->name) - { - gs_snprintfc(UTMP, 256, "%s%s", ul->name, u->name); - memcpy(name, UTMP, 256); - } + gs_snprintfc(UTMP, 256, "%s%s", ul->name, u->name); + memcpy(name, UTMP, 256); // Grab location of uniform based on name - u->location = glGetUniformLocation(shader, name ? name : "__EMPTY_UNIFORM_NAME"); + u->location = glGetUniformLocation(shader, *name ? name : "__EMPTY_UNIFORM_NAME"); if (u->location >= UINT32_MAX) { gs_println("Warning: Bind Uniform: Uniform not found: \"%s\"", name); @@ -2193,7 +2189,7 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb) gsgl_shader_t shader = gs_slot_array_get(ogl->shaders, sid); // Get uniform location based on name and bound shader - u->location = glGetUniformBlockIndex(shader, u->name ? u->name : "__EMPTY_UNIFORM_NAME"); + u->location = glGetUniformBlockIndex(shader, *u->name ? u->name : "__EMPTY_UNIFORM_NAME"); // Set binding for uniform block glUniformBlockBinding(shader, u->location, binding); @@ -2257,7 +2253,7 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb) { // Get uniform location based on name and bound shader CHECK_GL_CORE( - sbo->block_idx = glGetProgramResourceIndex(shader, GL_SHADER_STORAGE_BLOCK, sbo->name ? sbo->name : "__EMPTY_BUFFER_NAME"); + sbo->block_idx = glGetProgramResourceIndex(shader, GL_SHADER_STORAGE_BLOCK, *sbo->name ? sbo->name : "__EMPTY_BUFFER_NAME"); int32_t params[1]; GLenum props[1] = {GL_BUFFER_BINDING}; glGetProgramResourceiv(shader, GL_SHADER_STORAGE_BLOCK, sbo->block_idx, 1, props, 1, NULL, params); @@ -2483,7 +2479,7 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb) gsgl_buffer_t vbo = vdecl.vbo; // Manual override. If you manually set divisor/stride/offset, then will not automatically calculate any of those. - bool is_manual = pip->layout[i].stride | pip->layout[i].divisor | pip->layout[i].offset | vdecl.data_type == GS_GRAPHICS_VERTEX_DATA_NONINTERLEAVED; + bool is_manual = pip->layout[i].stride | pip->layout[i].divisor | pip->layout[i].offset | (vdecl.data_type == GS_GRAPHICS_VERTEX_DATA_NONINTERLEAVED); // Bind buffer glBindBuffer(GL_ARRAY_BUFFER, vbo); diff --git a/util/gs_gfxt.h b/util/gs_gfxt.h index 83321e4..30d4060 100644 --- a/util/gs_gfxt.h +++ b/util/gs_gfxt.h @@ -2349,33 +2349,34 @@ bool gs_parse_code(gs_lexer_t* lex, gs_gfxt_pipeline_desc_t* desc, gs_ppd_t* ppd { case GS_TOKEN_IDENTIFIER: { + // evil replace a const char* if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_MODEL_VIEW_PROJECTION_MATRIX")) { - gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_VIEW_PROJECTION_MATRIX, (char)32); + gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_VIEW_PROJECTION_MATRIX, (char)32); } else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_VIEW_PROJECTION_MATRIX")) { - gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_PROJECTION_MATRIX, (char)32); + gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_PROJECTION_MATRIX, (char)32); } else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_MODEL_MATRIX")) { - gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_MATRIX, (char)32); + gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_MATRIX, (char)32); } else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_INVERSE_MODEL_MATRIX")) { - gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_INVERSE_MODEL_MATRIX, (char)32); + gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_INVERSE_MODEL_MATRIX, (char)32); } else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_VIEW_MATRIX")) { - gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_MATRIX, (char)32); + gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_MATRIX, (char)32); } else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_PROJECTION_MATRIX")) { - gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_PROJECTION_MATRIX, (char)32); + gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_PROJECTION_MATRIX, (char)32); } else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_TIME")) { - gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_TIME, (char)32); + gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_TIME, (char)32); } } break; @@ -2397,7 +2398,8 @@ bool gs_parse_code(gs_lexer_t* lex, gs_gfxt_pipeline_desc_t* desc, gs_ppd_t* ppd if (tkn.type == GS_TOKEN_STRING) { memcpy(includes[iidx], tkn.text + 1, tkn.len - 2); - gs_util_string_replace(tkn.text - ilen, tkn.len + ilen, + // evil replace a const char* + gs_util_string_replace((char*)tkn.text - ilen, tkn.len + ilen, " ", (char)32); iidx++; } diff --git a/util/gs_gui.h b/util/gs_gui.h index 66ac4c6..ae96a72 100644 --- a/util/gs_gui.h +++ b/util/gs_gui.h @@ -6317,7 +6317,7 @@ gs_gui_label_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector_ gs_gui_parse_id_tag(ctx, label, id_tag, sizeof(id_tag), opt); gs_gui_parse_label_tag(ctx, label, label_tag, sizeof(label_tag)); - if (id_tag) gs_gui_push_id(ctx, id_tag, strlen(id_tag)); + gs_gui_push_id(ctx, id_tag, strlen(id_tag)); gs_gui_style_t style = gs_default_val(); gs_gui_animation_t* anim = gs_gui_get_animation(ctx, id, desc, elementid); @@ -6341,7 +6341,7 @@ gs_gui_label_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector_ gs_gui_update_control(ctx, id, r, 0x00); gs_gui_draw_control_text(ctx, label_tag, r, &style, 0x00); gs_gui_pop_style(ctx, save); - if (id_tag) gs_gui_pop_id(ctx); + gs_gui_pop_id(ctx); /* handle click */ if ( @@ -6525,9 +6525,7 @@ gs_gui_button_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector gs_gui_animation_t* anim = gs_gui_get_animation(ctx, id, desc, GS_GUI_ELEMENT_BUTTON); // Push id if tag available - if (id_tag) { - gs_gui_push_id(ctx, id_tag, strlen(id_tag)); - } + gs_gui_push_id(ctx, id_tag, strlen(id_tag)); // Update anim (keep states locally within animation, only way to do this) if (anim) @@ -6567,7 +6565,7 @@ gs_gui_button_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector gs_gui_pop_style(ctx, save); - if (id_tag) gs_gui_pop_id(ctx); + gs_gui_pop_id(ctx); return res; } @@ -6999,7 +6997,7 @@ static int32_t _gs_gui_header(gs_gui_context_t *ctx, const char *label, int32_t gs_gui_id id = gs_gui_get_id(ctx, id_tag, strlen(id_tag)); int32_t idx = gs_gui_pool_get(ctx, ctx->treenode_pool, GS_GUI_TREENODEPOOL_SIZE, id); - if (id_tag) gs_gui_push_id(ctx, id_tag, strlen(id_tag)); + gs_gui_push_id(ctx, id_tag, strlen(id_tag)); active = (idx >= 0); expanded = (opt & GS_GUI_OPT_EXPANDED) ? !active : active; @@ -7060,7 +7058,7 @@ static int32_t _gs_gui_header(gs_gui_context_t *ctx, const char *label, int32_t r.w -= r.h - ctx->style->padding[GS_GUI_PADDING_BOTTOM]; gs_gui_draw_control_text(ctx, label_tag, r, &ctx->style_sheet->styles[GS_GUI_ELEMENT_TEXT][0x00], 0); - if (id_tag) gs_gui_pop_id(ctx); + gs_gui_pop_id(ctx); return expanded ? GS_GUI_RES_ACTIVE : 0; } @@ -7160,9 +7158,7 @@ gs_gui_window_begin_ex(gs_gui_context_t * ctx, const char* title, gs_gui_rect_t } // Push id flag - if (id_tag) { - // cnt->flags |= GS_GUI_WINDOW_FLAGS_PUSH_ID; - } + // cnt->flags |= GS_GUI_WINDOW_FLAGS_PUSH_ID; if (cnt->flags & GS_GUI_WINDOW_FLAGS_FIRST_INIT) { memcpy(cnt->name, label_tag, 256);