Sign in to follow this  
longbough

Not able to draw a simple sprite

Recommended Posts

Hello everybody, I want to draw a simple sprite in a window, but I wasted the last hours with this. I´m following the tutorials on directxtutorial.com. Actually this one here: http://www.directxtutorial.com//Tutorial9/D-GameDisplay/dx9D1.aspx Everything works fine, no compile errors no warnings. Nothing! But if I run the compiler to see it, a black window opens. I read and followed every tutorial before and everything works fine. I could draw and transform vertices and meshes, but simple sprites are not possible. Does anybody have an idea about this? I searched google and this forum before but nothing helped.These two didn´t helped me either. http://members.gamedev.net/jhoxley/directx/DirectXForumFAQ.htm#D3D_7 http://members.gamedev.net/jhoxley/directx/DirectXForumFAQ.htm#D3D_22 I know its something simple, but i cannot find it. Thanks a lot. longbough

Share this post


Link to post
Share on other sites

I tried something like this

if(FAILED(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
{
MessageBox(NULL, L"The Direct3DCreate9 function failed", L"Error", MB_OK);
PostQuitMessage(0);
}

and played a lot with all debug settings i found in some debug-tutorials, but nothing helped. Its hard for me, to get into debugging, because i am still a noob at this.

Share this post


Link to post
Share on other sites

Finally I found two errors in the debugger.

1.First, he tells me, that he doesn´t find my Sprite File.
I have only one cpp and one png file in the same folder.
This is my code for the png.
D3DXCreateTextureFromFile(d3ddev, L"Panel1.png", &sprite);

2.Some thousand times he printed this line:
D3DX: pTexture pointer is invalid

Share this post


Link to post
Share on other sites
Have you set the correct "Working Directory" in the project properties ? You can also try with the full path of the texture file.
The second error is only a consequence : if the texture creation failed, then the pointer is invalid and you can't use it.

Share this post


Link to post
Share on other sites
if you're using VC++ which I'm assuming you are, then while you're running through the IDE the paths are relative to the directory of the solution file, when you're running the app through the EXE file itself, the paths have to be relative to the EXE. Try running the EXE and see if it still won't show up. Otherwise, try copying the png to the directory of the solution file.

-Alex

Share this post


Link to post
Share on other sites

Thank you both for your replies.

It was the solution/exe directory thing. I copied the png in the exe folders, so the exe´s worked. The same with the solution folder and the IDE.
But how can I build the png in the exe?
All the tutorials I saw, put the sprites into the IDE directories on the left(ccp, .h, resources).

Thank you again and have a nice Sunday

longbough

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this