View Full Version : Help, How to use a jpg, jpeg etc image in texture,

11-30-2003, 01:51 PM
Hi I am using windows and VC++, and the book says
glTexImage2D(GL_TEXURE_2D,something, something, ..... , image);

However How can I get an image named 'clock.jpg' and is stored in 'C:\images\'
do I type the following instead

glTexImage2D(GL_TEXURE_2D,something, something, ..... , 'C:\images\clock.jpg');
but the book also says that OpenGL doesn't regular image formatts

Thanking your attention to my matter

11-30-2003, 03:16 PM
I think you need to get ahold of some docs that lists the function parameters of all OpenGL functions, or you can at least look at the GL.h header file and find out what each parameter takes:

void glTexImage2D(
GLenum target,
GLint level,
GLint components,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels

pixels is a memory buffer, like:
pixels = new BYTE[image_size];

11-30-2003, 09:42 PM
OpenGL is only a graphics API. You have to handle the loading of image data yourself.

There are plenty of sites out there that have tutorials for doing this. Off the top of my head, check out http://nehe.gamedev.net. He has quite a few good tutorials.

[This message has been edited by simtap (edited 11-30-2003).]

[This message has been edited by simtap (edited 11-30-2003).]

11-30-2003, 09:59 PM
http://www.smalleranimals.com/isource.htm this will help you to load the images; after that u map the images to the Texture.