Skip to content

Commit

Permalink
[fix] texture-rendering color not interpolated
Browse files Browse the repository at this point in the history
  • Loading branch information
MrsRina committed Mar 31, 2024
1 parent 4e7dba4 commit 70251c1
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 23 deletions.
Binary file modified lib/windows/libekg.a
Binary file not shown.
1 change: 1 addition & 0 deletions src/ekg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void ekg::update() {

ekg::core->process_update();
ekg::core->p_os_platform->update_cursor(ekg::cursor);
ekg::core->io_event_serial = ekg::os::io_event_serial {};
}

void ekg::render() {
Expand Down
2 changes: 1 addition & 1 deletion src/os/ekg_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void ekg::os::opengl::init() {
" if (uActiveTexture && !shouldDiscard) {"
" vec4 color = vFragColor;\n"
" vFragColor = texture(uTextureSampler, vTexCoord);\n"
" //vFragColor = vec4(vFragColor.xyz - ((1.0f - color.xyz) - 1.0f), vFragColor.w - (1.0f - color.w));\n"
" vFragColor = vec4(vFragColor.xyz - ((1.0f - color.xyz) - 1.0f), vFragColor.w - (1.0f - color.w));\n"
" }\n"
"}"
};
Expand Down
30 changes: 18 additions & 12 deletions src/os/ekg_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ const char *ekg::os::sdl::get_clipboard_text() {
}

void ekg::os::sdl::init() {
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::arrow)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::ibeam)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::wait)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::crosshair)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::arrow)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::ibeam)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::wait)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::crosshair)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::wait_arrow)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_nwse)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_nesw)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_we)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_ns)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_all)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::no)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::hand)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_nwse)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_nesw)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_we)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_ns)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::size_all)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::no)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
this->loaded_system_cursor_list[static_cast<uint32_t>(ekg::system_cursor::hand)] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);

this->update_cursor(ekg::system_cursor::arrow);
ekg::cursor = ekg::system_cursor::arrow;
Expand Down Expand Up @@ -157,7 +157,6 @@ void ekg::os::sdl::get_special_key(int32_t key, ekg::special_key &special_key) {

void ekg::os::sdl_poll_event(SDL_Event &sdl_event) {
ekg::os::io_event_serial &serialized {ekg::core->io_event_serial};
serialized = ekg::os::io_event_serial {};

switch (sdl_event.type) {
case SDL_WINDOWEVENT:
Expand Down Expand Up @@ -213,6 +212,13 @@ void ekg::os::sdl_poll_event(SDL_Event &sdl_event) {
ekg::poll_io_event = true;
break;

case SDL_MOUSEMOTION:
serialized.is_mouse_motion = true;
serialized.mouse_motion_x = sdl_event.motion.x;
serialized.mouse_motion_y = sdl_event.motion.y;
ekg::poll_io_event = true;
break;

case SDL_FINGERUP:
serialized.is_finger_up = true;
serialized.finger_x = sdl_event.tfinger.x;
Expand Down
36 changes: 27 additions & 9 deletions src/service/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized
if (io_event_serialized.is_text_input) {
this->was_pressed = true;
this->was_typed = true;
} else if (io_event_serialized.is_key_down) {
}

if (io_event_serialized.is_key_down) {
this->was_pressed = true;

std::string key_name {};
Expand Down Expand Up @@ -95,7 +97,9 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized
this->special_keys_unit_pressed.push_back(string_builder);
}
}
} else if (io_event_serialized.is_key_up) {
}

if (io_event_serialized.is_key_up) {
this->was_released = true;
std::string key_name {};
std::string string_builder {};
Expand Down Expand Up @@ -133,7 +137,9 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized
this->callback(string_builder, true);
this->input_released_list.push_back(string_builder);
}
} else if (io_event_serialized.is_mouse_button_down) {
}

if (io_event_serialized.is_mouse_button_down) {
std::string string_builder {"mouse-"};
string_builder += std::to_string(io_event_serialized.mouse_button);

Expand All @@ -153,7 +159,9 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized
if (double_click_factor) {
ekg::reset(this->double_interact);
}
} else if (io_event_serialized.is_mouse_button_up) {
}

if (io_event_serialized.is_mouse_button_up) {
this->was_released = true;
std::string string_builder {"mouse-"};

Expand All @@ -162,11 +170,15 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized

this->callback(string_builder, true);
this->input_released_list.push_back(string_builder);
} else if (io_event_serialized.is_mouse_motion) {
}

if (io_event_serialized.is_mouse_motion) {
this->has_motion = true;
this->interact.x = static_cast<float>(io_event_serialized.mouse_motion_x);
this->interact.y = static_cast<float>(io_event_serialized.mouse_motion_y);
} else if (io_event_serialized.is_mouse_wheel) {
}

if (io_event_serialized.is_mouse_wheel) {
this->callback("mouse-wheel", true);
this->was_wheel = true;

Expand All @@ -177,7 +189,9 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized

this->interact.z = io_event_serialized.mouse_wheel_precise_x;
this->interact.w = io_event_serialized.mouse_wheel_precise_y;
} else if (io_event_serialized.is_finger_down) {
}

if (io_event_serialized.is_finger_down) {
this->was_pressed = true;
ekg::reset(this->timing_last_interact);
bool reach_double_interact {ekg::reach(this->double_interact, 500)};
Expand All @@ -194,7 +208,9 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized
if (reach_double_interact) {
ekg::reset(this->double_interact);
}
} else if (io_event_serialized.is_finger_up) {
}

if (io_event_serialized.is_finger_up) {
this->was_released = true;
this->callback("finger-hold", (this->finger_hold_event = ekg::reach(this->timing_last_interact, 750)));
this->callback("finger-click", false);
Expand All @@ -215,7 +231,9 @@ void ekg::service::input::on_event(ekg::os::io_event_serial &io_event_serialized

this->interact.z = 0.0f;
this->interact.w = 0.0f;
} else if (io_event_serialized.is_finger_motion) {
}

if (io_event_serialized.is_finger_motion) {
this->has_motion = true;
this->interact.x = io_event_serialized.finger_x * static_cast<float>(ekg::ui::width);
this->interact.y = io_event_serialized.finger_y * static_cast<float>(ekg::ui::height);
Expand Down
Binary file modified test/build/windows/ekg-gui-showcase-test.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion test/src/ekg_gui_showcase_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int32_t showcase_useless_window() {
ekg::render();

SDL_GL_SwapWindow(p_sdl_win);
SDL_Delay(16);
SDL_Delay(6);
}

return 666;
Expand Down

0 comments on commit 70251c1

Please sign in to comment.