TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
omar_cplusplus
NA
28
0
DirectX is not working at all
Jan 28 2005 1:30 PM
Please can any one help me in creating a direct draw surface. when i create a direct draw surface a compile error appears. take a look on the code: this code is an example from a book for creating a directx surface (which i could not compile) ///////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN #define INITGUID #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define WINDOW_CLASS_NAME "WINXCLASS" #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 #define SCREEN_BPP 16 #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1) typedef unsigned short USHORT; typedef unsigned short WORD; typedef unsigned char UCHAR; typedef unsigned char BYTE; HWND main_window_handle = NULL; HINSTANCE main_instance = NULL; LPDIRECTDRAW7 lpdd = NULL; LPDIRECTDRAWSURFACE7 lpddsprimary = NULL; LPDIRECTDRAWSURFACE7 lpddsback = NULL; LPDIRECTDRAWPALETTE lpddpal = NULL; DDSURFACEDESC2 ddsd; DDSCAPS2 ddscaps; HRESULT ddrval; LRESULT CALLBACK WindowProc(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 main(HINSTANCE hinstance,HINSTANCE hprevinstance,PSTR lpcmdline,int ncmdshow) { WNDCLASS winclass; HWND hwnd; MSG msg; HDC hdc; PAINTSTRUCT ps; 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; if (!RegisterClass(&winclass)) return(0); if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME,"WinX Game Console",WS_POPUP | WS_VISIBLE,0,0,WINDOW_WIDTH,WINDOW_HEIGHT,NULL,NULL,hinstance,NULL))) return(0); main_window_handle = hwnd; main_instance = hinstance; if (DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)!=DD_OK) return(0); if (lpdd->SetCooperativeLevel(main_window_handle,DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)!=DD_OK) return(0); if (lpdd->SetDisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,0,0)!=DD_OK) return(0); memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if (lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL)!=DD_OK) return(0); return(1); while(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } if (KEY_DOWN(VK_ESCAPE) || KEY_DOWN(VK_SPACE)) PostMessage(main_window_handle, WM_DESTROY,0,0); return(1); } if (lpddsprimary!=NULL) lpddsprimary->Release(); if (lpdd!=NULL) lpdd->Release(); return(1); return(msg.wParam); } //////////////////////////////////////////////////////////
Reply
Answers (
0
)
.wav files
Draw on secondary Monitor