Jump to content
  • Advertisement
Sign in to follow this  
andue

D3DXCreateTeapot function return an error,I really don't know how to deal with it,:(

This topic is 4804 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

I'm learing Direct3D with the book Introduction to 3D Game Programming with DirectX. I compiled a sample program that use D3DXCreateTeapot function to create a teapot, there has no errors when compiled. but when I run it,an error occured at function D3DXCreateTeapot, the code is ID3DXMesh* Teapot = 0; D3DXCreateTeapot(Device, &Teapot, 0); I found the Teapot parameter return is 0x00000000, and I get an error code of 1150(The specified program requires a newer version of Windows) when use GetLastError() function; my operating system is Windows2000. Is Windows2000 not support the D3DXCreateTeapot function? Thank you for your concern!

Share this post


Link to post
Share on other sites
Advertisement
the error is probably because you haven't allocated memory for your ID3DXMesh. You set it to 0x00000000 here:
ID3DXMesh* Teapot = 0;
and then directly after that you use it.
If you understand how memory allocation works, you should understand why (you should understand memory allocation if you're allready working with 3D, but I'm sure you do).
You might try ID3DXMesh * Teapot = new ID3DXMesh();, but I don't know if you can do that, or if ID3DXMesh has a constructor, or even if it is a class, so don't rely on me, at least you have knowledge of a possible mistake.

Share this post


Link to post
Share on other sites
Is the device valid at the point of the call? What does the debug runtime tell you? Windows 2000 should run D3D programs just fine, as long as you have the correct DX runtime installed.

Schildpad: DirectX interfaces usually have factory functions which allocate the memory for the undelying classes automatically. You can't "new" an ID3DXMesh - instead, you must use some function, such as D3DXCreateTeapot(), to allocate instances of ID3DXMesh's underlying class.

It is good practice to initialize pointers to zero, so you can test for their validity before trying to use them.

Share this post


Link to post
Share on other sites
Quote:
It is good practice to initialize pointers to zero, so you can test for their validity before trying to use them.

Quote:
DirectX interfaces usually have factory functions which allocate the memory


I know that, I just didn't know any initialization function for the teapot. That's why I said "I don't know if you can do that". I didn't know if it was so for the teapot, since I'm not using 3D yet, but then again, I shouldn't have said it.

Share this post


Link to post
Share on other sites
Thank you two upstairs!
Quote:

Is the device valid at the point of the call? What does the debug runtime tell you?


The device is valid, the follow info is the what I have seen

Direct3D9: (INFO) :======================= Hal SWVP device selected
Direct3D9: (INFO) :Using P4 PSGP
Direct3D9: (ERROR) :Invalid IDirect3DVolumeTexture9** pointer passed to CreateVolumeTexture
First-chance exception in D3DFirst.exe (KERNEL32.DLL): 0xC0000005: Access Violation.

what problem it would be?
and my video memory is allocated from system memory, is this related with the error?

Share this post


Link to post
Share on other sites
Quote:
Original post by andue
Thank you two upstairs!
Quote:

Is the device valid at the point of the call? What does the debug runtime tell you?


The device is valid, the follow info is the what I have seen

Direct3D9: (INFO) :======================= Hal SWVP device selected
Direct3D9: (INFO) :Using P4 PSGP
Direct3D9: (ERROR) :Invalid IDirect3DVolumeTexture9** pointer passed to CreateVolumeTexture
First-chance exception in D3DFirst.exe (KERNEL32.DLL): 0xC0000005: Access Violation.

what problem it would be?
and my video memory is allocated from system memory, is this related with the error?


This would imply that there's nothing wrong with the CreateTeapot() call, but instead the CreateVolumeTexture generating an error and messing your pointers up. Check your code carefully, that's the only advice we can offer without seeing your source.

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!