473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 2001
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dr Paul A Daniels | last post by:
I've got Visual Studio 7.0.9466 and have installed the Framework 1.1 and its SDK and DirectX 9.0 (Summer 2003 release) SDK. OS is Windows XP Pro. I'm logged on with Administrator rights. I...
6
by: Tim Bücker | last post by:
Hello. What is the best to use? DirectDraw from DirectX 7.0 or Direct3D from DirectX 8.0 when the only thing one wants to do is to draw bitmaps fast on the screen in fullscreen mode. I think...
3
by: chapmjw | last post by:
I'm looking for an C# example of a form with a picture box that Directx can draw to. My program plots the flight of a golf ball and I need to do it realtime. I would like to keep as a child window...
1
by: Aaron Lovi | last post by:
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...
9
by: john andrew | last post by:
-- hello is their much difference in using directx8 compared to directx9 in graphics programming or gaming.? I cant find this information on this website
6
by: poldoj | last post by:
Its possible to get directX working with vb.net? I have heard something about "managed code", where I can find more infos? thanks
14
by: Jessica Weiner | last post by:
I am writing an application in C# which need to plot graphs and simple shapes (polygons, circles, squares etc). Which library is better for this purpose and why? Thanks.
3
by: Abdul Azeez(BLR) | last post by:
Hi, I need to use DirectX in my application for drawing the network diagram. May I know the procedure to draw a Graph( Rectangular boxes connected with straight lines) using DirectX. Could you...
3
by: Edward Mitchell | last post by:
I am converting a project that uses DirectX and worked under VS.NET 2003. Now when I convert the project to .NET 2005, there are linker errors for _Xran and _Xlen as follows: ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.