How to easily load images into OpenGL

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
animangaman690
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 96
Joined: Mon Feb 02, 2009 8:03 am
Current Project: TDS
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++, C#
Location: Alexander City, AL
Contact:

How to easily load images into OpenGL

Post 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.
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: How to easily load images into OpenGL

Post by RyanPridgeon »

Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: How to easily load images into OpenGL

Post 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.
User avatar
animangaman690
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 96
Joined: Mon Feb 02, 2009 8:03 am
Current Project: TDS
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++, C#
Location: Alexander City, AL
Contact:

Re: How to easily load images into OpenGL

Post by animangaman690 »

:shock:

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