Skip to content

Commit

Permalink
adjusted structure to produce better behavior when vSync is disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
adcox committed Jun 17, 2016
1 parent 9cec6a8 commit 39e1f2f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/BaseEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ void BaseEngine::onKeyPressed(ofKeyEventArgs& event)

void BaseEngine::onMouseDragged(ofMouseEventArgs& event)
{
mouseDragged = true;
mouseReleased = false;
}

void BaseEngine::onMousePressed(ofMouseEventArgs& event)
{
if(event.button >= 0 && event.button < 5)
{
mousePressed[event.button] = true;
mouseReleased = false;
}
}

void BaseEngine::onMouseReleased(ofMouseEventArgs& event)
{
mouseDragged = false;
mouseReleased = true;
}

void BaseEngine::onMouseScrolled(ofMouseEventArgs& event)
Expand Down
2 changes: 1 addition & 1 deletion src/BaseEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BaseEngine
static unsigned int g_ElementsHandle;

bool mousePressed[5] = {false};
bool mouseDragged = false;
bool mouseReleased = true;
protected:
bool isSetup;
};
Expand Down
1 change: 1 addition & 0 deletions src/EngineGLFW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void EngineGLFW::onMousePressed(ofMouseEventArgs& event)
{
remapToGLFWConvention(button);
mousePressed[button] = true;
mouseReleased = false;
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/ofxImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ void ofxImGui::begin()
io.MousePos = ImVec2((float)ofGetMouseX(), (float)ofGetMouseY());
for(int i = 0; i < 5; i++){
io.MouseDown[i] = engine->mousePressed[i];
engine->mousePressed[i] = engine->mouseDragged || false; // Don't set to false if the mouse is being dragged

// Update for next frame; set to false only if the mouse has been released
engine->mousePressed[i] = !engine->mouseReleased;
}
ImGui::NewFrame();
}
Expand Down

0 comments on commit 39e1f2f

Please sign in to comment.