Original Post
First of all, Hello Gamedev! I would like to ask for help because I'm having trouble linking this code of mine. I tried compiling it but it seems to work fine. But when I tried linking it, it displays two errors. Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/window.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. window.exe - 2 error(s), 0 warning(s) This is my code. Please do take a look at it. Thanks in advance :)
[sourcecode]
#include<d3dx9.h>
#define D3DFVF_D3DVertex (D3DFVF_XYZ|D3DFVF_DIFFUSE)
// Here are our Direct3D objects. The first is used to get access to Direct3D
// and the second will be used to render to the screen.
LPDIRECT3D9 Direct3D_Object = NULL;
LPDIRECT3DDEVICE9 D3D_Device = NULL;
// This is the Windows procedure (WndProc). This handles messages that the
// windows operating sends to your application.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_KEYUP:
// If the user presses the escape key then exit the application.
if(wParam == VK_ESCAPE)
PostQuitMessage(0);
break;
case WM_DESTROY:
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
break;
}
return DefWindowProc( hwnd, message, wParam, lParam );
}
// This is the WinMain class.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
HWND hwnd; // Handle to the window.
WNDCLASSEX windowClass; // Window class object.
bool done = false; // Used to test if the app is running or not.
// This is the Window class.
windowClass.cbSize = sizeof(WNDCLASSEX); // size of the WNDCLASSEX structure.
windowClass.style = CS_HREDRAW | CS_VREDRAW; // style of the window.
windowClass.lpfnWndProc = WndProc; // Address to the windows procedure.
windowClass.cbClsExtra = 0; // Extra class information.
windowClass.cbWndExtra = 0; // Extra window information.
windowClass.hInstance = hInstance; // Handle of application Instance.
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);// Window Icon.
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); // Load mouse cursor.
windowClass.hbrBackground = NULL; // Background color.
windowClass.lpszMenuName = NULL; // Menu.
windowClass.lpszClassName = "UGPClass"; // Name of the window class.
windowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);// Minimized window icon.
// You must register you class with Windows.
if(!RegisterClassEx(&windowClass))
return 0;
// Create the window.
hwnd = CreateWindowEx(NULL, // The extended window style.
"UGPClass",// Window class.
"Direct3D Tutorial by The Programming Ace",// Window name.
WS_OVERLAPPEDWINDOW | WS_VISIBLE | // Window style.
WS_SYSMENU |WS_CLIPCHILDREN | // Window style.
WS_CLIPSIBLINGS, // Window style.
100, 100, // X, Y coords.
400, 400, // Window size.
NULL, // Handle to parent window.
NULL, // Menu.
hInstance, // Handle to app instance.
NULL); // Pointer to window.
// If there was an error with creating the window, then close the program.
if(!hwnd)
return 0;
ShowWindow(hwnd, SW_SHOW); // Show the window.
UpdateWindow(hwnd); // Update its display.
done = false; // false = run program, true means stop.
return 0;
}
[/sourcecode]