Im trying to use PNG:s as textures but the problem is that it doesn't work. I where using a PNG loader from a standard OpenGL library I used before but it still doesn't work at all. (Here is the link: http://www.iwr.uni-heidelberg.de/groups/ngg/CG200708/Txt/png.c)
Here is the code:
GLubyte* png_tex = ReadPNGFromFile (filename);
printf("GL Error %i \n" , glGetError());
if (png_tex)
{
glGenTextures (1, &texid);
glBindTexture (GL_TEXTURE_2D, texid);
printf("GL Error %i \n" , glGetError());
//glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
//glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D (GL_TEXTURE_2D, 0, format,
width, height, 0, format,
GL_UNSIGNED_BYTE, png_tex);
//for (int i = 0; i < width*height; i++)
// printf("%i", png_tex);
free (png_tex);
}
printf("GL Error %i \n" , glGetError());
I used the loop:
for (int i = 0; i < width*height; i++)
printf("%i", png_tex);
For looking if the loaded texture contained some data and it did. The problem is that I only get blank textures. So I believe I did something wrong in OpenGL ES and yes I have enabled texturing with: glEnable(GL_TEXTURE_2D);
The printf("GL Error %i \n" , glGetError()); All printed out zero so it should be OK. Is there a problem using a greyscale image as GL_Luminance?
Here is the code:
GLubyte* png_tex = ReadPNGFromFile (filename);
printf("GL Error %i \n" , glGetError());
if (png_tex)
{
glGenTextures (1, &texid);
glBindTexture (GL_TEXTURE_2D, texid);
printf("GL Error %i \n" , glGetError());
//glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
//glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D (GL_TEXTURE_2D, 0, format,
width, height, 0, format,
GL_UNSIGNED_BYTE, png_tex);
//for (int i = 0; i < width*height; i++)
// printf("%i", png_tex);
free (png_tex);
}
printf("GL Error %i \n" , glGetError());
I used the loop:
for (int i = 0; i < width*height; i++)
printf("%i", png_tex);
For looking if the loaded texture contained some data and it did. The problem is that I only get blank textures. So I believe I did something wrong in OpenGL ES and yes I have enabled texturing with: glEnable(GL_TEXTURE_2D);
The printf("GL Error %i \n" , glGetError()); All printed out zero so it should be OK. Is there a problem using a greyscale image as GL_Luminance?