Jump to content

  • Log In with Google      Sign In   
  • Create Account


DirectX Tutoial issues


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Braeden   Members   -  Reputation: 110

Like
0Likes
Like

Posted 12 June 2012 - 07:44 PM

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 http://www.directxtutorial.com/ . 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
LRESULT CALLBACK WindowProc(HWND hWnd,
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
WNDCLASSEX wc;

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

// fill in the struct with the needed information
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 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
RegisterClassEx(&wc);

// 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
TranslateMessage(&msg);

// send the message to the WindowProc function
DispatchMessage(&msg);
}

// 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
switch(message)
{
// this message is read when the window is closed
case WM_DESTROY:
{
// close the application entirely
PostQuitMessage(0);
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

Sponsor:

#2 NickUdell   Members   -  Reputation: 288

Like
0Likes
Like

Posted 13 June 2012 - 07:07 AM

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");
}

or:


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

Sole Creator of Pigment - a procedural, block-base space trading sim.

PhD student working on medical imaging at the University of Southampton.

Enjoyer of games, films, books and cider.

#3 Amr0   Members   -  Reputation: 1086

Like
0Likes
Like

Posted 13 June 2012 - 08:12 AM

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.

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.

Edited by Amr0, 13 June 2012 - 08:14 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS