PCX in OGL
You might want to take look at OpenIL. This library will load and save a variety of different formats, and it''s open source. So, you could use it, or it might help you write your own.
Take Care,
Nyko
Take Care,
Nyko
OpenGL by itself doesn''t have any file formats... all it can do is give you pixels. Using this feature, you can then write your own image saving function or you can use something like OpenIL.
If you want info on saving the images yourself, I suggest you check out www.wotsit.org.
Btw, where abouts in NSW do ya live?? I''m in Sydney.
If you want info on saving the images yourself, I suggest you check out www.wotsit.org.
Btw, where abouts in NSW do ya live?? I''m in Sydney.
Protozone
I assume you want to load .PCX files as textures in OpenGL... This is the first file format I used for my textures... I''ll tell you real quick how I got them to work as textures...
First off, you''ve gotta get some info on the .pcx file format... It''s not too difficult to find code around, or a very good reference on decoding the files... Remember, .pcx usually does 8-bit storage, so you''ll have to convert each of the pixels in the data buffer storing the image into 32-bit using the palette as a reference... This is done by creating a byte array with a size of 4 times the height and width of the image. For every pixel in the original source buffer access the appropriate palette color definition''s R G and B values, and write them into buffer as bytes, followed by an alpha value (255 for no transparency)... I can''t remember if it''s RGBA, or ARGB... Just put the alpha in the right spot... The code would look something like this:
for(int i = 0; i < width * height * 4; i += 4) {
byte colorIndex = pcxBuffer * 3;<br> <br> dest<i> = pcxPalette[colorIndex];<br> dest = pcxPalette[colorIndex + 1];<br> dest = pcxPalette[colorIndex + 2];<br> dest = 255; // alpha value either goes first or last.<br><br> } // ends for loop<br><br>You then pop this buffer in as your source for your source buffer for texture maps…<br><br>Good Luck!!! </i>
First off, you''ve gotta get some info on the .pcx file format... It''s not too difficult to find code around, or a very good reference on decoding the files... Remember, .pcx usually does 8-bit storage, so you''ll have to convert each of the pixels in the data buffer storing the image into 32-bit using the palette as a reference... This is done by creating a byte array with a size of 4 times the height and width of the image. For every pixel in the original source buffer access the appropriate palette color definition''s R G and B values, and write them into buffer as bytes, followed by an alpha value (255 for no transparency)... I can''t remember if it''s RGBA, or ARGB... Just put the alpha in the right spot... The code would look something like this:
for(int i = 0; i < width * height * 4; i += 4) {
byte colorIndex = pcxBuffer * 3;<br> <br> dest<i> = pcxPalette[colorIndex];<br> dest = pcxPalette[colorIndex + 1];<br> dest = pcxPalette[colorIndex + 2];<br> dest = 255; // alpha value either goes first or last.<br><br> } // ends for loop<br><br>You then pop this buffer in as your source for your source buffer for texture maps…<br><br>Good Luck!!! </i>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement