|
@@ -3,14 +3,31 @@
|
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
|
|
|
|
-#include "pltf/pltf.h"
|
|
|
|
|
#include "pltf/gl_funcs.h"
|
|
#include "pltf/gl_funcs.h"
|
|
|
|
|
+#include "pltf/pltf.h"
|
|
|
#include "shader.h"
|
|
#include "shader.h"
|
|
|
|
|
|
|
|
-void counter_cb(void* user_data) {
|
|
|
|
|
- int* counter = (int*) user_data;
|
|
|
|
|
- printf("Counter: %d\n", *counter);
|
|
|
|
|
- (*counter)++;
|
|
|
|
|
|
|
+typedef struct {
|
|
|
|
|
+ const char* up_msg;
|
|
|
|
|
+ const char* down_msg;
|
|
|
|
|
+ int up_count;
|
|
|
|
|
+ int down_count;
|
|
|
|
|
+} MsgState;
|
|
|
|
|
+
|
|
|
|
|
+void msg_cb(const PltfKeyAction action, void* user_data) {
|
|
|
|
|
+ MsgState* state = (MsgState*) user_data;
|
|
|
|
|
+ switch (action) {
|
|
|
|
|
+ case PLTF_KEY_DOWN:
|
|
|
|
|
+ printf("Key: %s Count: %d\n", state->down_msg, state->down_count);
|
|
|
|
|
+ state->down_count++;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case PLTF_KEY_UP:
|
|
|
|
|
+ printf("Key: %s Count: %d\n", state->up_msg, state->up_count);
|
|
|
|
|
+ state->up_count++;
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ printf("INVALID PltfKeyAction. Was %d\n", action);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
int main() {
|
|
@@ -22,8 +39,8 @@ int main() {
|
|
|
pltf_gl_ctx_info_print();
|
|
pltf_gl_ctx_info_print();
|
|
|
|
|
|
|
|
pltf_key_callback_set(PLTF_KEY_ESC, pltf_window_close, NULL);
|
|
pltf_key_callback_set(PLTF_KEY_ESC, pltf_window_close, NULL);
|
|
|
- int counter = 0;
|
|
|
|
|
- pltf_key_callback_set(PLTF_KEY_Q, counter_cb, &counter);
|
|
|
|
|
|
|
+ MsgState msg_state = { .up_msg = "UP", .down_msg = "DOWN", .up_count = 0, .down_count = 0 };
|
|
|
|
|
+ pltf_key_callback_set(PLTF_KEY_Q, msg_cb, &msg_state);
|
|
|
|
|
|
|
|
// clang-format off
|
|
// clang-format off
|
|
|
const float triangle_verts[] = {
|
|
const float triangle_verts[] = {
|