Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Project2100 committed Nov 8, 2021
2 parents d4883e3 + 9ebe90d commit e8d40ca
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
19 changes: 8 additions & 11 deletions graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void squareViewport(int screenWidth, int screenHeight) {


// The whole process of firing up DirectX
void InitD3D(HWND windowHandle, int width, int height) {
void InitD3D(HWND windowHandle) {


// Initialize the orientation matrix
Expand All @@ -188,11 +188,9 @@ void InitD3D(HWND windowHandle, int width, int height) {
transforms.orientMatrix[1][0] = sinf((FLOAT) M_PI_4);
transforms.orientMatrix[1][1] = cosf((FLOAT) M_PI_4);

int fsWidth = GetSystemMetrics(SM_CXFULLSCREEN);
int fsHeight = GetSystemMetrics(SM_CYFULLSCREEN);



// Set the screensaver only on the primary screen; these are the metrics to use
int fsWidth = GetSystemMetrics(SM_CXSCREEN);
int fsHeight = GetSystemMetrics(SM_CYSCREEN);

// This is the value that gets constantly checked for potential problems, almost always used by invocations from graphicsDevice
HRESULT code;
Expand All @@ -215,13 +213,12 @@ void InitD3D(HWND windowHandle, int width, int height) {
// If you create a swap chain with one buffer, specifying DXGI_SWAP_EFFECT_SEQUENTIAL does not cause the contents of the single buffer to be swapped with the front buffer.
// When you call IDXGIFactory::CreateSwapChain to create a full-screen swap chain, you typically include the front buffer in this value.
.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM, // describes the backbuffer display mode: use 32-bit color
.BufferDesc.Width = width,
.BufferDesc.Height = height,
.BufferDesc.Width = fsWidth,
.BufferDesc.Height = fsHeight,
.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, // how swap chain is to be used
.OutputWindow = windowHandle, // the application window to be used
.OutputWindow = windowHandle,
.SampleDesc = msDesc,
// .Windowed = FALSE, // start windowed or fullscreen
.Windowed = (width == fsWidth && height == fsHeight) ? FALSE : TRUE,
.Windowed = FALSE,
.SwapEffect = DXGI_SWAP_EFFECT_DISCARD, // Options for handling pixels in a display surface after calling IDXGISwapChain.present(...)
};

Expand Down
3 changes: 2 additions & 1 deletion graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#include <windows.h>

void InitD3D(HWND window, int width, int height);

void InitD3D(HWND window);

void resizeD3D(int width, int height);

Expand Down
37 changes: 27 additions & 10 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,38 @@ LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
buildShape(spongeLevel);

// Get window info, and start the engines
CREATESTRUCT* wInfo = (CREATESTRUCT*) lParam;
InitD3D(hWnd, wInfo->cx, wInfo->cy);
//CREATESTRUCT* wInfo = (CREATESTRUCT*) lParam;

// int fsWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// int fsHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);

HDC hdc = GetDC(hWnd);
RECT rc = (RECT) {
.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN),
.left = GetSystemMetrics(SM_XVIRTUALSCREEN),
.right = GetSystemMetrics(SM_CXVIRTUALSCREEN),
.top = GetSystemMetrics(SM_YVIRTUALSCREEN),
};
// GetClientRect (hWnd, &rc);
FillRect (hdc, &rc, GetStockObject(BLACK_BRUSH));
ReleaseDC(hWnd, hdc);



InitD3D(hWnd);

// Set a timer for the screen saver window using the redraw rate stored in Regedit.ini
uTimer = SetTimer(hWnd, 1, 13, RenderFrame);
break;


case WM_SIZE:
int width = LOWORD(lParam), height = HIWORD(lParam);
#ifdef DEBUG
fprintf(instanceLog, "Resizing to %d x %d\n", width, height);
#endif
resizeD3D(width, height);
break;
// Not handling SIZE messages, assuming window size remains unchanged (i.e. fullscreen on primary)
// case WM_SIZE:
// int width = LOWORD(lParam), height = HIWORD(lParam);
// #ifdef DEBUG
// fprintf(instanceLog, "Resizing to %d x %d\n", width, height);
// #endif
// resizeD3D(width, height);
// break;


case WM_DESTROY:
Expand Down

0 comments on commit e8d40ca

Please sign in to comment.