xboxscene.org forums

Pages: 1 [2]

Author Topic: The Ultimate Xdk Tutorial  (Read 297 times)

dankydoo

  • Archived User
  • Full Member
  • *
  • Posts: 145
The Ultimate Xdk Tutorial
« Reply #15 on: March 13, 2003, 09:03:00 AM »

QUOTE (Mage @ Mar 11 2003, 12:38 AM)
One question, why are you doing int __cdecl main()
cdecl is the default c calling convention, so it's already cdecl.

hehe.....remember that the xbox is considered a different architecture, it may have used a different calling convention by default in which the parameters were passed the other way and __cdecl needed to be appended to the main function.
Logged

razorrifh

  • Archived User
  • Sr. Member
  • *
  • Posts: 329
The Ultimate Xdk Tutorial
« Reply #16 on: March 14, 2003, 03:34:00 PM »

QUOTE (boris2 @ Mar 14 2003, 11:14 AM)
Quote from: dankydoo,Mar 13 2003, 05:03 PM

Logged

dankydoo

  • Archived User
  • Full Member
  • *
  • Posts: 145
The Ultimate Xdk Tutorial
« Reply #17 on: March 15, 2003, 11:46:00 AM »

QUOTE (boris2 @ Mar 14 2003, 11:14 AM)

The syntax of the programming language has less to do with the architecture of the console! laugh.gif

Edit: its possible that it is a result of the way the XDK was developed to compile XBE's though

razorrifh:

Main and winmain are just the entry points of the executable.....if you want to know exactly what __cdecl does, search on MSDN and read about it there....

Less than what?  I wasn't discussing the syntax of the C/C++ languages, I was discussing the fact that some architectures pass parameters on the stack and increment the stack pointer in different ways, and that __cdecl explicitly states how exactly that is occuring........if you are still confused, go read about it on the internet there is plenty out there.....
Logged

dankydoo

  • Archived User
  • Full Member
  • *
  • Posts: 145
The Ultimate Xdk Tutorial
« Reply #18 on: March 15, 2003, 11:46:00 AM »

QUOTE (boris2 @ Mar 14 2003, 11:14 AM)

The syntax of the programming language has less to do with the architecture of the console! laugh.gif

Edit: its possible that it is a result of the way the XDK was developed to compile XBE's though


Less than what?  I wasn't discussing the syntax of the C/C++ languages, I was discussing the fact that some architectures pass parameters on the stack and increment the stack pointer in different ways, and that __cdecl explicitly states how exactly that is occuring........if you are still confused, go read about it on the internet there is plenty out there.....

razorrifh:

Main and winmain are just the entry points of the executable.....if you want to know exactly what __cdecl does, search on MSDN and read about it there....

dankydoo
Logged

razorrifh

  • Archived User
  • Sr. Member
  • *
  • Posts: 329
The Ultimate Xdk Tutorial
« Reply #19 on: March 16, 2003, 02:27:00 PM »

QUOTE

//Main header file for the XDK
#include <xtl.h>

void InitialiseD3D();
PDIRECT3D8 g_pD3D = NULL;                      // DirectX Object
LPDIRECT3DDEVICE8 g_pD3DDevice = NULL;          // Screen Object

//Application entry point
void __cdecl main()
{
      InitialiseD3D();
      while(true)
      {
            //Clear the backbuffer to black
                //                                                      r   g   b
            g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,  0, 255), 1.0f, 0);
            //Begin the scene
            g_pD3DDevice->BeginScene();


            //End the scene
            g_pD3DDevice->EndScene();

            //Filp the back and front buffers so that whatever has been rendered on the back buffer
            //will now be visible on screen (front buffer).

            g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
      }     

      void CleanUp();
}


void InitialiseD3D()
{
    //First of all, create the main D3D object. If it is created successfully we
    //should get a pointer to an IDirect3D8 interface.
    g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);

    //Create a structure to hold the settings for our device
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory(&d3dpp, sizeof(d3dpp));

    //Fill the structure.
    // Set fullscreen 640x480x32 mode

      d3dpp.BackBufferWidth = 640;
      d3dpp.BackBufferHeight = 480;
      d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;


      // Create one backbuffer
      d3dpp.BackBufferCount = 1;



      // Set up how the backbuffer is "presented" to the frontbuffer each time
      d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;

    //Create a Direct3D device.
    g_pD3D->CreateDevice(0,
      D3DDEVTYPE_HAL,
      NULL,
                     D3DCREATE_HARDWARE_VERTEXPROCESSING,
                     &d3dpp,
      &g_pD3DDevice);
}

