Sign in to follow this  
iu1005

Direct3D+Bitmaps

Recommended Posts

I need to draw a 3D cube with high resolution images(1280*1024) on each side. Each image had to be half-transparent, so we would see all sides of the cube. And i need update(load) every image from bitmap on each render. I tried to use Direct3D (but it is no metter for me, what technologe i'll use), and i have some problems: 1. Loading Bitmap as texture takes too mach time - 100ms for each image, and help says, that device.GetSurfaceLevel(0).GetGraphics() cann't work with textures with alpha-channel. So, how else? Or maby my approach is wrong and I should do it another way? 2. Original bitmap isn't transparent, and to read and to set alpha for each pixel it is too long. I don't know, how to tell direct3D to draw whole image with specified transparency. P.S. Please, sorry if there were some mistakes. English is not my native language...

Share this post


Link to post
Share on other sites
Can't help with question one, but as far as question two goes, as long as your vertex structure has a diffuse colour e.g:


struct Vertex
{
float X,Y,Z,Rhw; DWORD Color; float U,V;
};

const DWORD D3DFVF_Vertex=(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1);


and you set up your renderstates like:


Dev->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
Dev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
Dev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

Dev->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);


Then you can control the alpha of an entire textured polygon by setting the alpha of the colour components of its vertices as well as by per-pixel alpha information in the texture.

HTH

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