-
26 errors! Why??
I have this code. You don't have to read it. Just copy - paste it on your compiler , compile it and tell me if it works. I compile it and it has 26 errors! If it works, press Alt+F4 to exit. If you want to read it, let me know where is the problem please...
Code:
#include <windows.h>
#include <ddraw.h>
HWND hWndMain;
IDirectDraw7 *pDD;
IDirectDrawSurface7 *lpPrimary, *lpBackBuffer;
// Initialise DirectDraw and go to full screen mode.
void InitDirectDraw()
{
// Create the DirectDraw object, through which we will create surfaces.
DirectDrawCreateEx(NULL, (void **)&pDD, IID_IDirectDraw7, NULL);
// Set the co-operative level to exclusive and full-screen.
pDD->SetCooperativeLevel(hWndMain,
DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT);
// Set the display mode to 640x480, 16-bit colour, default refresh rate.
pDD->SetDisplayMode(640, 480, 16, 0, 0);
DDSURFACEDESC2 ddsd;
// Create the primary surface with two back buffers.
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
ddsd.dwSize = sizeof(DDSURFACEDESC2);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 2;
pDD->CreateSurface(&ddsd, &lpPrimary, NULL);
// Get the back buffer pointer, to which we will do all drawing.
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
lpPrimary->GetAttachedSurface(&ddsd.ddsCaps, &lpBackBuffer);
}
void ExitDirectDraw()
{
// Release the primary surface. Note that the back buffer is automatically released
// (since it was created at the same time).
lpPrimary->Release();
lpPrimary = NULL;
// Release the DirectDraw object.
pDD->Release();
pDD = NULL;
}
// Handle all messages for the main window.
LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
ExitDirectDraw();
DestroyWindow(hWnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
// Register the window class for the main window.
void RegisterWindowClass()
{
WNDCLASSEX wcx;
ZeroMemory(&wcx, sizeof(WNDCLASSEX));
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.lpfnWndProc = MainWindowProc;
wcx.hInstance = GetModuleHandle(NULL);
// Windows-default icon. Replace with your own.
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcx.hCursor = NULL;
// Black background for the window.
wcx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = "SampleWindowClass";
RegisterClassEx(&wcx);
}
// Idle-time processing function.
void OnIdle(void)
{
}
// Program entry point.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
MSG msg;
RegisterWindowClass();
// Create a window that fills the screen.
hWndMain = CreateWindowEx(WS_EX_APPWINDOW,
"SampleWindowClass", "DirectDraw Bare-Bones Sample", WS_POPUP,
0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
NULL, NULL, hInstance, NULL);
ShowWindow(hWndMain, SW_SHOW);
InitDirectDraw();
// Message loop. Note that this has been modified to allow
// us to execute even if no messages are being processed.
for ( ; ; )
{
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!GetMessage(&msg, NULL, 0, 0))
break;
// If you want WM_CHAR messages, add
// TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Idle-time processing
OnIdle();
}
return 0;
}
Thanks in advance...
-
What do the errors say? Whe I copied your code and pasted it my compiler smushed some variable types and names together giving me 22 errors. I just separated them and it compiled fine. If you are getting linking errors make sure you are linking to the appropriate libraries.
dxguid.lib
ddraw.lib
Let me know your specific errors.
-
Because i cannot copy-past the errors:
-
Do you have the DirectX SDK?
-
Because i cannot copy-past the errors, i post this image:
-
Did you even look at my post?
-
DirectX SDK --> what is this?
-
LMAO that response is classic.
You need the SDK to make DX apps, get it from here:
http://www.microsoft.com/downloads/d...DisplayLang=en
-
It is 223 Mega Bytes! That's too much! I 'll have to wait some days untill i downloed it! Thanks a lot anyway. But do you have a better suggestion?
-
Either you download the DirectX SDK, or you don't use DirectX.
-
SDK which stands for 'Software developers kit' is what you need to link the header files to what functions you are trying to call from DirectX itself.
It would be like that too, say for instance you want to use a lot of the functionality of Winamp (stick with me here) in your program/app. You would have to download there SDK to 'plug in' there features/functions.
Hope that helps. :)