Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes (objects) port from ofxDatGui --> ImGui #18

Closed
d3cod3 opened this issue Apr 4, 2020 · 9 comments
Closed

Nodes (objects) port from ofxDatGui --> ImGui #18

d3cod3 opened this issue Apr 4, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@d3cod3
Copy link
Owner

d3cod3 commented Apr 4, 2020

No description provided.

@d3cod3 d3cod3 added the enhancement New feature or request label Apr 4, 2020
@d3cod3
Copy link
Owner Author

d3cod3 commented Apr 14, 2020

mosaicScreenshot_200414

I'm having trouble drawing OF stuff inside objects, it seems like imgui is always rendering on top of everything.

In the image you can see the video grabber object rendering the webcam image under the object window.

Did you know how to solve this?

@Daandelange
Copy link
Collaborator

Hmm, I didn't think about that case where you need to draw the GUI from OF.
One way would be to let objects draw after ImGui has flushed the graphics pipeline, so you can draw on top of it. (This happens when you call ofxImGui->end() in auto mode or ofxImGui->draw() in manual mode with my fork.)
Otherwise, we might be able to make a transparent zone so we can draw behind objects.
Both feel pretty hacky...

Another option is to link a texture-ID in order to display images. An image tex id can be an FBO tex ID, I think.
Do lots of objects have/need "custom GUIs" ? (involving drawing from OF)

@d3cod3
Copy link
Owner Author

d3cod3 commented Apr 15, 2020

Basically most of the objects that works with video/webcam/images, drawing ofTextures inside the objects, and sound objects with signal waveform visualizer (ofPolyline) or fft data (audio analysis).

The linking of a texture id from an FBO seems the better choice, i'll check it.

Don't like the transparent zone option, but i'm going to try them all and we'll talk again.

@d3cod3
Copy link
Owner Author

d3cod3 commented Apr 15, 2020

Got it!

using ofTexture with proper allocate:

ofTextureData texData;
texData.width = camWidth;
texData.height = camHeight;
texData.textureTarget = GL_TEXTURE_2D;
texData.bFlipTexture = true;
static_cast<ofTexture *>(_outletParams[0])->allocate(texData);

and calling a method from ofxImGui helpers did the trick:

ofxImGui::AddImage(*static_cast<ofTexture *>(_outletParams[0]), ImVec2(this->width*_nodeCanvas.GetCanvasScale(), this->height*_nodeCanvas.GetCanvasScale()));

So, problem solved, for ofPolyline waveform graphics, with ofTexture.bind()/unbind() will work!

mosaicScreenshot_200415

@Daandelange
Copy link
Collaborator

Daandelange commented Apr 15, 2020

Yes, the FBO option would be the best option, that keeps Gui separated and "canalised" (with API methods). (don't spend too much time on the other solutions?)
Seems pretty simple to do in fact.
One drawback with FBOs : on small hardware (with integrated GPU), we'll have to check what the FBO limit is and what happens when there's too much FBO objects to allocate ? We can always disable preview mode on nodes if hardware doesn't allow having too much.

For plotting, checkout the ImGui demo ImGui::PlotHistogram(), eventually some ImGuiExtension. Although drawing the GUI with OF will give a better example on how to use object data ?

Edit: Ok, great, works fine for FBOs. :)

@d3cod3
Copy link
Owner Author

d3cod3 commented Apr 15, 2020

Actually there's no need for FBO, just using the link ofTexture pointer, so no GPU limits problem, it works like a charm!

But is a really good idea to have a mechanism enabling/disabling automatic preview depending on the resources

Great the plotting from imgui, i'll check it!

@d3cod3
Copy link
Owner Author

d3cod3 commented Jun 11, 2020

Sin título

photo_2020-06-11 17 23 50

photo_2020-06-11 17 24 07

Porting objects...

@d3cod3
Copy link
Owner Author

d3cod3 commented Jun 21, 2020

Sin título

Sin título2

oscillator and envelopes sound objects

this starts to look good!

@d3cod3
Copy link
Owner Author

d3cod3 commented Jun 22, 2020

Sin título

@d3cod3 d3cod3 closed this as completed Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants