Compare commits

...

13 Commits

Author SHA1 Message Date
364504ae5c update 2024-01-21 12:58:38 -05:00
0d3e714f52 update 2024-01-21 05:15:24 -05:00
bfd4f6e187 Update CMakeLists.txt 2024-01-19 06:36:05 -05:00
98a04a15b2 vsync test 2024-01-19 06:28:54 -05:00
adda18b0cc WinMain (What the actual fuck?) 2024-01-04 06:03:33 -05:00
0d937b48d7 WinMain (What the actual fuck?) 2024-01-04 06:03:09 -05:00
9dd30ff8bd WinMain (What the actual fuck?) 2024-01-04 06:02:54 -05:00
31c31e925e Fix depend 2024-01-03 20:11:34 -05:00
38f3fc615a WIP KeyboardState 2024-01-03 19:53:18 -05:00
611da9f3ec WIP Keyboard, Mouse, Gamepad, Joystick support 2024-01-03 19:12:31 -05:00
8d445554ba J3ML 2024-01-03 19:10:17 -05:00
af93b712aa WIP Re-engineering input systems 2024-01-03 19:03:01 -05:00
5ae78b473c WIP Re-engineering input systems 2024-01-03 17:18:51 -05:00
3 changed files with 22 additions and 5 deletions

View File

@@ -31,7 +31,8 @@ private:
public:
bool getFlag(RWindowFlags flag);
void setFlag(RWindowFlags flag, bool state);
void init(RenderingAPI api, const char* title, int width, int height);
void init(RenderingAPI api, const char* title, int width, int height, bool vsync);
static void setVsyncEnabled(bool b);
void destroyWindow();
void pollEvents();
void setSize(int width, int height);

View File

@@ -2,11 +2,15 @@
#include "include/rewindow/types/window.h"
int main() {
auto* window = new(RWindow);
window->init(RenderingAPI::OPENGL, "name",100,100);
window->init(RenderingAPI::OPENGL, "name",1152,864, false);
window->setFlag(RWindowFlags::RESIZABLE, false);
int i;
while (true) {
if (i <= 10)
window->pollEvents();
window->glSwapBuffers();
i++;
std::cout << i << std::endl;
if (window->keyDown(SCANCODE::A)) {
std::cout << "A" << std::endl;
std::cout << (int64_t) window->getEvent(SCANCODE::A).empty() << std::endl;

View File

@@ -1,6 +1,7 @@
#include <iostream>
#include "rewindow/types/window.h"
bool vsync = false;
Window window;
XEvent xev;
Display* display = XOpenDisplay(nullptr);
@@ -13,17 +14,19 @@ XWindowAttributes windowAttributes;
Atom wmDeleteWindow;
XSizeHints hints;
GLXContext glContext;
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr;
void RWindow::init(RenderingAPI api, const char* title, int width, int height) {
void RWindow::init(RenderingAPI api, const char* title, int width, int height, bool sync) {
if (api == RenderingAPI::OPENGL) {
xSetWindowAttributes.border_pixel = BlackPixel(display, defaultScreen);
xSetWindowAttributes.background_pixel = BlackPixel(display, defaultScreen);
xSetWindowAttributes.override_redirect = True;
xSetWindowAttributes.event_mask = ExposureMask;
GLint glAttributes[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
visual = glXChooseVisual(display, defaultScreen, glAttributes);
glContext = glXCreateContext(display, visual, nullptr, GL_TRUE);
setVsyncEnabled(sync);
vsync = sync;
xSetWindowAttributes.colormap = XCreateColormap(display, RootWindow(display, defaultScreen), visual->visual,
AllocNone);
@@ -197,5 +200,14 @@ MouseButtonDownEvent RWindow::getEvent(MOUSEBUTTONCODE buttoncode) {
void RWindow::glSwapBuffers() {
glXSwapBuffers(display,window);
//This seems to be the best option for now
//Because sending it *only once* doesn't work.
setVsyncEnabled(vsync);
}
void RWindow::setVsyncEnabled(bool b) {
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
glXSwapIntervalEXT(display, window, b);
}