Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
9a4a4dddcc | |||
04fa303a81 | |||
4facfb11fa | |||
ef257765fe | |||
5696dd4ed8 |
@@ -22,7 +22,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME J3ML
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Prerelease-18.zip
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Release-1.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
|
@@ -158,11 +158,9 @@ namespace ReWindow
|
||||
RWindow(const std::string& title, int width, int height);
|
||||
RWindow(const std::string& title, int width, int height, RenderingAPI renderer);
|
||||
|
||||
static Vector2 GetMouseCoordinates()
|
||||
Vector2 GetMouseCoordinates() const
|
||||
{
|
||||
if (singleton != nullptr)
|
||||
return singleton->getCursorPos();
|
||||
return Vector2::NaN;
|
||||
return getCursorPos();
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +228,9 @@ namespace ReWindow
|
||||
RenderingAPI renderer;
|
||||
bool open = false;
|
||||
bool resizable;
|
||||
static RWindow* singleton;
|
||||
|
||||
//You can't do this because you can't initialize a static member inside the class constructor.
|
||||
//static RWindow* singleton;
|
||||
|
||||
};
|
||||
|
||||
|
5
main.cpp
5
main.cpp
@@ -49,11 +49,12 @@ int main() {
|
||||
|
||||
window->setRenderer(RenderingAPI::OPENGL);
|
||||
window->Open();
|
||||
|
||||
// TODO: Cannot set flags until after window is open
|
||||
// Make this work somehow
|
||||
window->setFullscreen(false);
|
||||
window->setVsyncEnabled(true);
|
||||
window->setResizable(true);
|
||||
window->setVsyncEnabled(false);
|
||||
window->setResizable(false);
|
||||
|
||||
window->OnKeyDownEvent += [&] (ReWindow::KeyDownEvent e)
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ namespace ReWindow {
|
||||
title = "ReWindow Application";
|
||||
width = 640;
|
||||
height = 480;
|
||||
RWindow::singleton = this;
|
||||
//RWindow::singleton = this;
|
||||
}
|
||||
|
||||
RWindow::RWindow(const std::string& title, int width, int height) : flags(false,false,false,false) {
|
||||
@@ -41,14 +41,14 @@ namespace ReWindow {
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
|
||||
RWindow::singleton = this;
|
||||
//RWindow::singleton = this;
|
||||
|
||||
}
|
||||
|
||||
RWindow::RWindow(const std::string& title, int width, int height, RenderingAPI renderer) :
|
||||
title(title), width(width), height(height), renderer(renderer)
|
||||
{
|
||||
RWindow::singleton = this;
|
||||
//RWindow::singleton = this;
|
||||
}
|
||||
|
||||
void RWindow::raise() const { XRaiseWindow(display, window); }
|
||||
@@ -128,7 +128,7 @@ namespace ReWindow {
|
||||
auto scancode = (X11Scancode) xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
currentKeyboard.PressedKeys[key] = false;
|
||||
KeyUpEvent eventData = KeyUpEvent(key);
|
||||
auto eventData = KeyUpEvent(key);
|
||||
OnKeyUp(eventData);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace ReWindow {
|
||||
auto scancode = (X11Scancode) xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
currentKeyboard.PressedKeys[key] = true;
|
||||
KeyDownEvent eventData = KeyDownEvent(key);
|
||||
auto eventData = KeyDownEvent(key);
|
||||
OnKeyDown(eventData);
|
||||
eventLog.push_back(eventData);
|
||||
}
|
||||
@@ -185,10 +185,10 @@ namespace ReWindow {
|
||||
// Might make the window go off the screen on some window managers.
|
||||
void RWindow::setSize(int newWidth, int newHeight)
|
||||
{
|
||||
this->width = newWidth;
|
||||
this->height = newHeight;
|
||||
if (!getFlag(RWindowFlags::RESIZABLE))
|
||||
return;
|
||||
this->width = newWidth;
|
||||
this->height = newHeight;
|
||||
XResizeWindow(display, window, width, height);
|
||||
}
|
||||
|
||||
@@ -319,16 +319,15 @@ namespace ReWindow {
|
||||
}
|
||||
|
||||
void RWindow::setVsyncEnabled(bool b) {
|
||||
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr;
|
||||
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
|
||||
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
|
||||
glXSwapIntervalEXT(display, None, b);
|
||||
glXSwapIntervalEXT(display, window, b);
|
||||
}
|
||||
|
||||
bool RWindow::isFullscreen() const {
|
||||
return fullscreenmode;
|
||||
}
|
||||
|
||||
using J3ML::u32;
|
||||
void RWindow::setCursorStyle(CursorStyle style) const {
|
||||
u32 x11_cursor_resolved_enum = static_cast<u32>(style.X11Cursor);
|
||||
Cursor c = XCreateFontCursor(display, x11_cursor_resolved_enum);
|
||||
|
Reference in New Issue
Block a user