Pixels are not allocated

Hello everyone, I am getting the annoying Pixels are not allocated nmessage in console screen (command screen). The code below is running, however nothing is drawing to the output folder. I have successfully managed to draw files to output folder before, not sure why not working now. Am I missing anything? It must be something small.

I tried fboAllocate and imageAllocate, and both at the same time too, in setup.

void ofApp::setup(){
	shader.load("shaderVert.c", "shaderFrag.c");
	int counter = 0;

	image.loadImage( "sunflower.png" );	
	image.allocate(image.getWidth(), image.getHeight(), OF_IMAGE_COLOR);
	//fbo.allocate(image.getWidth(), image.getHeight(), GL_RGBA);


void ofApp::draw(){
	ofClear(255, 255, 255, 0);

	float time = ofGetElapsedTimef();
	shader.setUniform1f("time", time);

	ofBackgroundGradient( ofColor( 255 ), ofColor( 128 ) );
	ofSetColor( 255, 255, 255 );
	image.draw( 0, 0 );

		fbo.draw( 0, 0 );
	ofPixels pix;
	ofSaveImage(pix, "output/" + ofToString(counter) + ".png", OF_IMAGE_QUALITY_BEST);


this line in setup:

is not necesary and it’s indeed reallocating the image with blank pixels. that’s the reason why you get nothing when drawing i would say.

then when saving i’m not sure what you are trying to do but:

ofPixels pix;
ofSaveImage(pix, "output/" + ofToString(counter) + ".png", OF_IMAGE_QUALITY_BEST);

is creating an empty ofPixels called pix and saving it so you are getting again a blank image saved to counter.png, you probably want to use ofSaveScreen here but not sure what you want to do

1 Like

You don’t need to allocate your image again cause your image is already loaded from the file “sunflower.png”

also I see couple things which might cause problems.

a. you need to declare variable counter as a global. So move the “int counter = 0” in your setup to your header so that you can access it in everywhere

b. as I mentioned above, delete “image.allocate()” in your setup

c. if you want to use fbo in draw loop, you need to allocate it in setup. you would uncomment it

hope this help

it was solved

thank you for the tips,

imageAllocate indeed caused the problem.
Secondly, also I moved counter to the header as avseoul said
Next, I had a smaller screen size in main than the fbo.
Lastly, this particular shader only takes square images ??!!! omg why??!!

thank you for your help!!!