How to FadeIn/FadeOut Manged DirectX3d

LDV

Freshman
Joined
Dec 29, 2003
Messages
31
Hi Guys,

Any ideas how to create a full screen fadein / fadeout in Managed DirectX3d?

Thanks.
 
Hey,

Thank you all guys... as i understood correctly..
I'm building a black full screen texture and paste it over the current screen playing with it's alpha value.

I haven't tried it yet - but it should work.

Thanks.
 
DrunkenHyena said:
You can save memory by skipping the texture. Just use a quad (2 triangles) and set their diffuse colour to black. Fiddle with the alpha and you're set.

Pardon me for asking, but how do i do that. I mean creating the traingles. Untill now i used only Textures and Surfaces with the Sprite class or UpdateSurface. :-\

I have the Device3D, and i have the back buffer surface.

Thanks, LDV.
 
Create a VertexBuffer, an array of vertices. Fill the vertices with data and set data to the VertexBuffer. Check the documentation. Although it's scarce I think there's a howto about this.
 
More problems ...

Ok, Guys, Thanks i did it.

But there is still a problem.
If i draw somethings uding .UpdateSurface or .StrechRectangle the quad shows transpernet on them. - that's OK.
But if i draw something using the Sprite object (Yes - with Alpha flags) it draw over the Quad, and i can not see the transpernt quad.

Maybe it's something for the order i do the:
m_sprite.Begin(SpriteFlags.AlphaBlend);??

Or maybe it's something using the .Z property??

Here is some code:
The Vertex:
m_device.RenderState.CullMode = Cull.None;
m_device.VertexFormat = CustomVertex.PositionColored.Format;

m_vertexFade = new VertexBuffer(typeof(CustomVertex.PositionColored), 6, m_device, 0, CustomVertex.PositionColored.Format, Pool.Default);
CustomVertex.PositionColored[] fverts = (CustomVertex.PositionColored[]) m_vertexFade.Lock(0, 0);
fverts[0] = new CustomVertex.PositionColored(0, 0, 1, m_clrFade.ToArgb());
fverts[1] = new CustomVertex.PositionColored(0, 768, 1, m_clrFade.ToArgb());
fverts[2] = new CustomVertex.PositionColored(1024, 768, 1, m_clrFade.ToArgb());

fverts[3] = new CustomVertex.PositionColored(0, 0, 1, m_clrFade.ToArgb());
fverts[4] = new CustomVertex.PositionColored(1024, 0, 1, m_clrFade.ToArgb());
fverts[5] = new CustomVertex.PositionColored(1024, 768, 1, m_clrFade.ToArgb());
m_vertexFade.Unlock();

The drawing of the obeject with Sprite object:
sprite.Draw(m_texture, m_rect[num], new Vector3(0, 0, 0), new Vector3(x, y, 0.5F), Color.FromArgb(255, 255, 255, 255));

Thank you all in advance, LDV
 
First, DrunkenHyana i want to thank you for your truely help.

I tried to set them all Z to 0, and i checked i draw the Preimitve after i draw the Sprite and it didn't help.

I found another thing that was the problem.

I called Sprite.Flush() before i draw the primetives - that made it almost ok.

There are two new problems now:
1. Somehow i don't get the full fae out now, i set it all to Alpha-255,RGB 0,0,0 and still it looks darker but now totally black - before - it was all black, except for the Sprite object ofcousre.
2. The program is much slower now.

Thanks, LDV
 
Back
Top