Sign in to follow this  

DirectX Tutoial issues

Recommended Posts

Braeden    110
Hi guys,

I've been trying to learn DirectX for a while now. I've tried to use the tutorials in the June 2010 sdk but the basic ones wouldnt compile in 2008 VC++ for some reason, so i look for some more tutorials and found this website . I really liked it, but I'm still having issues when i try to run a program. Here is the code

#include <windows.h>
#include <windowsx.h>

// the WindowProc function prototype
UINT message,
WPARAM wParam,
LPARAM lParam);

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
// the handle for the window, filled by a function
HWND hWnd;
// this struct holds information for the window class

// clear out the window class for use
ZeroMemory(&wc, sizeof(WNDCLASSEX));

// fill in the struct with the needed information
wc.cbSize = sizeof(WNDCLASSEX); = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = L"WindowClass1";

// register the window class

// create the window and use the result as the handle
hWnd = CreateWindowEx(NULL,
L"WindowClass1", // name of the window class
L"Our First Windowed Program", // title of the window
WS_OVERLAPPEDWINDOW, // window style
300, // x-position of the window
300, // y-position of the window
500, // width of the window
400, // height of the window
NULL, // we have no parent window, NULL
NULL, // we aren't using menus, NULL
hInstance, // application handle
NULL); // used with multiple windows, NULL

// display the window on the screen
ShowWindow(hWnd, nCmdShow);

// enter the main loop:

// this struct holds Windows event messages
MSG msg;

// wait for the next message in the queue, store the result in 'msg'
while(GetMessage(&msg, NULL, 0, 0))
// translate keystroke messages into the right format

// send the message to the WindowProc function

// return this part of the WM_QUIT message to Windows
return msg.wParam;

// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// sort through and find what code to run for the message given
// this message is read when the window is closed
// close the application entirely
return 0;
} break;

// Handle any messages the switch statement didn't
return DefWindowProc (hWnd, message, wParam, lParam);

and here are the errors i get
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Programming\Visual Studio 2008\Projects\DirectXWindow\Debug\DirectXWindow.exe : fatal error LNK1120: 1 unresolved externals

Please help, I really want to get into game programming but i'm starting to get a bit frustrated because I've been trying for weeks to get something working

Share this post

Link to post
Share on other sites
NickUdell    292
Protip: If you highlight your code in the post editor and select the "code" button (symbol: <>) it'll be a lot easier for us to understand.

Like so:

public static void main()
Console.WriteLine("This is ugly");


public static void main()
Console.WriteLine("This is beautiful");

Share this post

Link to post
Share on other sites
Amr0    2230
I guess it doesn't say so in the tutorial, but when you create a new project in VC++2008, you need to select "windows application" (or something like that) from the projects templates. This takes care of setting up the required linker options.

[size=2]P.S. Your post belongs in the "General Programming", or the "For Beginners" sections rather than DX & XNA since it practically has nothing to do with DirectX.[/size] Edited by Amr0

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