Compare commits

...

8 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
Redacted
9f0a511022 Update CMakeLists.txt 2024-02-24 07:48:37 -05:00
ffe49e4c67 Implement static GetMouseCoordinates() ? 2024-02-22 00:31:04 -05:00
28f904783f Fix SIGILL 2024-02-21 23:46:42 -05:00
4 changed files with 103 additions and 87 deletions

View File

@@ -1,72 +1,72 @@
cmake_minimum_required(VERSION 3.20)
project(ReWindowLibrary
VERSION 1.0
LANGUAGES CXX
)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-Source builds are not allowed")
endif()
set(CMAKE_CXX_STANDARD 20)
if (WIN32)
set(CMAKE_CXX_FLAGS "-municode")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Enable Package Managers
include(cmake/CPM.cmake)
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/Prerelease-18.zip
)
CPMAddPackage(
NAME Event
URL https://git.redacted.cc/josh/Event/archive/Release-1.zip
)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
include_directories(${J3ML_SOURCE_DIR}/include)
file(GLOB_RECURSE HEADERS "include/*.h" "include/*.hpp")
if(UNIX AND NOT APPLE)
file(GLOB_RECURSE SOURCES "src/rewindow/*.cpp" "src/linux/*.cpp")
endif()
if(WIN32)
file(GLOB_RECURSE SOURCES "src/rewindow/*.cpp" "src/windows/*.cpp")
endif()
include_directories("include")
add_library(ReWindowLibrary SHARED ${SOURCES}
include/rewindow/types/cursors.h
)
target_include_directories(ReWindowLibrary PUBLIC ${Event_SOURCE_DIR}/include)
# Why god???
set_target_properties(ReWindowLibrary PROPERTIES LINKER_LANGUAGE CXX)
if(UNIX AND NOT APPLE)
target_link_libraries(ReWindowLibrary PUBLIC X11)
target_link_libraries(ReWindowLibrary PUBLIC ${OPENGL_LIBRARIES})
target_link_libraries(ReWindowLibrary PUBLIC J3ML)
target_link_libraries(ReWindowLibrary PUBLIC Event)
add_executable(ReWindowLibraryDemo main.cpp)
#target_include_directories(ReWindowLibraryDemo PRIVATE ${JGL_SOURCE_DIR}/include)
target_link_libraries(ReWindowLibraryDemo PUBLIC ReWindowLibrary)
#target_link_libraries(ReWindowLibraryDemo PRIVATE JGL)
endif()
if(WIN32)
cmake_minimum_required(VERSION 3.20)
project(ReWindowLibrary
VERSION 1.0
LANGUAGES CXX
)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-Source builds are not allowed")
endif()
set(CMAKE_CXX_STANDARD 20)
if (WIN32)
set(CMAKE_CXX_FLAGS "-municode")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Enable Package Managers
include(cmake/CPM.cmake)
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/Release-1.zip
)
CPMAddPackage(
NAME Event
URL https://git.redacted.cc/josh/Event/archive/Release-2.zip
)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
include_directories(${J3ML_SOURCE_DIR}/include)
file(GLOB_RECURSE HEADERS "include/*.h" "include/*.hpp")
if(UNIX AND NOT APPLE)
file(GLOB_RECURSE SOURCES "src/rewindow/*.cpp" "src/linux/*.cpp")
endif()
if(WIN32)
file(GLOB_RECURSE SOURCES "src/rewindow/*.cpp" "src/windows/*.cpp")
endif()
include_directories("include")
add_library(ReWindowLibrary SHARED ${SOURCES}
include/rewindow/types/cursors.h
)
target_include_directories(ReWindowLibrary PUBLIC ${Event_SOURCE_DIR}/include)
# Why god???
set_target_properties(ReWindowLibrary PROPERTIES LINKER_LANGUAGE CXX)
if(UNIX AND NOT APPLE)
target_link_libraries(ReWindowLibrary PUBLIC X11)
target_link_libraries(ReWindowLibrary PUBLIC ${OPENGL_LIBRARIES})
target_link_libraries(ReWindowLibrary PUBLIC J3ML)
target_link_libraries(ReWindowLibrary PUBLIC Event)
add_executable(ReWindowLibraryDemo main.cpp)
#target_include_directories(ReWindowLibraryDemo PRIVATE ${JGL_SOURCE_DIR}/include)
target_link_libraries(ReWindowLibraryDemo PUBLIC ReWindowLibrary)
#target_link_libraries(ReWindowLibraryDemo PRIVATE JGL)
endif()
if(WIN32)
endif()

View File

@@ -146,7 +146,7 @@ namespace ReWindow
virtual void OnFocusGain(const RWindowEvent& e) {}
virtual void OnRefresh(float elapsed) {}
virtual void OnResizeSuccess() {}
virtual bool OnResizeRequest(const WindowResizeRequestEvent& e) {}
virtual bool OnResizeRequest(const WindowResizeRequestEvent& e) { return true;}
virtual void OnKeyDown(const KeyDownEvent&) {}
virtual void OnKeyUp(const KeyUpEvent&) {}
virtual void OnMouseMove(const MouseMoveEvent&) {}
@@ -158,6 +158,12 @@ namespace ReWindow
RWindow(const std::string& title, int width, int height);
RWindow(const std::string& title, int width, int height, RenderingAPI renderer);
Vector2 GetMouseCoordinates() const
{
return getCursorPos();
}
void setRenderer(RenderingAPI api);
void Open();
void Close();
@@ -223,6 +229,8 @@ namespace ReWindow
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;
};

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

@@ -29,15 +29,27 @@ GLXContext glContext;
namespace ReWindow {
RWindow::RWindow() {
title = "ReWindow Application";
width = 640;
height = 480;
//RWindow::singleton = this;
}
RWindow::RWindow(const std::string& title, int width, int height) : flags(false,false,false,false) {
this->title = title;
this->width = width;
this->height = height;
//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;
}
void RWindow::raise() const { XRaiseWindow(display, window); }
void RWindow::lower() const { XLowerWindow(display, window); }
@@ -116,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);
}
@@ -124,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);
}
@@ -173,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);
}
@@ -307,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);
@@ -383,11 +394,7 @@ namespace ReWindow {
return false;
}
RWindow::RWindow() {
title = "ReWindow Application";
width = 640;
height = 480;
}
void RWindow::setRenderer(RenderingAPI api) {
renderer = api;