Skip to content

Commit db7152d

Browse files
committed
more
1 parent 0dff74d commit db7152d

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

libs/openFrameworks/app/ofAppGLFWWindow.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){
5050

5151
ofAppPtr = nullptr;
5252

53-
pixelScreenCoordScale = 1;
5453
nFramesSinceWindowResized = 0;
5554
iconSet = false;
5655
windowP = nullptr;
@@ -467,10 +466,9 @@ void ofAppGLFWWindow::setWindowTitle(const std::string & title) {
467466

468467
//------------------------------------------------------------
469468
int ofAppGLFWWindow::getPixelScreenCoordScale() {
470-
471-
// TODO:
472-
// discover which monitor this window
473-
return pixelScreenCoordScale;
469+
glm::vec2 contentScale;
470+
glfwGetWindowContentScale(windowP, &contentScale.x, &contentScale.y);
471+
return contentScale.x;
474472
}
475473

476474
//------------------------------------------------------------
@@ -491,8 +489,11 @@ glm::ivec2 ofAppGLFWWindow::getWindowSize() {
491489

492490
//------------------------------------------------------------
493491
glm::ivec2 ofAppGLFWWindow::getFramebufferSize() {
492+
494493
glm::ivec2 size;
495494
glfwGetFramebufferSize(windowP, &size.x, &size.y);
495+
cout << "getFramebufferSize " << size << endl;
496+
496497
return size;
497498
}
498499

@@ -1047,13 +1048,14 @@ void ofAppGLFWWindow::motion_cb(GLFWwindow * windowP_, double x, double y) {
10471048
action = ofMouseEventArgs::Dragged;
10481049
}
10491050

1050-
// FIXME: ok, pixelScrenCoordScale nao ta funcionando legal. mas da pra corrigir legal em breve
1051-
cout << "motion_cb " << x << " : " << (x * instance->pixelScreenCoordScale)<< endl;
1051+
glm::vec2 contentScale;
1052+
glfwGetWindowContentScale(windowP_, &contentScale.x, &contentScale.y);
1053+
10521054
ofMouseEventArgs args(action,
1053-
x * instance->pixelScreenCoordScale,
1054-
y * instance->pixelScreenCoordScale,
1055-
// x ,
1056-
// y ,
1055+
// x * contentScale.x,
1056+
// y * contentScale.y,
1057+
x ,
1058+
y ,
10571059
instance->buttonInUse,
10581060
instance->events().getModifiers());
10591061
instance->events().notifyMouseEvent(args);

libs/openFrameworks/app/ofAppGLFWWindow.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow {
7373
void setClipboardString(const std::string & text);
7474
std::string getClipboardString();
7575

76+
// FIXME: int? does it float?
7677
int getPixelScreenCoordScale();
7778

7879
void makeCurrent();
@@ -151,9 +152,6 @@ class ofAppGLFWWindow : public ofAppBaseWindow {
151152

152153
bool bEnableSetupScreen;
153154

154-
// FIXME remove
155-
float pixelScreenCoordScale; /// Scale factor from virtual operating-system defined client area extents (as seen in currentW, currentH) to physical framebuffer pixel coordinates (as seen in windowW, windowH).
156-
157155
ofRectangle windowRect { 20, 20, 800, 600 };
158156
ofRectangle windowRectFS { 0, 0, 1920, 1080 };
159157
void setFSTarget(ofWindowMode targetWindowMode);

libs/openFrameworks/types/ofRectangle.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ ofRectangle::ofRectangle(float px, float py, float w, float h) : x(position.x),
1818
set(px,py,w,h);
1919
}
2020

21+
//----------------------------------------------------------
22+
ofRectangle::ofRectangle(int px, int py, int w, int h) : x(position.x), y(position.y) {
23+
set(px,py,w,h);
24+
}
25+
2126
//----------------------------------------------------------
2227
ofRectangle::ofRectangle(const glm::vec3& p, float w, float h) : x(position.x), y(position.y) {
2328
set(p,w,h);

libs/openFrameworks/types/ofRectangle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class ofRectangle {
105105
/// \param w The width of the rectangle.
106106
/// \param h The height of the rectangle.
107107
ofRectangle(float px, float py, float w, float h);
108+
ofRectangle(int px, int py, int w, int h);
108109

109110
/// \brief Construct a rectangle from a point and dimensions.
110111
///

libs/openFrameworks/utils/ofMatrixStack.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ glm::ivec2 ofMatrixStack::getRenderSurfaceSize() const {
142142
if (currentRenderSurface) {
143143
return currentRenderSurface->getSize();
144144
} else if (currentWindow) {
145-
// FIXME: FramebufferSize
146-
return currentWindow->getWindowSize();
145+
return currentWindow->getFramebufferSize();
147146
} else {
148147
return {};
149148
}
@@ -204,12 +203,15 @@ ofRectangle ofMatrixStack::getNativeViewport() const{
204203
}
205204

206205
ofRectangle ofMatrixStack::getFullSurfaceViewport() const{
206+
cout << "ofMatrixStack::getFullSurfaceViewport()" << endl;
207207
if(currentRenderSurface){
208-
return ofRectangle(0,0,currentRenderSurface->getWidth(),currentRenderSurface->getHeight());
208+
return { 0.0f, 0.0f, currentRenderSurface->getWidth(), currentRenderSurface->getHeight() };
209209
}else if(currentWindow){
210-
return ofRectangle(0,0,currentWindow->getWidth(),currentWindow->getHeight());
210+
// FIXME: OWWW
211+
// return { 0, 0, currentWindow->getWidth(), currentWindow->getHeight() };
212+
return { 0, 0, currentWindow->getFramebufferSize().x, currentWindow->getFramebufferSize().y };
211213
}else{
212-
return ofRectangle();
214+
return {};
213215
}
214216
}
215217

0 commit comments

Comments
 (0)