Jump to content
  • Advertisement
Sign in to follow this  
Fixxer

Direct Draw Help

This topic is 4721 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my code: /*================================================================== * * * "DDWINDOW" Nathan Krygier 6/20/05 * * "Tricks of the windows game programming gurus" * * source_DDWINDOW.cpp * *///================================================================= #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif // Include files //////////////////////////////////////////////////// #include <windows.h> #include <mmsystem.h> #include <windowsx.h> #include <iostream.h> #include <conio.h> #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <string.h> #include <stdarg.h> #include <stdio.h> #include <math.h> #include <io.h> #include <fcntl.h> #include <ddraw.h> // Defines ////////////////////////////////////////////////////////// #ifndef WINDOW_CLASS_NAME #define WINDOW_CLASS_NAME "WINCLASS1" #endif #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1) // Globals ////////////////////////////////////////////////////////// HWND main_window_handle = NULL; HINSTANCE hinstance_app = NULL; // Prototypes /////////////////////////////////////////////////////// int Game_Init(); int Game_Main(); int Game_Shutdown(); // WINPROC ////////////////////////////////////////////////////////// LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { PAINTSTRUCT ps; HDC hdc; // Handle windows messages ////////////////////////////////////////// switch(msg){ // WM_CREATE //////////////////////////////////////////////////////// case WM_CREATE:{ return(0); break; } // WM_PAINT ///////////////////////////////////////////////////////// case WM_PAINT:{ InvalidateRect(hwnd, NULL, FALSE); hdc = BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); return(0); break; } // WM_DESTROY /////////////////////////////////////////////////////// case WM_DESTROY:{ PostQuitMessage(0); return(0); break; } default:break; } return (DefWindowProc(hwnd, msg, wparam, lparam)); } // WINMAIN ///////////////////////////////////////////////////////// int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevistance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX WinClass; HWND hwnd; MSG msg; WinClass.cbSize = sizeof(WNDCLASSEX); WinClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; WinClass.lpfnWndProc = WindowProc; WinClass.cbClsExtra = 0; WinClass.cbWndExtra = 0; WinClass.hInstance = hinstance; WinClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); WinClass.hCursor = LoadCursor(NULL, IDC_ARROW); WinClass.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH); WinClass.lpszMenuName = NULL; WinClass.lpszClassName = WINDOW_CLASS_NAME; WinClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // Save hinstance in global ///////////////////////////////////////// hinstance_app = hinstance; // Register window class //////////////////////////////////////////// if (!RegisterClassEx(&WinClass)) return(0); // Construct window ///////////////////////////////////////////////// if (!(hwnd = CreateWindowEx(NULL, WINDOW_CLASS_NAME, "T3D Game Console", WS_POPUP | WS_VISIBLE, 0,0,GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hinstance, NULL))) return(0); // Save main window handle ////////////////////////////////////////// main_window_handle = hwnd; HDC hdc = GetDC(hwnd); // GAME ENGINE ////////////////////////////////////////////////////// // Initialize game ////////////////////////////////////////////////// Game_Init(); // GAME LOOP //////////////////////////////////////////////////////// while (TRUE) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } Game_Main(); } Game_Shutdown(); return(msg.wParam); } // Main game function //////////////////////////////////////////////// int Game_Main() { if (KEYDOWN(VK_ESCAPE)) SendMessage(main_window_handle, WM_CLOSE,0,0); return(0); } // Game startup ////////////////////////////////////////////////////// int Game_Init() { // Creat IDirectDraw interface /////////////////////////////////////// if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL))) { return(0); } // Set cooperation level ////////////////////////////////////////////// lpdd->SetCooperativeLevel(main_window_handle, DDSCL_NORMAL); return(1); } // Game end ////////////////////////////////////////////////////////// int Game_Shutdown() { // Destroy IDirectDraw interface ///////////////////////////////////// if (lpdd) { lpdd->Release(); lpdd = NULL; } return(1); } Here are the errors: --------------------Configuration: DDWINDOW - Win32 Debug-------------------- Compiling... source_DDWINDOW.cpp c:\documents and settings\owner\desktop\comp prog\c++\windows programming\chapter six\ddwindow\source_ddwindow.cpp(166) : error C2065: 'lpdd' : undeclared identifier c:\documents and settings\owner\desktop\comp prog\c++\windows programming\chapter six\ddwindow\source_ddwindow.cpp(172) : error C2227: left of '->SetCooperativeLevel' must point to class/struct/union c:\documents and settings\owner\desktop\comp prog\c++\windows programming\chapter six\ddwindow\source_ddwindow.cpp(183) : error C2227: left of '->Release' must point to class/struct/union Error executing cl.exe. DDWINDOW.exe - 3 error(s), 0 warning(s)

Share this post


Link to post
Share on other sites
Advertisement
The first error message answers all of your questions. You didn't define the variable lpdd, so nothing that references that variable will compile.

Share this post


Link to post
Share on other sites
You're not defining 'lpdd' anywhere. You probably want to have something like "LPDIRECTDRAW7 lpdd = NULL;" somewhere.

edit: gaak! beat me to it :)

Share this post


Link to post
Share on other sites
ate ty kind sir.
My book left out a huge chunk of code :-/
I had to go to the disk to get it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!