Page 1 of 4 123 ... LastLast
Results 1 to 15 of 56

Hybrid View

  1. #1
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish

    Starting in Direct-X 8.1

    What You Need
    Strong knowledge of C++
    Direct-X SDK Current version that supports Direct-X 8.1
    Microsoft Visual Studios (6.0 w/ C++ Support, 2003 (Preferable), 2005)

    Information
    C++ with Direct-X is extremely complicated. Some one with no prior C++ knowledge shouldn't attempt this tutorial. If you are using this as a learning experience, feel free to read.

    By the way, we are using Direct-X 8.1 because Microsoft decided managed is the best way to program in 9.0… So we aren't going to program in it.

    What we will try to do now is make a basic window that you can use in later tutorials to begin writing your first game in Direct-X!

    Lets Start
    If you don't have any of the noted software above installed, you probably should install it. You also need to install the SDK, you should do that after installing your compiler otherwise you will have to add the libraries/headers manually the compiler's options.

    Creating a Project
    If you have some C++ knowledge you should know what to do. Make a new EMPTY PROJECT called "MPGH.net Tutorial 1".

    Now, you must access your "Project's Settings". Open your Project's Settings, head to the Link tab (Project Settings and Link may not exist, it depends on what compiler your using. I am using VS 2003). In that tab there are about seven settings, on the first input box enter "d3d8.lib". This library holds all you need for basic Direct-X functionality (functions). Well you are basically ready.

    Coding Begins
    Right click and add "New" > "CPP File", if you know where else goto "File" > "New" > "CPP File". Call this CPP file "Main.cpp", I like keeping my base file where all main function is placed. However I use my game name as the CPP name when its a big project I am working on. Anyways open up your new Main CPP file, whatever you named it.
    First we need the Direct-X base header file that will use the libary file you added to your project above. This header file is called "d3d8.h". Include this header file:

    Code:
    #include <d3d8.h>
    
    //Application Title, using this variable the window class is easy to unregister
    static char appTitle[ ]= "Starting in C++/Direct-X 8.1 - Tutorial 1";
    We don't want your code to be sketchy so we need to make a header file. Make a new header file as you named your Main CPP file, for example if you named your main cpp "Main.cpp" then call your header file "Main.h".
    Include this header file to your main cpp so code looks something like this:

    Code:
    #include <d3d8.h>
    #include "Main.h"
    Since we are using the Windows API to display your window and Direct-X surface, we need to create a main method initialize the project (Where your game starts). Add the following function to your main cpp.

    Code:
    INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIsntance, LPSTR cmd, INT cmdsh)
    {
    Now we must configure the window class settings. Add the following code:

    Code:
    //Declares the windows class
    WNDCLASSEX wc;
    
    ZeroMemory(&wc, sizeof(WNDCLASSEX));
    wc.cbSize = sizeof(WNDCLASSEX);					//Sets the window’s size
    wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;		//Sets the window’s style
    wc.lpfnWndProc = MsgProc;							//Passes the message handler
    wc.hInstance = hInstance;							//Passes the instance handler
    wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);	//Colors the window background black
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);			//Uses the default application icon - large
    wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); 			//Uses the default application icon - small
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);				//Uses the default application pointer
    wc.lpszClassName = appTitle;						//Window’s Name
    
    //Or Use:
    //WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW | CS_OWNDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, appTitle, NULL};
    
    //Register the window class
    RegisterClassEx(&wc);
    The settings of the window are all done. Now we have to pass the settings to the window we are going to create.

    Code:
    //Create the window
    HWND hWnd = CreateWindow(appTitle, appTitle, WS_OVERLAPPEDWINDOW, 100, 100, 640, 480, NULL, NULL, wc.hInstance, NULL );
    
    //Show the window
    ShowWindow(hWnd, nCmdShow);
    Great! Now your window shows – Code isn’t fully functional so expect errors if you try to run it. It doesn’t stay up though. We need to initialize Direct-X and create a while loop to keep the game running while it should be.

    Code:
    //If DirectX Initializes properly, simply begin updating window
    if (InitializeDirectX())
    {
    	while (gameIsRunning)
    {
    	//Update the window
    UpdateWindow(hWnd);
    }
    }
    
    UnregisterClass(appTitle, wc.hInstance);
    Now… We need a message handler to finish this tutorial up.
    Code:
    //Message handler
    LRESULT WINAPI MsgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
    {
    switch(wMsg)
    {
    case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
    break;
    }
    
    return DefWindowProc(hWnd, WMsg, wParam, lParam);
    }
    Now we need to add these two function declarations to your main header file.
    Code:
    INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIsntance, LPSTR cmd, INT cmdsh);
    LRESULT WINAPI MsgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
    Good job guy! You did it, you setup the basic Win32 window where your game will play.

    Project File & Source Code

    *This tutorial isn’t complete, may be buggy, I wrote this tutorial straight from my head*





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  2. The Following 22 Users Say Thank You to Dave84311 For This Useful Post:

    ApUsE (02-26-2011),bean147932 (07-04-2009),birky (12-19-2008),Destyn (02-06-2009),[MPGH]Disturbed (07-22-2009),G0ld_User (12-06-2009),hopefordope (01-10-2010),Iwin (08-20-2008),Lynie (10-11-2008),msp123 (11-22-2010),nepito (03-13-2010),NewbieH (01-28-2009),niemi (01-06-2009),oilu (06-01-2008),olie122333 (05-17-2008),osiel (09-26-2009),Ricky1337 (09-05-2009),spazmeister (08-23-2008),SteeL (11-12-2007),why06 (09-12-2009),wieter20 (12-23-2007),xEnd (07-07-2009)

  3. #2
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish
    Post any problems, bugs or comments you have. If you need better description for anything let me know.





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  4. #3
    phooj's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Location
    .................:::::::::::::::::::::::::|||||||||||||||||||||||||||||||||||||||||||||||!!!!!!!!!!!
    Posts
    75
    Reputation
    7
    Thanks
    3
    My C++ says win32 out of date or sumthin

    and i cant debug it.....

    please help !

  5. #4
    arunforce's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    A place for amigos
    Posts
    24,717
    Reputation
    4747
    Thanks
    12,563
    My Mood
    Yeehaw
    It's DirectX not Direct-X!



    BRING BACK BT, BRING BACK SAGA, BRING BACK VF, BRING BACK MPGHCRAFT, BRING BACK HABAMON


  6. #5
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish
    It's whatever I want to call it





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  7. #6
    shercipher's Avatar
    Join Date
    Dec 2005
    Posts
    108
    Reputation
    10
    Thanks
    14
    Tried a Code::Blocks port but C::B doesn't support DX 8.1 (just DX 9). Will try again tomorrow.

  8. #7
    hjerherjdsd's Avatar
    Join Date
    Jun 2006
    Posts
    110
    Reputation
    10
    Thanks
    6
    i use Ogre (an Object-Oriented Graphics Rendering Engine), a lot easyer then learning the directX api and 100 times quicker to learn. i know a bit of directX but its just too time consuming to do even simple things. u might think a prebuilt engine would be slower and limit u to certain game types but u can build anything in ogre. look at this game https://www.alliancethegame.com/screenshots.php this was built on ogre.

  9. #8
    SadisticGrin's Avatar
    Join Date
    Jan 2006
    Gender
    male
    Location
    Behind you.
    Posts
    1,428
    Reputation
    10
    Thanks
    125
    Quote Originally Posted by hjerherjdsd
    i use Ogre (an Object-Oriented Graphics Rendering Engine), a lot easyer then learning the directX api and 100 times quicker to learn. i know a bit of directX but its just too time consuming to do even simple things. u might think a prebuilt engine would be slower and limit u to certain game types but u can build anything in ogre. look at this game https://www.alliancethegame.com/screenshots.php this was built on ogre.


    wouldn't this be for making a game? Not for hacking one? :P
    [CENTER]
    The Grin is in.
    [IMG]https://i33.photobucke*****m/albums/d74/sadisticgrin/The-grincopy.png[/IMG]
    I AM the Influence.

  10. #9
    Wizzo1d's Avatar
    Join Date
    Oct 2007
    Posts
    6
    Reputation
    10
    Thanks
    3
    Quote Originally Posted by hjerherjdsd View Post
    i use Ogre (an Object-Oriented Graphics Rendering Engine), a lot easyer then learning the directX api and 100 times quicker to learn. i know a bit of directX but its just too time consuming to do even simple things. u might think a prebuilt engine would be slower and limit u to certain game types but u can build anything in ogre. look at this game https://www.alliancethegame.com/screenshots.php this was built on ogre.
    Thanks for that link and the information on OGRE. It's a great program!

  11. #10
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish
    Great engine*





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  12. #11
    castaway's Avatar
    Join Date
    Mar 2007
    Location
    In a BIG Box.
    Posts
    1,636
    Reputation
    14
    Thanks
    97
    that alliance game is fckin nice
    mpgh shud have its own shotter like that :P

  13. #12
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish
    lol if anyone wants to write a game like that + model the models + make the music, then GL!





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  14. #13
    wieter20's Avatar
    Join Date
    Feb 2007
    Gender
    male
    Location
    doesn't matter i only say im fam. of queen of holland!
    Posts
    207
    Reputation
    16
    Thanks
    41
    Where can i download a d3d starter kit?
    Gtfo k

  15. The Following User Says Thank You to wieter20 For This Useful Post:

    wieter202 (01-20-2008)

  16. #14
    shaheenster's Avatar
    Join Date
    Jul 2008
    Gender
    male
    Posts
    476
    Reputation
    9
    Thanks
    15
    My Mood
    Pensive
    Quote Originally Posted by Dave84311 View Post
    lol if anyone wants to write a game like that + model the models + make the music, then GL!
    lolz, i wouldnt mind making the models. it would just be the coding that i wouldnt want to touch :P
    __________
    _________________________
    _________________________________________

    RIP ILLUM. My only collabbuddy
    [IMG]https://i459.photobucke*****m/albums/qq318/shaheenster/Untitled-9.png[/IMG]
    [/CENTER]
    ____________________________________________
    ______________________________
    _______________

  17. #15
    hjerherjdsd's Avatar
    Join Date
    Jun 2006
    Posts
    110
    Reputation
    10
    Thanks
    6
    well, yea...

Page 1 of 4 123 ... LastLast

Similar Threads

  1. [Discussion] Web Start/ Direct Start?
    By Wax. in forum Combat Arms Discussions
    Replies: 17
    Last Post: 06-25-2011, 06:36 PM
  2. Combat Arms Direct Start
    By cyagon in forum Combat Arms Hacks & Cheats
    Replies: 1
    Last Post: 04-24-2010, 12:50 PM
  3. [REQUEST] Direct Combat Arms Start [CODE]
    By Katie_Perry in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 12
    Last Post: 01-01-2010, 04:55 PM
  4. [Release] Combat Arms Direct Start
    By zmansquared in forum Combat Arms Hacks & Cheats
    Replies: 40
    Last Post: 12-20-2009, 12:49 AM
  5. crossfire direct start
    By teun95 in forum CrossFire Hacks & Cheats
    Replies: 6
    Last Post: 09-27-2009, 06:26 AM

Tags for this Thread