feed (Normal User)
Newbie
Messaggi: 1
Iscritto: 08/10/2013
|
ciao a tutti,
grazie in anticipo delle risposte.
Questa č la mia funzione:
Codice sorgente - presumibilmente C/C++ |
void old2()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, prova.getID());
glBegin(GL_POLYGON);
//alto-sx
glTexCoord3f(0.0, 0.0, 0.0);
glVertex3f(-0.5, -0.5, 0.0);
//alto-dx
glTexCoord3f(1.0, 0.0, 0.0);
glVertex3f(0.5, -0.5, 0.0);
//basso-dx
glTexCoord3f(1.0, 1.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
//basso-sx
glTexCoord3f(0.0, 1.0, 0.0);
glVertex3f(-0.5, 0.5, 0.0);
glEnd();
glDisable(GL_TEXTURE_2D);
}
|
In pratica questa funziona mi disegna solo un quadrato bianco su uno sfondo nero mentre la texture che ho caricato dovrebbe essere rossa!
(la carica come texture 1, larghezza 100px, altezza 100px, mode GL_RGB)
Questa č la funzione per caricare le texture. Dai Log questa funziona:
Codice sorgente - presumibilmente C++ |
bool myTexture::prova1(std::string path) { bool success = true; SDL_Surface* loadedSurface = IMG_Load(path.c_str()); if (loadedSurface == NULL) { printf("Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError());//da lavorarci success = false; } else { //Create texture from surface pixels //newTexture = SDL_CreateTextureFromSurface(gRenderer, loadedSurface); mColors = loadedSurface->format->BytesPerPixel; if (mColors == 4) { if (loadedSurface->format->Rmask == 0x000000ff) texture_format = GL_RGBA; else texture_format = GL_BGRA_EXT; } else if (mColors == 3) { if (loadedSurface->format->Rmask == 0x000000ff) texture_format = GL_RGB; else texture_format = GL_BGR_EXT; } else { printf("Errore caricamento texture!"); success = false; } glGenTextures(1, &mID);//genera un id glBindTexture(GL_TEXTURE_2D, mID);//aggiunge l'id all'area di memoria delle txtr2d glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//setta parametri a caso glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, mColors, loadedSurface->w, loadedSurface->h, 0, texture_format, GL_UNSIGNED_BYTE, loadedSurface->pixels);//carica la txtr in memoria mWidth = loadedSurface->w; mHeight = loadedSurface->h; SDL_FreeSurface(loadedSurface); printf("Texture(%d), W(%d), H(%d), Mode(%0x).\n", mID, loadedSurface->w, loadedSurface->h, texture_format); } return success; }
|
qualche idea del mio errore? Ultima modifica effettuata da feed il 08/10/2013 alle 1:31 |