• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
StoneMask

1>LINK : fatal error LNK1104: cannot open file 'd3dx9.lib'; should I be using DX9?

3 posts in this topic

I am being studious and everything so I thought that I'd do this the old-fashioned way before the Google mentality of "if you can't find it within the first three minutes, it doesn't exist" and joined a forum. Hello everyone! I hope I can get acquainted with you guys and get some help along the way and vise versa. Before I give you my problem, I'd like to ask if DirectX9 is the best thing to use. My book is outdated and I don't particularly want to muck through trying out DX10+ until I get better at DirectX in general and I know the transition is smooth and/or worth it.

I'll organize this post so this thread isn't cluttered and unattractive. I know some topics get dropped just because people don't format their code in a way that's easy to look through. Also, I am using a Windows 7 machine.

How experienced am I?:
[spoiler]I'm not "new" per se to C++, as I've been pretty acquainted with it. I just haven't made a lot of progress in terms of actually doing things in it, if you know what I mean. Without DirectX, I'm still learning things like templates and sorting in school, but I have a firm grasp on programmer mentality, I think, having independently studied programming for awhile.[/spoiler]

What is the problem?:
[spoiler]When I compile my code, I get this error:[b] 1>LINK : fatal error LNK1104: cannot open file 'd3dx9.lib'[/b][/spoiler]

What steps have I taken so far to try and solve it?:
[spoiler]I already knew I had to include d3d9.lib and d3dx9.lib, and I have added them, like so:
[center][img]http://i.imgur.com/x2MxY.png[/img][/center]

I have also added the [b]Lib[/b] and [b]Include[/b] folders to my Include directories from [b]Microsoft DirectX SDK (March 2009)[/b], like so.
[center][img]http://i.imgur.com/WZEjE.png[/img][/center]
[/spoiler]

What is my code?:
[spoiler]
[code]
#include <d3d9.h>
#include <time.h>
#include <d3dx9.h>

#define APPTITLE L"CREATE_SURFACE"

#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1: 0)
#define KEY_DN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1: 0)

// screen resolution
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480

// forward declarations
LRESULT WINAPI WinProc(HWND, UINT, WPARAM, LPARAM);
ATOM MyRegisterClass(HINSTANCE);
int Game_Init(HWND);
void Game_Run(HWND);
void Game_End(HWND);

// Direct3D objects
PDIRECT3D9 d3d = NULL;
LPDIRECT3DDEVICE9 d3ddev = NULL;

LPDIRECT3DSURFACE9 backbuffer = NULL;
LPDIRECT3DSURFACE9 surface = NULL;

// window event callback function
LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
Game_End(hWnd);
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hWnd, msg, wParam, lParam);
}

// helper function to set up the window properties
ATOM MyRegisterClass(HINSTANCE hInstance)
{
// create the window class structure
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);

// fill the struct with info
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = APPTITLE;
wc.hIconSm = NULL;

// set up the window with the class info
return RegisterClassEx(&wc);
}

// entry point for a Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// declare variables
MSG msg;

// register the class
MyRegisterClass(hInstance);

// initiailize the application
HWND hWnd;

// create the window
hWnd = CreateWindow(
APPTITLE,
APPTITLE,
WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP,
CW_USEDEFAULT,
CW_USEDEFAULT,
SCREEN_WIDTH,
SCREEN_HEIGHT,
NULL,
NULL,
hInstance,
NULL);

// was there an error?
if(!hWnd)
return false;

// display the window
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

// initialize the game
if (!Game_Init(hWnd))
return 0;

// main message loop
short done = 0;
while (!done)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// look for quit message
if (msg.message = WM_QUIT)
done = 1;

// decode and pass messages onto WndProc
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
// process game loop (else prevents running after window is closed
Game_Run(hWnd);
} return msg.wParam;
}

int Game_Init(HWND hwnd)
{
HRESULT result;

// intialize Direct3D
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (d3d == NULL)
{
MessageBox(hwnd, L"Error initializing Direct3D", L"Error", MB_OK);
return 0;
}

// set Direct3D presentation parameters
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));

d3dpp.Windowed = false;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.hDeviceWindow = hwnd;

// create Direct3D device
d3d->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);

if(d3ddev == NULL)
{
MessageBox(hwnd, L"Error creating Direct3D device", L"Error", MB_OK);
return 0;
}

// set random number seed
srand(time(NULL));

// clear the backbuffer to black
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

// create pointer to the back buffer
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);

// create surface
result = d3ddev->CreateOffscreenPlainSurface(
100,
100,
D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT,
&surface,
NULL);

// return okay
return 1;
}

void Game_Run(HWND hwnd)
{
RECT rect;
short r, g, b;

// make sure the Direct3D device is valid
if (d3ddev == NULL)
return;

// start rendering
if (d3ddev->BeginScene())
{
// fill the surface with random color
r = rand() % 255;
g = rand() % 255;
b = rand() % 255;
d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(r, g, b));
// copy the surface to the backbuffer
rect.left = rand() % SCREEN_WIDTH/2;
rect.right = rect.left + rand()%SCREEN_WIDTH/2;
rect.top = rand() % SCREEN_HEIGHT;
rect.bottom = rect.top + rand() % SCREEN_HEIGHT/2;
d3ddev->StretchRect(surface, NULL, backbuffer, &rect, D3DTEXF_NONE);

// stop rendering
d3ddev->EndScene();
}

// display the back buffer on the screen
d3ddev->Present(NULL, NULL, NULL, NULL);

// check for the escape key
if(KEY_DN(VK_ESCAPE))
PostMessage(hwnd, WM_DESTROY, 0, 0);
}

void Game_End(HWND hwnd)
{
// free the surface
surface->Release();

// release the Direct3D device
if (d3ddev != NULL)
d3ddev->Release();

// release the Direct3D object
if (d3d != NULL)
d3d->Release();
}
[/code]
[/spoiler]

Hopefully I was descriptive as possible!
0

Share this post


Link to post
Share on other sites
Well, I Googled a bunch more (took a few hours) and I finally found the solution. Turns out I also had to go to Library Directories and add in the x86 folder of my SDK's Lib folder, like so. (x64 if it's a higher-end machine apparently?)

[center][img]http://i.imgur.com/unERo.png[/img][/center]

After seeing infuriatingly unspecific responses to problems, I would hope this helps other people out in the future. :x

Now all I have to do is figure out how to make my program not close immediately. ):
0

Share this post


Link to post
Share on other sites
Regarding your other question - no reason not to jump straight to D3D11 (I'd advise skipping 10 - if you need to run on downlevel hardware you can accomplish this in 11 via feature levels). D3D9 is rather old and contains quite a bit of legacy cruft that will make things a little painful (lost devices, I'm looking at you in particular) whereas 11 is nice and clean and modern. Yes, the initialization code can look scary, but it's very front-loaded in initialization and object-creation; once you get over those 2 humps actually drawing stuff is shockingly simple.

The main downside to 11 is that the quality of the SDK documentation is nowhere near up to the same standard as that for 9 or 10; there were still some quite basic errors in it for a long time that were only corrected in the most recent versions (CopySubresourceRegion, I'm looking at you in particular). Arm yourself with a good book - like Frank Luna's - and you shouldn't go too far wrong.
2

Share this post


Link to post
Share on other sites
Would I need to change any of my code in order to adapt to D3D11 or can I just change the header files and library files and not have a problem? As far as you know?
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0