user1019901
user1019901

Reputation: 581

PNGs in OpenGL?

How can I load a PNG into an OpenGL texture?

Upvotes: 2

Views: 706

Answers (3)

Wunkolo
Wunkolo

Reputation: 33

There is also stb_image. Just include the source in your code and you can import JPG,PNG,TGA,BMP,PSD,GIF,HDR, and PIC. It is also entirely public domain.

unsigned char * data = stbi_load(FileName.c_str(),&width,&height,&channels,STBI_rgb_alpha);

Upvotes: 1

ther
ther

Reputation: 888

I suggest using:

http://openil.sourceforge.net/

It was originally developed to be used with OpenGL, so everything comes naturally. It supports all the major image formats, including png. I read that in the newer releases they even added a function exactly for people like you:

GLuint textureHandle = ilutGLLoadImage("some-picture.jpg");

Upvotes: 2

wormsparty
wormsparty

Reputation: 2499

You may need to patch it for more recent libpng versions, since the last version is from July 2000, but glpng does exactly what you want:

http://libglpng.sourcearchive.com/documentation/1.45/glpng_8c-source.html

Upvotes: 0

Related Questions