Page 1 of 4 123 ... LastLast
Results 1 to 15 of 56
  1. #1
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,836
    Reputation
    5782
    Thanks
    41,290
    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,836
    Reputation
    5782
    Thanks
    41,290
    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
    arunforce's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    A place for amigos
    Posts
    24,687
    Reputation
    4747
    Thanks
    12,552
    My Mood
    Yeehaw
    It's DirectX not Direct-X!



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


  5. #4
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,836
    Reputation
    5782
    Thanks
    41,290
    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

  6. #5
    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.

  7. #6
    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.

  8. #7
    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.

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

  10. #9
    smartie's Avatar
    Join Date
    Mar 2007
    Location
    Holland
    Posts
    434
    Reputation
    15
    Thanks
    30
    Any pics of the result?

    Nice tut, for straight from your head.

  11. #10
    killer2334's Avatar
    Join Date
    Jun 2007
    Gender
    male
    Location
    Tampa,Florida
    Posts
    160
    Reputation
    16
    Thanks
    10
    how can i learn more about c++ pm me any solutions
    Quote Originally Posted by yogilek View Post
    omg.... do u can read?

  12. The Following 2 Users Say Thank You to killer2334 For This Useful Post:

    atropelei (01-08-2009),unspeakable (09-29-2012)

  13. #11
    crisp1994's Avatar
    Join Date
    May 2007
    Location
    up ur ass
    Posts
    214
    Reputation
    10
    Thanks
    2
    kk thx ill test it

  14. #12
    yacniel's Avatar
    Join Date
    Jul 2007
    Gender
    male
    Posts
    33
    Reputation
    10
    Thanks
    4
    i'ma give it a try

  15. #13
    somethingwitty's Avatar
    Join Date
    Aug 2007
    Gender
    male
    Location
    A place far far away... Next door.
    Posts
    315
    Reputation
    10
    Thanks
    12
    god i am such a newb....

  16. #14
    FluffyStuff's Avatar
    Join Date
    May 2007
    Location
    Dark side of the moon
    Posts
    308
    Reputation
    10
    Thanks
    150
    Quote Originally Posted by somethingwitty View Post
    god i am such a newb....
    Newb + restarting old threads == ultra lame.

  17. #15
    colommm752's Avatar
    Join Date
    Sep 2007
    Location
    i the world in puerto rico in my house in my room
    Posts
    36
    Reputation
    10
    Thanks
    0
    i have only C++ i have to download other programs

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