Skip to content
Snippets Groups Projects
Commit f2d4b9d8 authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#14] add example code for window event

parent da91ed91
No related branches found
No related tags found
1 merge request!25Resolve "EventPoll mit Lambdas"
Checking pipeline status
......@@ -2,6 +2,7 @@
#include <vkcv/Core.hpp>
#include <vkcv/Window.hpp>
#include <vkcv/ShaderProgram.hpp>
#include <GLFW/glfw3.h>
int main(int argc, const char** argv) {
const char* applicationName = "First Triangle";
......@@ -15,6 +16,32 @@ int main(int argc, const char** argv) {
false
);
// showing basic usage lambda events of window
window.e_mouseMove.add([&](double x, double y){
std::cout << "movement: " << x << " , " << y << std::endl;
});
window.e_key.add([&](int key, int scancode, int action, int mods){
switch (key) {
case GLFW_KEY_W:
std::cout << "Move forward" << std::endl;
break;
case GLFW_KEY_A:
std::cout << "Move left" << std::endl;
break;
case GLFW_KEY_S:
std::cout << "Move backward" << std::endl;
break;
case GLFW_KEY_D:
std::cout << "Move right" << std::endl;
break;
default:
std::cout << "this key is not supported yet: " << std::endl;
}
});
window.initEvents();
vkcv::Core core = vkcv::Core::create(
window,
applicationName,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment