Advertisement

16bit textures..

Started by April 27, 2001 10:07 AM
1 comment, last by panic 23 years, 7 months ago
Ok, I'm abit lost here.. I need to create a texture from an unsigned short [256*256] array. This is the same as a [256*256*2] byte array , I think.. I don't really understand how this works, since from what I can see only 2 pixel colors can be stored for the texture (wich is 256*256 pixels) I can export the texture to a 16bit TGA, and when opening in photoshop it has the correct RGB values and displays correct. when I export it I do: (after writing tga header)
      
fwrite((byte *)mMaterial[num]->mImage, sizeof(byte), 256*256*2, stream);

Where mMaterial[num]->mImage is a 256*256 unsigned short.
  
But this doesn't really have anything with my question to do, just some extra information It's when I try to create a texture from this data I get problems. I tried with:
  
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16, 256,256,0, GL_RGB, GL_UNSIGNED_SHORT, mMaterial[num]->mImage);
      
But that creates a grayscale texture wich is tiled and combined with textures wich comes after the current in the source file. Here's a screenshot that might explain better And this is how the texture looks like after beeing exported to tga the way I said earlier, and this is what I would like to have in openGL aswell. Thanks return 1; Edited by - panic on April 27, 2001 11:30:53 AM Edited by - panic on April 27, 2001 11:33:14 AM
From your export code, it looks like you''re writing it in 16bit format to the file, correct? And, after you load it all (still 16bit format):
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16, 256, 256,//                             ^Store as 16bit in Video Memory    0, GL_RGB, //     ^Read in in the format [R][G] (continued…)<br></font><br>    GL_UNSIGNED_SHORT, mMaterial[<font color="purple">num</font>]-&gt;mImage);<br><font color="gray">//  ^Of 16bits per part. So that''s 16R_16G_16B, 48bpp…<br></font><br>  </pre></font></td></tr></table></center><!–ENDSCRIPT–><br>That''s not what you want to do I assume. If I''m mistaken, then tell me <img src="smile.gif" width=15 height=15 align=middle>.    <br><br><a href="http://www.gamedev.net/community/forums/topic.asp?whichpage=1&pagesize=24&topic_id=41100"><IMG SRC="http://druidgames.warfactory.com/Out_Source/resist.jpg" BORDER=0 ALT="Resist Windows XP''s Invasive Production Activation Technology!"></A><br><A href="http://druidgames.cjb.net/">http://druidgames.cjb.net/</a>    
Advertisement
Nevermind, solved it.. had to write a 16bpp->24bpp converter and then create the texture using normal GL_RGB,,,GL_RGB
Every other way failed, tried with GL_RGB5 and so on, bute nothing seemed to work.



return 1;

Edited by - panic on April 28, 2001 7:40:35 AM

This topic is closed to new replies.

Advertisement