Skip to content

Commit

Permalink
fixed pmouseX/Y, PVector uses include guard now,
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisppaul committed Oct 11, 2024
1 parent 909e597 commit 3f88cc1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/PApplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -329,6 +330,9 @@ namespace umgebung {
virtual void draw() {}

virtual void post_draw() {
pmouseX = mouseX;
pmouseY = mouseY;

#ifndef DISABLE_GRAPHICS
// glFlush();
// glFinish();
Expand Down
7 changes: 5 additions & 2 deletions include/PVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once
#ifndef PVECTOR_H
#define PVECTOR_H

#include <cmath>
#include <random>
Expand Down Expand Up @@ -244,4 +245,6 @@ namespace umgebung {
return arr;
}
};
} // namespace umgebung
} // namespace umgebung

#endif // PVECTOR_H
4 changes: 2 additions & 2 deletions src/UmgebungGraphicsOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(event.motion.x);
Expand All @@ -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;
Expand Down

0 comments on commit 3f88cc1

Please sign in to comment.