problem with vertex buffers (long)
i think i''m going crazy. i was first using a vertex and vertex-buffer class from a tutorial i''ve read, but now i wanted to create my own stuff, it''s better to understand how it works then and, well it''s my own then
what i''m doing is, i have a structure for a vertex and one for a processed vertex, since i''m using a vertexbuffer for my data and a vertexbuffer containing the processed data. here are the structures:
struct VERTEX
{
float x;
float y;
float z;
};
struct PROCESSEDVERTEX
{
float x;
float y;
float z;
float w;
DWORD Color;
};
naturally, i need some FVFs:
#define D3DFVF_VERTEX ( D3DFVF_XYZ )
#define D3DFVF_PROCESSEDVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE )
now here i do all the init stuff:
void *pVertices;
IDirect3DDevice8 *g_pDevice
LPDIRECT3DVERTEXBUFFER8 g_pVertexBuffer = NULL;
LPDIRECT3DVERTEXBUFFER8 g_pProcessedVertexBuffer = NULL;
g_pDevice->CreateVertexBuffer( 3*sizeof(VERTEX), 0, D3DFVF_VERTEX, D3DPOOL_DEFAULT, &g_pVertexBuffer );
g_pVertexBuffer->Lock( 0, 3*sizeof(VERTEX), (BYTE**)&pVertices, 0 );
memcpy( pVertices, g_pVertices, 3*sizeof(VERTEX) );
g_pVertexBuffer->Unlock();
g_pDirect3D->pDevice->CreateVertexBuffer( 3*sizeof(PROCESSEDVERTEX), 0, D3DFVF_PROCESSEDVERTEX, D3DPOOL_DEFAULT, &g_pProcessedVertexBuffer );
and here is the rendering:
g_pDevice->SetStreamSource( 0, g_pVertexBuffer, sizeof(VERTEX) );
g_pDevice->SetVertexShader( D3DFVF_VERTEX );
g_pDevice->ProcessVertices( 0, 0, 3, g_pProcessedVertexBuffer, 0 );
g_pDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
i don''t know exactly how (and when) to use the ProcessVertices function, it''s nearly nothin in the SDK. the problem i have now is, somehow i got that triangle on the screen, then i changed some coordinates of the vertices: black screen. i put the coordinates back to normal: black screen!? that''s what happened i don''t know why, i''ve tried so many thing, changing the coords some times again, changing the vertex-structures, adding view-point, translation, render states and i-don''t-know-what-else; (<-oops :D)
the only thing i can do is, when i fill my vertex data into the PROCESSEDVERTEX structure and then putting that onto the screen without processing. i really have to get rid of this problem, it doesn''t let me sleep...
perhaps anyone is so kind and shows me (newbie ) step by step how to use the ProcessVertices function, and what i have to look for (RenderState, or so for example).
thanks to anyone reading this completely
and many thanks to all the ones thinking about my problem
perhaps someone may at least post links to tutorials about processing vertices or some alternatives? i really don''t find the error...
Are you resetting the stream source and vertex shader to g_pProcessedVertexBuffer and D3DFVF_PROCESSEDVERTEX after your call to IDirect3DDevice8:rocessVertices?
when i was writing my post, i didn''t, but i did it some time before, with the same annoying black screen.
perhaps it''s a problem with the coordinates or the view-point? anyway, i tried that in a lot of variations, too. i think i should switch to meshes or something, since i read that ProcessVertices uses always software vertexprocessing.
perhaps it''s a problem with the coordinates or the view-point? anyway, i tried that in a lot of variations, too. i think i should switch to meshes or something, since i read that ProcessVertices uses always software vertexprocessing.
Could it be as simple as accidentally you have changed the order of your vertices.
012 faces forward, but 021 faces away.
Simple idea from a newb.
Be seeing you...
lemming
012 faces forward, but 021 faces away.
Simple idea from a newb.
Be seeing you...
lemming
You should use ProcessVertices() if you need the processed vertices (e.g. for collision detection). If you just want to render your vertices use Draw(Indexed)Primitive() with your unprocessed vertices. This way you''ll get the full power of HW-TnL (ProcessVertices() runs always in software and needs at least a mixed mode device, the D3DUSAGE_SOFTWAREPROCESSING behavior flag in the vb creation and the D3DRS_SOFTWAREVERTEXPROCESSING render state set before the PV call).
Bjørn.
Bjørn.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement