Surface and Texture Formats

Started by
5 comments, last by erejam 21 years, 11 months ago
hi erveryone, i am relatively new to DX and i am a little confused about Formats. Which texture formats can i render to which surface fomats? Can i render a D3DFMT_A8R8G8B8 texture to a D3DFMT_A1R5G5B5 surface, or ARGB_4444 texture to ARGB_1555 surface or ARGB_1555 texture to ARGB_8888 surface. If possible, are there any flaws or reasons not to use not equal surfaces and textures? Till now i made everything with ARGB_1555 but now i could need a way to do alpha blending with 256 levles on pixel base. How can this be acomplished with ARGB_1555? Multitexturing? thx for any help
Advertisement
That can''t be accomplished at all. That''s the reasons there''s different texture formats. One format may be more suitable than others in a certain case. Also, there''s the quality-memory tradeoff. And not all cards support all formats.

What do you mean by "render to" a surface? Do you mean you''ve set up your backbuffer in that format? If so, then yes, it''s possible. The number of alpha levels is determined only by the texture format. If that is what you mean, you should probably stop what you are doing. Except in extremely rare case, you have no need for alpha in your backbuffer, so get rid of it.

Kippesoep
I am trying to put some text on the screen with DX 8.1. I set up a ''dynamic'' vertex buffer with trianglelists to produce rectangles which are textured with the correct character. (using DrawPrimitive)
I was testing with ARGB_565 surface and one ARGB_8888 Font texture. Everything is fine as long as i not use more than 2 primitives. As soon i give the DrawPrimitive 4 or more prmitives to render there is nothing to see at all. With one ARGB_4444 Font Texture it was not possible to render anything to the screen (or i am making some faults).
The reason for needing 256 alpha channels is, i have font information with 256 gray levels. So a value of 256 means ''black'' and a value of 128 means half font, half dest pixel value. I know i can use the material to assign a alpha value for the whole texture on it, but how can i make alpha information for every texel on the polygon?
Perhaps i should just use monochrome fonts, but first i want to try everything ...
Sounds like there''s something wrong with your DrawPrimitive call.
Using A4R4G4B4 should work for what you''re doing (although it does, of course, reduce alpha levels to 16), but A8R8G8B8 is better.
So for your texture you need per pixel alpha.
Not for your backbuffer (which, I still assume, is the "surface" you''re referring to).

Kippesoep
Yes, the ''surface'' i am refering to is the backbuffer.
So it is possible to use RGB_565 Backbuffer and ARGB_4444 or ARGB_8888 textures together.
ok, i''m going to debug my code...
thx Kippesoep
i found the error! :D
The font texture was created with 240x240 dimensions. changing to 256x256 made it possible to render the argb_4444 texture.
I wonder if there are some ''optimal'' texture sizes for different graphic cards.
quote:Original post by erejam
I wonder if there are some ''optimal'' texture sizes for different graphic cards.

There are ''allowed'' texture sizes, and those must have width and height equal to powers of two (32, 64, etc.).

Also, it seems that you''re not using the debug DX runtime. Check other threads here for a discussion of what it is, how to turn it on, and why you should use it.
---visit #directxdev on afternet <- not just for directx, despite the name

This topic is closed to new replies.

Advertisement