Hey, I'm having the wierdest of issues plotting pixels... here is the
code:
private void InitializePoints()
{
Random rand = new Random();
numberOfPrims = 2000;
m_random_data = new CustomVertex.TransformedColored[numberOfPrims];
int zeroCount = 0;
for (int count=0;count < numberOfPrims;count++)
{
m_random_data[count].X=rand.Next(this.Width);
m_random_data[count].Y=rand.Next(this.Height);
m_random_data[count].Z=rand.Next(0, 2);
//m_random_data[count].Z=1.0f;
m_random_data[count].Rhw=1.0f;
m_random_data[count].Color = Color.Violet.ToArgb();
}
}
private void Render()
{
long startFrameTime = hpTime.CurrentTime;
device.Clear(ClearFlags.Target, Color.Black.ToArgb() , 1.0f, 0);
device.BeginScene();
device.VertexFormat= CustomVertex.TransformedColored.Format;
device.DrawUserPrimitives(PrimitiveType.PointList,
numberOfPrims,
m_random_data);
device.EndScene();
device.Present();
//Control execution time by waiting at least 10 milliseconds
float elapsedTime = (hpTime.CurrentTime - startFrameTime) /
hpTime.TicksPerMs;
while( elapsedTime < 10 )
{
elapsedTime = (hpTime.CurrentTime - startFrameTime) /
hpTime.TicksPerMs;
}
}
In the InitializePoints function I fill an array of
CustomVertex.TransformedColored structures. The problem is with the Z
dimension. As you can see there is a commented out line that sets all
the pixels Z to 1.0f. This is the recomendation of the tutorial I
started with and what makes sense to me. However, when I specify this
value the screen is blank. The program does not throw any exceptions
but seemingly runs fine, except ofcourse that it doesn't seem to draw
the pixels. The line thats uncommented sets the Z dimension to either 0
or 1. The ones set to 0 display; I've tested this by lowering the
number of primitives down to 10 and outputing the result of the random
and adding up how many I see and how many 0's or 1's were set. I tried
setting all the pixels Z dimension to 0.0f (and just 0) but that has
the same result as setting it to 1.0f, nothing.
Actually thats not true, when i lower the primitives to 24 or less and
set the Z dimension to 0.0f, it works. 25 or more and nothing. When I
set the number of primitives to 2000 and use the random (resulting in
either 0 or 1), it usually produces something like 1700 pixels with
z=0, and all of these pixels display.
Can someone give me some guidance, this is blowing my mind. :! Try
testing the code yourself if that helps. If you get it to work...
please let me know.
I'm using dx 9.0c and the following device setup:
private void InitializeDevice()
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = false;
presentParams.BackBufferFormat = Format.X8R8G8B8;
presentParams.BackBufferHeight = this.Size.Height;
presentParams.BackBufferWidth = this.Size.Width;
presentParams.PresentationInterval = PresentInterval.Immediate;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
presentParams.EnableAutoDepthStencil = true;
device = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing, presentParams);
}
Thank you for your time.
[Edited by - demiurgeinc on March 15, 2005 7:13:48 AM]