openframeworks / openframeworks/openFrameworks

ofAppGLFWWindow - Incorrect value for pixelScreenCoordScale when minimizing window

Open
#6,902 2 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.