keymapping
This commit is contained in:
20
src/main.c
20
src/main.c
@@ -7,6 +7,12 @@
|
||||
#include "pltf/gl_funcs.h"
|
||||
#include "shader.h"
|
||||
|
||||
void counter_cb(void* user_data) {
|
||||
int* counter = (int*) user_data;
|
||||
printf("Counter: %d\n", *counter);
|
||||
(*counter)++;
|
||||
}
|
||||
|
||||
int main() {
|
||||
pltf_init();
|
||||
pltf_window_create();
|
||||
@@ -15,6 +21,10 @@ int main() {
|
||||
|
||||
pltf_gl_ctx_info_print();
|
||||
|
||||
pltf_key_callback_set(PLTF_KEY_ESC, pltf_window_close, NULL);
|
||||
int counter = 0;
|
||||
pltf_key_callback_set(PLTF_KEY_Q, counter_cb, &counter);
|
||||
|
||||
// clang-format off
|
||||
const float triangle_verts[] = {
|
||||
// pos
|
||||
@@ -60,10 +70,6 @@ int main() {
|
||||
glClearColor(0.0f, 0.0f, 0.8f, 1.0f);
|
||||
|
||||
while (true) {
|
||||
if (pltf_window_event_handle() == PLTF_WE_QUIT) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glUseProgram(shader);
|
||||
@@ -71,9 +77,13 @@ int main() {
|
||||
glDrawArrays(GL_TRIANGLES, 0, triangle_vert_count);
|
||||
|
||||
pltf_swap_buffers();
|
||||
|
||||
const int pltf_we = pltf_window_event_handle();
|
||||
if (pltf_we == PLTF_WE_DESTROY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
pltf_gl_ctx_destroy();
|
||||
pltf_window_destroy();
|
||||
pltf_deinit();
|
||||
|
||||
Reference in New Issue
Block a user