Original Post
#includeWhat''s wrong with this? Why doesn''t it work? It compiles fine, but it doesn''t do anything.#include #define WIN32_LEAN_AND_MEAN #define _RGB16BIT(r,g,b) ((b%32)+((g%32)<<5)+((r%32)<<10)) /* Declare Windowsprocedure */ LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); /* Make the classname into a global variable */ char szClassName[ ] = "Project1"; int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application is saved */ WNDCLASSEX wincl; /* Datastructure for the windowclass */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof(WNDCLASSEX); wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); if(!RegisterClassEx(&wincl)) return 0; hwnd = CreateWindowEx( 0, szClassName, "Project 1", WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, HWND_DESKTOP, NULL, hThisInstance, NULL ); ShowWindow(hwnd, nFunsterStil); while(GetMessage(&messages, NULL, 0, 0)) { DispatchMessage(&messages); } LPDIRECTDRAW lpdd; DDSURFACEDESC ddsd; LPDIRECTDRAWSURFACE lpddsprimary; if(DirectDrawCreate(NULL, &lpdd, NULL) != DD_OK) { MessageBox(hwnd, "The Bastard Didn''t Work", "Damnit", MB_OK); DestroyWindow(hwnd); } lpdd->SetCooperativeLevel(hwnd, DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT); lpdd->SetDisplayMode(640, 480, 8); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL)!=DD_OK) { MessageBox(hwnd, "The Bastard Didn''t Work", "Damnit", MB_OK); DestroyWindow(hwnd); } memset(&ddsd, 0 ,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); lpddsprimary->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); UCHAR *video_buffer; video_buffer = (UCHAR *)ddsd.lpSurface; int x = 50; int y = 100; for(int i = 0; i < 20; i++) { video_buffer[(x + i) + (y*ddsd.lPitch >> 1)] = (USHORT)_RGB16BIT(100,200,100); } Sleep(1000); lpddsprimary->Unlock(ddsd.lpSurface); if(lpddsprimary) lpddsprimary->Release(); if(lpdd) lpdd->Release(); return messages.wParam; } /* This function is called by the Windowsfunction DispatchMessage( ) */ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_DESTROY: PostQuitMessage(0); /* send a WM_QUIT to the messagequeue */ break; case WM_CHAR: PostQuitMessage(0); break; default: /* for messages that we don''t deal with */ return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }