Jump to content
  • Advertisement
Sign in to follow this  
Psykocyber

VERTEXBUFFER9, crash on lock()

This topic is 3618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I'm new to this site and need some help with this problem. (How do you enable code view?) So, the problem is that my window crashes when reaching this point in the code. t_buffer is a LPDIRECT3DVERTEXBUFFER9: CUSTOMVERTEX* pVoid = NULL; // a void pointer // lock t_buffer and load the vertices into it t_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, t_vert, sizeof(t_vert)); t_buffer->Unlock(); However, it only occurs when I run the exe file manually. When compiling/launching via Visual Studio 2008, the program run flawlessly. Do any of you know what the problem is?

Share this post


Link to post
Share on other sites
Advertisement
Your t_buffer pointer is NULL or invalid for some reason. Are you checking the return value from CreateVertexBuffer() and all other D3D functions that return interfaces correctly?

The main thing that changes when you run the EXE through the IDE is that the current working directory is set to that of the project file, not that of the EXE file. So if you load any files, the paths will be wrong. You'll have to either account for that when you load the files, or move the EXE into the project directory before running it.

In addition, the Debug Runtimes will tell you if any D3D functions fail and why. it sounds to me like you're not constructing a vertex buffer if loading a texture fails, but not checking if the vertex buffer is valid when you go to lock it.

Share this post


Link to post
Share on other sites
First, I will say: Sorry.
The crash came from 20*sizeof(CUSTOMVERTEX), which should have been: 24*sizeof(CUSTOMVERTEX) not the lock().

But, the debug & HRESULT tip will definately help in the future. So, thanks.

However, there is another error. The release version (when launched directly) isn't showing any graphics. The debug is, and so is the released when launched from Visual Studio. Any idea?

Share this post


Link to post
Share on other sites
Quote:
Original post by Psykocyber
However, there is another error. The release version (when launched directly) isn't showing any graphics. The debug is, and so is the released when launched from Visual Studio. Any idea?

Different paths might be causing issues. When you run your program from VS (either with debugging or without), the working directory is the project directory. When you launch from explorer, it would be the exe directory (that is, Release or Debug).
If your application isn't finding a file it needs, and isn't handling the error result, it might not render anything.

Share this post


Link to post
Share on other sites
Quote:
Original post by Psykocyber
But, the debug & HRESULT tip will definately help in the future. So, thanks.

However, there is another error. The release version (when launched directly) isn't showing any graphics. The debug is, and so is the released when launched from Visual Studio. Any idea?
Try the debug tip [smile]

You can still use DebugView or similar to capture the output from the debug runtimes, even when you're running a release build.

Share this post


Link to post
Share on other sites
It isn't a directory problem. There is only one file, and without it the cube is just white. It would still run.

Just tried the debug tip. There are no errors on running the program, but a crash on close. And even then the crash is only when in debug mode.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!