From 3f88cc1c0c0172b765eae758b6243999161c395f Mon Sep 17 00:00:00 2001 From: dennisppaul Date: Fri, 11 Oct 2024 16:58:17 +0200 Subject: [PATCH] fixed pmouseX/Y, PVector uses include guard now, --- include/PApplet.h | 4 ++++ include/PVector.h | 7 +++++-- src/UmgebungGraphicsOpenGL.cpp | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/PApplet.h b/include/PApplet.h index 5108d13..c7518ad 100644 --- a/include/PApplet.h +++ b/include/PApplet.h @@ -265,6 +265,7 @@ namespace umgebung { float pmouseX; float pmouseY; int mouseButton; + bool isMousePressed; // in processing this is `mousePressed` … however this does not work in C++ as it conflicts with the function name int key; int frameCount; float frameRate; @@ -329,6 +330,9 @@ namespace umgebung { virtual void draw() {} virtual void post_draw() { + pmouseX = mouseX; + pmouseY = mouseY; + #ifndef DISABLE_GRAPHICS // glFlush(); // glFinish(); diff --git a/include/PVector.h b/include/PVector.h index 2141204..37b016f 100644 --- a/include/PVector.h +++ b/include/PVector.h @@ -17,7 +17,8 @@ * along with this program. If not, see . */ -#pragma once +#ifndef PVECTOR_H +#define PVECTOR_H #include #include @@ -244,4 +245,6 @@ namespace umgebung { return arr; } }; -} // namespace umgebung \ No newline at end of file +} // namespace umgebung + +#endif // PVECTOR_H \ No newline at end of file diff --git a/src/UmgebungGraphicsOpenGL.cpp b/src/UmgebungGraphicsOpenGL.cpp index fd7d530..1219c5c 100644 --- a/src/UmgebungGraphicsOpenGL.cpp +++ b/src/UmgebungGraphicsOpenGL.cpp @@ -258,10 +258,12 @@ namespace umgebung { fApplet->mouseButton = event.button.button; fMouseIsPressed = true; fApplet->mousePressed(); + fApplet->isMousePressed = true; break; case SDL_MOUSEBUTTONUP: fMouseIsPressed = false; fApplet->mouseReleased(); + fApplet->isMousePressed = false; break; case SDL_MOUSEMOTION: fApplet->mouseX = static_cast(event.motion.x); @@ -271,8 +273,6 @@ namespace umgebung { } else { fApplet->mouseMoved(); } - fApplet->pmouseX = fApplet->mouseX; - fApplet->pmouseY = fApplet->mouseY; break; case SDL_DROPFILE: { char* dropped_filedir = event.drop.file;