Programming 2D Games

The official forum for "Programming 2D Games" the book by: Charles Kelly

It is currently Sat Sep 22, 2018 6:23 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Aug 20, 2015 5:22 pm 
Offline

Joined: Thu Aug 20, 2015 5:14 pm
Posts: 2
Hello, I am a novice > amateur programmer. I'm interested in learning to program things beyond command prompt windows, and have earned a Certificate for Fundamentals in Programming at my local community college.

Problem starts here: At checkpoint 3.2, the first page on Chapter 3 "In order to successfully compile the following code, the d3d9.h header file and the d3d9.lib library file are required. The first step in writing a DirectX application is to create a Direct3D object and get an interface to it. The Direct3DCreate9 function does just that.
IDirect3D9 * Direct3DCreate9(
UINT SDKVersion
);"

I've downloaded the code, from the books website, and cannot find this code anywhere, am not sure where to include it. Instructions on building the first DirectX program begin on 3.8 (to my knowledge), it's very confusing. I've used Control + F to (search entire solution) and have not found this code.

This is not the only sample that seems to be missing. The only d3d9.h I've found is in the external dependencies, and the above code isn't there, either.

Thanks in advance for helping me through this problem.


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 20, 2015 8:09 pm 
Offline
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 546
Good questions.

Section 3.8.1 "Configuring a Project for DirectX" shows how to configure a project's properties so Visual Studio will be able to locate the required libraries and include files.

Near the top of our graphics.h file we have added the code:
Code:
#include <d3d9.h>
This will include the d3d9.h header file.

The call to Direct3DCreate9 is in the Graphics::initialize function located in the graphics.h file.
Code:
//=============================================================================
// Initialize DirectX graphics
// throws GameError on error
//=============================================================================
void Graphics::initialize(HWND hw, int w, int h, bool full)
{
    hwnd = hw;
    width = w;
    height = h;
    fullscreen = full;

    //initialize Direct3D
    direct3d = Direct3DCreate9(D3D_SDK_VERSION);

_________________
Professor Kelly


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 20, 2015 9:29 pm 
Offline

Joined: Thu Aug 20, 2015 5:14 pm
Posts: 2
This is very helpful, it makes a lot more sense now.

So, following the instructions beginning at 3.8.1, that will point to d3d9.lib and d3d9.h? That seems to be the case.

Also, in 3.3 it says to copy d3dref9.dll to the project folder, but this step wasn't necessary to compile. I'm using Windows 7 and Microsoft Visual C++ 2010 Express.

Thanks for all the help.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group