Several smaller updates
Windows version of ReWindow now compiling Added to gitignore
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
/cmake-build-debug
|
||||
/.idea
|
||||
build/CMakeCache.txt
|
||||
build/CMakeCache.txt
|
||||
build/*
|
||||
.vscode/*
|
||||
|
@@ -51,7 +51,7 @@ namespace ReWindow
|
||||
}
|
||||
#else
|
||||
// https://learn.microsoft.com/en-us/windows/win32/menurc/about-cursors
|
||||
enum class WindowsCursorStyle {
|
||||
enum WindowsCursorStyle {
|
||||
Arrow,
|
||||
IBeam,
|
||||
Wait,
|
||||
@@ -65,6 +65,5 @@ namespace ReWindow
|
||||
WindowsCursorStyle WindowsCursor;
|
||||
CursorStyle (WindowsCursorStyle style): WindowsCursor(style) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
@@ -19,9 +19,9 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#include <rewindow/types/cursors.h>
|
||||
#endif
|
||||
|
||||
#include <rewindow/types/cursors.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using precision_clock = std::chrono::high_resolution_clock;
|
||||
@@ -179,6 +179,8 @@ namespace ReWindow
|
||||
OnKeyDown(eventData);
|
||||
}
|
||||
#ifndef __linux___
|
||||
RWindow(HINSTANCE hInst);
|
||||
|
||||
void setRect (int nx, int ny, int nw, int nh) {
|
||||
setPos(nx, ny);
|
||||
width = nw;
|
||||
@@ -253,16 +255,12 @@ namespace ReWindow
|
||||
RenderingAPI renderer;
|
||||
bool open = false;
|
||||
bool resizable;
|
||||
|
||||
//You can't do this because you can't initialize a static member inside the class constructor.
|
||||
//static RWindow* singleton;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class WindowsImplementationRWindow : public RWindow {
|
||||
class WindowsImplementationRWindow: public RWindow {
|
||||
};
|
||||
|
||||
class X11ImplementationRWindow : public RWindow {
|
||||
class X11ImplementationRWindow: public RWindow {
|
||||
};
|
||||
}
|
41
main.cpp
41
main.cpp
@@ -81,44 +81,15 @@ int main() {
|
||||
#include <windows.h>
|
||||
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||
{
|
||||
auto* window = new RWindow();
|
||||
window->init(RenderingAPI::OPENGL, "mame", 100, 100);
|
||||
window->setFlag
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
|
||||
auto* window = new ReWindow::RWindow(hInstance);
|
||||
window->setTitle ("Sample Window");
|
||||
window->raise ();
|
||||
|
||||
// Register the window class.
|
||||
const wchar_t CLASS_NAME[] = L"Sample Window Class";
|
||||
while (window->pollEvents ()) {
|
||||
|
||||
WNDCLASS wc = { };
|
||||
wc.lpfnWndProc = WindowProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.lpszClassName = CLASS_NAME;
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
// Create the window.
|
||||
HWND hwnd = CreateWindowEx(
|
||||
0,
|
||||
CLASS_NAME,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, // Parent Window
|
||||
NULL, // Menu
|
||||
hInstance, // Instancehandle
|
||||
NULL
|
||||
);
|
||||
if (hwnd == NULL)
|
||||
return 0;
|
||||
|
||||
ShowWindow(hwnd, nCmdShow);
|
||||
|
||||
// Run the message loop
|
||||
MSG msg = {};
|
||||
while (GetMessage(&msg, NULL, 0, 0) > 0)
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -117,12 +117,14 @@ static DEVMODEA mode;
|
||||
|
||||
ReWindow::RWindow::RWindow() {
|
||||
if (!reClass) {
|
||||
WNDCLASSA rewc = {
|
||||
ReWindowProc, 0, 0, NULL, NULL, , NULL, NULL,
|
||||
GetStockObject (BLACK_BRUSH), NULL, "ReWindowClass"
|
||||
HINSTANCE module = GetModuleHandleA (NULL);
|
||||
|
||||
WNDCLASS rewc = {CS_HREDRAW | CS_VREDRAW,
|
||||
ReWindowProc, 0, 0, module, NULL, LoadCursor (NULL, IDC_ARROW),
|
||||
(HBRUSH) GetStockObject (BLACK_BRUSH), NULL, "ReWindowClass"
|
||||
};
|
||||
|
||||
reClass = RegisterClassA (&rewc);
|
||||
reClass = RegisterClass (&rewc);
|
||||
}
|
||||
|
||||
hwnd = CreateWindowA ("ReWindowClass", "ReWindow", WS_TILEDWINDOW,
|
||||
@@ -198,13 +200,18 @@ void ReWindow::RWindow::refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
void ReWindow::RWindow::pollEvents() {
|
||||
bool ReWindow::RWindow::pollEvents() {
|
||||
MSG msg;
|
||||
|
||||
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
if (msg.message == WM_QUIT) {
|
||||
return FALSE;
|
||||
}
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Might make the window go off the screen on some window managers.
|
||||
@@ -280,13 +287,13 @@ void ReWindow::RWindow::refresh() {
|
||||
screen.dmPelsHeight = height;
|
||||
screen.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
|
||||
if (ChangeDisplaySettings (&screen, 0) == DISP_CHANGE_SUCCESSFUL) {
|
||||
if (ChangeDisplaySettingsA (&screen, 0) == DISP_CHANGE_SUCCESSFUL) {
|
||||
fullscreenmode = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ReWindow::RWindow::restoreFromFullscreen() {
|
||||
if (ChangeDisplaySettings (&mode, 0) == DISP_CHANGE_SUCCESSFUL) {
|
||||
if (ChangeDisplaySettingsA (&mode, 0) == DISP_CHANGE_SUCCESSFUL) {
|
||||
fullscreenmode = false;
|
||||
}
|
||||
}
|
||||
@@ -302,8 +309,8 @@ void ReWindow::RWindow::refresh() {
|
||||
}
|
||||
|
||||
void ReWindow::RWindow::setCursorStyle (CursorStyle style) const {
|
||||
uint ids = [IDC_ARROW, IDC_IBEAM, IDC_WAIT, IDC_CROSS, IDC_HAND, IDC_APPSTARTING];
|
||||
SetClassLongPtr (hwnd, GCLIP_HCURSOR, LoadCursor (NULL, ids[style]));
|
||||
LPWSTR ids[] ={IDC_ARROW, IDC_IBEAM, IDC_WAIT, IDC_CROSS, IDC_HAND, IDC_APPSTARTING};
|
||||
SetClassLongPtr (hwnd, GCLP_HCURSOR, (LONG_PTR) LoadCursor (NULL, ids[style.WindowsCursor]));
|
||||
}
|
||||
|
||||
void ReWindow::RWindow::Open() {
|
||||
@@ -325,7 +332,7 @@ void ReWindow::RWindow::refresh() {
|
||||
|
||||
if (glrc) {
|
||||
wglMakeCurrent (hdc, glrc);
|
||||
EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &mode);
|
||||
EnumDisplaySettingsA (NULL, ENUM_CURRENT_SETTINGS, &mode);
|
||||
open = true;
|
||||
}
|
||||
}
|
||||
@@ -342,8 +349,8 @@ void ReWindow::RWindow::refresh() {
|
||||
}
|
||||
|
||||
bool ReWindow::RWindow::isKeyDown (Key key) const {
|
||||
return currentKeyboard.PressedKeys.contains(key) ?
|
||||
currentKeyboard.PressedKeys.at(key) : false;
|
||||
return currentKeyboard.PressedKeys.contains (key) ?
|
||||
currentKeyboard.PressedKeys.at (key) : false;
|
||||
}
|
||||
|
||||
// TODO: Implement MouseButton map
|
||||
|
Reference in New Issue
Block a user