Skip to content

Commit

Permalink
[fix] not-rendering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
MrsRina committed Mar 30, 2024
1 parent ce26be4 commit fb57150
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Binary file modified lib/windows/libekg.a
Binary file not shown.
5 changes: 4 additions & 1 deletion src/core/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void ekg::runtime::process_render() {
auto &all {this->loaded_widget_list};
this->gpu_allocator.invoke();

for (ekg::ui::abstract_widget *&p_widgets: all) {
for (ekg::ui::abstract_widget *&p_widgets : all) {
if (p_widgets != nullptr && p_widgets->p_data->is_alive() &&
p_widgets->p_data->is_visible()) {
p_widgets->on_draw_refresh();
Expand Down Expand Up @@ -533,12 +533,15 @@ void ekg::runtime::do_task_reload(ekg::ui::abstract_widget *p_widget) {
void ekg::runtime::prepare_ui_env() {
ekg::log() << "Preparing internal user interface environment";

this->f_renderer_small.sampler_texture.gl_protected_active_index = 0;
this->f_renderer_small.set_size(16);
this->f_renderer_small.bind_allocator(&this->gpu_allocator);

this->f_renderer_small.sampler_texture.gl_protected_active_index = 1;
this->f_renderer_normal.set_size(0);
this->f_renderer_normal.bind_allocator(&this->gpu_allocator);

this->f_renderer_small.sampler_texture.gl_protected_active_index = 2;
this->f_renderer_big.set_size(24);
this->f_renderer_big.bind_allocator(&this->gpu_allocator);
this->update_size_changed();
Expand Down
13 changes: 6 additions & 7 deletions src/os/ekg_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void ekg::os::opengl::init() {
"void main() {\n"
" vFragColor = vec4(uContent[0], uContent[1], uContent[2], uContent[3]);\n"
" vec2 fragPos = vec2(gl_FragCoord.x, uViewportHeight - gl_FragCoord.y);\n"
" bool shouldDiscard = (fragPos.x <= uContent[4] || fragPos.y <= uContent[5] || fragPos.x >= uContent[4] + uContent[7] || fragPos.y >= uContent[5] + uContent[6]);\n"
" bool shouldDiscard = (fragPos.x <= uContent[4] || fragPos.y <= uContent[5] || fragPos.x >= uContent[4] + uContent[6] || fragPos.y >= uContent[5] + uContent[7]);\n"

" float lineThicknessf = float(uLineThickness);\n"
" if (uLineThickness > 0) {"
Expand All @@ -116,7 +116,6 @@ void ekg::os::opengl::init() {
" vFragColor = texture(uTextureSampler, vTexCoord);\n"
" vFragColor = vec4(vFragColor.xyz - ((1.0f - color.xyz) - 1.0f), vFragColor.w - (1.0f - color.w));\n"
" }\n"
" vFragColor = vec4(1.0f);\n"
"}"
};

Expand Down Expand Up @@ -192,7 +191,7 @@ void ekg::os::opengl::update_viewport(int32_t w, int32_t h) {
);

glUseProgram(this->pipeline_program);
glUniformMatrix4fv(this->uniform_projection, GL_FALSE, 1, ekg::gpu::api::projection);
glUniformMatrix4fv(this->uniform_projection, GL_TRUE, 0, ekg::gpu::api::projection);
glUniform1i(this->uniform_viewport_height, ekg::gpu::api::viewport[3]);
glUseProgram(0);
}
Expand Down Expand Up @@ -455,6 +454,8 @@ uint64_t ekg::os::opengl::bind_sampler(ekg::gpu::sampler_t *p_sampler) {
* when THIS is a protected sampler.
**/
if (ekg_is_sampler_protected(p_sampler->gl_protected_active_index)) {
std::cout << this->protected_texture_active_index << std::endl;

glActiveTexture(
GL_TEXTURE0 + this->protected_texture_active_index
);
Expand All @@ -474,13 +475,11 @@ void ekg::os::opengl::draw(
glUseProgram(this->pipeline_program);
glBindVertexArray(this->vbo_array);

glDisable(GL_DEPTH_TEST);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glActiveTexture(
GL_TEXTURE0 + this->protected_texture_active_index
);

int32_t previous_sampler_bound {};
bool sampler_going_on {};

Expand Down
2 changes: 2 additions & 0 deletions src/os/ekg_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

ekg::os::sdl::sdl(SDL_Window *p_sdl_win) {
this->p_sdl_win = p_sdl_win;
this->update_monitor_resolution();
SDL_SetWindowSize(this->p_sdl_win, this->monitor_resolution[0], this->monitor_resolution[1]);
}

void ekg::os::sdl::set_clipboard_text(const char *p_text) {
Expand Down
Binary file modified test/build/windows/ekg-gui-showcase-test.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion test/src/ekg_gui_showcase_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ int32_t showcase_useless_window() {
ekg::init(&runtime, &ekg_runtime_property);

auto frame = ekg::frame("aurora-fofa", {20, 20}, {200, 200})->set_drag(ekg::dock::top);
ekg::label("salve akilesnunes", ekg::dock::fill);

ekg::input::bind("hiroodrop", "finger-click");
ekg::input::bind("hiroodrop", "mouse-1");
Expand All @@ -58,7 +59,7 @@ int32_t showcase_useless_window() {
}

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.6f, 0.6f, 0.6f, 0.993f);
glClearColor(0.6f, 0.1f, 0.6f, 0.993f);

ekg::ui::dt = 0.016f;
ekg::update();
Expand Down

0 comments on commit fb57150

Please sign in to comment.