Fbo drawing issue

Hi all,
i have an issue with draw something inside a fbo. I draw a red circle in the fbo. Later i wanted to draw a green circle inside the fbo. It is drwan correctly but when the circle is overlapping the old red one it is drawn behind. I also tried to call ofClearAlpha() after the last drawing but the same result.

Any help would be nice.

HI,

Do you get the same if you throw a ofEnableBlendMode( OF_BLENDMODE_DISABLED ) just before you draw the second circle?

nope not working, still the same issue.
here is the function:

fishTex.begin();
ofEnableBlendMode(OF_BLENDMODE_DISABLED);
ofSetColor(drawColor);
ofSetCircleResolution(50);
ofDrawCircle(x,y, 40);
fishTex.end();

So that’s only drawing one circle, can you post a minimal but complete version of the code that exhibits the problem? This is usually a great way to solve the problem as well.

This here draws a green circle on top of a red one:

#pragma once
#include "ofMain.h"

class ofApp : public ofBaseApp
{
	public:
	
		// -------------------
		void setup()
		{
			fbo.allocate( ofGetWidth(), ofGetHeight(), GL_RGBA );
			ofSetCircleResolution(50);
		}

		// -------------------
		void draw()
		{
			fbo.begin();
			
				ofClear( ofColor::black );
			
				ofSetColor( ofColor::red );
				ofDrawCircle( ofGetWidth() * 0.5, ofGetHeight() * 0.5, 50 );

				ofSetColor( ofColor::green );
				ofDrawCircle( ofGetMouseX(), ofGetMouseY(), 50 );
			
			fbo.end();
			
			ofSetColor( ofColor::white );
			fbo.draw( 0,0 );
		}
	
		ofFbo fbo;
};

this function is called by mousepresed and it changes the color;

void ofApp::mousePressed(int x, int y, int button)
{
drawColor = ofColor(ofRandom(255),ofRandom(255),ofRandom(255)):
drawToFbo(x,y);
}

void ofApp::drawToFbo(int x,int y)
{
fishTex.begin();
//ofEnableBlendMode(OF_BLENDMODE_DISABLED);
//ofClearAlpha();
ofSetColor(drawColor);
ofSetCircleResolution(50);

ofDrawCircle(x -20,y - 50, 40);
ofClearAlpha();
fishTex.end();

}

Without a complete example it’s hard to know if something is done somewhere else that is affecting your result.

Here is a minimal example that does what I think you are trying to do.

#pragma once
#include "ofMain.h"

class ofApp : public ofBaseApp
{
	public:
	
		// -------------------
		void setup()
		{
			fbo.allocate( ofGetWidth(), ofGetHeight(), GL_RGBA );

			// Clear, there might be random garbage in the memory we got
			fbo.begin();
				ofClear( ofColor::black );
			fbo.end();
			
			ofSetCircleResolution(50);
		}

		// -------------------
		void draw()
		{
			ofSetColor( ofColor::white );
			fbo.draw( 0,0 );
		}
	
		// -------------------
		void mousePressed(int x, int y, int button)
		{
			fbo.begin();
		
				ofSetColor( ofRandom(255), ofRandom(255), ofRandom(255) );
				ofDrawCircle( ofGetMouseX(), ofGetMouseY(), 50 );
			
			fbo.end();
		}
	
		ofFbo fbo;
};

Found the mistake, it was en enableDepthTest() in my setup, which caused the issue.

Thanks