Skip to main content
gamedev.net
🔒 Locked

wireframe presentation using dx8

Started by radix 2 replies 400+ views
Original Post
radix
radix
hi there. i just posted this but it somehow didn''t work. so i do it again =) i''m relatively new to graphics programming using dx. now i want to convert the examples done in a course in unversity from java to dx (vc++). the first task is to present a wireframe from a polygon model data file (PLG format if anyone knows that). i''ve played a bit with the examples from the dx sdk tutorials and they help a lot. but i cannot find out how to just use dx to present a polygon model or at least a simple polygon consisting if three vertices as a wireframe. i don''t wanna have that polygon filled or anything. just the borders in plain old white. simply a wireframe. in the dx sdk tutorials they use // A structure for our custom vertex type struct CUSTOMVERTEX { FLOAT x, y, z; // The untransformed, 3D position for the vertex DWORD color; // The vertex color }; // Our custom FVF, which describes our custom vertex structure #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE) as the vertex buffer. after that they fill it with their data and finish up by calling // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 ); could anyone tell me in what way i should fill the vertex buffer? what FVF should i use? how to use the DrawPrimitive function of the dx device? all of these question concering simple wireframe presentation. i''d appreciate any help. greetings. radix.
----------------- [GSS]radix-----------------
radix
radix
lol. answering my own topic =)

well i just found out something concerning the vertex buffer. in an example using the famous teapot i have 530 vertices and 1024 polygons.

i just finished it using filled polygons and it works. but it seems to me that there must be a better way to do it. if i use the vertex buffer to draw polygons by calling

lpD3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, nPolygons )

the vertex buffer is 3 times the size of the number of polygons (as there are three vertices per polygon). that way a lot of vertices are many times in the buffer. is that the normal way? to me this is a waste of memory.

if i wanted to draw a wireframe model of that teapot using

lpD3DDevice->DrawPrimitive( D3DPT_LINELIST, 0, n )

the vertex buffer had to be even bigger. so now i know how to draw the wireframe model but i think that way it''d be very complicated. i''d have to fill the vertex buffer different each time i want to render a different way.

any solutions?
----------------- [GSS]radix-----------------
DefCom
DefCom
My friend showed me this the other day when i asked him the same question, it goes in your render function.

//set model in world space
m_pd3dDevice->SetTransform(D3DTS_WORLD, &matLocal );
//Render as wireframe
m_pd3dDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
Mephs
Mephs
One thing to bear in mind with that method of course is that the "wires" in wireframe take on the colour of the polygon, so textured polygons will lead to textured lines, blank white polygons will give white lines, just in case that''s of any consequence to you.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.