Sign in to follow this  
david_watt78

gui rendering

Recommended Posts

what is the best method for rendering gui components in d3d9? I am trying using textures to render it in billboard fashion using squares but using odd sized textures seems to be trouble.

Share this post


Link to post
Share on other sites
Use only power-of-two textures, and put your gui graphics into pow2 texture atlasses. The easiest way to render GUI is by using ID3DXSprite9 interface - it takes care of batching for you. However, it's difficult to get it to work along side vertex and pixel shaders (because you need to figure out what projection matrix it uses in order to correctly transform verts in the vertex shader), so it may be less suitable for anything besides GUI rendering. Certain effects, such as per-vertex color blend/alpha blend, are impossible to achieve directly with D3DXSprite.

Share this post


Link to post
Share on other sites
If you don't need any special effects for the GUI just paste all your odd sized textures into one power of two sized texture then when using D3DXSprite you can specify which parts of the texture go where.

Share this post


Link to post
Share on other sites
So far the problems I see are all caused by texture magnification or minification. I think I will just see if there is a way to alpha blend directly to the backbuffer from a surface.

Share this post


Link to post
Share on other sites
You can just set the mag/min filters to point, in which case extra pixels surrounding edges will not get sampled. This will also cause a pixellated look.

Why do you think alpha blending to the backbuffer will solve any of your problems?

Share this post


Link to post
Share on other sites
actually found my issue with the quad the bottom left uv was wrong. So I am using quads and 1/tan(fov/2) to find the distance where the screen is +-aspect ratio in x and +-1 in height to make screen coordinate translation easy. I am using textures that are nearest power of 2 and let the unused space be transparent. Its working nicely actually finally I have a vector based GUI that I wanted so I can easily create custom controls like I do with a regular windows app.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this