Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Please Help!!!

This topic is 6176 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

The project I am working on seems to be more choppy than the projects I have made. I think the problem is that with this project I am drawing everything to an off-screen surface, then blt'ing it to the back-buffer, then flipping it. I do have a reason for doing this though!! I put an alpha blending function into my program (it is 2D in dx7 by the way), here is the code:
void CDDLayer::BltAlpha(RECT *DestRect, 
                        SDDS *DDSSrc, 
                        RECT *SrcRect, 
                        BYTE factor, 
                        bool clear, 
                        bool ckey)

	if (ckey)
		DDSTexture->Blt(&RTexture, DDSRender, DestRect, 0, NULL);
		DDSTexture->Blt(&RTexture, DDSSrc->DDS, SrcRect, DDBLT_KEYSRC, NULL);
		DDSTexture->Blt(&RTexture, DDSSrc->DDS, SrcRect, 0, NULL);

	D3DTLVERTEX Square[4];
	Square[0] = D3DTLVERTEX(D3DVECTOR(D3DVAL(DestRect->left), D3DVAL(DestRect->top), 0.0), 
                                1.0, RGBA_MAKE(255, 255, 255, factor), 0, 0, 0);
	Square[1] = D3DTLVERTEX(D3DVECTOR(D3DVAL(DestRect->right), D3DVAL(DestRect->top), 0.0), 
                                1.0, RGBA_MAKE(255, 255, 255, factor), 0, 1, 0);
	Square[2] = D3DTLVERTEX(D3DVECTOR(D3DVAL(DestRect->left), D3DVAL(DestRect->bottom), 0.0), 
                                1.0, RGBA_MAKE(255, 255, 255, factor), 0, 0, 1);
	Square[3] = D3DTLVERTEX(D3DVECTOR(D3DVAL(DestRect->right), D3DVAL(DestRect->bottom), 0.0), 
                                1.0, RGBA_MAKE(255, 255, 255, factor), 0, 1, 1);

	if (clear)
		D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);


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

	D3DDevice->SetTexture(0, DDSTexture);

	hRet = D3DDevice->BeginScene();
	if (hRet == D3D_OK)
		D3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, Square, 4, 0);
I wanted a way to use a color key AND do alpha blending at the same time, so what I did, I decided to copy the destination rectangle for the picture to the texture surface and then blt the picture on the texture surface using the colorkey, that way the color keyed parts of the surface aren't replaced. The reason I used an off-screen surface to render to is because I couldn't seem to get the program to blt to the texture surface FROM the back buffer. The performance of my program is noticibly dropping because of this (probably mostly due to the addition of another large blt every frame from the render surface to the back buffer). How can I speed this up? Is it possible to blt from the back buffer to an off-screen? Is there another way I can do alpha blending AND color keying at the same time? Please reply!!! Thanks! Edited by - alex5 on June 26, 2001 8:33:10 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!