I thought I’d share an example of using Dear ImGui, a popular C++ graphical user interface (GUI) library, in conjunction with PsychoPy. This could be used for simple, in-experiment GUIs/text entry/debugging utilities/etc.
but didn’t know whether I was mucking up the OpenGL state elsewhere. Any more OpenGL-savvy folks have an idea why they might not cooperate (some residual texture setting)?
I’d bet the pyimgui people would love you to pull-request with the additional pyglet intergration (well done) and your tweak to psychopy.visual.ShapeStim looks fine too.
Then we could start exploring how to use this inside experiments!
but didn’t know whether I was mucking up the OpenGL state elsewhere. Any more OpenGL-savvy folks have an idea why they might not cooperate (some residual texture setting)?
Check the window.flip() code which usually sets the state for all successive stimuli drawing. As long as you return to the previous state at some point it should be fine.
After a win.flip() I’m sure it will all be fine (that resets everything) but @aforren1’s concern about leaving a broken state is valid for other stimuli drawn after the GUI on this frame.
We do need to test some of the stimuli after rendering the GUI box, particularly, a shape, a TextStim and a GratingStim (or ImageStim). These cover the main rendering methods. This will be easy enough to add to the test suite making sure that drawing the GUI before the others generates the same frame as rendering it after the others.
Definitely, it’s in the works (though I need to think about how to structure it, given it’s very similar to the cocos2d integration).
I can hang onto my changes for now and do these as part of the same PR. I can also throw in a stimulus (region) vs. GUI + stimulus (just stimulus region) comparison.
After a win.flip() I’m sure it will all be fine (that resets everything) but @aforren1’s concern about leaving a broken state is valid for other stimuli drawn after the GUI on this frame.
Yeah when unsure set everything as it would after a flip