openframeworks / openframeworks/openFrameworks

Feature : ofPresentWindow()

Open
#4,847 5 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

Hey!

I use a feature quite often, where I force glfw to present the window "as is" (e.g. during an update)
generally this involves something like:

glfwSwapBuffers(glfwGetCurrentContext());
glFlush();

This has been relatively stable with OpenGL 2 on Windows and OSX. I had to fiddle a bit when we moved to 0.9.0 (not sure why), but now I've moved Rulr to OpenGL 3.2, I'm having issues again.

For a start, glfwGetCurrentContext now returns NULL (great! how did that happen? :)
But even if I do something like

            auto window = ofGetWindowPtr();
            auto glfwAppWindow = dynamic_cast<ofAppGLFWWindow*>(window);
            if (glfwAppWindow) {
                auto glfwWindow = glfwAppWindow->getGLFWWindow();
                ofClear(0, 0);
                drawText(message, 0, 0, true, ofGetHeight(), ofGetWidth());
                glfwMakeContextCurrent(glfwWindow);
                glfwSwapBuffers(glfwWindow);
                glfwPollEvents();
            }

I still don't get the drawing on the screen.
The next frame of the app works fine, but i never see that drawText happen.

I use this feature especially for scanning, where it's important to sync the timing of the drawing and capture, and when using a for loop is much easier than sending the graphics out on separate app frames.

I'm wondering:

  1. What am I doing wrong this time?
  2. Could we make this a core feature? (especially as changes to oF core seem to break this usage)

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 by tracing the provided glfwSwapBuffers, glfwMakeContextCurrent, and glfwPollEvents calls through ofAppGLFWWindow, using ofGetWindowPtr() and getGLFWWindow() as entry points. Reproduce the missing immediate drawing with the supplied loop, then define and verify a core API that presents the current window reliably during such a loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.