few windows changes
This commit is contained in:
parent
ddcdf479a2
commit
662f1d9027
@ -106,3 +106,14 @@ WindowSize GetWindowSize()
|
|||||||
{
|
{
|
||||||
return _GetWindowSize();
|
return _GetWindowSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b32 ShouldQuit()
|
||||||
|
{
|
||||||
|
return _ShouldQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
b32 NeedWindowResize()
|
||||||
|
{
|
||||||
|
return _NeedWindowResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,8 @@ b32 CreateSystemWindow();
|
|||||||
b32 GetWindowEvent(WindowEvent *event);
|
b32 GetWindowEvent(WindowEvent *event);
|
||||||
void WaitForWindowEvent(WindowEvent *event);
|
void WaitForWindowEvent(WindowEvent *event);
|
||||||
WindowSize GetWindowSize();
|
WindowSize GetWindowSize();
|
||||||
|
b32 NeedWindowResize()
|
||||||
|
b32 ShouldQuit();
|
||||||
|
|
||||||
// Directory Functions
|
// Directory Functions
|
||||||
b32 ChangeWorkingDir(const char *);
|
b32 ChangeWorkingDir(const char *);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
HINSTANCE win32_instance = {};
|
HINSTANCE win32_instance = {};
|
||||||
|
|
||||||
Window win32_window = {};
|
Window win32_window = {};
|
||||||
|
b32 global_quit = false;
|
||||||
|
|
||||||
LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM w_param, LPARAM l_param)
|
LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM w_param, LPARAM l_param)
|
||||||
{
|
{
|
||||||
@ -10,15 +10,14 @@ LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM w_param, LPARAM l_
|
|||||||
{
|
{
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
OutputDebugStringA("WM_SIZE\n");
|
win32_window.w = LOWORD(l_param);
|
||||||
|
win32_window.h = HIWORD(l_param);
|
||||||
|
win32_window.resize_requested = true;
|
||||||
} break;
|
} break;
|
||||||
case WM_DESTROY:
|
case WM_DESTROY: // TODO(MA): Probably handle these separately but for now, they're together
|
||||||
{
|
|
||||||
OutputDebugStringA("WM_DESTROY\n");
|
|
||||||
} break;
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
{
|
{
|
||||||
OutputDebugStringA("WM_CLOSE\n");
|
global_quit = true;
|
||||||
} break;
|
} break;
|
||||||
case WM_ACTIVATEAPP:
|
case WM_ACTIVATEAPP:
|
||||||
{
|
{
|
||||||
@ -37,48 +36,9 @@ int CALLBACK WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line
|
|||||||
{
|
{
|
||||||
win32_instance = instance;
|
win32_instance = instance;
|
||||||
|
|
||||||
WNDCLASS window_class = {
|
int result = main(__argc, __argv);
|
||||||
.style = CS_OWNDC|CS_HREDRAW|CS_VREDRAW,
|
|
||||||
.lpfnWndProc = WindowProc,
|
|
||||||
.hInstance = instance,
|
|
||||||
.lpszClassName = "GearsWindowClass",
|
|
||||||
};
|
|
||||||
|
|
||||||
if (RegisterClass(&window_class))
|
PostQuitMessage(result);
|
||||||
{
|
|
||||||
HWND window_handle = CreateWindowEx(
|
|
||||||
0,
|
|
||||||
window_class.lpszClassName,
|
|
||||||
"Video Game",
|
|
||||||
WS_OVERLAPPEDWINDOW|WS_VISIBLE,
|
|
||||||
CW_USEDEFAULT,
|
|
||||||
CW_USEDEFAULT,
|
|
||||||
CW_USEDEFAULT,
|
|
||||||
CW_USEDEFAULT,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
instance,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
if (window_handle)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
MSG message;
|
|
||||||
BOOL message_result = GetMessage(&message, 0, 0, 0);
|
|
||||||
if (message_result > 0)
|
|
||||||
{
|
|
||||||
TranslateMessage(&message);
|
|
||||||
DispatchMessage(&message);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b32 _LoadLib(const char *name, Library *out_lib)
|
b32 _LoadLib(const char *name, Library *out_lib)
|
||||||
@ -188,23 +148,37 @@ b32 _CreateWindow()
|
|||||||
|
|
||||||
Window *_GetWindow()
|
Window *_GetWindow()
|
||||||
{
|
{
|
||||||
return NULL;
|
return &win32_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
b32 _GetWindowEvent(WindowEvent *event)
|
void _ProcessWindowEvents()
|
||||||
{
|
{
|
||||||
b32 success = true;
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _WaitForWindowEvent(WindowEvent *event)
|
void _WaitForWindowEvent(WindowEvent *event)
|
||||||
{
|
{
|
||||||
|
MSG message;
|
||||||
|
BOOL message_result = GetMessageA(&message, 0, 0, 0);
|
||||||
|
if (message_result > 0)
|
||||||
|
{
|
||||||
|
TranslateMessage(&message);
|
||||||
|
DispatchMessage(&message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b32 _ShouldQuit()
|
||||||
|
{
|
||||||
|
return global_quit;
|
||||||
|
}
|
||||||
|
|
||||||
|
b32 _NeedWindowResize()
|
||||||
|
{
|
||||||
|
return win32_window.resize_requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowSize _GetWindowSize()
|
WindowSize _GetWindowSize()
|
||||||
{
|
{
|
||||||
return (WindowSize){ .w = 0, .h = 0 };
|
return (WindowSize){ .w = win32_window.w, .h = win32_window.h };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
HWND handle;
|
HWND handle;
|
||||||
|
u16 h, w;
|
||||||
|
b32 resize_requested;
|
||||||
} Window;
|
} Window;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user