Updates to windows version
Many changes to flesh out windows version of ReWindow. Incomplete, not compiled or tested. Almost certainly won't work as is but a lot closer to a functioning Windows version
This commit is contained in:
98
build/CMakeCache.txt
Normal file
98
build/CMakeCache.txt
Normal file
@@ -0,0 +1,98 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: d:/Work/ReWindow/build
|
||||
# It was generated by CMake: C:/Program Files/CMake/bin/cmake.exe
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
//Value Computed by CMake.
|
||||
CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=D:/Work/ReWindow/build/CMakeFiles/pkgRedirects
|
||||
|
||||
//Program used to build from makefiles.
|
||||
CMAKE_MAKE_PROGRAM:STRING=nmake
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_DESCRIPTION:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_NAME:STATIC=ReWindowLibrary
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION:STATIC=1.0
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_MAJOR:STATIC=1
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_MINOR:STATIC=0
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_PATCH:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_TWEAK:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
ReWindowLibrary_BINARY_DIR:STATIC=D:/Work/ReWindow/build
|
||||
|
||||
//Value Computed by CMake
|
||||
ReWindowLibrary_IS_TOP_LEVEL:STATIC=ON
|
||||
|
||||
//Value Computed by CMake
|
||||
ReWindowLibrary_SOURCE_DIR:STATIC=D:/Work/ReWindow
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=d:/Work/ReWindow/build
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=29
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=2
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake.exe
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cpack.exe
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=C:/Program Files/CMake/bin/ctest.exe
|
||||
//Path to cache edit program executable.
|
||||
CMAKE_EDIT_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake-gui.exe
|
||||
//Name of external makefile project generator.
|
||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
||||
//Name of generator.
|
||||
CMAKE_GENERATOR:INTERNAL=NMake Makefiles
|
||||
//Generator instance identifier.
|
||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=
|
||||
//Name of generator platform.
|
||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=
|
||||
//Name of generator toolset.
|
||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
||||
//Source directory with the top level CMakeLists.txt file for this
|
||||
// project
|
||||
CMAKE_HOME_DIRECTORY:INTERNAL=D:/Work/ReWindow
|
||||
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
|
||||
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
|
||||
//number of local generators
|
||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
|
||||
//Platform information initialized
|
||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=C:/Program Files/CMake/share/cmake-3.29
|
||||
|
15
build/CMakeFiles/3.29.2/CMakeSystem.cmake
Normal file
15
build/CMakeFiles/3.29.2/CMakeSystem.cmake
Normal file
@@ -0,0 +1,15 @@
|
||||
set(CMAKE_HOST_SYSTEM "Windows-10.0.15063")
|
||||
set(CMAKE_HOST_SYSTEM_NAME "Windows")
|
||||
set(CMAKE_HOST_SYSTEM_VERSION "10.0.15063")
|
||||
set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")
|
||||
|
||||
|
||||
|
||||
set(CMAKE_SYSTEM "Windows-10.0.15063")
|
||||
set(CMAKE_SYSTEM_NAME "Windows")
|
||||
set(CMAKE_SYSTEM_VERSION "10.0.15063")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "AMD64")
|
||||
|
||||
set(CMAKE_CROSSCOMPILING "FALSE")
|
||||
|
||||
set(CMAKE_SYSTEM_LOADED 1)
|
11
build/CMakeFiles/CMakeConfigureLog.yaml
Normal file
11
build/CMakeFiles/CMakeConfigureLog.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
---
|
||||
events:
|
||||
-
|
||||
kind: "message-v1"
|
||||
backtrace:
|
||||
- "C:/Program Files/CMake/share/cmake-3.29/Modules/CMakeDetermineSystem.cmake:205 (message)"
|
||||
- "CMakeLists.txt:2 (project)"
|
||||
message: |
|
||||
The system is: Windows - 10.0.15063 - AMD64
|
||||
...
|
1
build/CMakeFiles/cmake.check_cache
Normal file
1
build/CMakeFiles/cmake.check_cache
Normal file
@@ -0,0 +1 @@
|
||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
25
builddir/meson-logs/meson-log.txt
Normal file
25
builddir/meson-logs/meson-log.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
Build started at 2024-04-29T21:04:24.529054
|
||||
Main binary: C:\Program Files\Meson\meson.exe
|
||||
Python system: Windows
|
||||
The Meson build system
|
||||
Version: 0.49.0
|
||||
Source dir: d:\Work\ReWindow
|
||||
Build dir: d:\Work\ReWindow\builddir
|
||||
Build type: native build
|
||||
Project name: verse
|
||||
Project version: 0.1.0
|
||||
Sanity testing C compiler: gcc
|
||||
Is cross compiler: False.
|
||||
Sanity check compiler command line: gcc d:\Work\ReWindow\builddir\meson-private\sanitycheckc.c -o d:\Work\ReWindow\builddir\meson-private\sanitycheckc.exe
|
||||
Sanity check compile stdout:
|
||||
|
||||
-----
|
||||
Sanity check compile stderr:
|
||||
|
||||
-----
|
||||
Running test binary command: d:\Work\ReWindow\builddir\meson-private\sanitycheckc.exe
|
||||
Native C compiler: gcc (gcc 9.2.0 "gcc (tdm64-1) 9.2.0")
|
||||
|
||||
meson.build:1:0: ERROR: Unknown compiler(s): ['cc']
|
||||
The follow exceptions were encountered:
|
||||
Running "cc --version" gave "[WinError 2] The system cannot find the file specified"
|
0
builddir/meson-private/meson.lock
Normal file
0
builddir/meson-private/meson.lock
Normal file
1
builddir/meson-private/sanitycheckc.c
Normal file
1
builddir/meson-private/sanitycheckc.c
Normal file
@@ -0,0 +1 @@
|
||||
int main(int argc, char **argv) { int class=0; return class; }
|
BIN
builddir/meson-private/sanitycheckc.exe
Normal file
BIN
builddir/meson-private/sanitycheckc.exe
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
enum class X11CursorStyle
|
||||
@@ -31,15 +32,14 @@ namespace ReWindow
|
||||
Hand,
|
||||
AppStarting,
|
||||
};
|
||||
class CursorStyle
|
||||
{
|
||||
public:
|
||||
X11CursorStyle X11Cursor;
|
||||
CursorStyle(X11CursorStyle style) : X11Cursor(style) {}
|
||||
|
||||
class CursorStyle {
|
||||
public:
|
||||
X11CursorStyle X11Cursor;
|
||||
CursorStyle(X11CursorStyle style) : X11Cursor(style) {}
|
||||
};
|
||||
|
||||
namespace Cursors
|
||||
{
|
||||
namespace Cursors {
|
||||
static const CursorStyle Default {X11CursorStyle::Default};
|
||||
static const CursorStyle X {X11CursorStyle::X};
|
||||
static const CursorStyle Arrow {X11CursorStyle::Arrow};
|
||||
|
@@ -163,10 +163,8 @@ namespace MouseButtons
|
||||
static const MouseButton Side2;
|
||||
}
|
||||
|
||||
static MouseButton GetMouseButtonFromXButton(unsigned int button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
static MouseButton GetMouseButtonFromXButton(unsigned int button) {
|
||||
switch(button) {
|
||||
case Button1: return MouseButtons::Left;
|
||||
case Button2: return MouseButtons::Right;
|
||||
case Button3: return MouseButtons::Middle;
|
||||
@@ -180,8 +178,7 @@ static MouseButton GetMouseButtonFromXButton(unsigned int button)
|
||||
}
|
||||
}
|
||||
|
||||
static Key GetKeyFromX11Scancode(X11Scancode code)
|
||||
{
|
||||
static Key GetKeyFromX11Scancode(X11Scancode code) {
|
||||
for (auto& key : Key::GetKeyboard()) {
|
||||
if (key.x11ScanCode == code)
|
||||
return key;
|
||||
@@ -189,8 +186,7 @@ static Key GetKeyFromX11Scancode(X11Scancode code)
|
||||
std::cout << "Unavaliable Scancode: " + std::to_string((int)code) << std::endl;
|
||||
return Keys::Space;
|
||||
}
|
||||
static Key GetKeyFromWindowsScancode(WindowsScancode code)
|
||||
{
|
||||
static Key GetKeyFromWindowsScancode(WindowsScancode code) {
|
||||
for (auto& key : Key::GetKeyboard()) {
|
||||
if (key.winScanCode == code)
|
||||
return key;
|
||||
|
23
meson.build
Normal file
23
meson.build
Normal file
@@ -0,0 +1,23 @@
|
||||
project ('ReWindow', 'cpp', version: '0.1.0')
|
||||
|
||||
sources = ['spng.c', 'nx/nxObject.m', 'nx/nxApp.m', 'nx/nxWindow.m', 'nx/nxUtil.m', 'nx/nxClipboard.m', 'nx/nxMultiTouch.m', 'nx/nxNav.m', 'State.m', 'Geom.m', 'Surface.m', 'Chunk.m', 'Resource.m', 'gx.m', 'gxMath.c', 'gxTile.m', 'Heap.c', 'uiMenu.m', 'uiFrame.m', 'uiSplit.m', 'uiTool.m', 'main.m', 'Section.m', 'Track.m', 'Plan.m', 'Profile.m', 'Book.m', 'Elevate.m']
|
||||
|
||||
includes = include_directories ('/usr/include/gtk-3.0', '/usr/include/libevdev-1.0')
|
||||
|
||||
libs = [
|
||||
dependency ('gio-2.0', version: '>= 2.50'),
|
||||
dependency ('gdk-3.0', version: '>= 3.20'),
|
||||
dependency ('gtk+-3.0', version: '>= 3.22'),
|
||||
dependency ('cairo', version: '>= 1.00'),
|
||||
compiler.find_library ('m'),
|
||||
compiler.find_library ('GL'),
|
||||
compiler.find_library ('objc'),
|
||||
compiler.find_library ('jpeg'),
|
||||
compiler.find_library ('evdev'),
|
||||
]
|
||||
|
||||
verse = executable ('verse', [sources, resource],
|
||||
include_directories: includes,
|
||||
dependencies: libs,
|
||||
install: true
|
||||
)
|
@@ -1,31 +1,353 @@
|
||||
#include <rewindow/types/window.h>
|
||||
|
||||
LRESULT CALLBACK ReWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage (0);
|
||||
break;
|
||||
|
||||
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
case WM_SETFOCUS: {
|
||||
RWindowEvent event {};
|
||||
OnFocusGain (event);
|
||||
setFlag (RWindowFlags::IN_FOCUS, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_FOCUSLOST: {
|
||||
RWindowEvent event {};
|
||||
OnFocusLost (event);
|
||||
setFlag (RWindowFlags::IN_FOCUS, false);
|
||||
break;
|
||||
}
|
||||
|
||||
LPTSTR szClassName = TEXT("GenericProgramWindowClass");
|
||||
case WM_KEYDOWN: {
|
||||
auto key = GetKeyFromWindowsScancode (wParam);
|
||||
currentKeyboard.PressedKeys[key] = true;
|
||||
auto event = KeyDownEvent(key);
|
||||
OnKeyDown(event);
|
||||
eventLog.push_back (event);
|
||||
break;
|
||||
}
|
||||
|
||||
WNDCLASS wc = { };
|
||||
wc.lpfnWndProc = WindowProc;
|
||||
case WM_KEYUP: {
|
||||
auto key = GetKeyFromWindowsScancode (wParam);
|
||||
currentKeyboard.PressedKeys[key] = false;
|
||||
auto event = KeyUpEvent(key);
|
||||
OnKeyUp(event);
|
||||
break;
|
||||
}
|
||||
|
||||
HWND hwnd;
|
||||
case WM_LBUTTONDOWN: {
|
||||
auto event = MouseButtonDownEvent();
|
||||
event.Button = MouseButtons::Left;
|
||||
OnMouseButtonDown(event);
|
||||
break;
|
||||
}
|
||||
|
||||
RWindow::RWindow()
|
||||
{
|
||||
hwnd = CreateWindow();
|
||||
case WM_RBUTTONDOWN: {
|
||||
auto event = MouseButtonDownEvent();
|
||||
event.Button = MouseButtons::Right;
|
||||
OnMouseButtonDown(event);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MBUTTONDOWN: {
|
||||
auto event = MouseButtonDownEvent();
|
||||
event.Button = MouseButtons::Middle;
|
||||
OnMouseButtonDown(event);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_LBUTTONUP: {
|
||||
auto event = MouseButtonUpEvent();
|
||||
event.Button = MouseButtons::Left;
|
||||
OnMouseButtonUp(event);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_RBUTTONUP: {
|
||||
auto event = MouseButtonUpEvent();
|
||||
event.Button = MouseButtons::Right;
|
||||
OnMouseButtonUp(event);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MBUTTONUP: {
|
||||
auto event = MouseButtonUpEvent();
|
||||
event.Button = MouseButtons::Middle;
|
||||
OnMouseButtonUp(event);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE: {
|
||||
auto event = MouseMoveEvent (xev.xmotion.x, xev.xmotion.y);
|
||||
OnMouseMove(event);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SHOW: // as for Expose event in linux
|
||||
break;
|
||||
|
||||
case WM_SIZE: {
|
||||
auto event = WindowResizeRequestEvent();
|
||||
lastKnownWindowSize = event.Size;
|
||||
event.Size = {LOWORD (lParam), HIWORD (lParam)};
|
||||
lastKnownWindowSize = event.Size;
|
||||
OnResizeRequest (event);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HWND hwnd = NULL;
|
||||
static HDC hdc = NULL;
|
||||
static ATOM reClass = 0;
|
||||
static HGLRC glrc = NULL;
|
||||
static DEVMODEA mode;
|
||||
|
||||
RWindow::RWindow() {
|
||||
if (!reClass) {
|
||||
WNDCLASSA rewc = {
|
||||
ReWindowProc, 0, 0, NULL, NULL, , NULL, NULL,
|
||||
GetStockObject (BLACK_BRUSH), NULL, "ReWindowClass"
|
||||
};
|
||||
|
||||
reClass = RegisterClassA (&rewc);
|
||||
}
|
||||
|
||||
hwnd = CreateWindowA (reClass, "ReWindow", WS_TILEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, NULL, , 0);
|
||||
}
|
||||
|
||||
void RWindow::raise() const {
|
||||
SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); // Restore
|
||||
SetForegroundWindow(hwnd);
|
||||
SetActiveWindow(hwnd);
|
||||
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
|
||||
// Redraw to prevent the window blank
|
||||
RedrawWindow(hwnd, NULL, 0, RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
|
||||
SetForegroundWindow (hwnd);
|
||||
SetActiveWindow (hwnd);
|
||||
SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
|
||||
ShowWindow (hwnd, SW_SHOW)
|
||||
// Redraw to prevent the window blank
|
||||
RedrawWindow (hwnd, NULL, 0, RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
|
||||
}
|
||||
|
||||
void RWindow::lower() const {
|
||||
ShowWindow (hwnd, SW_MINIMIZE);
|
||||
}
|
||||
|
||||
void RWindow::destroyWindow() {
|
||||
if (hwnd) {
|
||||
if (hdc) {
|
||||
if (glrc) {
|
||||
wglMakeCurrent (NULL, NULL);
|
||||
wglDeleteContext (glrc);
|
||||
}
|
||||
|
||||
ReleaseDC (hdc);
|
||||
}
|
||||
|
||||
DestroyWindow (hwnd);
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
void RWindow::refresh() {
|
||||
// TODO: Implement refresh time keeping
|
||||
OnRefresh (0.f);
|
||||
|
||||
// TODO: Check if mouse coords have changed, only then fire OnMouseMove event
|
||||
Vector2 mouse_coords = getCursorPos();
|
||||
|
||||
auto eventData = MouseMoveEvent(mouse_coords);
|
||||
OnMouseMove(eventData);
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
bool RWindow::getFlag (RWindowFlags flag) const {
|
||||
return (flags[(int) flag]);
|
||||
}
|
||||
|
||||
void RWindow::setFlag (RWindowFlags flag, bool state) {
|
||||
XGetWindowAttributes(display,window,&windowAttributes);
|
||||
flags[(int) flag] = state;
|
||||
|
||||
if (flag == RWindowFlags::RESIZABLE && !state) {
|
||||
hints.flags = PMinSize | PMaxSize;
|
||||
hints.min_width = hints.max_width = windowAttributes.width;
|
||||
hints.min_height = hints.max_height = windowAttributes.height;
|
||||
XSetWMNormalHints(display, window, &hints);
|
||||
}
|
||||
}
|
||||
|
||||
void RWindow::pollEvents() {
|
||||
MSG msg;
|
||||
|
||||
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Might make the window go off the screen on some window managers.
|
||||
void RWindow::setSize (int newWidth, int newHeight) {
|
||||
if (!getFlag(RWindowFlags::RESIZABLE)) return;
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
MoveWindow (hwnd, x, y, width, height, TRUE);
|
||||
}
|
||||
|
||||
void RWindow::setSize(const Vector2& size)
|
||||
if (!getFlag(RWindowFlags::RESIZABLE)) return;
|
||||
width = size.x;
|
||||
height = size.y;
|
||||
MoveWindow (hwnd, x, y, width, height, TRUE);
|
||||
}
|
||||
|
||||
Vector2 RWindow::getCursorPos() const {
|
||||
POINT pos;
|
||||
GetCursorPos (&pos);
|
||||
|
||||
// TODO: normalize coordinates from displaySpace to windowSpace
|
||||
// TODO: fire mouse movement event
|
||||
//std::cout << win_x_ret << ", " << win_y_ret << std::endl;
|
||||
// TODO: Compensate for height of window TitleBar + window border width
|
||||
Vector2 mouse_coords_raw = {(float) pos.x, (float) pos.y};
|
||||
auto window_pos = getPos();
|
||||
return mouse_coords_raw - window_pos;
|
||||
}
|
||||
|
||||
// TODO: implement integer vector2/3 types
|
||||
Vector2 RWindow::getSize() const {
|
||||
RECT area;
|
||||
GetClientRect (hwnd, &area);
|
||||
return {(float) area.right, (float) area.bottom};
|
||||
}
|
||||
|
||||
// TODO: implement integer vector2/3 types
|
||||
Vector2 RWindow::getPos() const {
|
||||
XGetWindowAttributes(display,window,&windowAttributes);
|
||||
return {(float)windowAttributes.x, (float)windowAttributes.y};
|
||||
}
|
||||
|
||||
void RWindow::setPos(int newx, int newy) {
|
||||
x = newx;
|
||||
y = newy;
|
||||
MoveWindow (hwnd, x, y, width, height, TRUE);
|
||||
}
|
||||
|
||||
void RWindow::setPos(const Vector2& pos) {
|
||||
this->setPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
void RWindow::glSwapBuffers() {
|
||||
SwapBuffers (hdc);
|
||||
}
|
||||
|
||||
bool RWindow::isResizable() const {
|
||||
return this->getFlag (RWindowFlags::RESIZABLE);
|
||||
}
|
||||
|
||||
bool RWindow::isAlive() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RWindow::setResizable(bool resizable) {
|
||||
this->resizable = resizable;
|
||||
this->setFlag(RWindowFlags::RESIZABLE, resizable);
|
||||
}
|
||||
|
||||
void RWindow::setFullscreen(bool fs) {
|
||||
if (fs) {
|
||||
fullscreen();
|
||||
}
|
||||
else restoreFromFullscreen();
|
||||
}
|
||||
|
||||
void RWindow::fullscreen() {
|
||||
DEVMODEA screen = {sizeof (DEVMODEA)};
|
||||
screen.dmBitsPerPixel = 32;
|
||||
screen.dmPelsWidth = width;
|
||||
screen.dmPelsHeight = height;
|
||||
screen.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
|
||||
if (ChangeDisplaySettings (&screen, 0) == DISP_CHANGE_SUCCESSFUL) {
|
||||
fullscreenmode = true;
|
||||
}
|
||||
}
|
||||
|
||||
void RWindow::restoreFromFullscreen() {
|
||||
if (ChangeDisplaySettings (&mode, 0) == DISP_CHANGE_SUCCESSFUL) {
|
||||
fullscreenmode = false;
|
||||
}
|
||||
}
|
||||
|
||||
void RWindow::setVsyncEnabled (bool b) {
|
||||
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
|
||||
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
|
||||
glXSwapIntervalEXT(display, window, b);
|
||||
}
|
||||
|
||||
bool RWindow::isFullscreen() const {
|
||||
return fullscreenmode;
|
||||
}
|
||||
|
||||
void RWindow::setCursorStyle (CursorStyle style) const {
|
||||
u32 x11_cursor_resolved_enum = static_cast<u32>(style.X11Cursor);
|
||||
Cursor c = XCreateFontCursor(display, x11_cursor_resolved_enum);
|
||||
XDefineCursor(display, window, c);
|
||||
}
|
||||
|
||||
void RWindow::Open() {
|
||||
if (hwnd) {
|
||||
hdc = GetDC (hwnd);
|
||||
|
||||
PIXELFORMATDESCRIPTIOR pfd = {
|
||||
sizeof (PIXELFORMATDESCRIPTIOR),
|
||||
1, PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW,
|
||||
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 32,
|
||||
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
int ipf = ChoosePixelFormat (hdc, &pfd);
|
||||
|
||||
if (ipf) {
|
||||
SetPixelFormat (hdc, ipf, &pfd);
|
||||
glrc = wglCreateContext (hdc);
|
||||
|
||||
if (hglrc) {
|
||||
wglMakeCurrent (hdc, glrc);
|
||||
EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &mode);
|
||||
open = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RWindow::setTitle (const std::string &title) {
|
||||
this->title = title;
|
||||
SetWindowTextA (hwnd, title.c_str ());
|
||||
}
|
||||
|
||||
std::string RWindow::getTitle () const {
|
||||
return this->title;
|
||||
}
|
||||
|
||||
bool RWindow::isKeyDown (Key key) const {
|
||||
return currentKeyboard.PressedKeys.contains(key) ?
|
||||
currentKeyboard.PressedKeys.at(key) : false;
|
||||
}
|
||||
|
||||
// TODO: Implement MouseButton map
|
||||
bool RWindow::isMouseButtonDown(MouseButton button) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RWindow::setRenderer (RenderingAPI api) {
|
||||
renderer = api;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user