#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddraw.h>
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
HWND global_hwnd = NULL;
LPDIRECTDRAW lpdd = NULL;
LPDIRECTDRAW lpdd4 = NULL;
if(FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
{
}
if(FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4)))
{
}
lpdd->Release();
lpdd = NULL;
HRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{
return(0);
}break;
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return(0);
}break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
}break;
default:break;
}
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
winclass.lpfnWndProc = WinProc;
winclass.hInstance = hinstance;
winclass.cbClsExtra = NULL;
winclass.cbWndExtra = NULL;
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
winclass.lpszClassName = "Winclass1";
winclass.lpszMenuName = NULL;
if(!(RegisterClassEx(&winclass)))
return(0);
if(!(hwnd = CreateWindowEx(NULL,
"Winclass1",
"My First Ecounter with DirectX!",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
700,700,
NULL,
NULL,
hinstance,
NULL)))
return(0);
while(1)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(KEYDOWN(VK_ESCAPE))
SendMessage(hwnd, WM_CLOSE, 0 , 0);
}
return(msg.wParam);
}
Why won't DirectX work?!
Why won''t this work?
Here are the errors:
Compiling...
Main.cpp
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(13) : error C2143: syntax error : missing '';'' before ''if''
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(14) : error C2143: syntax error : missing '';'' before ''{''
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(14) : error C2447: missing function header (old-style formal list?)
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(17) : error C2143: syntax error : missing '';'' before ''if''
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(18) : error C2143: syntax error : missing '';'' before ''{''
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(18) : error C2447: missing function header (old-style formal list?)
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(21) : error C2143: syntax error : missing '';'' before ''->''
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(21) : error C2501: ''lpdd'' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(21) : error C2040: ''lpdd'' : ''int'' differs in levels of indirection from ''struct IDirectDraw *''
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(21) : error C2143: syntax error : missing '';'' before ''->''
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(22) : error C2501: ''lpdd'' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\DirectX\FirstEcounter\Main.cpp(22) : error C2040: ''lpdd'' : ''int'' differs in levels of indirection from ''struct IDirectDraw *''
Error executing cl.exe.
Main.obj - 12 error(s), 0 warning(s)
Take it to the Xtreme!
Wachar's Eternity <-<-<-<-<- Me own site!
a. Your errors have nothing to do with DX.
b. That''s Encounter.
c. Code must be put inside functions.
d. You really should learn the language (C++), your compiler (VC), and in particular understand error messages produced before attempting to program DX or any other API for that matter.
e. Stop copy-pasting code. How many lines of your program do you understand?
b. That''s Encounter.
c. Code must be put inside functions.
d. You really should learn the language (C++), your compiler (VC), and in particular understand error messages produced before attempting to program DX or any other API for that matter.
e. Stop copy-pasting code. How many lines of your program do you understand?
---visit #directxdev on afternet <- not just for directx, despite the name
add the line: #include "d3d.h" to the top (or whatever the header file for DX7 is)
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
You should buy a good book about Windows programming. I recommend "Programming Windows" by Charles Petzold or "Windows 98 programming from the ground up" by Herbert Schildt.
Those books will teach you these things. You should understand basic win32 before atempting DX.
Those books will teach you these things. You should understand basic win32 before atempting DX.
-------------Ban KalvinB !
This site teaches basic Win32 programming (I still recommend a book).
http://www.winprog.org/tutorial/
http://www.winprog.org/tutorial/
-------------Ban KalvinB !
hi!
where do you find tut''s with that Win2_lean_and_mean stuff in it?
cos i cant find any good ones on win32!
_________________________________________________________________________
Can someone be nice and help me on my way to be the next Hideo Kojima? Thought So...
where do you find tut''s with that Win2_lean_and_mean stuff in it?
cos i cant find any good ones on win32!
_________________________________________________________________________
Can someone be nice and help me on my way to be the next Hideo Kojima? Thought So...
quote: Original post by granat
I recommend ... "Windows 98 programming from the ground up" by Herbert Schildt.
I second that. It makes a pretty good reference and teaches you anything you want to know about windows programming, and I do mean just about anything!
Moe''s site
I''ve been over that tutorial many times. Well, I got it the DirectX to work a bit. Now it''s down to 2 link errors. I have the build directories set correctly and I know because I tested it. Also, the compiler seems not to care if I use:
LPDIRECTDRAW4 lpdd4 = NULL;
or
LPDIRECTDRAW lppd4 = NULL;
Which one''s correct?
Link errors:
Main.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw4
Debug/FirstEcounter.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Take it to the Xtreme!
LPDIRECTDRAW4 lpdd4 = NULL;
or
LPDIRECTDRAW lppd4 = NULL;
Which one''s correct?
Link errors:
Main.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw4
Debug/FirstEcounter.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Take it to the Xtreme!
Wachar's Eternity <-<-<-<-<- Me own site!
I can''t debug without it linking successfully anyways!
Take it to the Xtreme!
Take it to the Xtreme!
Wachar's Eternity <-<-<-<-<- Me own site!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement