Compare commits

...

5 Commits

Author SHA1 Message Date
9a4a4dddcc Merge remote-tracking branch 'origin/main' 2024-04-09 16:38:49 -04:00
04fa303a81 Migrate to J3ML Release 1 2024-04-09 16:38:39 -04:00
4facfb11fa Update window.cpp
vsync fix
2024-03-26 11:47:59 -04:00
ef257765fe Migrate to J3ML v20 2024-03-21 13:05:09 -04:00
5696dd4ed8 Un-break 2024-02-24 08:42:42 -05:00
4 changed files with 18 additions and 18 deletions

View File

@@ -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(

View File

@@ -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;
};

View File

@@ -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)
{

View File

@@ -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);