Jump to content
  • Advertisement
Sign in to follow this  
iu1005

Direct3D+Bitmaps

This topic is 3892 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!