[Solved] Everything suddenly renders white

Started by
-1 comments, last by djr 16 years, 2 months ago
Hi I've got a real head-scratcher of a problem with MDX. I was trying out an idea using a couple of DrawUserPrimitives - one call to draw a single red triangle, another for a load of white dots. I was using a really simple effect but due to other issues (like nothing showing up) I ended up switching to the fixed function pipeline. Everything was working fine until suddenly the triangle started being rendered white instead of red, and now despite going through my whole program making sure nothing uses white it still renders the points and triangle in white despite them being set to other values. The setup code I'm using for the primitives is this:

int nPoints = 360 * 180;

points = new CustomVertex.PositionColored[nPoints];
int index = 0;
for (int y = 90; y > -90; y--)
{
	for (int x = -180; x < 180; x++)
	{
		VectorD3 pos = MathEx.SphericalToCartesian((double)y, (double)x, Simulation.Core.Earth.EquatorialRadiusKm);
		VectorD3 cartesian = pos;
					
		points[index].X = (float)cartesian.X;
		points[index].Y = (float)cartesian.Y;
		points[index].Z = (float)cartesian.Z;
		points[index].Color = Color.Red.ToArgb();

		index++;
	}
}


debugTri = new CustomVertex.PositionColored[3];

VectorD3 posdt = MathEx.SphericalToCartesian(37, 6, Simulation.Core.Earth.EquatorialRadiusKm);

debugTri[0].X = (float)posdt.X;
debugTri[0].Y = (float)posdt.Y;
debugTri[0].Z = (float)posdt.Z;
debugTri[0].Color = Color.Yellow.ToArgb();

posdt = MathEx.SphericalToCartesian(37, 7, Simulation.Core.Earth.EquatorialRadiusKm);
debugTri[1].X = (float)posdt.X;
debugTri[1].Y = (float)posdt.Y;
debugTri[1].Z = (float)posdt.Z;
debugTri[1].Color = Color.Green.ToArgb();

posdt = MathEx.SphericalToCartesian(36, 6, Simulation.Core.Earth.EquatorialRadiusKm);
debugTri[2].X = (float)posdt.X;
debugTri[2].Y = (float)posdt.Y;
debugTri[2].Z = (float)posdt.Z;
debugTri[2].Color = Color.Blue.ToArgb();


and the rendering code:

// Render a frame during idle time (no messages are waiting)
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer | ClearFlags.Stencil, Color.Blue, 1.0f, 0);

device.BeginScene();

device.RenderState.ZBufferEnable = true;
device.RenderState.ZBufferWriteEnable = true;
device.RenderState.ZBufferFunction = Compare.LessEqual;
device.RenderState.CullMode = Cull.None;
device.RenderState.FillMode = FillMode.Solid;
device.RenderState.ShadeMode = ShadeMode.Gouraud;
device.RenderState.Lighting = false;
				
					
device.Transform.World = Matrix.Identity;
device.Transform.View = camera.ViewMatrix;
device.Transform.Projection = camera.ProjectionMatrix;

device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, debugTri);

device.DrawUserPrimitives(PrimitiveType.PointList, 360 * 180, points);

font.DrawText(null, camera.Position.ToString(), new System.Drawing.Point(10, 100), Color.Yellow);

device.EndScene();
device.Present();


Anyone got any ideas? I've also reset my machine, reinstalled the runtimes, run other MDX and native DX apps and they're all fine but still this app resists (and I'm at a total loss as to how one execution it worked and the next it didn't when I didn't touch any of the code associated with it). BTW this is on Vista32 with a Geforce 8800GTS 320 and 169.25 drivers if it makes any difference... Cheers [Edited by - djr on February 3, 2008 4:16:22 AM]

This topic is closed to new replies.

Advertisement