I want to reuse the same image several times as tiles in a game level. I defined the texture as class member:
Then I load the image for the texture in the setup() method:
And finally, I draw it:
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?
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.
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:
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.