Thread: newb-ish DirectX questions

  1. #1
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916

    newb-ish DirectX questions

    These are going to be really simple. I just started reading NeXe's first tutorial and I noticed that a lot of the variables are prefixed with g_ ...what does it stand for?

    Also, he declared a global HRESULT g_hr; - is it worth it to declare this as a global, should I declare it in main() and pass by reference to other functions if they need it, or declare it in any function that needs it? I don't know how often it's really going to be used.

    He's using DX8. I just downloaded 9. I see this: g_pDirect3D=Direct3DCreate8(D3D_SDK_VERSION);
    Should I change the Create8 to a Create9 if I want to use the DX9 version?

    If you want to look at the tutorial, here's a link that will take you directly there. That's all for now, I'm going to bed
    Away.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    I noticed that a lot of the variables are prefixed with g_ ...what does it stand for?
    The g_ prefix just indicates a global variable.

    He's using DX8. I just downloaded 9. I see this: g_pDirect3D=Direct3DCreate8(D3D_SDK_VERSION);
    Should I change the Create8 to a Create9 if I want to use the DX9 version?
    I'd stick with Create8 for now, because there might be some discrepancies between versions.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    NeXe's tutorials are a bit outdated. The SDK documentation is pretty good at the beginners tutorials, that's where I learned most of what I know. Then when you get more advanced, the web has a lot of good intermediate tutorials. The advanced ones you usually have to find a book or a class for.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Re: newb-ish DirectX questions

    >>Also, he declared a global HRESULT g_hr; - is it worth it to declare this as a global, should I declare it in main() and pass by reference to other functions if they need it, or declare it in any function that needs it? I don't know how often it's really going to be used.

    It is going to be used VERY often. In fact, almost every function in DirectX API will return an HRESULT to tell you of any errors. I don't know about making a global HRESULT, I generally don't do that. I usually have my error logger translate the error message into meaningful text and output to a file along with the file and line # it happened on. If is VERY good practice to get in the habit of always checking the return values. I generally do things like this...

    Code:
    HRESULT hr;
    
    if(FAILED( hr = lpDevice->SomeDXFunction( ) ) )
    {
      // Do something about the error, probably log..
    }
    
    // or.....
    
    if( SUCCEEDED( hr = lpDevice->BeginScene( ) ) )
    {
      // Render...
    }
    In case you didn't know, you can use the FAILED and SUCCEEDED macro's to check return values of HRESULT's.

    >>He's using DX8. I just downloaded 9. I see this: g_pDirect3D=Direct3DCreate8(D3D_SDK_VERSION);
    Should I change the Create8 to a Create9 if I want to use the DX9 version?

    Well then certain functions you are using would take a different number of parameters, etc. Just stick with 8 for now. You probably won't be dealing with the newer stuff in DX9 like the new version pixel and vertex shaders for a while anyways.

  5. #5
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Thanks guys, I think you got everything that I asked.
    Away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Directx questions
    By lruc in forum Game Programming
    Replies: 8
    Last Post: 07-07-2011, 10:26 PM
  2. Total newb directx invisable geometry question
    By -pete- in forum Game Programming
    Replies: 5
    Last Post: 08-13-2006, 01:45 PM
  3. DirectX errors (newb alert)
    By confuted in forum Game Programming
    Replies: 2
    Last Post: 07-19-2003, 09:20 AM
  4. DirectX Newb
    By Stan100 in forum Game Programming
    Replies: 4
    Last Post: 07-03-2003, 09:50 AM
  5. Various DirectX questions
    By Hunter2 in forum Game Programming
    Replies: 6
    Last Post: 11-28-2002, 09:42 PM