OpenGL textures
Hello,
I have a question about the opengl texture format. Before I always read in textures using glaux bmp load functions. But now I''ve come to the point where I want to make my own picture-loading routines. But what I want to know is how do I save the file''s (array?) so that I can pass them to opengl and use them as textures. (I need to know the format of the arrays in which
the textures are stored, before opengl puts them in video mem.)
Thanks, in advance!
actually OpenGL supports many formats: depending on your video card driver. most likely you''ll just want raw bitmap format or GL_RGBA or GL_RGB. if you have the OpenGL reference book you should look up the glTexture2D function for all the different formats.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Ok, thought about that myself too. But how do you store raw bitmap RGB in an array to pass it to glTexture2d. because RGB 24-bit for example exists (for a 100x100 bitmap) 100 x 100 x 3 = 30000 bytes. what size do you make te array then? 300 x 100? (byte bitmap[300][100]? And then just take 3 bytes for a singel pixel, or is there an other way to make the array?
Greats, Rob Koster...
Greats, Rob Koster...
i wrote a little app to turn 8 & 24 bit bmp, and 8 & 32bit tga files into arrays, it is called gfx2tex and is available from:
http://freespace.virginnet.co.uk/al.braidwood/
along with the source code...it might help you
alistair
http://freespace.virginnet.co.uk/al.braidwood/
along with the source code...it might help you
alistair
Hello,
Thank you for that extremely helpfull programm, especially the output header file helped me in determing what the format of the array is.
Many thanks, Rob Koster
Thank you for that extremely helpfull programm, especially the output header file helped me in determing what the format of the array is.
Many thanks, Rob Koster
You''d be better off reading in a ''proper'' format texture file from your art package.
OpenGL allows you to pass it one big unwound array of all the RGB(A) triples. So multidimensional arrays are not necessary.
Check out my site for a .raw loader and a .tga loader
Try www.wotsit.org for more info all different file formats.
Paul Groves
pauls opengl page
paul's opengl message board
OpenGL allows you to pass it one big unwound array of all the RGB(A) triples. So multidimensional arrays are not necessary.
Check out my site for a .raw loader and a .tga loader
Try www.wotsit.org for more info all different file formats.
Paul Groves
pauls opengl page
paul's opengl message board
Paul Grovespauls opengl page
Well, The texture maps are arrays, being output from my fractal terrain generator. So I would have to write the values to an image format. I need the texture map to first make a very detailed texture of the landscape and then decrease the detail of the landscape and paint it with the texture so it looks like high-detail terrain. The method of passing an array to a file and just read that in as a texture seemed the most simple to me.
Any suggestions?
Greats, Rob Koster!
Any suggestions?
Greats, Rob Koster!
i recommend the png format, it does everything
dont know the url of the top of me head but have a search for glpng http://www.wyatt100.freeserve.co.uk/download.htm
"This is a library for OpenGL to load PNG graphics files as an OpenGL texture as easily as possible. It also has a number of options for generating the alpha channel and mipmaps. It is implemented using modified versions of the LibPNG 1.0.2 and ZLib 1.1.3 libraries.
"
an example , its that easy
GLuint id = pngBind("Texture.png", PNG_NOMIPMAP, PNG_SOLID, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);
Edited by - zedzeek on September 7, 2000 7:05:21 AM
dont know the url of the top of me head but have a search for glpng http://www.wyatt100.freeserve.co.uk/download.htm
"This is a library for OpenGL to load PNG graphics files as an OpenGL texture as easily as possible. It also has a number of options for generating the alpha channel and mipmaps. It is implemented using modified versions of the LibPNG 1.0.2 and ZLib 1.1.3 libraries.
"
an example , its that easy
GLuint id = pngBind("Texture.png", PNG_NOMIPMAP, PNG_SOLID, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);
Edited by - zedzeek on September 7, 2000 7:05:21 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement