Cleanup
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m15s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m15s
This commit is contained in:
8
main.cpp
8
main.cpp
@@ -1,13 +1,8 @@
|
||||
#include <iostream>
|
||||
#include <ReWindow/types/Window.h>
|
||||
|
||||
#if _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <ReWindow/Logger.h>
|
||||
using namespace ReWindow;
|
||||
|
||||
using namespace ReWindow;
|
||||
std::ostream& operator<<(std::ostream& os, const IPair& v) {
|
||||
return os << "{" << v.x << ", " << v.y << "}";
|
||||
}
|
||||
@@ -89,6 +84,5 @@ int main() {
|
||||
|
||||
while (!window->IsClosing())
|
||||
window->ManagedRefresh();
|
||||
|
||||
delete window;
|
||||
}
|
@@ -22,6 +22,7 @@ public:
|
||||
XSizeHints hints;
|
||||
Cursor invisible_cursor = 0;
|
||||
XWMHints* wm_hints = nullptr;
|
||||
GLXContext gl_context;
|
||||
};
|
||||
|
||||
void* glx_lib = nullptr;
|
||||
@@ -57,9 +58,6 @@ namespace OpenGL {
|
||||
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display *, GLXFBConfig, GLXContext, Bool, const int *);
|
||||
}
|
||||
|
||||
GLXContext gl_context;
|
||||
|
||||
|
||||
void OpenGLWindow::SwapBuffers() {
|
||||
OpenGL::glXSwapBuffers(platform->display,platform->window);
|
||||
}
|
||||
@@ -93,7 +91,7 @@ bool OpenGLWindow::Open() {
|
||||
if (!glXCreateContextAttribsARB) {
|
||||
GLint glAttributes[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
|
||||
platform->visual = OpenGL::glXChooseVisual(platform->display, platform->defaultScreen, glAttributes);
|
||||
gl_context = OpenGL::glXCreateContext(platform->display, platform->visual, nullptr, GL_TRUE);
|
||||
platform->gl_context = OpenGL::glXCreateContext(platform->display, platform->visual, nullptr, GL_TRUE);
|
||||
platform->window = XCreateWindow(platform->display, RootWindow(platform->display, platform->defaultScreen), 0, 0, width, height, 0, platform->visual->depth,
|
||||
InputOutput, platform->visual->visual, CWBackPixel | CWColormap | CWBorderPixel | NoEventMask, &platform->xSetWindowAttributes);
|
||||
Logger::Debug("Created OpenGL Context with glXCreateContext.");
|
||||
@@ -129,14 +127,14 @@ bool OpenGLWindow::Open() {
|
||||
|
||||
// TODO allow the user to specify what OpenGL version they want.
|
||||
int context_attributes[] { GLX_CONTEXT_MAJOR_VERSION_ARB, gl_major, GLX_CONTEXT_MINOR_VERSION_ARB, gl_minor, None };
|
||||
gl_context = glXCreateContextAttribsARB(platform->display, best_fbc, nullptr, True, context_attributes);
|
||||
platform->gl_context = glXCreateContextAttribsARB(platform->display, best_fbc, nullptr, True, context_attributes);
|
||||
XFree(fb_configurations);
|
||||
Logger::Debug("Created OpenGL Context with glXCreateContextAttribsARB");
|
||||
}
|
||||
|
||||
if (!gl_context)
|
||||
if (!platform->gl_context)
|
||||
return false;
|
||||
if (!OpenGL::glXMakeCurrent(platform->display, platform->window, gl_context))
|
||||
if (!OpenGL::glXMakeCurrent(platform->display, platform->window, platform->gl_context))
|
||||
return false;
|
||||
|
||||
if (vi)
|
||||
|
@@ -22,6 +22,7 @@ public:
|
||||
Cursor invisible_cursor = 0;
|
||||
XWMHints* wm_hints = nullptr;
|
||||
bool window_visible = true;
|
||||
IPair position = {0, 0};
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +44,6 @@ platform = new Platform();
|
||||
extant = this;
|
||||
}
|
||||
|
||||
IPair position;
|
||||
RWindow::RWindow(const std::string& wTitle, int wWidth, int wHeight, bool wFullscreen, bool wResizable, bool wVsync)
|
||||
: title(wTitle), width(wWidth), height(wHeight), fullscreen_mode(wFullscreen), resizable(wResizable), vsync(wVsync)
|
||||
{ platform = new Platform(); extant = this; }
|
||||
@@ -276,8 +276,8 @@ void RWindow::PollEvents() {
|
||||
OnResizeRequestEvent(eventData);
|
||||
}
|
||||
//Window Moved.
|
||||
if (position.x != platform->xev.xconfigurerequest.x || position.y != platform->xev.xconfigurerequest.y)
|
||||
position = {platform->xev.xconfigurerequest.x, platform->xev.xconfigurerequest.y};
|
||||
if (platform->position.x != platform->xev.xconfigurerequest.x || platform->position.y != platform->xev.xconfigurerequest.y)
|
||||
platform->position = { platform->xev.xconfigurerequest.x, platform->xev.xconfigurerequest.y };
|
||||
}
|
||||
|
||||
if (platform->xev.type == VisibilityNotify) {
|
||||
@@ -339,12 +339,12 @@ IPair RWindow::GetSize() const {
|
||||
|
||||
// TODO: implement integer IPair/3 types
|
||||
IPair RWindow::GetPos() const {
|
||||
return position;
|
||||
return platform->position;
|
||||
}
|
||||
|
||||
void RWindow::SetPos(int x, int y) {
|
||||
XMoveWindow(platform->display, platform->window, x, y);
|
||||
position = {x, y};
|
||||
platform->position = {x, y};
|
||||
}
|
||||
|
||||
void RWindow::SetPos(const IPair& pos) {
|
||||
|
Reference in New Issue
Block a user