Mouse click input
This commit is contained in:
parent
31cd55cf1f
commit
232494cc46
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "Win32AssetManager.h"
|
#include "Win32AssetManager.h"
|
||||||
|
#include "TouchInput.h"
|
||||||
|
#include "Position.h"
|
||||||
|
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
@ -44,22 +46,65 @@ int main()
|
||||||
|
|
||||||
Renderer::create();
|
Renderer::create();
|
||||||
|
|
||||||
|
// BEISPIELCODE
|
||||||
|
Position smiley_pos = {512, 384};
|
||||||
|
StringHandle smiley = StringRepository::global->internString("smiley_PNG42.png");
|
||||||
|
// ENDE BEISPIELCODE
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
while (!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
Renderer::ptr->addRect(100,
|
/* Gather keyboard input */
|
||||||
100,
|
|
||||||
500,
|
/* Gather mouse input */
|
||||||
500,
|
TouchInputEvent touch_event = {};
|
||||||
0.3,
|
int input_event_count = 0;
|
||||||
0.3,
|
if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS) {
|
||||||
0.3,
|
double x, y;
|
||||||
1.0f,
|
glfwGetCursorPos(window, &x, &y);
|
||||||
StringRepository::global->internString("smiley_PNG42.png"));
|
touch_event.kind = TouchInputEventKind::Tap;
|
||||||
|
touch_event.start = {static_cast<float>(x), static_cast<float>(y)};
|
||||||
|
touch_event.end = touch_event.start;
|
||||||
|
input_event_count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
glfwGetFramebufferSize(window, &w, &h);
|
glfwGetFramebufferSize(window, &w, &h);
|
||||||
|
|
||||||
|
// INTEGRATION Rufe hier deine "gameloop"/"update" funktion auf, die als Parameter
|
||||||
|
// den GameState, input_events und input_event_count und die Displaygröße bekommen sollte:
|
||||||
|
//
|
||||||
|
// kUpdate(&m_state, input_events, input_event_count, m_display_width, m_display_height)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Die Funktion könnte folgende Definition haben:
|
||||||
|
// void kUpdate(GameState* state,
|
||||||
|
// const TouchInputEvent* touch_events,
|
||||||
|
// unsigned int touch_event_count,
|
||||||
|
// float display_width,
|
||||||
|
// float display_height)
|
||||||
|
// ENDE INTEGRATION
|
||||||
|
|
||||||
|
// BEISPIELCODE
|
||||||
|
static float x = 1.f;
|
||||||
|
static float d = -0.01f;
|
||||||
|
x += d;
|
||||||
|
if (x <= 0.f)
|
||||||
|
d *= -1.f;
|
||||||
|
else if (x >= 1.f)
|
||||||
|
d *= -1.f;
|
||||||
|
|
||||||
|
if (input_event_count > 0) {
|
||||||
|
smiley_pos = touch_event.end;
|
||||||
|
smiley_pos.x -= 250;
|
||||||
|
smiley_pos.y -= 250;
|
||||||
|
}
|
||||||
|
|
||||||
|
Renderer::ptr->addRect(100, 100, 500, 500, 0.3f, 0.3f, 0.3f, 1.f);
|
||||||
|
Renderer::ptr->addRect(smiley_pos.x, smiley_pos.y, 500, 500, 0.f, x * x, 1.f - x * x, 1.f, smiley);
|
||||||
|
// ENDE BEISPIELCODE
|
||||||
|
|
||||||
Renderer::ptr->renderFrame(static_cast<float>(w), static_cast<float>(h));
|
Renderer::ptr->renderFrame(static_cast<float>(w), static_cast<float>(h));
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user