Skip to main content
GameDev.net gamedev.net
🔒 Locked

Break Error when creating VertexBuffer.

Started by snoddas14 Jul 29, 2007 at 2:36 PM 11 replies 1.2k views
Original Post
snoddas14
snoddas14
hello everybodey! i got this issue, when i lanuch my Application i get a break error and it is pointing towardws my vertexbuffer

void Object::InitThing()
{
		VERTEXSTRUCT Vertex[] = {
		{1.0f,1.0f,0.0f,D3DCOLOR_ARGB(0,0,0,255),},
		{-1.0f,1.0f,0.0f,D3DCOLOR_ARGB(0,0,0,255),},
		{1.0f,-1.0f,0.0f,D3DCOLOR_ARGB(0,0,0,255),},
	};

		Raw.RawGDevice()->CreateVertexBuffer(sizeof(VERTEXSTRUCT),0,
		VERTEXFVF,
		D3DPOOL_MANAGED,
		&vDev,NULL);

	vDev->Lock(0,0,(void**)&pVoid,0);
	memcpy(pVoid,Vertex,sizeof(Vertex));
	vDev->Unlock();
}

i think it is somthing about my Direct3DDevice9 which i have stord in another class but got my function

inline LPDIRECT3DDEVICE RawGDevice(void)
{
     return gDev;
}

and the thig is, when im not using it and using antoher function allso using my RawGDevice function it is pointin on that line of code. here is the break error "description" : Unhandled exception at 0x00412054 in projekt 1.exe: 0xC0000005: Access violation reading location 0x00000000. and i have been wounder all day what it is! any help is welcome!
Benden
Benden
Looks to me like your creating a vertex buffer equal to the size of one VERTEXSTRUCT and then trying to stuff 3 of them into it...
snoddas14
snoddas14
allredy tryd that out, but it´s not fixing it :/
Benden
Benden
So your creating it with 3*sizeof(VERTEXSTRUCT)?

What line exactly does it break on? The CreateVertexBuffer or during the lock/unlock?
snoddas14
snoddas14
yes i have. it dose break on the last one in the code.

at
->&vDev,NULL);
Benden
Benden
In that case its breaking on hte CreateVertexBuffer call.

3 possibilities that i can think of...

D3DDevice is not created properly
FVF is wrong
vDev isnt a pointer to an LPDIRECT3DVERTEXBUFFER9
snoddas14
snoddas14
going to try both! stay tuned.

/ edit /

no it wasent any one of those 3 options.
must be somthing about the device.

/ edit 2 /

i just tryd to lay all the code in the same class as where i got my gDev;
and it ran fine but now i may got one reason.

Direct3D9: (WARN) :Stream 0 stride and vertex size, computed from the current vertex declaration or FVF, are different, which might not work with pre-DX8 drivers
Benden
Benden
Can you post your FVF?
snoddas14
snoddas14
#define VERTEXFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
Benden
Benden
My guess is when you call SetStreamSource your Stride value is not 16?
snoddas14
snoddas14
that an advanced topic for me!

exaplain it in more noobie style :P

or print me an exampel.
im gooder whit code than chatting.
Benden
Benden
OK presumably you call SetStreamSource on your vertex buffer before rendering?

The last value that you pass to that function is the 'stride', which is basically the size of your vertex. With your FVF there the stride should be 3*4 = 12 (For the position) + 4 (for the colour) = 16.
snoddas14
snoddas14
oh okey.

i got only a sizeof there. and the sizeof(VERTEXSTRUCT)

Topic Locked

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

Sign in to reply to this topic.