Sign in to follow this  
zeldatoothemax

Drawing simple lines in DirectX10?

Recommended Posts

Hi i have been searching around the Internet trying to find a answer to this simple question, all i can seem to find is people telling others to use IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_LINELIST ); and i did searches on that but cant understand its use, could anyone just give me a super quick example of drawing a line using this? i cant find a single example anywhere. thanks in advanced

Share this post


Link to post
Share on other sites
Its not that im having a problem getting it to work, im just still incredibly new to Directx, and for a while i was using directx9 but im completely in the dark when using 10 :(. would i just use the directx device function draw to draw the mesh, its the simple things im having trouble with, like i have already made my own camera class, and loaded 3d models, but its hard to find a good example or any info on simple things..

Share this post


Link to post
Share on other sites
So you currently have nothing drawing on-screen?

What are you having trouble with, specifically?

Here are the basic d3d10 tutorials:

http://msdn.microsoft.com/en-us/library/ee416410(VS.85).aspx

Share this post


Link to post
Share on other sites
I currently just have it drawing a simple 3d model ( a space ship), the ship has a bounding box, which is represented by 4 sets of cords(x,and z, or in a 2d plane x and y), all im trying to do is draw a box to be able to see this box, all i need is a simple example of drawing one line and i can figure out the rest.

Share this post


Link to post
Share on other sites
Well the thing is, the only way i have seen how to draw something like a triangle is with vertex buffers, and effect systems, is there no simpler way? i mean i just want to get a my two verticies and tell it to put a line in between, i understand what your are saying, and how this is supposed to work,
Like what is with all this crap

SimpleVertex vertices[] =
{
D3DXVECTOR3( 0.0f, 0.5f, 0.5f ),
D3DXVECTOR3( 0.5f, -0.5f, 0.5f ),
D3DXVECTOR3( -0.5f, -0.5f, 0.5f ),
};
D3D10_BUFFER_DESC bd;
bd.Usage = D3D10_USAGE_DEFAULT;
bd.ByteWidth = sizeof( SimpleVertex ) * 3;
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA InitData;
InitData.pSysMem = vertices;
if( FAILED( g_pd3dDevice->CreateBuffer( &bd, &InitData, &g_pVertexBuffer ) ) )
return FALSE;

// Set vertex buffer
UINT stride = sizeof( SimpleVertex );
UINT offset = 0;
g_pd3dDevice->IASetVertexBuffers( 0, 1, &g_pVertexBuffer, &stride, &offset );

why is all this necessary? in DX9 you could just use draw primitives and what not?

Share this post


Link to post
Share on other sites
I'm not sure exactly what you're comparing that code to, but maybe the biggest difference to you is that there's no more junky fixed-function pipeline stuff in D3D10. Everything is more programmable, so things are set up a little differently

Below I linked a decent rundown I found on the difference between using vertex buffers between D3D9 and D3D10. In reality the code is almost identical, looks like D3D10 needs a few extra lines of code here and there, but it's not that much.

APIs change - sorry ;) Part of programming is moving forward, it's all in the interest of progress!

http://members.gamedev.net/jhoxley/directx/DirectX10/VertexBuffersinDirect3D10.htm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this