ofImage GL: texture not allocated

Hello and happy coding to you all :slight_smile:

I just have a little problem, i’m trying to make a 3D book (don’t ask why, my boss just want it, so 'im doing it), and it’s not working:
Xcode told me this:
[warning] ofGLRenderer: drawing an unallocated texture

here is the code, can you told me where i’m wrong please, so i will change it :slight_smile: ?

Thank you all and have fun with OF !

//
//  PhotoClass.cpp
//  AppenzellerFB
//
//  Created by Vincent Marsat on 01/09/14.
//
//

#include "PhotoClass.h"

PhotoClass::PhotoClass(){
    Photo == 1;
    
    Photo01.loadImage(Photo1);
    Photo02.loadImage(Photo2);
    Photo03.loadImage(Photo3);
    Photo04.loadImage(Photo4);
    Photo05.loadImage(Photo5);
    Photo06.loadImage(Photo6);
    Photo07.loadImage(Photo7);
    Photo08.loadImage(Photo8);
    Photo09.loadImage(Photo9);
    Photo10.loadImage(Photo010);
}

void PhotoClass::update(){
    
    Photo01.update(); Photo02.update(); Photo03.update(); Photo04.update(); Photo05.update(); Photo06.update(); Photo07.update(); Photo08.update(); Photo09.update(); Photo10.update();

    if (Photo == 1) { //chapter one
        Photo1 = "1011.jpg";
        Photo2 = "1012.jpg";
        Photo3 = "1013.jpg";
        Photo4 = "1014.jpg";
        Photo5 = "1015.jpg";
        Photo6 = "1016.jpg";
        Photo7 = "1017.jpg";
        Photo8 = "1018.jpg";
        Photo9 = "1019.jpg";
        Photo010 = "1020.jpg";
    }
    
    if (Photo == 2) { //chapter two
        Photo1 = "1021.jpg";
        Photo2 = "1022.jpg";
        Photo3 = "1023.jpg";
        Photo4 = "1024.jpg";
        Photo5 = "1025.jpg";
        Photo6 = "1026.jpg";
        Photo7 = "1027.jpg";
        Photo8 = "1028.jpg";
        Photo9 = "1029.jpg";
        Photo010 = "1030.jpg";
    }
    if (Photo == 3) {// tree
        Photo1 = "1031.jpg";
        Photo2 = "1032.jpg";
        Photo3 = "1033.jpg";
        Photo4 = "1034.jpg";
        Photo5 = "1035.jpg";
        Photo6 = "1036.jpg";
        Photo7 = "1037.jpg";
        Photo8 = "1038.jpg";
        Photo9 = "1039.jpg";
        Photo010 = "1040.jpg";
    }
    if (Photo == 4) {//four
        Photo1 = "1041.jpg";
        Photo2 = "1042.jpg";
        Photo3 = "1043.jpg";
        Photo4 = "1044.jpg";
        Photo5 = "1045.jpg";
        Photo6 = "1046.jpg";
        Photo7 = "1047.jpg";
        Photo8 = "1048.jpg";
        Photo9 = "1049.jpg";
        Photo010 = "1050.jpg";
    }


    
}

void PhotoClass::draw(int Rotate, int PhotoNumber){
    ofEnableDepthTest();

    Photo01.draw(0, 0); // first page
    
}

In the class constructor, are the Photo* strings initialized? Make sure images are actually loading.

I’d say your update function should be performed before loading the images. Also, the ofImage::update operation might not be necessary. Usually you call it when you’ve set some pixels manually and want to upload the image to the GL texture.

Try something like this to test it out:

PhotoClass::PhotoClass(){
        
    Photo1 = "1011.jpg";
    Photo2 = "1012.jpg";
    Photo3 = "1013.jpg";
    Photo4 = "1014.jpg";
    Photo5 = "1015.jpg";
    Photo6 = "1016.jpg";
    Photo7 = "1017.jpg";
    Photo8 = "1018.jpg";
    Photo9 = "1019.jpg";
    Photo010 = "1020.jpg";

    Photo01.loadImage(Photo1);
    Photo02.loadImage(Photo2);
    Photo03.loadImage(Photo3);
    Photo04.loadImage(Photo4);
    Photo05.loadImage(Photo5);
    Photo06.loadImage(Photo6);
    Photo07.loadImage(Photo7);
    Photo08.loadImage(Photo8);
    Photo09.loadImage(Photo9);
    Photo10.loadImage(Photo010);
}

void PhotoClass::update(){
    ///empty
}

void PhotoClass::draw(int Rotate, int PhotoNumber){
    ofEnableDepthTest();

    Photo01.draw(0, 0); // first page

}

Tht is what i’m trying to do actually (thanks for your quick respond :slight_smile: )

Now i’m trying to change the image: it is a class for a bigger program, and i use the gesture of the leap motion to tur the pages (int rotation). The problem s like, i think i missed something beacause it is not toally working…

If i can show you (yes, i like to be complicated), just tell me if you see something wrong… please :frowning: :

//
// PhotoClass.cpp
// AppenzellerFB
//
// Created by Vincent Marsat on 01/09/14.
//
//

#include “PhotoClass.h”

PhotoClass::PhotoClass(){
Photo = 0;

}

void PhotoClass::update(){

if (Photo < 360) { //chapter zero
    Photo1 = "1001.jpg";
    Photo2 = "1002.jpg";
    Photo3 = "1003.jpg";
    Photo4 = "1004.jpg";
    Photo5 = "1005.jpg";
    Photo6 = "1006.jpg";
    Photo7 = "1007.jpg";
    Photo8 = "1008.jpg";
    Photo9 = "1009.jpg";
    Photo010 = "1010.jpg";
}
Photo01.loadImage(Photo1);
Photo02.loadImage(Photo2);
Photo03.loadImage(Photo3);
Photo04.loadImage(Photo4);
Photo05.loadImage(Photo5);
Photo06.loadImage(Photo6);
Photo07.loadImage(Photo7);
Photo08.loadImage(Photo8);
Photo09.loadImage(Photo9);
Photo10.loadImage(Photo010);
Photo01.update(); Photo02.update(); Photo03.update(); Photo04.update(); Photo05.update(); Photo06.update(); Photo07.update(); Photo08.update(); Photo09.update(); Photo10.update();

}

void PhotoClass::draw(int Rotate){
ofEnableDepthTest();

Photo = PhotoNumber*20;
ofTranslate(0, 0);
ofPushMatrix();
ofRotateY(-P1*20);
Photo01.draw(0,0,0, 785, 600); // Recto
ofPushMatrix();
ofRotateY(180);
ofTranslate(0,0,1);// Verso - 1px
Photo02.draw(-785,0,0, 785,600); // Verso
ofPopMatrix();
ofPopMatrix();
ofPushMatrix();
ofRotateY(-P2*20);
Photo03.draw(0,0,-1, 785, 600); // Recto
ofPushMatrix();
ofRotateY(180);
ofTranslate(0,0,1);// Verso - 1px
Photo04.draw(-785,0,-1, 785,600); // Verso
ofPopMatrix();
ofPopMatrix();
ofPushMatrix();
ofRotateY(-P3*20);
Photo05.draw(0,0,-2, 785, 600); // Recto
ofPushMatrix();
ofRotateY(180);
ofTranslate(0,0,1);// Verso - 1px
Photo06.draw(-785,0,-2, 785,600); // Verso
ofPopMatrix();
ofPopMatrix();
ofPushMatrix();
ofRotateY(-P4*20);
Photo07.draw(0,0,-3, 785, 600); // Recto
ofPushMatrix();
ofRotateY(180);
ofTranslate(0,0,1);// Verso - 1px
Photo08.draw(-785,0,-3, 785,600); // Verso
ofPopMatrix();
ofPopMatrix();
ofPushMatrix();
ofRotateY(-P5*20);
Photo09.draw(0,0,-4, 785, 600); // Recto
ofPushMatrix();
ofRotateY(180);
ofTranslate(0,0,1);// Verso - 1px
Photo10.draw(-785,0,-4, 785,600); // Verso
ofPopMatrix();
ofPopMatrix();
if (PhotoNumber*20 == 180*5 || PhotoNumber*20 == 180 * 10|| PhotoNumber*20 == 180 * 15 || PhotoNumber*20 == 180 * 20 || PhotoNumber*20 == 180 * 25) {
    P1 = 0;
    P2 = 0;
    P3 = 0;
    P4 = 0;
    P5 = 0;
}
if (Photo > -1 && Photo < 180*10) { //chapter zero
    Photo1 = "1001.jpg";
    Photo2 = "1002.jpg";
    Photo3 = "1003.jpg";
    Photo4 = "1004.jpg";
    Photo5 = "1005.jpg";
    Photo6 = "1006.jpg";
    Photo7 = "1007.jpg";
    Photo8 = "1008.jpg";
    Photo9 = "1009.jpg";
    Photo010 = "1010.jpg";
    cout << "chapitre 1"<< endl;
    switch (Rotate) {
        case 3:
            PhotoNumber --;
            if (PhotoNumber*20 == -1 && PhotoNumber*20 == 180){
                P1 --;
            }
            if (PhotoNumber*20 == 180 && PhotoNumber*20 == 180*2){
                P2 --;
            }
            if (PhotoNumber*20 == 360 && PhotoNumber*20 == 180*3){
                P3 --;
            }
            if (PhotoNumber*20 == 180 * 3 && PhotoNumber*20 == 180 * 4){
                P4 --;
            }
            if (PhotoNumber*20 == 180 * 4 && PhotoNumber*20 == 180 * 5){
                P5 --;
            }
            cout<< "photonumber -- = "<< PhotoNumber*20<< endl;
            break;
        case 4:
            PhotoNumber ++;
            if (PhotoNumber*20 == 0 && PhotoNumber*20 == 180){
                P1 ++;
            }
            if (PhotoNumber*20 == 180 && PhotoNumber*20 == 180 * 2){
                P2 ++;
            }
            if (PhotoNumber*20 == 180 * 2 && PhotoNumber*20 == 180 * 3){
                P3 ++;
            }
            if (PhotoNumber*20 == 180 * 3 && PhotoNumber*20 == 180 * 4){
                P4 ++;
            }
            if (PhotoNumber*20 == 180 * 4 && PhotoNumber*20 == 180 * 5){
                P5 ++;
            }
            cout<< "photonumber ++ = "<< PhotoNumber*20<< endl;
            break;
        default:
            break;
    }
}
if (Photo > 180*5 && Photo < 180*10) { //chapter one
    Photo1 = "1011.jpg";
    Photo2 = "1012.jpg";
    Photo3 = "1013.jpg";
    Photo4 = "1014.jpg";
    Photo5 = "1015.jpg";
    Photo6 = "1016.jpg";
    Photo7 = "1017.jpg";
    Photo8 = "1018.jpg";
    Photo9 = "1019.jpg";
    Photo010 = "1020.jpg";
    cout << "chapitre 2"<< endl;
    switch (Rotate) {
        case 3:
            PhotoNumber --;
            if (PhotoNumber*20 == 180*5 && PhotoNumber*20 == 180*6){
                P1 --;
            }
            if (PhotoNumber*20 ==180*6 && PhotoNumber*20 == 180*7){
                P2 --;
            }
            if (PhotoNumber*20 ==360*7 && PhotoNumber*20 == 180*8){
                P3 --;
            }
            if (PhotoNumber*20 ==180*8 && PhotoNumber*20 == 180*9){
                P4 --;
            }
            if (PhotoNumber*20 ==180*9 && PhotoNumber*20 == 180*10){
                P5 --;
            }
            cout<< "photonumber -- = "<< PhotoNumber*20<< endl;
            break;
        case 4:
            PhotoNumber ++;
            if (PhotoNumber*20 == 180*5 && PhotoNumber*20 == 180*6){
                P1 ++;
            }
            if (PhotoNumber*20 == 180*6 && PhotoNumber*20 == 180*7){
                P2 ++;
            }
            if (PhotoNumber*20 == 360*7 && PhotoNumber*20 == 180*8){
                P3 ++;
            }
            if (PhotoNumber*20 == 180*8 && PhotoNumber*20 == 180*9){
                P4 ++;
            }
            if (PhotoNumber*20 == 180*9 && PhotoNumber*20 == 180*10){
                P5 ++;
            }
            cout<< "photonumber ++ = "<< PhotoNumber*20<< endl;
            break;
        default:
            break;
    }
}
if (Photo > 180*10 && Photo < 180*15) { //chapter two
    Photo1 = "1021.jpg";
    Photo2 = "1022.jpg";
    Photo3 = "1023.jpg";
    Photo4 = "1024.jpg";
    Photo5 = "1025.jpg";
    Photo6 = "1026.jpg";
    Photo7 = "1027.jpg";
    Photo8 = "1028.jpg";
    Photo9 = "1029.jpg";
    Photo010 = "1030.jpg";
    cout << "chapitre 3"<< endl;
    switch (Rotate) {
        case 3:
            PhotoNumber --;
            if (PhotoNumber*20 == 180*10 && PhotoNumber*20 == 180*11){
                P1 --;
            }
            if (PhotoNumber*20 == 180*11 && PhotoNumber*20 == 180*12){
                P2 --;
            }
            if (PhotoNumber*20 == 360*12 && PhotoNumber*20 == 180*13){
                P3 --;
            }
            if (PhotoNumber*20 == 180*13 && PhotoNumber*20 == 180*14){
                P4 --;
            }
            if (PhotoNumber*20 == 180*14 && PhotoNumber*20 == 180*15){
                P5 --;
            }
            cout<< "photonumber -- = "<< PhotoNumber*20<< endl;
            break;
        case 4:
            PhotoNumber ++;
            if (PhotoNumber*20 == 180*10 && PhotoNumber*20 == 180*11){
                P1 ++;
            }
            if (PhotoNumber*20 == 180*11 && PhotoNumber*20 == 180*12){
                P2 ++;
            }
            if (PhotoNumber*20 == 360*12 && PhotoNumber*20 == 180*13){
                P3 ++;
            }
            if (PhotoNumber*20 == 180*13 && PhotoNumber*20 == 180*14){
                P4 ++;
            }
            if (PhotoNumber*20 == 180*14 && PhotoNumber*20 == 180*15){
                P5 ++;
            }
            cout<< "photonumber ++ = "<< PhotoNumber*20<< endl;
            break;
        default:
            break;
    }
}
if (Photo > 180*15 && Photo < 180*20) {// tree
    Photo1 = "1031.jpg";
    Photo2 = "1032.jpg";
    Photo3 = "1033.jpg";
    Photo4 = "1034.jpg";
    Photo5 = "1035.jpg";
    Photo6 = "1036.jpg";
    Photo7 = "1037.jpg";
    Photo8 = "1038.jpg";
    Photo9 = "1039.jpg";
    Photo010 = "1040.jpg";
    cout << "chapitre 4"<< endl;
    switch (Rotate) {
        case 3:
            PhotoNumber --;
            if (PhotoNumber*20 == 180*15 && PhotoNumber*20 == 180*16){
                P1 --;
            }
            if (PhotoNumber*20 == 180*16 && PhotoNumber*20 == 180*17){
                P2 --;
            }
            if (PhotoNumber*20 == 360*17 && PhotoNumber*20 == 180*18){
                P3 --;
            }
            if (PhotoNumber*20 == 180*18 && PhotoNumber*20 == 180*19){
                P4 --;
            }
            if (PhotoNumber*20 == 180*19 && PhotoNumber*20 == 180*20){
                P5 --;
            }
            cout<< "photonumber -- = "<< PhotoNumber*20<< endl;
            break;
        case 4:
            PhotoNumber ++;
            if (PhotoNumber*20 == 180*15 && PhotoNumber*20 == 180*16){
                P1 ++;
            }
            if (PhotoNumber*20 == 180*16 && PhotoNumber*20 == 180*17){
                P2 ++;
            }
            if (PhotoNumber*20 == 360*17 && PhotoNumber*20 == 180*18){
                P3 ++;
            }
            if (PhotoNumber*20 == 180*18 && PhotoNumber*20 == 180*19){
                P4 ++;
            }
            if (PhotoNumber*20 == 180*19 && PhotoNumber*20 == 180*20){
                P5 ++;
            }
            cout<< "photonumber ++ = "<< PhotoNumber*20<< endl;
            break;
        default:
            break;
    }
}
if (Photo > 180*20 && Photo < 180*25) {//four
    Photo1 = "1041.jpg";
    Photo2 = "1042.jpg";
    Photo3 = "1043.jpg";
    Photo4 = "1044.jpg";
    Photo5 = "1045.jpg";
    Photo6 = "1046.jpg";
    Photo7 = "1047.jpg";
    Photo8 = "1048.jpg";
    Photo9 = "1049.jpg";
    Photo010 = "1050.jpg";
    cout << "chapitre 5"<< endl;
    switch (Rotate) {
        case 3:
            PhotoNumber --;
            if (PhotoNumber*20 == 180*20 && PhotoNumber*20 <= 180*21){
                P1 --;
            }
            if (PhotoNumber*20 == 180*21 && PhotoNumber*20 <= 180*22){
                P2 --;
            }
            if (PhotoNumber*20 == 360*22 && PhotoNumber*20 <= 180*23){
                P3 --;
            }
            if (PhotoNumber*20 == 180*23 && PhotoNumber*20 <= 180*24){
                P4 --;
            }
            if (PhotoNumber*20 == 180*24 && PhotoNumber*20 <= 180*25){
                P5 --;
            }
            cout<< "photonumber -- = "<< PhotoNumber*20<< endl;
            break;
        case 4:
            PhotoNumber ++;
            if (PhotoNumber*20 == 180*20 && PhotoNumber*20 == 180*21){
                P1 ++;
            }
            if (PhotoNumber*20 == 180*21 && PhotoNumber*20 == 180*22){
                P2 ++;
            }
            if (PhotoNumber*20 == 360*22 && PhotoNumber*20 == 180*23){
                P3 ++;
            }
            if (PhotoNumber*20 == 180*23 && PhotoNumber*20 == 180*24){
                P4 ++;
            }
            if (PhotoNumber*20 == 180*24 && PhotoNumber*20 == 180*25){
                P5 ++;
            }
            cout<< "photonumber ++ = "<< PhotoNumber*20<< endl;
            break;
        default:
            break;
    }
}

}

Again, keep in mind that update is done at every frame, you do not need to load images every frame.
Maybe you are calling the PhotoClass::update method only once from you lfApp, in that case I guess there is no problem. You can do those operations at the constructor (only once). And you don’t need to call ofImage::update, it is called within ofImage::loadImage.

I’d recommend you to take a look at some of the GL examples. This draw method seems overly complicated for what you are trying to do. I’m sorry if I cannot be of more help. Also, try with a smaller test, maybe loading a single page and successfully turning it with the Leap.

Good luck! :smiley: