openframeworks / openframeworks/openFrameworks
ofAppGLFWWindow - Incorrect value for pixelScreenCoordScale when minimizing window
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
When ofAppGLFWWindow is minimized, a call to ofAppGLFWWindow::resize_cb() is made while window and framebuffer width/height are 0.
Therefore, the code updates pixelScreenCoordScale with an invalid value (division by 0) :
void ofAppGLFWWindow::resize_cb(GLFWwindow* windowP_, int w, int h) {
ofAppGLFWWindow * instance = setCurrent(windowP_);
// Detect if the window is running in a retina mode
int framebufferW, framebufferH; // <- physical pixel extents
glfwGetFramebufferSize(windowP_, &framebufferW, &framebufferH);
int windowW, windowH; // <- screen coordinates, which may be scaled
glfwGetWindowSize(windowP_, &windowW, &windowH);
// Find scale factor needed to transform from screen coordinates
// to physical pixel coordinates
instance->pixelScreenCoordScale = (float)framebufferW / (float)windowW; // <----- Division by zero
Calls to ofGetWidth() and ofGetHeight() in ofApp::Draw()/ofApp::Update() then returns invalid values since they scale according to pixelScreenCoordScale .
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ofAppGLFWWindow::resize_cb() and trace how the window and framebuffer dimensions update pixelScreenCoordScale during minimization. Reproduce the minimized-window path, then verify that ofGetWidth() and ofGetHeight() remain valid when the dimensions are zero; the payload does not name a test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100