|
|
|
date: 11 May 2006 09:15:17 -0700,
group: microsoft.public.win32.programmer.directx.sdk
back
DirectX SDK - Vertex buffers
Hi there,
Newbie to directx, and wanted to know if was possible to build a vertex
buffer containing lots of many vertices, each one with a different
texture ?
Below is the code i used to draw a primative (square) currently and
apply a texture, if i have eighty objects to draw, that is a lot of
procedures to go through. shurely their must eb a better way to do
this by queing all the pimatives i want to draw in a vertex buffer.
Can not seen to find any examples.
Can anyone point me in the right direction please?
Many Regards
Roberto
if
(FAILED(g_pd3dDevice->SetStreamSource(0,pVertexBuffer,0,sizeof(CUSTOMVERTEX))))
return FALSE;
if (FAILED(g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX)))
return FALSE;
if (FAILED(g_pd3dDevice->SetTexture(0, image[imgBackground].l_pTexture
) ))
return FALSE;
if (FAILED(g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2)))
return FALSE;
date: 11 May 2006 09:15:17 -0700
author: Roberto
Re: DirectX SDK - Vertex buffers
No, you can't define te-references insinde a vertex-buffer
(or at least: D3D9 will ignore them).
But objects*tex_sets_per_object*frames_per_second
shouldn't be a much too high number, if you claim
objects=80, assuming tex_sets_per_object<10.
Merely avoid more than a million drawPrimitive calls per second,
or so, not just a few thousand.
But you can still try keeping all your objects in a single vb,
of couse.
Gruss
Jan Bruns
"Roberto" schrieb im Newsbeitrag news:1147364117.570745.287340@i40g2000cwc.googlegroups.com...
> Hi there,
>
> Newbie to directx, and wanted to know if was possible to build a vertex
> buffer containing lots of many vertices, each one with a different
> texture ?
>
> Below is the code i used to draw a primative (square) currently and
> apply a texture, if i have eighty objects to draw, that is a lot of
> procedures to go through. shurely their must eb a better way to do
> this by queing all the pimatives i want to draw in a vertex buffer.
>
> Can not seen to find any examples.
>
> Can anyone point me in the right direction please?
>
> Many Regards
> Roberto
>
>
>
> if
> (FAILED(g_pd3dDevice->SetStreamSource(0,pVertexBuffer,0,sizeof(CUSTOMVERTEX))))
> return FALSE;
>
> if (FAILED(g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX)))
> return FALSE;
>
> if (FAILED(g_pd3dDevice->SetTexture(0, image[imgBackground].l_pTexture
> ) ))
> return FALSE;
>
> if (FAILED(g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2)))
> return FALSE;
>
date: Thu, 11 May 2006 21:12:17 +0200
author: Jan Bruns
Re: DirectX SDK - Vertex buffers
One approach you may want to look into is using a 'texture atlas.'
Simply put, it involves packing a bunch of your textures together into a
single image, and then fixing up all the texture coordinates of the
vertices that used to use those textures, and then rendering them all in
one go. Because they're all in the same image, you can treat them as a
single texture and so you don't need to switch for each piece.
D3DX contains some utilities for building texture atlases.
- Richard
Roberto wrote:
> Hi there,
>
> Newbie to directx, and wanted to know if was possible to build a vertex
> buffer containing lots of many vertices, each one with a different
> texture ?
>
> Below is the code i used to draw a primative (square) currently and
> apply a texture, if i have eighty objects to draw, that is a lot of
> procedures to go through. shurely their must eb a better way to do
> this by queing all the pimatives i want to draw in a vertex buffer.
>
> Can not seen to find any examples.
>
> Can anyone point me in the right direction please?
>
> Many Regards
> Roberto
>
>
>
> if
> (FAILED(g_pd3dDevice->SetStreamSource(0,pVertexBuffer,0,sizeof(CUSTOMVERTEX))))
> return FALSE;
>
> if (FAILED(g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX)))
> return FALSE;
>
> if (FAILED(g_pd3dDevice->SetTexture(0, image[imgBackground].l_pTexture
> ) ))
> return FALSE;
>
> if (FAILED(g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2)))
> return FALSE;
>
date: Sat, 13 May 2006 02:43:45 +0100
author: Richard Fine [DXMVP]
|
|