当我使用d3ddev->Present()
将后台缓冲区复制到屏幕上时,什么也没发生(返回值为D3D_OK
)。当我创建一个没有标题栏(例如WS_POPUP
)的窗口时,它将起作用。有人可以告诉我为什么吗?谢谢。
对不起,英语不好。
win10,Direct3D9
//Game update function
void Game_Run(HWND hwnd)
{
//make sure the Direct3D device is valid
if (!d3ddev) return;
//start rendering
if (SUCCEEDED(d3ddev->BeginScene())) {
//fill the surface with random color
int r = rand() % 255;
int g = rand() % 255;
int b = rand() % 255;
d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(r, g, b));
//copy the surface to the backbuffer
RECT rect;
rect.left = rand() % SCREENW / 2;
rect.right = rect.left + rand() % SCREENW / 2;
rect.top = rand() % SCREENH / 2;
rect.bottom = rect.top + rand() % SCREENH / 2;
d3ddev->StretchRect(surface, NULL, backbuffer, &rect, D3DTEXF_NONE);
//stop rendering
d3ddev->EndScene();
//copy the back buffer to the screen
d3ddev->Present(NULL, NULL, NULL, NULL);
}
//check for escape key
if (KEY_DOWN(VK_ESCAPE))
PostMessage(hwnd, WM_DESTROY, 0, 0);
}
...
//create a new window
HWND hwnd = CreateWindow(
"MainWindowClass",
APPTITLE.c_str(),
WS_POPUP, //it works
//WS_OVERLAPPEDWINDOW, it doesn't work
CW_USEDEFAULT, CW_USEDEFAULT,
SCREENW, SCREENH,
NULL, NULL, hInstance, NULL);