Hi masters!
I’m experiencing problems while loading a texture from a .raw file generated by Photoshop.
the function to load is quite simple:
void CarregaTextura(const char* caminho, GLuint TextIndex)
{
int largura = 256;
int altura = 256;
GLubyte *dados;
FILE *arquivo;
dados = (GLubyte*) malloc( largura * altura * 4 );
//abre e lê como bytes
arquivo = fopen(caminho, "rb");
//faz a leitura do arquivo para dentro da variável dados
fread(dados, altura * largura * 4, 1, arquivo);
fclose(arquivo);
glBindTexture(GL_TEXTURE_2D, TextIndex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256,256, 0, GL_RGBA, GL_UNSIGNED_BYTE,dados);
}
The problem is the texture is not loading correctly (see image below). I’ve tried paintbrush bitmaps but the problem is the same.
The original texture is as below:
Also, when I put the text coordinates inside a display list, nothing happens.
Can someone help me again?
Regards!
EDIT: I got it! the problem was GL_RGBA. It’s GL_RGB in that case. But now another problem:
How to remove this borders? Why this happens?
and also, the problem with display list continues…