flickering skybox (newb question)
- From: "Aaron Lovi" <AaronLovi@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 6 Nov 2005 08:35:36 -0800
Hi, I'm using C# from Visual Studio 2003 and DX9 for this. Basically, I just
created a skybox into a panel control on a windowed form, and I'm rotating
it. The rotation is done by a timer that goes off every 50ms, and increases
the "dblAngle". The problem is that there is a lot of flicker. (I hope I'm
posting enough info. If not, please tell me what else to post!)
------------------------------------------
Here is how I'm setting my presentParams:
presentParams.Windowed=true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.BackBufferFormat = Format.X8R8G8B8;
presentParams.BackBufferHeight = this.Height;
presentParams.BackBufferWidth = this.Width;
presentParams.BackBufferCount = 3;
presentParams.PresentationInterval = PresentInterval.Default;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
device = new Device(0, DeviceType.Hardware,
this.panelMain, CreateFlags.HardwareVertexProcessing, presentParams);
------------------------------------
Here is how I'm setting up my matrices:
device.Transform.World = Matrix.Identity;
// dblAngle is incremented by a timer going off every 50ms
device.MultiplyTransform(TransformType.World, Matrix.RotationY(dblAngle));
device.Transform.View = Matrix.LookAtLH( new Vector3( 0.0f, 0.0f, 0.0f ),
new Vector3( 0.0f, 0.0f, 400.0f ), new Vector3( 0.0f, 1.0f, 0.0f ) );
device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI/4.0f,
(float)this.Width/(float)this.Height, 1.0f, 500.0f );
----------------------------------------------------------
Here is my render:
private void Render()
{
if (device == null) return;
try
{
//Clear the backbuffer to a Green color
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer,
System.Drawing.Color.Green, 1.0f, 0);
//Begin the scene
device.BeginScene();
// Setup the world, view, and projection matrices
SetupMatrices();
device.VertexFormat = CustomVertex.PositionColored.Format;
device.SetTexture(0, null);
device.SetStreamSource(0, vbTerrain, 0);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
// draw the skybox
this.dxSkyBox.Render(device);
//End the scene
device.EndScene();
device.Present();
}
catch (DeviceLostException)
// etc.
--
Aaron Lovi,
Poker Villain support
support [at] pokervillain.com
.
- Follow-Ups:
- RE: flickering skybox (newb question)
- From: Alex C. Barberi
- Re: flickering skybox (newb question)
- From: Zman
- Re: flickering skybox (newb question)
- From: Cyril Dex
- RE: flickering skybox (newb question)
- Prev by Date: Custom EffectStateManagers causes huge amount of memory allocations!
- Next by Date: Re: Plot pixels - newbie Q
- Previous by thread: Custom EffectStateManagers causes huge amount of memory allocations!
- Next by thread: Re: flickering skybox (newb question)
- Index(es):