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

how to use dynamic textures #30

Closed
carlesgutierrez opened this issue Mar 28, 2016 · 4 comments
Closed

how to use dynamic textures #30

carlesgutierrez opened this issue Mar 28, 2016 · 4 comments

Comments

@carlesgutierrez
Copy link

Hi,
Im trying to use this addon to show dynamic images in the GUi. For this Im using the texture inside of an FBO. Not sure how i should link or bind the texture to resolve this.

Here is my code. Texture is visible in the Draw app but not inside the GUI. May be some of you know how to do it properly.
Cheers.

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    myFBO.allocate(255, 255);
    myGui.setup();
}

//--------------------------------------------------------------
void ofApp::update(){

    myFBO.begin();
    ofSetColor(255);
    ofRect(0, 0, 255, 255);
    ofSetColor(0);
    ofEllipse(ofVec2f(mouseX, mouseY), 10, 10);
    myFBO.end();

}

//--------------------------------------------------------------
void ofApp::draw(){

    ofSetColor(255);

    myFBO.draw(255, 255, 255, 255);

    //required to call this at beginning
    myGui.begin();

    ImGui::Text("Hello");
    ImGui::Image((ImTextureID)(uintptr_t)myFBO.getTexture().getTextureData().textureID, ImVec2(255, 255));

    //required to call this at end
    myGui.end();


}
@jvcleave
Copy link
Owner

you have to create the FBO a bit differently - see this

https://github.com/jvcleave/ofxImGui/blob/develop/example-experimental/src/ofApp.cpp#L59

@carlesgutierrez
Copy link
Author

Thanks that works perfect, and works for any size( Not only powered 2 texture dimensions )

@armdz
Copy link

armdz commented Jan 23, 2018

Hi! Im having the same problem with dynamics textures, and the link that @jvcleave provides, won't work.
How its the method to solve that problem ?
(I tried setting the fbo as TEXTURE_2D, but then that fbo won't work in shaders)

Thanks!
pd: great work! love this gui implementation.

@jvcleave
Copy link
Owner

@armdz
here is a version of that project's source files

https://gist.github.com/jvcleave/47fc93217a24474abc787dbf5facecb2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants