The basic basic directX and windows boilerplate code

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
jimmyt1988
Posts: 20
Joined: November 15th, 2012, 2:15 am

The basic basic directX and windows boilerplate code

Post by jimmyt1988 » March 15th, 2013, 12:30 am

Hi all,

I have now watched all of the current Chili DirectX videos. I love them. I get severe nipple rash watching them. However, in an attempt to explore directX directly, I decided to resort to the following example provided by MSDN:

http://msdn.microsoft.com/en-us/library ... s.85).aspx

I had managed to get the application to run fine, but because I am so used to the way Chili lays out his code in a shagadellic way, I was utterly confused at where to start in separating the code up.

I was wondering if anyone had the utmost basic components of directX; a windowsapi window using a directX surface X wide and Y high. I could then use it as a reference to try and sort out my knobbed code.

For a start, I had tried to separate my code into sections like Chili, Windows.cpp, DXGraphics.cpp + h and Game.cpp + h, I think I just need a nudge in the right direction. I have attached my project file to this forum so you can point and laugh at what I have done.

I have a side question to this... and it is related in a way, it's one of the things I have become slightly confused about:

If I were a complete ass and I decided to make a game that only worked on DX11.1 (win 8) and I wanted to use all of DirectX built in stuff... Does DirectX have a "draw png to surface" function or a "draw line from here to here" function pre-made? I understand that we are interfacing and loose coupling, but.. well.. my plan is to make a rocking game for my surface pro and well, that means i'm good to go on just Win 8 11.1 kinda thing.

Thank you for any help... I'm feeling quite lost.

Have a lovely day/night
Attachments
Mexico.zip
(754.98 KiB) Downloaded 151 times

jimmyt1988
Posts: 20
Joined: November 15th, 2012, 2:15 am

Re: The basic basic directX and windows boilerplate code

Post by jimmyt1988 » March 15th, 2013, 12:49 am

Okay so I have started by moving the:

Code: Select all

int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
{
    HeapSetInformation( NULL, HeapEnableTerminationOnCorruption, NULL, 0 );

    if ( SUCCEEDED( CoInitialize( NULL ) ) )
    {
        {
            Game app;

            if ( SUCCEEDED( app.Initialize() ) )
            {
                app.RunMessageLoop();
            }
        }
        CoUninitialize();
    }

    return 0;
}
to the bottom of my windows.cpp file and including my game.h at the top of it

jimmyt1988
Posts: 20
Joined: November 15th, 2012, 2:15 am

Re: The basic basic directX and windows boilerplate code

Post by jimmyt1988 » March 15th, 2013, 1:42 am

Hope you're impressed, managed to pull it together a bit more and got a window to open and close properly. I was reading about that inline function:

Code: Select all

template<class Interface>
inline void SafeRelease( Interface **ppInterfaceToRelease )
{
    if ( *ppInterfaceToRelease != NULL )
    {
        ( *ppInterfaceToRelease )->Release();

        ( *ppInterfaceToRelease ) = NULL;
    }
}
http://msdn.microsoft.com/query/dev11.q ... s)&rd=true
Not sure I really understand it but it can stay in there for now.

I've attached my current copy of the basic directX boiler plate code I'm aiming for. I'll keep you updated on how I strip it back... Any help would be wicked!!!
Attachments
Mexico.zip
(331.33 KiB) Downloaded 148 times

jimmyt1988
Posts: 20
Joined: November 15th, 2012, 2:15 am

Re: The basic basic directX and windows boilerplate code

Post by jimmyt1988 » March 18th, 2013, 12:48 am

Well, it all went wrong... I got totally stuck.. And now I'm back to not understanding anything again. I wish I could just break the back on directX.

I'm now basically using this example http://blogs.msdn.com/b/devschool/archi ... ample.aspx which feels like i'm cheating myself... I once again have no idea how to get a texture on the screen.

If anyone can help, please post answers here, I'd mega appreciate it: http://stackoverflow.com/questions/1546 ... breaking-t

User avatar
Nosferatu
Posts: 36
Joined: July 25th, 2012, 7:08 am
Location: Slovakia

Re: The basic basic directX and windows boilerplate code

Post by Nosferatu » March 18th, 2013, 1:21 pm

Well, loading textures is easy, just use D3DXCreateTextureFromFile( 1, 2, 3 );
1st parameter is pointer to IDirect3DDevice9
2nd is the path to your texture
3rd is address of pointer to IDirect3DTexture9

Drawing it is a bit more complicated and because last time I've done something with D3D was a while ago I don't remember it enough to explain it :D , but in PM I sent you link to a great book from which I learned, you can find there anything about D3D9 and somewhere on the web there are examples and solutions to exercises used in the book.

blueyeredragon
Posts: 12
Joined: June 20th, 2012, 7:29 pm

Re: The basic basic directX and windows boilerplate code

Post by blueyeredragon » March 19th, 2013, 9:56 am

You can look at this page it is pretty usefull http://www.directxtutorial.com/

blueyeredragon
Posts: 12
Joined: June 20th, 2012, 7:29 pm

Re: The basic basic directX and windows boilerplate code

Post by blueyeredragon » March 19th, 2013, 10:14 am

and ı have to say that chili's way of dealing with directx is simplest way ı have ever seen . I am waiting for his 3d tuttorials . Hope he returns sooonnnn :(

jimmyt1988
Posts: 20
Joined: November 15th, 2012, 2:15 am

Re: The basic basic directX and windows boilerplate code

Post by jimmyt1988 » March 20th, 2013, 12:59 am

I have put together a project that now implements the D3DXCreateTextureFromFile but I can't see what on earth is going wrong... gahhh. Anyone see why my sprite isn't being drawn :S. I think my artery is gnna burst duddee.
Attachments
Game.zip
(714.53 KiB) Downloaded 203 times

jimmyt1988
Posts: 20
Joined: November 15th, 2012, 2:15 am

Re: The basic basic directX and windows boilerplate code

Post by jimmyt1988 » March 20th, 2013, 1:23 pm

Ahhh what a plonker!

I was presenting the scene before ending the scene:


gfx.Begin();
ComposeFrame();
gfx.End();
gfx.Present();

Sorted, now I've got my pubes png rendering! yahoo.

Keep on truckin'

Post Reply