Page 1 of 1

How to easily load images into OpenGL

Posted: Tue Nov 17, 2009 11:39 pm
by animangaman690
Okay so the other day I was looking up how to load pngs into openGL for textures and I found this: http://www.gamedev.net/community/forums ... hpage=1�

Basically in short it is an image library for OpenGL. I thought it would come in handy for some one who hasn't seen this.

EDIT:

This is an example for loading a png.

Code: Select all

/* load an image file directly as a new OpenGL texture */
GLuint tex_2d = SOIL_load_OGL_texture
	(
		"img.png",
		SOIL_LOAD_AUTO,
		SOIL_CREATE_NEW_ID,
		SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
	);
	
There are more examples on the info page of the library.

Re: How to easily load images into OpenGL

Posted: Wed Nov 18, 2009 2:19 am
by RyanPridgeon

Re: How to easily load images into OpenGL

Posted: Wed Nov 18, 2009 3:21 am
by K-Bal
You can also use SFML to load many different file formats. Then you just have to call sf::Image::Bind before your OpenGL rendering.

Re: How to easily load images into OpenGL

Posted: Wed Nov 18, 2009 6:43 am
by animangaman690
:shock:

I didn't see that post my bad. I went to gamedev(dot)net first...
Sorry. :oops: