Answer the question
In order to leave comments, you need to log in
Using Direct2D In FullScreen?
Actually how?
On some site I read that Direct2D itself cannot translate into full-screen mode, so you need to use either the capabilities of WinAPI or direct3d.
Googled the code to convert to fullscreen:
void SetFullScreenMode(HWND hwnd)
{
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE);
if (dwStyle & WS_OVERLAPPEDWINDOW) {
MONITORINFO mi = { sizeof(mi) };
if (GetWindowPlacement(hwnd, &g_wpPrev) &&
GetMonitorInfo(MonitorFromWindow(hwnd,
MONITOR_DEFAULTTOPRIMARY), &mi)) {
SetWindowLong(hwnd, GWL_STYLE,
dwStyle & ~WS_OVERLAPPEDWINDOW);
SetWindowPos(hwnd, HWND_TOP,
mi.rcMonitor.left, mi.rcMonitor.top,
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}
} else {
//Перевод обратно в оконный режим
}
}
ID2D1Factory* pD2DFactory = NULL;
HRESULT hr = D2D1CreateFactory(
D2D1_FACTORY_TYPE_SINGLE_THREADED,
&pD2DFactory);
// Obtain the size of the drawing area.
RECT rc;
GetClientRect(hWnd, &rc);
// Create a Direct2D render target
ID2D1HwndRenderTarget* pRT = NULL;
hr = pD2DFactory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(),
D2D1::HwndRenderTargetProperties(
hWnd,
D2D1::SizeU(
rc.right - rc.left,
rc.bottom - rc.top)),
&pRT);
//Create a Brush
ID2D1SolidColorBrush* pBlackBrush = NULL;
if (SUCCEEDED(hr))
{
pRT->CreateSolidColorBrush(
D2D1::ColorF(D2D1::ColorF::Black),
&pBlackBrush
);
}
Answer the question
In order to leave comments, you need to log in
Something tells me that the problem is in the pixel format. See what the D2D1::PixelFormat() function returns in fullscreen and windowed modes.
The pixel format is how the video encodes characters, what bits are used for, you can set many different formats, for example, 16-bit, 32-bit, 48-bit, with several more variations, it all depends on your needs.
GetClientRect returns the rectangle of the window's client area, this is where you can draw. In this case, the coordinates are windowed, i.e. the upper left corner should be 0.0, the lower right is the size, if you need screen coordinates, you can convert it using the ClientToScreen method, there is also a reverse method, usually needed to work with the mouse.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question