|
@@ -1,5 +1,6 @@
|
|
|
#include "window.h"
|
|
#include "window.h"
|
|
|
#include <assert/assert.h>
|
|
#include <assert/assert.h>
|
|
|
|
|
+#include "callbacks.h"
|
|
|
|
|
|
|
|
void pika::PikaWindow::create()
|
|
void pika::PikaWindow::create()
|
|
|
{
|
|
{
|
|
@@ -7,6 +8,11 @@ void pika::PikaWindow::create()
|
|
|
|
|
|
|
|
PIKA_PERMA_ASSERT(context.wind, "problem initializing window");
|
|
PIKA_PERMA_ASSERT(context.wind, "problem initializing window");
|
|
|
glfwMakeContextCurrent(context.wind);
|
|
glfwMakeContextCurrent(context.wind);
|
|
|
|
|
+
|
|
|
|
|
+ glfwSetWindowUserPointer(context.wind, this);
|
|
|
|
|
+
|
|
|
|
|
+ glfwSetMouseButtonCallback(context.wind, mouseCallback);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool pika::PikaWindow::shouldClose()
|
|
bool pika::PikaWindow::shouldClose()
|
|
@@ -16,6 +22,42 @@ bool pika::PikaWindow::shouldClose()
|
|
|
|
|
|
|
|
void pika::PikaWindow::update()
|
|
void pika::PikaWindow::update()
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
glfwPollEvents();
|
|
glfwPollEvents();
|
|
|
glfwSwapBuffers(context.wind);
|
|
glfwSwapBuffers(context.wind);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#pragma region input
|
|
|
|
|
+
|
|
|
|
|
+ auto processInput = [](pika::Button &b)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ if (!b.lastState() && b.held())
|
|
|
|
|
+ {
|
|
|
|
|
+ b.setPressed(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ b.setPressed(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (b.lastState() && !b.held())
|
|
|
|
|
+ {
|
|
|
|
|
+ b.setReleased(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ b.setReleased(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ b.setLastState(b.held());
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ processInput(input.lMouse);
|
|
|
|
|
+ processInput(input.rMouse);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#pragma endregion
|
|
|
}
|
|
}
|