Skip to main content
gamedev.net
🔒 Locked

16 bit bitmaps

Started by Weston 1 reply 450+ views
Original Post
Weston
Weston
I''m finally learning DirectX 8.0 programming, and I''m now learning about textures. with each new chapter in the book I''m reading, I just get more questions to arise. I have a fullscreen application i want to run in 16 bit mode. However, I was going to use a 16 bit bitmap in the application but my image software doesn''t create that type of file. I may just decide to use 32 bit color in the end. I noticed that one of the programs in the book uses a 24 bit bitmap and uses it in a 32 bit environment. So do I even need to worry if the file type matches the color mode? I''m confused about all this, and any information about bitmaps and color modes would really help. somewhat off the topic, but I also want to develop a tile engine wuth Direct3D. In DirectDraw, I needed to blit the background first, then the foreground and finally flip the surface. But in Direct3D, it draws whatever I say relative to the position of the world and doesn''t care if I drew something first or last. How would I handle multiple layers in a tile map? If I put the first layer furthest from the viewpoint, I worry that the bitmaps will be scaled differently (shrunk) and that the top layer would be enlarged because it''s closer. I''m probably way off on how this is done, so just give me a quick explaination on how multiple layer tile maps work in 3D Lastly, does anybody know of a good tile game in the GD Showcase that uses DirectX 8.0 Direct3D for the graphics?
---Will DDR for food.
Namethatnobodyelsetook
Namethatnobodyelsetook
You don''t have to match color depths, but there are some things to be aware of:

In 32 bit modes, it can be faster to use 16, and/or 8 bit textures. This is because there is less data to fetch. For example, greyscale images can be loaded as L8 (luminance, ie: r=g=b=l, a=1), P8 (paletted), or X8R8G8B8 depending on your hardware. Each will produce a perfect 256 level grey image. Whether that''s an 8 bit image, or 32 bit, is partly your problem as a developer, and partly the end user''s problem based on what card they have. Similarly, 256 level alpha masks could be loaded as A8, or P8, or A8L8, or A8R8G8B8 depending on what your hardware supports.

Even for color images, if you don''t require subtle gradients in the source texture, use a 16 bit (A1R5G5B5, X1R5G5B5, R5G6B5) texture. You save GPU memory, and precious clock cycles. Most of your subtle gradients are going to come from lighting most likely anyway, and the source bitmap''s depth doesn''t matter.

In 16 bit modes you may want to use 32 bit images. Lets say you have a fullcolor image with alpha. You want this to be a single texture. You want to mix this image with another image. Your options for the first image are A4R4G4B4 (which most card''s can''t do), A1R5G5B5 (only 1 bit of alpha, and limited color), or A8R8G8B8, which gives plenty of alpha and color information to blend with.

Then again, most times you don''t want to blend the texture with anything, in which case anything over 16 bit would be wasteful.

Look into using DDS textures with the DXTn formats. They are compressed, and most modern hardware knows how to deal with them. They save both RAM and bandwidth. If your hardware doesn''t know how to deal with DXT, D3DXCreateTextureFromFile[InMemory][Ex] decompresses them for you. Some images may look bad as DXT (it IS lossy), so keep those images 16, or 32 bit.

Anyway, there are no short answers. Every project is different. But you don''t have to worry about matching formats.


About the tiles: If you create an Ortho projection matrix, no depth scaling will occur. Another option, if you''ve already got your DDraw engine going, is to disable the Z buffer (or not make one in the first place), and draw all the objects back to front just like you used to.

The advantage of the depth buffer and orthogonal projection is that you can batch together several sets of tiles at several depths and draw them at once, then switch textures, and drawing all tiles that need the new texture in the next draw call. Don''t worry about batching yet, just be aware that there is something to learn once you''re past the basics, which can provide a nice speed boost.

Any tiles that have semi-transparent parts must be draw back to front for alpha blending to work correctly. This is something the depth buffer can''t help you out with. (Blended with alpha 0, or alpha 255 is fine, but blending with alpha of 10, 50, 127, etc. are potential problems)
Weston
Weston
Wow... that''s a load of helpful information. I think that pretty much covers what I needed to know. so color loss won''t be a problem with mixing formats then? Well, thank you for that response! I''m going to have to print it out.
---Will DDR for food.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.