void CleanUp()
{
    g_pD3DDevice->Release();
    g_pD3D->Release();
}

the stuff in bold is new or moved
Logged

dankydoo

  • Archived User
  • Full Member
  • *
  • Posts: 145
The Ultimate Xdk Tutorial
« Reply #20 on: March 17, 2003, 11:10:00 AM »

move your declarations to global variables.....ie. move them right under the #include <xtl.h>
Logged

razorrifh

  • Archived User
  • Sr. Member
  • *
  • Posts: 329
The Ultimate Xdk Tutorial
« Reply #21 on: March 17, 2003, 05:09:00 PM »

um.. isnt that where they are? should i swap the function definition with the pointers to the screen/directx objects?
Logged

dankydoo

  • Archived User
  • Full Member
  • *
  • Posts: 145
The Ultimate Xdk Tutorial
« Reply #22 on: March 17, 2003, 09:37:00 PM »

oops..hehe....looked over it a little too quickly....prototype for other functions?
Logged

dankydoo

  • Archived User
  • Full Member
  • *
  • Posts: 145
The Ultimate Xdk Tutorial
« Reply #23 on: March 18, 2003, 02:14:00 PM »

QUOTE (Mage @ Mar 18 2003, 06:05 AM)
First off, being explicit with __cdecl is not needed.  That is the standard calling convention in C/C++, so it's just redundant.  
To top it off, your main function had no argruments to it, therefore you had no calling convention to worry about, and stack cleanup won't really matter since main should never exit anyways.

As I said, typically, you do not write a program that never exits from it's main function...
Logged

razorrifh

  • Archived User
  • Sr. Member
  • *
  • Posts: 329
The Ultimate Xdk Tutorial
« Reply #24 on: March 20, 2003, 01:37:00 PM »

QUOTE (dankydoo @ Mar 18 2003, 12:37 AM)
oops..hehe....looked over it a little too quickly....prototype for other functions?

that is sorta wierd... i didnt have a declaration for the CleanUp() function and it still compiled. oh well.  blink.gif

does anyone feel like making a small guide on how to get access the controller ports? i was reading the help file but its way over my head. i know that i have to poll the devices with the max number of controllers that you want to use in your program, then you can access them somehow...  blink.gif

*edit* unless you just wanna make one, i found a game with source that's simple enough for me to figure out for controller support.
Logged

razorrifh

  • Archived User
  • Sr. Member
  • *
  • Posts: 329
The Ultimate Xdk Tutorial
« Reply #25 on: March 21, 2003, 02:12:00 PM »

CODE
XFONT_OpenBitmapFont( L"D:Arial18Normal.bmf", dwFontCacheSize, &m_pArial18BitmapFont );

*edit* sorry if im asking extremely newbie questions, but this is whats wrong with taking c++ in college... you expect them to teach you something and they dont. ive learned leagues more from online than i could have hoped for from a class.   laugh.gif

also, what does ZeroMemory do? setup contiguous memory the sizeof the var and then pass the var to that part of memory?
Logged

Mage

  • Archived User
  • Sr. Member
  • *
  • Posts: 482
The Ultimate Xdk Tutorial
« Reply #26 on: March 21, 2003, 02:25:00 PM »

QUOTE (razorrifh @ Mar 21 2003, 03:12 PM)
in this line of code, what is the L for before the font path?
CODE
XFONT_OpenBitmapFont( L"D:Arial18Normal.bmf", dwFontCacheSize, &m_pArial18BitmapFont );


also, what does ZeroMemory do? setup contiguous memory the sizeof the var and then pass the var to that part of memory?

L"String" means the string is unicode, easy way to input unicode strings in C without having to actually input unicode characters.
Logged
Pages: 1 [2]