Skip to content

Commit

Permalink
wayland render
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Mar 27, 2024
1 parent 087f882 commit e627dfb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/ruisapp/glue/linux/glue_wayland.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ struct window_wrapper : public utki::destructable {
struct wl_array* states
)
{
LOG([](auto&o){o << "window configure" << std::endl;})

// not a window geometry event, ignore
if (width == 0 && height == 0) {
return;
Expand All @@ -313,6 +315,8 @@ struct window_wrapper : public utki::destructable {

// window resized

LOG([](auto&o){o << "window resized" << std::endl;})

auto& ww = get_impl(ruisapp::inst());

wl_egl_window_resize(ww.egl_window.win, width, height, 0, 0);
Expand Down Expand Up @@ -447,9 +451,8 @@ struct window_wrapper : public utki::destructable {
}
}

// TODO: is this needed?
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
throw std::runtime_error("eglBindApi() failed");
throw std::runtime_error("eglBindApi(OpenGL ES) failed");
}

this->egl_surface = eglCreateWindowSurface(this->egl_display, egl_config, egl_window.win, nullptr);
Expand Down Expand Up @@ -490,6 +493,9 @@ struct window_wrapper : public utki::destructable {
}

utki::scope_exit scope_exit_egl_context([this]() {
// unset current context
eglMakeCurrent(this->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

eglDestroyContext(this->egl_display, this->egl_context);
});

Expand All @@ -498,6 +504,11 @@ struct window_wrapper : public utki::destructable {
throw std::runtime_error("eglMakeCurrent() failed");
}

// disable v-sync
// if (eglSwapInterval(this->egl_display, 0) != EGL_TRUE) {
// throw std::runtime_error("eglSwapInterval() failed");
// }

scope_exit_egl_context.release();
scope_exit_egl_window_surface.release();
scope_exit_egl_display.release();
Expand Down Expand Up @@ -631,7 +642,7 @@ application::application(std::string name, const window_params& wp) :
)),
storage_dir(initialize_storage_dir(this->name))
{
// TODO:
this->update_window_rect(ruis::rect(0, 0, ruis::real(wp.dims.x()), ruis::real(wp.dims.y())));
}

void application::swap_frame_buffers()
Expand All @@ -652,7 +663,8 @@ void application::set_fullscreen(bool fullscreen)

void ruisapp::application::quit() noexcept
{
// TODO:
auto& ww = get_impl(this->window_pimpl);
ww.quit_flag.store(true);
}

int main(int argc, const char** argv)
Expand All @@ -666,14 +678,10 @@ int main(int argc, const char** argv)

while (!ww.quit_flag.load()) {
wl_display_dispatch_pending(ww.display.disp);
std::cout << "loop" << std::endl;

glClearColor(0, 0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);

// render(*app);
std::cout << "loop" << std::endl;

ww.egl_context.swap_frame_buffers();
render(*app);
}

return 0;
Expand Down
2 changes: 2 additions & 0 deletions tests/app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,8 @@ class application : public ruisapp::application{
}
};
}

std::cout << "application constructed" << std::endl;
}
};

Expand Down

0 comments on commit e627dfb

Please sign in to comment.