Original Post
Which is the easiest way to work with PNG textures (I want them for transparency) in OpenGL? I work in Visual Studio using C.
int texture_id;glGenTextures(1, &texture_id); // create 1 texture and store its ID in the variable texture_idglBindTexture(GL_TEXTURE_2D, texture_id);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_CHAR, pixels);delete pixels;unsigned error;unsigned char* image;size_t w, h, x, y; /*load the PNG in one function call*/error = LodePNG_decode32f(ℑ, &w, &h, "rwar.png");glGenTextures(1, &texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);AUX_RGBImageRec *TextureImage[1];TextureImage[0]=LoadBMP("Data/NeHe.bmp");glBindTexture(GL_TEXTURE_2D, texture[0]);glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);Quote:
The texture won't work because it is incomplete. The default GL_TEXTURE_MIN_FILTER state is GL_LINEAR_MIPMAP_NEAREST so GL will consider the texture incomplete as long as you don't create the mipmaps.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more