Similar Threads:
1.Changing vertex color after vertex buffer and index buffer definition
Hi,
Say you have this custom vertex structure:
struct CUSTOMVERTEX
{
float x, y, z;
DWORD color;
};
Is it possible once you've defined values for a vertex
buffer using that structure to subsequently change the
color for a vertex that you defined? If so, how?
Thanks :)
2.memory-loss when locking & unlocking vertex/index buffers
Hi,
I am finding that memory is being consumed at the rate of 1 to 6
megabytes per lock/unlock on my vertex and index buffer. The memory
does not get released until my application exits, which means that the
longer my app runs the more memory is consumed, so at a low 20fps
that's an awful lot of memory being consumed per second. Surely this
should not happen?
I am running VB .Net and Managed Direct X.
Cheers, code is posted below,
Richy
' I lock my buffers:
_vbdata = _vb.Lock(0, 0)
_ibdata = _ib.Lock(0, 0)
_lmvbdata = _lmvb.Lock(0, 0)
_lmibdata = _lmib.Lock(0, 0)
' and then I unlock it all:
_vb.Unlock()
_ib.Unlock()
_lmib.Unlock()
_lmvb.Unlock()
' and then I set the variables to nothing
_vbdata = Nothing
_ibdata = Nothing
_lmvbdata = Nothing
_lmibdata = Nothing
3.Vertex and Index Buffer - color updating after definition
Andy wrote:
> I realized that my earlier question was not complete...
>
> Given a defined vertex structure, a defined set of
> vertices in a vertex buffer, and a defined index buffer
> that has referenced those vertices, can you then change
> vertex color as you use items being referenced by the
> index buffer? If so, how?
>
> (Simply put I'm trying to reuse vertex data that needs to
> vary in color at different index buffer values... is there
> a smarter way to do this?)
>
> Thanks :)
If you mean you're trying to save duplicating vertices that have the
same position but different colour, just duplicate them. There's no
good way to reuse them.
Eyal
4.Filling vertex and index buffers
I am trying to do indexed rendering, and have a question. The book I am
going through (Zen of Direct 3D Game Programming) uses the following method
to fill a vertex buffer: (I have changed some variable names to make their
use more obvious in such a small snippet)
LPDIRECT3DVERTEXBUFFER8 pVB = 0;
hresult = g_pDevice->CreateVertexBuffer( sizeof (CustomVertex) * iNumVerts,
D3DUSAGE_WRITEONLY,
CUSTOMVERTEXTYPE, D3DPOOL_DEFAULT, &pVB);
BYTE* pVertexData = 0;
hResult = pVB->Lock(0,0,&pVertexData,0);
///////////////////////////////////////////////////
//Here is the bit that gives me trouble
/////////////////////////////////////////////////
CopyMemory( pVertexData, (void *)&m_Vertices, sizeof(m_Vertices));
pVB->Unlock();
I have 2 questions about the use of CopyMemory(). First, what protection do
I have against a memory overrun? I think I am having this problem, and if I
understand the Copymemory() function correctly, there is nothing that says
the block of memory pointed to by pVertexData is going to safely hold what
I'm trying to copy to it? Is this how it is usually done? It just seems
wrong to me.
Also, and this is really a C++ question, but it is relevant to this task, In
this example m_Vertices is an array of Vertices. So doesn't
sizeof(m_Vertices) only give me the size of the first element of the array?
I think I must not understand arrays as I thought I did, because I though
you couldn't use "sizeof" to find the size of an entire array.
Thanks!
5.index and vertex buffers
Hey,
I'm new to MDX and i had a question regarding index and vertex buffers. I have code set up to read in vertex data and store it into a VB. I also have an index buffer set up for building a cube, so if you pass the VB 8 vertices, use the index buffer, it renders the image correctly. The question i have, is that although usually i will have a shape with 8 vertices, sometimes i will have more, i.e. a 3d pentagon as oppossed to a cube. how do you create a "universal" index buffer to handle a varying number of vertices.
As i said I'm very new at this, and maybe I'm going at it the wrong way. Any help or suggestions you can give would be great!
Note: I set up the vertex and index buffer according to Tom Miller's book.
Thanks in advance
Aaron
6. Indexed Vertex Buffer with noraml
7. optimizing vertex/index buffer use
8. Sprite or big vertex & index buffers?