Loading textures

Loading textures

BY 09 Jul 2013 Native Application Development

Hello. How to correctly load textures (OpenGL) ?  The textures are distorted and in different colour.

Image *obraz = new Image();
    Bitmap *graf1 = new Bitmap();

    obraz->Construct();
    graf1 = obraz->DecodeN(Tizen::App::App::GetInstance()->GetAppRootPath() + L"res/fire.png",BITMAP_PIXEL_FORMAT_R8G8B8A8);
    glGenTextures(1, &tex[0]);

glBindTexture(GL_TEXTURE_2D, tex[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,  graf1->GetWidth(), graf1->GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE , graf1 );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

Can someone show me the correct way (sample of code or something)

 

Written by