Archived

This topic is now archived and is closed to further replies.

V00D00

problems with Lock()

Recommended Posts

Please help me out with this strange error... I''m trying to make an UI for a game. I made it exactly as it is made in the Donuts 4 sample demo. Firs I made a new DX9.0b app in MSVC using the wizard and added the code for the UI as it is in the Donuts sample. I''m 99.99% sure that I have copied all the code used for this. When I try to execute the code I get the following error (in debug mode, located at the ======>): Unhandled exception in andromeda.exe: 0xC0000005: Access Violation; SCREENVERTEX* v; ======> if( FAILED( m_pViewportVB->Lock( 0, 0, (void**)&v, 0 ) ) ) return E_FAIL; v[0].color = v[1].color = v[2].color = v[3].color = 0xFFFFFFFF; v[0].p = D3DXVECTOR4( 0,sy,0.0f,1.0f); v[0].tu = 0.0f; v[0].tv = 1.0f; v[1].p = D3DXVECTOR4( 0, 0,0.0f,1.0f); v[1].tu = 0.0f; v[1].tv = 0.0f; v[2].p = D3DXVECTOR4(sx,sy,0.0f,1.0f); v[2].tu = 1.0f; v[2].tv = 1.0f; v[3].p = D3DXVECTOR4(sx, 0,0.0f,1.0f); v[3].tu = 1.0f; v[3].tv = 0.0f; m_pViewportVB->Unlock(); Anybody knows what could be the problem? Thanx, V00D00 is there no more than one god or no less than one god?

Share this post


Link to post
Share on other sites
should it be empty or full? i think it has some data but i will check it out...

is there no more than one god or no less than one god?

Share this post


Link to post
Share on other sites
An "Access Violation" means your code followed a bad pointer somewhere. As don has suggested, it might be because the variable "m_pViewportVB" contains an incorrect address. Make sure that this variable has been properly initialized by your app prior to its use here. The variable is probably initialized by a call to CreateVertexBuffer somewhere in your app.

As a tip, make sure you are using the Debug Runtime when you are programming DirectX. The debugging information generated is invaluable. See the Forum Faq for details.

neneboricua

Share this post


Link to post
Share on other sites
Breakpoint on each section of code and find out where it crashes. It could also be that you didn''t allocate enough memory for the vertex buffer. Show us that part of the code if so.

Chris

Share this post


Link to post
Share on other sites