"texture is not allocated" warning when drawing

Hi,

I want to reuse the same image several times as tiles in a game level. I defined the texture as class member:

private:
ofTexture floor;

Then I load the image for the texture in the setup() method:
void ofApp::setup(){
ofLoadImage(floor, “floor.png”);

}

And finally, I draw it:
void ofApp::draw(){
floor.draw(x,y,1);

}

I receive the warning message [warning] ofGLRenderer: draw(): texture is not allocated for each tile; what am I doing wrong? Where and how can I allocate the texture, and how? Is there a better way to do what I’m trying to achieve?

Thanks,
Christian

check your image name and image path… for example if your image path is : yourProject/bin/images/floor.png … in your setup must: ofLoadImage(floor, “images/floor.png”);

Thanks, but the images are loaded and displayed correctly. It’s just the warning message that i want to get rid of or better, the reason behind.

push

2 suggestions:

if you know the dimensions of the image (300x300 for example), you can call the allocate() method explicitly before loading the texture:

floor.allocate( 300, 300, GL_RGB );

you could also check for the loading/allocation in the draw method:

if(floor.isAllocated()){
floor.draw(x,y,1)
}

cheers!

Thanks @nickhubben! Checking whether textures are allocated before calling the drawing functions did the job, apparently draw() was called before setup() (where the textures were loaded and allocated) was finished.

1 Like