int dd_Window::set_win(int w, int h, int bpp) { // RECT r, r2; HRESULT hr; shutdown_win(); dx_win_bsd.dwWidth = w; dx_win_bsd.dwHeight = h; hr = dx_dd->CreateSurface(&dx_win_bsd, &dx_win_bs, NULL); if (hr != DD_OK) { return 0; } hr = dx_win_bs->Lock(0, &dx_win_bsd, 0, 0); if (hr != DD_OK) { DX_RELEASE(dx_win_bs); return 0; } dx_win_bs->Unlock(0); hr = dx_dd->CreateClipper(0, &clipper, 0); if (hr != DD_OK) { DX_RELEASE(dx_win_bs); return 0; } hr = clipper->SetHWnd(0, hwnd); if (hr != DD_OK) { DX_RELEASE(dx_win_bs); DX_RELEASE(clipper); return 0; } if(bGameWindow) { int ws = GetWindowLong(hwnd,GWL_STYLE); ws &= ~WS_POPUP; ws |= WS_OVERLAPPEDWINDOW | WS_THICKFRAME; SetWindowLong(hwnd, GWL_STYLE, ws); } //set pixelformat parameters //if(bGameWindow) //{ // DDPIXELFORMAT ddpf; // ddpf.dwSize = sizeof(ddpf); // ddpf.dwFlags = DDPF_RGB; // hr = dx_win_ps->GetPixelFormat(&ddpf); // if (hr != DD_OK) err("Could not get pixel format!"); // //if (ddpf.dwRBitMask == 0x7C00 && bpp == 16) // // vid_bpp = 15, vid_bytesperpixel = 2; // //else // // vid_bpp = bpp, vid_bytesperpixel = bpp / 8; //} delete img; img = new image(); img->width = w; img->height = h; img->cx1 = 0; img->cx2 = w-1; img->cy1 = 0; img->cy2 = h-1; if(vid_bpp == DesktopBPP) { img->shell = true; img->data = (quad*)dx_win_bsd.lpSurface; img->pitch = dx_win_bsd.lPitch / vid_bytesperpixel; } else { img->alloc_data(); } SetHandleImage(imgHandle,img); if(bGameWindow) { SetHandleImage(1,img); screen = img; } return 1; }