Sign in to follow this  
rem24

Damn you De Sousa!

Recommended Posts

Once again, I cannot help but feel that Bruno De Sousa is sitting in his mansion, with cup of cocoa warming his hands, laughing at me for dilligently copying out his code, which so often fails to work. Here's the deal. All I want to do is render a surface to the screen. I can handle all the initialisation and shutdown stuff, and can clear the background to blue. De Sousa gives me a neat little function for creating a spirally type pattern for my surface, and I'm pretty sure that's working fine. The problem comes when I attempt to copy the surface to the screen with; m_pD3DDevice ->CopyRects(m_pD3DSurface, NULL, 0, pBackBuffer, NULL); Whereupon I get a wealth of 'Access violations'. I have an inkling that it might be something to do with De Sousa declaring a variable; Unsigned Int m_iD3DFormat; // D3D current format And then using it in; m_pD3DDevice ->CreateImageSurface(256, 256, (D3DFORMAT)m_iD3DFormat, &m_pD3DSurface *Without* initialising it inbetween times. If I'm on the right track, can someone please tell me what to do next. And if I'm not, can someone please tell me what to do next. Failing that, can anyone reccommend a *basic* tutorial on rendering surfaces in Direct3D. Until I get this sorted, my progression through De Sousas book is kinda hung. Cheers.

Share this post


Link to post
Share on other sites
Not to worry, I figured it;

You initialise the said variable by saving the back-buffer format after you recover it for the device *presentation mode* parameters.



/* Fill in the present parameters */

D3DPRESENT_PARAMETERS d3dpp; // 'd3d' for Direct3D, 'pp' for present parameters.

ZeroMemory(&d3dpp, sizeof(d3dpp)); // The ZeroMemory macro fills a block of memory with zeros; In this case we are zeroing out all the parameters relating to the Device (starting with a blank slate).
d3dpp.Windowed = TRUE; // We want windowed mode (i.e we want our app to run in a window raher than full screen mode (which would require us to input the argument 'FALSE')).
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // We don't need any particular back-buffer stuff for this basic graphics window, so we let Direct3D decide (find out what this is all about below).
d3dpp.BackBufferFormat = d3ddm.Format; // Set the BackBufferFormat to the same format we recovered with 'GetAdapterDisplayMode()' (current display mode).

/* NEW: Save the current format */

m_iD3DFormat = d3ddm.Format;

Share this post


Link to post
Share on other sites
Quote:
Original post by rem24
I cannot help but feel that Bruno De Sousa is sitting in his mansion...
You've overestimated how much money technical authors make by several orders of magnitude if you really think that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Guimo
Hi,
Move to Direct3D as soon as posible. There are lots of tutorials online. Like NeXe. Also, you can check the samples in the DX9 and DX9c SDK.

Luck!
Guimo


Um... He is using Direct3D. Perhaps you meant he should move from DX8 to DX9?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Avoid Nexe tutorials by all means!
They are all but the right way to do!

Try codesampler or other resources you can find here on gamedev!

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