Sender: Winson (Ah), Write Area: Programming Title: A DirectX Example Send Station: BBS Shuimu Tsinghua Station (WED JAN 14 16:49:07 1998) #include
RectDest.Bottom = 32; DDS2-> BLT (& RectDest, DDS3, & RectSrc, DDBLT_WAIT, NULL); IF (ABS (NX - OX) <32 && ABS (NY - OY) <32) {IF (NX
rectSrc, DDBLT_WAIT, NULL);} LRESULT CALLBACK WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {HDC hDC; PAINTSTRUCT paintStruct; switch (uMsg) {case WM_PAINT: hDC = BeginPaint (hwnd, & paintStruct); if ( HDC! = NULL) {Moveball (hwnd, false); endpaint (hwnd, & paintstruct);} Break; Case WM_TIMER: Moveball (hwnd, true); Break; Case WM_KeyDown: Switch (wparam) {Case VK_LEFT: VX -; break; case VK_UP: vy--; break; case VK_RIGHT: vx ; break; case VK_DOWN: vy ; break; case VK_ESCAPE: PostMessage (hwnd, WM_CLOSE, 0, 0);} break; case WM_DESTROY: PostQuitMessage (0); Break; Default: Return DefwindowProc (HWND, UMSG, WPARAM, LPARAM) ;} Return 0;} int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR d3, int nCmdShow) {MSG msg; HWND hwnd; WNDCLASS wndClass; DDSURFACEDESC ddsd; DSBUFFERDESC dsbd; HDC hddDC; RECT rect; HRSRC hrsrc; HGLOBAL hRData; DWORD * pRData; LPBYTE pMem1, pMem2; DWORD dwSize1, dwSize2; if (hPrevInstance == NULL) {memset (& wndClass, 0, sizeof (wndClass)); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass. Hinstance = hinstance; wndclass.hcursor = loadingcursor (null, idc_arrow);
wndClass.hbrBackground = (HBRUSH) (COLOR_WINDOW 1); wndClass.lpszClassName = "BOUNCE"; if (RegisterClass (& wndClass)!) return FALSE;} hwnd = CreateWindow ( "BOUNCE", "BOUNCE", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0 , CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); DirectDrawCreate (NULL, & dd, NULL); dd-> SetCooperativeLevel (hwnd, DDSCL_NORMAL | DDSCL_NOWINDOWCHANGES); memset (& ddsd, 0, sizeof (DDSURFACEDESC)); ddsd.dwSize = sizeof (DDSURFACEDESC); ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; ddsd.dwFlags = DDSD_CAPS; dd-> CreateSurface (& ddsd, & dds0, NULL); dd-> CreateClipper (0, & ddc, NULL); dds0-> SetClipper (ddc ); ddc-> SetHWnd (0, hwnd); ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwHeight = 32; ddsd.dwWidth = 32; ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; dd-> CreateSurface (& ddsd, & dds1 NULL); DD-> CreateSurface (& DDSD, & DDS2, NULL); DD-> CreateSurface (& DDSD, & DDS3, NULL); DDS1-> Getdc (& HDDDC); Savedc (HDDDC); Rect.Lep = Rect.top = 0; Rect.right = rect.bottom = 32; FillRect (hddDC, & rect, (HBRUSH) (COLOR_WINDOW 1)); SelectObject (hddDC, GetStockObject (BLACK_BRUSH)); SelectObject (hddDC, GetStockObject (BLACK_PEN)); Ellipse (hddDC, 0, 0 , 32, 32); RestoredC (HDDDC, -1); DDS1-> ReleaseDC (HDDC); DDS3-> Getdc (& HDDDC); FillRect (HDDDC, & Rect, (Hbrush) (color_window 1)); DDS3->