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

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

Started by andue Jun 18, 2005 at 10:48 AM 4 replies 2.9k views
Original Post
andue
andue
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!
Schildpad
Schildpad
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.
Nik02
Nik02
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.
Niko Suni
Schildpad
Schildpad
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.
andue
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?
Nik02
Nik02
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.
Niko Suni

Topic Locked

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

Sign in to reply to this topic.