PDA

View Full Version : uploading textures



lara
11-27-2002, 04:21 AM
Hi,
I want to add some texture to my polygon.
So far I did not come across any tutorial that speaks of uploading a texture from some place...they only talk of binding it to objects.
Could some one direct me to a link, or give me an example of uploading a texture file.
I am wondering what kind of file (by which i mean in which format) does the file need to be...

Thanks,
Lara

nexusone
11-27-2002, 04:27 AM
First openGL does not have any file loading functions, the texture file will have to be loaded by a file loading routine. There are lot's of them floating around.

I use a TGA file format texture loader, you can see examples on my website in GLblackjack and glBall: http://www.angelfire.com/linux/nexusone/index.html

You can also find BMP, JPG, GIF, texture loaders out there also.
nehe.gamedev.net has an example of a BMP and TGA also.



Originally posted by lara:
Hi,
I want to add some texture to my polygon.
So far I did not come across any tutorial that speaks of uploading a texture from some place...they only talk of binding it to objects.
Could some one direct me to a link, or give me an example of uploading a texture file.
I am wondering what kind of file (by which i mean in which format) does the file need to be...

Thanks,
Lara

dabeav
11-27-2002, 04:37 AM
To to www.imagelib.org (http://www.imagelib.org) Its the home of devIL. A image loading library with the same syntax setup as OpenGL. Very native to opengl, and make things like mip mapping, and such very easy.

lara
11-27-2002, 06:00 AM
Well, I finally opbtained quite a few file loading routines for tga files..but they all are in C,
and as i have my program all coded in C++, i guess it is giving me problems.
Would someone have a tga file uploading routine in c++ that i could use.
Moreover i have some problems understanding the texture id... is that just nay random number we assign to the image in the main function?

Thanks for helping.

nexusone
11-27-2002, 06:54 AM
Yes, texture id could be random depends on which TGA loader you are using.

If I have list of textures I just use 1,2,3 order.
example of an array I use for the TGA loader I use.
GLint deck_store_textures[53];

I have used another which you need only supply a number in which to identify the texture when binding.

nehe.gamedev.net should have a C++ example on his site.

Originally posted by lara:
Well, I finally opbtained quite a few file loading routines for tga files..but they all are in C,
and as i have my program all coded in C++, i guess it is giving me problems.
Would someone have a tga file uploading routine in c++ that i could use.
Moreover i have some problems understanding the texture id... is that just nay random number we assign to the image in the main function?

Thanks for helping.

Deiussum
11-27-2002, 07:29 AM
You should be able to use C functions in C++ with no problems. (OpenGL functions themselves are C.)

Perhaps whoever wrote the code you are using didn't add something like this around his function prototypes...

#ifdef __cplusplus
extern "C" {
#endif

// function prototypes

#ifdef __cplusplus
}
#endif


Try place those remarks around the place you include the header. (putting the #include where I have the comment above.)

lara
11-27-2002, 07:29 AM
How can I view a tga file..someone sends me?

nexusone
11-27-2002, 07:34 AM
I use paint shop pro to make and view them.
It is a free download to try it.

Also use a free image viewer, called Irfanview.

Both can be downloaded from the internet.


Originally posted by lara:
How can I view a tga file..someone sends me?