Using ofxGui over a shader

Hello, I have a very simple project just to test using a glsl shader in oF and I want to use ofxGui to control some of the uniforms. How can I get the ofxPanel to draw above or next to the shaded area? The way I have it below shows some of the panel text, but I can’t interact with it or see the whole thing:

void ofApp::setup() {
	m_shader.load("sun2");
	m_panel.add(m_displace.set("displace", ofVec2f(0.5, 0.25), ofVec2f(-1.0), ofVec2f(1.0)));
	m_panel.setPosition(1124, 0);
}

void ofApp::draw() {
	m_shader.begin(); 
	m_shader.setUniform2f("u_resolution", 1024, 768);
	m_shader.setUniform2f("u_displace", m_displace);
	ofDrawRectangle(0, 0, 1024, 768);
	m_shader.end();

	m_panel.draw();
}

can you try adding m_panel.setup() at the start (before m_panel.add…)

Thanks, I forgot I needed that. Maybe I’ll delete this post out of shame…

Hey (chuckling) no need to delete out of shame! Also just a quick note that drawing an ofxPanel will also overwrite the tex0 shader texture, which is the default variable name when .draw() is called inside a shader (for an ofImage, ofFbo, etc). So it can help if you send textures into the shader with.setUniformTexture() and use some other variable name like tex1, tex2, etc.

1 Like

I’ll keep that in mind- thank you!