471,336 Members | 1,239 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

directx questions

Hi,

I'm a noob trying to use managed DirectX (VC# 2003, DX9.0 Apr 2005 SDK). I
used to use OpenGL with QT and VC++6.0, but I was a relative newcomer to
that as well.

When I used OpenGL, my understanding was that if you used display lists,
your vertices would normally be held in memory on the video card. Now, with
managed DirectX, I am looking at code that looks like this:

public void OnCreateVertexBuffer(object sender, EventArgs e)
{
VertexBuffer vb = (VertexBuffer)sender;
CustomVertex.PositionColored[] verts =
(CustomVertex.PositionColored[])vb.Lock(0,0);
verts[0].X=-1.0f; verts[0].Y=-1.0f; verts[0].Z=0.0f; verts[0].Color =
System.Drawing.Color.DarkGoldenrod.ToArgb();
verts[1].X=1.0f; verts[1].Y=-1.0f ;verts[1].Z=0.0f; verts[1].Color =
System.Drawing.Color.MediumOrchid.ToArgb();
verts[2].X=0.0f; verts[2].Y=1.0f; verts[2].Z = 0.0f; verts[2].Color =
System.Drawing.Color.Cornsilk.ToArgb();
vb.Unlock();
}

private void Render()
{
if (device == null)
return;
if (pause)
return;
//Clear the backbuffer to a blue color
device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
//Begin the scene
device.BeginScene();
// Setup the world, view, and projection matrices
SetupMatrices();
device.SetStreamSource(0, vertexBuffer, 0);
device.VertexFormat = CustomVertex.PositionColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
//End the scene
device.EndScene();
device.Present();
}

Now, this code takes it's vertices from the Stream Source (the vertexBuffer)
which is in main CPU memory. I'm guessing these vertices have to cross the
bus to the video card, and then they are displayed. That sounds slower than
OpenGL display lists! Is there something in managed DirectX like an OpenGL
display list where the vertices are held in video card memory?

Thanks in advance,
Aaron Lovi
su*****@pokervillain.com

Jul 21 '05 #1
1 1822
I'm not sure what makes you think so. What matters is in which pool
(Pool.Default is the video memory) you created the vertex buffer...

If this is filling an array, see the Lock/Unlock pair as a download/upload
mechanism from/to video memory (if the vb was created there).

If this is because the "vertexBuffer is in main CPU memory", don't confuse
the "programming model" with the "real thing". The object that represents a
File is in system memory but it still *represents* or *symbolizes* something
that is actually stored on disk. The object itself is not the real thing -
we would need a philosopher here ;-)

For future questions, I strongly suggest :

microsoft.public.win32.programmer.directx.managed

Patrice

--

"Aaron Lovi" <su*****@pokervillain.com> a écrit dans le message de
news:QBJpe.1605688$6l.951247@pd7tw2no...
Hi,

I'm a noob trying to use managed DirectX (VC# 2003, DX9.0 Apr 2005 SDK). I used to use OpenGL with QT and VC++6.0, but I was a relative newcomer to
that as well.

When I used OpenGL, my understanding was that if you used display lists,
your vertices would normally be held in memory on the video card. Now, with managed DirectX, I am looking at code that looks like this:

public void OnCreateVertexBuffer(object sender, EventArgs e)
{
VertexBuffer vb = (VertexBuffer)sender;
CustomVertex.PositionColored[] verts =
(CustomVertex.PositionColored[])vb.Lock(0,0);
verts[0].X=-1.0f; verts[0].Y=-1.0f; verts[0].Z=0.0f; verts[0].Color =
System.Drawing.Color.DarkGoldenrod.ToArgb();
verts[1].X=1.0f; verts[1].Y=-1.0f ;verts[1].Z=0.0f; verts[1].Color =
System.Drawing.Color.MediumOrchid.ToArgb();
verts[2].X=0.0f; verts[2].Y=1.0f; verts[2].Z = 0.0f; verts[2].Color =
System.Drawing.Color.Cornsilk.ToArgb();
vb.Unlock();
}

private void Render()
{
if (device == null)
return;
if (pause)
return;
//Clear the backbuffer to a blue color
device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
//Begin the scene
device.BeginScene();
// Setup the world, view, and projection matrices
SetupMatrices();
device.SetStreamSource(0, vertexBuffer, 0);
device.VertexFormat = CustomVertex.PositionColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
//End the scene
device.EndScene();
device.Present();
}

Now, this code takes it's vertices from the Stream Source (the vertexBuffer) which is in main CPU memory. I'm guessing these vertices have to cross the bus to the video card, and then they are displayed. That sounds slower than OpenGL display lists! Is there something in managed DirectX like an OpenGL display list where the vertices are held in video card memory?

Thanks in advance,
Aaron Lovi
su*****@pokervillain.com

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Dr Paul A Daniels | last post: by
6 posts views Thread by Tim Bücker | last post: by
3 posts views Thread by chapmjw | last post: by
1 post views Thread by Aaron Lovi | last post: by
9 posts views Thread by john andrew | last post: by
6 posts views Thread by poldoj | last post: by
14 posts views Thread by Jessica Weiner | last post: by
3 posts views Thread by Abdul Azeez(BLR) | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.