I been trying to solve this by my own, but it simply don't make any sence. I'm trying to do the required initializing of the necessary D3DX components, so I can use the Sprite interface and draw an image. The main code runs fine, but as soon as the loop reaches the Graphics class, it crashes. Here's my code:

can you get the result of thos D3D creation calls ?
because checking the return values of D3D is very important, and dont forget to try the D3D Debug runtimes.
they help a lot.

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

I know how to get the HRESULT from the method, but how do I check the actual info of the HRESULT? I can't write the HRESULT in a messagebox? Is there any smarter way then checking with a switch?

it would be quicker to set a break point and copy the value of the HRESULT and look it up in the DirectX Error Lookup tool / google.

D3D Debug runtimes? How do I use it?

goto the Microsoft DirectX SDK folder in the StartMenu -> then in the startmenu -> Microsoft DirectX SDK( whatever version your using ) -> DirectX Utilities -> DirectX Control Panel.then set the debug out put and select "use debug runtimes" option.then run your game again and check the "output window" of the IDE for the info from D3D.

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

it would be quicker to set a break point and copy the value of the HRESULT and look it up in the DirectX Error Lookup tool / google.

Sorry, but, how do I set a break point? And how can I copy the value of the HRESULT? Sorry, but I've never done this before, first time I even hear about it :/

to set a break point( in VS ) click in the light brown line on the left of the code page, or there should be a add break point here buttonwhen the break point hits, hold the mouse over the hresult and a little box should pop up, select the text in there and copy it.

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

also check if the interfaces are NULL or nullpre( C++0x )what about the debug runtimes ?

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

You call D3DXCreateSprite with d3ddev as a parameter. Then in the line following it you create d2ddev, since this is your constructor and I don't see you setting d3ddev to NULL it would be logical to assume that they crash happens in D3DXCreateSprite since you pass it a invalid pointer (unless you are using VS in debug mode which I think sets all uninitialized variables to 0). Also you should error check these functions (d3d != NULL, d3d->CreateDevice(...) != S_OK).

It has been ages since I last looked at D3D9 but I think that you should check out the following.
1. Error check texture loading, make sure its loaded!
2. I don't know to what extend d3dxsprite sets its own rendering states (try searching the help files that come with the sdk) but you might want to try to turn of lighting (again its in the help files).
3. I don't see any d3ddev->Clear(...), d3ddev->BeginScene() d3ddev->EndScene() and d3ddev->Present(...). Do you call them somewhere else?

Maybe its a good idea to check out the tutorials in the help files, make your application mimic the the one that only draws a triangle and remove the triangle code and insert sprite begin, draw, end.

Do I have to use the clear, beginscene, endscene and present even with Sprite?

I started off by fixing the Clear method and choosing it to clear with black, but it gives me strange results. In fullscreen my application background is black, but when I run it windowed it is white? And I notice it gets really laggy when I run Clear?

Do I have to use the clear, beginscene, endscene and present even with Sprite?

I started off by fixing the Clear method and choosing it to clear with black, but it gives me strange results. In fullscreen my application background is black, but when I run it windowed it is white? And I notice it gets really laggy when I run Clear?

Yes they are essential. You should try to structure your program like this:

int WINAPI WinMain(...)
{
//create your window
...
//create graphics
Graphics g(hwnd);
//create a way to check if this was successful or better move the initialization into a separate method
if (!g.init(hwnd))
{
//FAIL, I can't stress it enough if you are serious about finding the problem you have to rule out bogus function calls with error checking
}
//maybe a separate method to load the texture(s)?
//your game loop
while (gameNotClosed)
{
//update window
//begin the scene
g.beginScene(); //which calls d3ddev->Clear d3ddev->BeginScene()
//draw sprite
g.begin(); //which calls sprite->begin(), and try turning of alpha blending for the moment
g.draw(); //which calls the drawing function on the sprite
g.end(); //which calls sprite->end();
//EDIT: and ofcourse EndScene()
g.endScene();
}
return 0;
}

And ofcourse do not use the standard updatewindow function to acquire window messages, try searching the forums for "game loop" I think on windows you should use PeekMessage to acquire the messages but I haven't been on a windows platform for a while so I can't say for sure.

Are you clearing the Z-Buffer? If you are clearing the z-buffer when you didn't create one you may run into some artifacts/problems! The sprite Draw(), Begin() and End() methods must be called between BeginScene() and EndScene() pair.

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

Does this seem correct, or should you have changed anything? (I'll also add the error checking)

Then I also have 2 more questions:

1. I've noticed that the texture is scaling to the closest 64x64, 128x128, 256x256, 512x512, 1024x1024 etc. If my texture is 300 in height, it's going to be scaled to 512 in height. Can I disable this somehow?

2. What do you think is better? Using Sprites or setting up vertices?

@ryan20fun: Ok, I've checked the Debug Runtime Version. Should I do anything with the Debug Output Level? Where will I find this debug help in Visual Studio when I work?

1. I've noticed that the texture is scaling to the closest 64x64, 128x128, 256x256, 512x512, 1024x1024 etc. If my texture is 300 in height, it's going to be scaled to 512 in height. Can I disable this somehow?

it depends, does the card support non power of two textures ?if so you can manually specify the x and y size, its what i do.

2. What do you think is better? Using Sprites or setting up vertices?

i would vote sprites for now, i think if you are going to upgrade to D3D10 / 11, it might be easier to use vertices and rotate them manually etc.because from D3D10, Microsoft dropped the fixed function pipeline.

@ryan20fun: Ok, I've checked the Debug Runtime Version. Should I do anything with the Debug Output Level?

the more debug out put D3D will Do.if you select the highest out put, you will get mesages for everything you did wtong, and forgot to do.

Where will I find this debug help in Visual Studio when I work?

D3D will output the info to the "Output" Window, the one that tells you X has been compiled.

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

1. I've noticed that the texture is scaling to the closest 64x64, 128x128, 256x256, 512x512, 1024x1024 etc. If my texture is 300 in height, it's going to be scaled to 512 in height. Can I disable this somehow?

Try using D3DXCreateTextureFromFileEx() instead of the D3DXCreateTextureFromFile().