Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions Core/Platforms/Win32.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "Win32.hpp"

#define TODO(msg) OutputDebugStringA(msg);

constexpr size_t MAX_ERROR_MSG_SIZE = 512;
GLOBAL TCHAR SYSTEM_ERROR_MESSAGE[MAX_ERROR_MSG_SIZE];

Expand Down Expand Up @@ -99,10 +97,9 @@ INTERNAL void SurfacePresentFrameBuffer(gdi_surface_t& surface, gdi_offscreen_bu
int srcH = backBuffer.bitmap.height;
int destW = surface.width;
int destH = surface.height;
if(!StretchBlt(surface.displayDeviceContext, 0, 0, destW, destH, surface.offscreenDeviceContext,
0, 0, srcW, srcH, SRCCOPY)) {
TODO("StretchBlt failed\n");
}
BOOL success = StretchBlt(surface.displayDeviceContext, 0, 0, destW, destH, surface.offscreenDeviceContext,
0, 0, srcW, srcH, SRCCOPY);
ASSUME(success, "StretchBlt failed (multi-monitor setup with mismatching source/destination HDCs?)");
}

INTERNAL void SurfaceDrawDebugUI(gdi_surface_t& doubleBufferedWindowSurface) {
Expand Down Expand Up @@ -184,11 +181,6 @@ LRESULT CALLBACK MainWindowProcessIncomingMessage(HWND window, UINT message, WPA
LRESULT result = 0;

switch(message) {
case WM_CREATE: {
TODO("Received WM_CREATE\n");
// TODO Initialize child windows here?
} break;

case WM_DISPLAYCHANGE:
case WM_MOVE:
case WM_MOVING:
Expand Down Expand Up @@ -266,14 +258,9 @@ LRESULT CALLBACK MainWindowProcessIncomingMessage(HWND window, UINT message, WPA
} break;

case WM_CLOSE: {
TODO("Received WM_CLOSE\n");
APPLICATION_SHOULD_EXIT = true;
} break;

case WM_ACTIVATEAPP: {
TODO("Received WM_ACTIVATEAPP\n");
} break;

case WM_ERASEBKGND: {
// NOTE: No need for the OS to clear since the entire window is always fully painted
constexpr bool didEraseBackground = true;
Expand Down Expand Up @@ -338,10 +325,8 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);

if(!RegisterClassEx(&windowClass)) {
TODO("Failed to register window class\n");
return EXIT_FAILURE;
}
ATOM classGUID = RegisterClassEx(&windowClass);
ASSUME(classGUID != NULL, "Failed to register window class (...really?)");

// TODO: On modern Windows systems, MAX_PATH is insufficient and Unicode paths should ideally be supported (later?)
TCHAR executableFileSystemPath[MAX_PATH];
Expand All @@ -358,10 +343,8 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR,
0, windowClass.lpszClassName, windowTitle.buffer,
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, instance, 0);
if(!mainWindow) {
TODO("Failed to CreateWindowExA - Exiting...");
return EXIT_FAILURE;
}
ASSUME(mainWindow != NULL, "Failed to CreateWindowExA (...can this actually happen in practice?)");

MainWindowCreateFrameBuffers(mainWindow, GDI_SURFACE, GDI_BACKBUFFER);

CPU_PERFORMANCE_INFO.applicationLaunchTime = PerformanceMetricsGetTimeSince(applicationStartTime);
Expand Down
8 changes: 4 additions & 4 deletions Core/Platforms/Win32/GamePad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ INTERNAL void GamePadPollControllers(gamepad_state_t& controllerInputs) {

constexpr DWORD MAX_SUPPORTED_GAMEPAD_COUNT = XUSER_MAX_COUNT;
for(DWORD gamePadID = 0; gamePadID < MAX_SUPPORTED_GAMEPAD_COUNT; ++gamePadID) {
XINPUT_STATE gamePadButtonState;
if(XInputGetState(gamePadID, &gamePadButtonState) != ERROR_SUCCESS) {
TODO("XInput detected a GamePad but it wasn't usable?\n")
}
XINPUT_STATE gamePadButtonState = {};
DWORD result = XInputGetState(gamePadID, &gamePadButtonState);
ASSUME(result != ERROR_DEVICE_NOT_CONNECTED, "GamePad detected, but not connected (...how does that work?)");
ASSUME(result == ERROR_SUCCESS, "GamePad detected, but it wasn't usable - despite being connected (...why?)");

XINPUT_GAMEPAD* gamePad = &gamePadButtonState.Gamepad;
controllerInputs.stickX = gamePad->sThumbLX;
Expand Down
Loading