Added callbacks

This commit is contained in:
NaifBanana
2026-10-11 17:48:27 -05:00
parent 06f261b793
commit b9e8144519
3 changed files with 61 additions and 18 deletions
+13 -4
View File
@@ -69,13 +69,22 @@ int main() {
}}, indxs);
LOG(prog.log());
GLFWwindow* window_ptr = window->getWindowPtr();
while(!glfwWindowShouldClose(window_ptr)) {
window->setCallback<nb::OGLWindow::KEY>(
(std::function<void(nb::OGLWindow*, int, int, int, int)>)[](nb::OGLWindow* w, int key, int x, int actiom, int mods)->void{
if (key == GLFW_KEY_Q) {
w->shouldClose(true);
}
});
window->setCallback<nb::OGLWindow::CURSOR_POS>(
(std::function<void(nb::OGLWindow*, double, double)>)[](nb::OGLWindow* w, double x, double y)->void{
nb::logger.msg("Pos in x is " + std::to_string(x));
});
while(!window->shouldClose()) {
OPENGL_CALL(glClearColor(0.2f, 0.3f, 0.3f, 1.0f));
OPENGL_CALL(glClear(GL_COLOR_BUFFER_BIT));
tri.draw();
glfwPollEvents();
glfwSwapBuffers(window_ptr);
window->pollEvents();
window->swapBuffers();
}
return 0;