Allow the user to specify the OpenGL version they want.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m23s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m23s
This commit is contained in:
@@ -346,13 +346,15 @@ public:
|
||||
};
|
||||
|
||||
class ReWindow::OpenGLWindow : public RWindow {
|
||||
protected:
|
||||
uint8_t gl_major, gl_minor;
|
||||
public:
|
||||
void SwapBuffers() override;
|
||||
void SetVsyncEnabled(bool state) override;
|
||||
std::string GetGraphicsDriverVendor() override;
|
||||
void Open() override;
|
||||
public:
|
||||
OpenGLWindow(const std::string& title, int width, int height) : RWindow(title, width, height) {};
|
||||
OpenGLWindow(const std::string& title, int width, int height, uint8_t gl_major, uint8_t gl_minor) : gl_major(gl_major), gl_minor(gl_minor), RWindow(title, width, height) {};
|
||||
};
|
||||
|
||||
class ReWindow::VulkanWindow : public RWindow {
|
||||
|
10
main.cpp
10
main.cpp
@@ -1,29 +1,21 @@
|
||||
#include <iostream>
|
||||
#include <ReWindow/types/Window.h>
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Windows :/
|
||||
#if _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <ReWindow/Logger.h>
|
||||
|
||||
using namespace ReWindow;
|
||||
IPair mouse_pos;
|
||||
|
||||
// TODO: Move to J3ML::LinearAlgebra::Vector2
|
||||
std::ostream& operator<<(std::ostream& os, const IPair& v) {
|
||||
return os << "{" << v.x << ", " << v.y << "}";
|
||||
}
|
||||
|
||||
class MyWindow : public OpenGLWindow {
|
||||
public:
|
||||
MyWindow(const std::string& title, int w, int h) : OpenGLWindow(title, w, h) {}
|
||||
MyWindow(const std::string& title, int w, int h) : OpenGLWindow(title, w, h, 2, 1) {}
|
||||
|
||||
void OnMouseMove(const MouseMoveEvent& e) override {}
|
||||
|
||||
|
@@ -41,7 +41,6 @@ void OpenGLWindow::Open() {
|
||||
gl_context = glXCreateContext(xVars.display, xVars.visual, nullptr, GL_TRUE);
|
||||
xVars.window = XCreateWindow(xVars.display, RootWindow(xVars.display, xVars.defaultScreen), 0, 0, width, height, 0, xVars.visual->depth,
|
||||
InputOutput, xVars.visual->visual, CWBackPixel | CWColormap | CWBorderPixel | NoEventMask, &xVars.xSetWindowAttributes);
|
||||
|
||||
ReWindow::Logger::Debug("Created OpenGL Context with glXCreateContext.");
|
||||
}
|
||||
else {
|
||||
@@ -70,7 +69,7 @@ void OpenGLWindow::Open() {
|
||||
vi->visual, CWBackPixel | CWColormap | CWBorderPixel, &xVars.xSetWindowAttributes);
|
||||
|
||||
// TODO allow the user to specify what OpenGL version they want.
|
||||
int context_attributes[] { GLX_CONTEXT_MAJOR_VERSION_ARB, 2, GLX_CONTEXT_MINOR_VERSION_ARB, 1, None };
|
||||
int context_attributes[] { GLX_CONTEXT_MAJOR_VERSION_ARB, gl_major, GLX_CONTEXT_MINOR_VERSION_ARB, gl_minor, None };
|
||||
gl_context = glXCreateContextAttribsARB(xVars.display, best_fbc, nullptr, True, context_attributes);
|
||||
XFree(fb_configurations);
|
||||
ReWindow::Logger::Debug("Created OpenGL Context with glXCreateContextAttribsARB");
|
||||
|
@@ -301,7 +301,7 @@ void RWindow::SetCursorStyle(CursorStyle style) const {
|
||||
XDefineCursor(xVars.display, xVars.window, c);
|
||||
}
|
||||
|
||||
void RWindow::SetTitle(const std::string &title) {
|
||||
void RWindow::SetTitle(const std::string& title) {
|
||||
this->title = title;
|
||||
XStoreName(xVars.display, xVars.window, title.c_str());
|
||||
}
|
||||
|
Reference in New Issue
Block a user