format and fixing compile errors to get to a workable state

dev
keldu.magnus 2020-10-27 03:13:52 +01:00
parent dc021d7c00
commit f8344a3b66
16 changed files with 476 additions and 245 deletions

View File

@ -38,11 +38,9 @@ env.__class__.add_source_files = add_kel_source_files
env.sources = []
env.headers = []
env.objects = []
env.gl_sources = []
env.gl_headers = []
env.gl_objects = []
Export('env')
SConscript('source/SConscript')
@ -54,11 +52,15 @@ env_library = env.Clone()
env.objects_shared = []
env_library.add_source_files(env.objects_shared, env.sources, shared=True)
env.library_shared = env_library.SharedLibrary('#bin/kelgin-window', [env.objects_shared])
env.gl_objects_shared = []
env_library.add_source_files(env.gl_objects_shared, env.gl_sources, shared=True)
env.library_shared = env_library.SharedLibrary('#bin/kelgin-window', [env.objects_shared, env.gl_objects_shared])
env.objects_static = []
env_library.add_source_files(env.objects_static, env.sources)
env.library_static = env_library.StaticLibrary('#bin/kelgin-window', [env.objects_static])
env.gl_objects_static = []
env_library.add_source_files(env.gl_objects_static, env.gl_sources)
env.library_static = env_library.StaticLibrary('#bin/kelgin-window', [env.objects_static, env.gl_objects_static])
env.Alias('library', [env.library_shared, env.library_static])
env.Alias('library_shared', env.library_shared)
@ -79,7 +81,7 @@ def format_iter(env,files):
env.format_actions.append(env.AlwaysBuild(env.ClangFormat(target=f+"-clang-format",source=f)))
pass
format_iter(env,env.sources + env.headers)
format_iter(env,env.sources + env.headers + env.gl_sources + env.gl_headers)
env.Alias('format', env.format_actions)

View File

@ -11,3 +11,6 @@ dir_path = Dir('.').abspath
env.sources += sorted(glob.glob(dir_path + "/*.cpp"))
env.headers += sorted(glob.glob(dir_path + "/*.h"))
env.gl_sources += sorted(glob.glob(dir_path + "/gl/*.cpp"))
env.gl_headers += sorted(glob.glob(dir_path + "/gl/*.h"))

View File

@ -5,114 +5,110 @@
#include "window_xcb.h"
namespace gin {
XcbDevice::XcbDevice(::Display* display, int screen, xcb_connection_t* xcb_connection, xcb_screen_t* xcb_screen):
display{display},
screen{screen},
xcb_connection{xcb_connection},
xcb_screen{xcb_screen}
{
XcbDevice::XcbDevice(::Display* display, int screen,
xcb_connection_t* xcb_connection, xcb_screen_t* xcb_screen,
Own<InputStream>&& an)
: display{display},
screen{screen},
xcb_connection{xcb_connection},
xcb_screen{xcb_screen},
async_notifier{std::move(an)},
async_conveyor{async_notifier->readReady()
.then([this]() { handleEvents(); })
.buffer(1)} {}
XcbDevice::~XcbDevice() {
if (display) {
xcb_flush(xcb_connection);
::XCloseDisplay(display);
}
}
XcbDevice::~XcbDevice()
{
if(display){
xcb_flush(xcb_connection);
::XCloseDisplay(display);
}
void XcbDevice::windowDestroyed(xcb_window_t window_id) {
windows.erase(window_id);
}
void XcbDevice::windowDestroyed(xcb_window_t window_id){
windows.erase(window_id);
Own<XcbWindow> XcbDevice::createXcbWindow(const VideoMode& video_mode,
std::string_view title_view,
int visual_id) {
assert(xcb_screen);
assert(xcb_connection);
xcb_colormap_t xcb_colormap = xcb_generate_id(xcb_connection);
xcb_window_t xcb_window = xcb_generate_id(xcb_connection);
xcb_create_colormap(xcb_connection, XCB_COLORMAP_ALLOC_NONE, xcb_colormap,
xcb_screen->root, visual_id);
uint32_t eventmask = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS;
uint32_t valuelist[] = {eventmask, xcb_colormap, 0};
uint32_t valuemask = XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
xcb_create_window(xcb_connection, XCB_COPY_FROM_PARENT, xcb_window,
xcb_screen->root, 0, 0, video_mode.width, video_mode.height,
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visual_id, valuemask,
valuelist);
xcb_change_property(xcb_connection, XCB_PROP_MODE_REPLACE, xcb_window,
XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, title_view.size(),
title_view.data());
xcb_flush(xcb_connection);
return heap<XcbWindow>(*this, xcb_window, xcb_colormap, video_mode,
title_view);
}
Own<XcbWindow> XcbDevice::createXcbWindow(const VideoMode& video_mode, std::string_view title_view, int visual_id){
assert(xcb_screen);
assert(xcb_connection);
xcb_colormap_t xcb_colormap = xcb_generate_id(xcb_connection);
xcb_window_t xcb_window = xcb_generate_id(xcb_connection);
xcb_create_colormap(
xcb_connection,
XCB_COLORMAP_ALLOC_NONE,
xcb_colormap,
xcb_screen->root,
visual_id
);
uint32_t eventmask = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS;
uint32_t valuelist[] = { eventmask, xcb_colormap, 0 };
uint32_t valuemask = XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
xcb_create_window(
xcb_connection,
XCB_COPY_FROM_PARENT,
xcb_window,
xcb_screen->root,
0, 0,
video_mode.width, video_mode.height,
0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
visual_id,
valuemask,
valuelist
);
xcb_change_property(xcb_connection,
XCB_PROP_MODE_REPLACE,
xcb_window,
XCB_ATOM_WM_NAME,
XCB_ATOM_STRING,
8,
title_view.size(),
title_view.data()
);
xcb_flush(xcb_connection);
return heap<XcbWindow>(*this, xcb_window, xcb_colormap, video_mode, title_view);
Own<Window> XcbDevice::createWindow(const VideoMode& video_mode,
std::string_view title_view) {
assert(xcb_screen);
return createXcbWindow(video_mode, title_view, xcb_screen->root_visual);
}
Own<Window> XcbDevice::createWindow(const VideoMode& video_mode, std::string_view title_view){
assert(xcb_screen);
return createXcbWindow(video_mode, title_view, xcb_screen->root_visual);
void XcbDevice::flush() {
assert(xcb_connection);
xcb_flush(xcb_connection);
}
void XcbDevice::flush(){
assert(xcb_connection);
xcb_flush(xcb_connection);
Own<XcbDevice> createXcbDevice(AsyncIoProvider& provider) {
::Display* display = ::XOpenDisplay(nullptr);
if (!display) {
/// @todo log errors
return nullptr;
}
int screen = ::XDefaultScreen(display);
xcb_connection_t* xcb_connection = ::XGetXCBConnection(display);
if (!xcb_connection) {
/// @todo log errors
::XCloseDisplay(display);
return nullptr;
}
int fd = xcb_get_file_descriptor(xcb_connection);
Own<InputStream> fd_wrapped = provider.wrapInputFd(fd);
if (!fd_wrapped) {
::XCloseDisplay(display);
return nullptr;
}
::XSetEventQueueOwner(display, XCBOwnsEventQueue);
xcb_screen_iterator_t screen_iter =
xcb_setup_roots_iterator(xcb_get_setup(xcb_connection));
for (int screen_i = screen; screen_iter.rem && screen_i > 0;
--screen_i, xcb_screen_next(&screen_iter))
;
xcb_screen_t* xcb_screen = screen_iter.data;
return heap<XcbDevice>(display, screen, xcb_connection, xcb_screen,
std::move(fd_wrapped));
}
Own<XcbDevice> createXcbDevice(){
::Display* display = ::XOpenDisplay(nullptr);
if(!display){
/// @todo log errors
return nullptr;
}
int screen = ::XDefaultScreen(display);
xcb_connection_t* xcb_connection = ::XGetXCBConnection(display);
if(!xcb_connection){
/// @todo log errors
::XCloseDisplay(display);
return nullptr;
}
::XSetEventQueueOwner(display, XCBOwnsEventQueue);
xcb_screen_iterator_t screen_iter =
xcb_setup_roots_iterator(xcb_get_setup(xcb_connection));
for(int screen_i = screen; screen_iter.rem && screen_i > 0; --screen_i, xcb_screen_next(&screen_iter));
xcb_screen_t* xcb_screen = screen_iter.data;
int fd = xcb_get_file_descriptor(xcb_connection);
return heap<XcbDevice>(display, screen, xcb_connection, xcb_screen);
Own<Device> createDevice(AsyncIoProvider& provider) {
return createXcbDevice(provider);
}
Own<Device> createDevice(){
return createXcbDevice();
}
}
} // namespace gin

View File

@ -1,35 +1,44 @@
#pragma once
#include <X11/Xlib-xcb.h>
#include <X11/Xlib.h>
#include <kelgin/io.h>
#include <xcb/xcb.h>
#include <map>
#include "device.h"
#include "window_xcb.h"
#include <map>
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
namespace gin {
class XcbDevice final : public Device {
public:
::Display* display;
int screen;
public:
::Display* display;
int screen;
xcb_connection_t* xcb_connection;
xcb_screen_t* xcb_screen;
xcb_connection_t* xcb_connection;
xcb_screen_t* xcb_screen;
std::map<xcb_window_t, XcbWindow*> windows;
public:
XcbDevice(::Display* display, int screen, xcb_connection_t* xcb_connection, xcb_screen_t* xcb_screen);
~XcbDevice();
Own<InputStream> async_notifier;
Conveyor<void> async_conveyor;
void windowDestroyed(xcb_window_t window_id);
std::map<xcb_window_t, XcbWindow*> windows;
Own<XcbWindow> createXcbWindow(const VideoMode& mode, std::string_view title_view, int visual_id);
Own<Window> createWindow(const VideoMode& video_mode, std::string_view title_view) override;
public:
XcbDevice(::Display* display, int screen, xcb_connection_t* xcb_connection,
xcb_screen_t* xcb_screen, Own<InputStream>&& an);
~XcbDevice();
void flush() override;
void windowDestroyed(xcb_window_t window_id);
void handleEvents();
Own<XcbWindow> createXcbWindow(const VideoMode& mode,
std::string_view title_view, int visual_id);
Own<Window> createWindow(const VideoMode& video_mode,
std::string_view title_view) override;
void flush() override;
};
Own<XcbDevice> createXcbDevice();
}
Own<XcbDevice> createXcbDevice(AsyncIoProvider& provider);
} // namespace gin

View File

@ -1,15 +1,184 @@
#include "gl_context_xcb.h"
#include <GL/glx.h>
#include <cassert>
#include <cstdint>
#include <string_view>
#include <vector>
#include "device_xcb.h"
namespace gin {
void XcbGlContext::bind(){
namespace {
GlxLibraryExtensions glxLibraryExtensions(const char* extension_string) {
std::string_view extensions_view{extension_string};
std::set<std::string_view> extensions;
while (1) {
size_t n = extensions_view.find_first_not_of(' ');
if (n != extensions_view.npos && n < extensions_view.size()) {
std::string_view sub_glx_ext = extensions_view.substr(0, n);
extensions.insert(sub_glx_ext);
} else {
break;
}
}
auto find = extensions.find("glXCreateContextAttribsARB");
GLXContext (*glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext,
Bool, const int*) = nullptr;
if (find != extensions.end()) {
glXCreateContextAttribsARB = reinterpret_cast<GLXContext (*)(
Display*, GLXFBConfig, GLXContext, Bool, const int*)>(
glXGetProcAddress(
reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB")));
}
return {extensions_view, glXCreateContextAttribsARB};
}
int translateRenderTypeSetting(GlSettings::RenderType cmp) {
switch (cmp) {
case GlSettings::RenderType::RGBA:
return GLX_RGBA_BIT;
break;
}
return 0;
}
int translateDrawableTypeSetting(GlSettings::DrawableType cmp) {
int i = 0;
if (static_cast<int32_t>(cmp) &
static_cast<int32_t>(GlSettings::DrawableType::WindowBit)) {
i |= static_cast<int32_t>(GLX_WINDOW_BIT);
}
if (static_cast<int32_t>(cmp) &
static_cast<int32_t>(GlSettings::DrawableType::PixMapBit)) {
i |= static_cast<int32_t>(GLX_PIXMAP_BIT);
}
if (static_cast<int32_t>(cmp) &
static_cast<int32_t>(GlSettings::DrawableType::PBufferBit)) {
i |= static_cast<int32_t>(GLX_PBUFFER_BIT);
}
return i;
}
} // namespace
XcbGlContext::XcbGlContext(const GlxLibraryExtensions& ext_lib,
Own<XcbDevice>&& dev, int visual_id,
GLXContext context, GLXFBConfig fb_config)
: ext_lib{ext_lib},
device{std::move(dev)},
visual_id{visual_id},
context{context},
fb_config{fb_config} {}
XcbGlContext::~XcbGlContext() {
assert(device);
assert(device->display);
if (context) {
::glXMakeContextCurrent(device->display, None, None, nullptr);
::glXDestroyContext(device->display, context);
}
device->flush();
}
Own<GlWindow> XcbGlContext::createWindow(const VideoMode&, std::string_view){
return nullptr;
void XcbGlContext::bind() {}
Own<GlWindow> XcbGlContext::createWindow(const VideoMode& video_mode,
std::string_view title_view) {
return nullptr;
}
void XcbGlContext::flush(){
void XcbGlContext::flush() {}
Own<GlContext> createGlContext(AsyncIoProvider& provider,
const GlSettings& settings) {
Own<XcbDevice> device = createXcbDevice(provider);
if (!device) {
return nullptr;
}
/*
* Translate all attributes
*/
std::vector<int> attributes;
attributes.reserve(33);
attributes.push_back(GLX_X_RENDERABLE);
attributes.push_back(settings.renderable ? True : False);
attributes.push_back(GLX_RENDER_TYPE);
attributes.push_back(translateRenderTypeSetting(settings.render_type));
attributes.push_back(GLX_RED_SIZE);
attributes.push_back(settings.red_bits);
attributes.push_back(GLX_GREEN_SIZE);
attributes.push_back(settings.green_bits);
attributes.push_back(GLX_BLUE_SIZE);
attributes.push_back(settings.blue_bits);
attributes.push_back(GLX_ALPHA_SIZE);
attributes.push_back(settings.alpha_bits);
attributes.push_back(GLX_DEPTH_SIZE);
attributes.push_back(settings.depth_bits);
attributes.push_back(GLX_STENCIL_SIZE);
attributes.push_back(settings.stencil_bits);
attributes.push_back(GLX_DOUBLEBUFFER);
attributes.push_back(settings.double_buffer ? True : False);
attributes.push_back(GLX_DRAWABLE_TYPE);
attributes.push_back(translateDrawableTypeSetting(settings.drawable_type));
attributes.push_back(GLX_X_VISUAL_TYPE);
attributes.push_back(GLX_TRUE_COLOR);
attributes.push_back(None);
int num_fb_configs = 0;
GlxLibraryExtensions lib_ext = glxLibraryExtensions(
glXQueryExtensionsString(device->display, device->screen));
GLXFBConfig* fb_configs = glXChooseFBConfig(device->display, device->screen,
&attributes[0], &num_fb_configs);
if (!fb_configs || num_fb_configs == 0) {
/// @todo log errors
return nullptr;
}
::GLXFBConfig fb_config = fb_configs[0];
::XFree(fb_configs);
::GLXContext context;
if (lib_ext.glXCreateContextAttribsARB) {
std::vector<int> glx_attribs;
glx_attribs.reserve(11);
glx_attribs.push_back(GLX_CONTEXT_MAJOR_VERSION_ARB);
glx_attribs.push_back(settings.gl_major);
glx_attribs.push_back(GLX_CONTEXT_MINOR_VERSION_ARB);
glx_attribs.push_back(settings.gl_minor);
glx_attribs.push_back(GLX_CONTEXT_PROFILE_MASK_ARB);
glx_attribs.push_back(settings.core_profile
? GLX_CONTEXT_CORE_PROFILE_BIT_ARB
: GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
glx_attribs.push_back(None);
context = lib_ext.glXCreateContextAttribsARB(device->display, fb_config,
NULL, True, &glx_attribs[0]);
if (!context) {
return nullptr;
}
} else {
return nullptr;
}
int visual_id = 0;
glXGetFBConfigAttrib(device->display, fb_config, GLX_VISUAL_ID, &visual_id);
return heap<XcbGlContext>(lib_ext, std::move(device), visual_id, context,
fb_config);
}
}
} // namespace gin

View File

@ -1,13 +1,38 @@
#pragma once
#include <GL/glx.h>
#include <set>
#include <string_view>
#include "gl/gl_context.h"
namespace gin {
class XcbGlContext final : public GlContext {
public:
void bind() override;
Own<GlWindow> createWindow(const VideoMode&, std::string_view) override;
struct GlxLibraryExtensions {
public:
std::string_view raw_extension_string;
void flush() override;
GLXContext (*glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext,
Bool, const int*) = nullptr;
};
}
class XcbDevice;
class XcbGlContext final : public GlContext {
private:
GlxLibraryExtensions ext_lib;
Own<XcbDevice> device;
int visual_id;
GLXContext context;
GLXFBConfig fb_config;
public:
XcbGlContext(const GlxLibraryExtensions&, Own<XcbDevice>&&, int, GLXContext,
GLXFBConfig);
~XcbGlContext();
void bind() override;
Own<GlWindow> createWindow(const VideoMode&, std::string_view) override;
void flush() override;
};
} // namespace gin

View File

@ -0,0 +1,5 @@
#include "gl_window_xcb.h"
#include "window_xcb.h"
namespace gin {}

View File

@ -1,9 +1,22 @@
#pragma once
#include <GL/glx.h>
#include <kelgin/common.h>
#include "gl/gl_window.h"
namespace gin {
class XcbWindow;
class XcbGlContext;
class XcbGlWindow final : public GlWindow {
public:
public:
Own<XcbWindow> window;
XcbGlContext& context;
::GLXWindow glx_window;
public:
XcbGlWindow(Own<XcbWindow>&&, XcbGlContext&, ::GLXWindow);
~XcbGlWindow();
};
}
} // namespace gin

View File

@ -1,40 +1,36 @@
#include "window_xcb.h"
#include "device_xcb.h"
#include <cassert>
#include "device_xcb.h"
namespace gin {
XcbWindow::XcbWindow(XcbDevice& device, xcb_window_t xcb_window, xcb_colormap_t xcb_colormap, const VideoMode& video_mode, std::string_view title_view):
device{device},
xcb_window{xcb_window},
xcb_colormap{xcb_colormap},
video_mode{video_mode},
window_title{title_view}
{
XcbWindow::XcbWindow(XcbDevice& device, xcb_window_t xcb_window,
xcb_colormap_t xcb_colormap, const VideoMode& video_mode,
std::string_view title_view)
: device{device},
xcb_window{xcb_window},
xcb_colormap{xcb_colormap},
video_mode{video_mode},
window_title{title_view} {}
XcbWindow::~XcbWindow() {
device.windowDestroyed(xcb_window);
xcb_destroy_window(device.xcb_connection, xcb_window);
device.flush();
}
XcbWindow::~XcbWindow(){
device.windowDestroyed(xcb_window);
xcb_destroy_window(device.xcb_connection, xcb_window);
device.flush();
void XcbWindow::show() {
assert(device.xcb_connection);
xcb_map_window(device.xcb_connection, xcb_window);
}
void XcbWindow::show(){
assert(device.xcb_connection);
xcb_map_window(device.xcb_connection, xcb_window);
void XcbWindow::hide() {
assert(device.xcb_connection);
xcb_unmap_window(device.xcb_connection, xcb_window);
}
void XcbWindow::hide(){
assert(device.xcb_connection);
xcb_unmap_window(device.xcb_connection, xcb_window);
}
const VideoMode& XcbWindow::videoMode() const { return video_mode; }
const VideoMode& XcbWindow::videoMode() const{
return video_mode;
}
const std::string_view XcbWindow::title() const {
return window_title;
}
}
const std::string_view XcbWindow::title() const { return window_title; }
} // namespace gin

View File

@ -1,32 +1,35 @@
#pragma once
#include "window.h"
#include <X11/Xlib-xcb.h>
#include <X11/Xlib.h>
#include <xcb/xcb.h>
#include <string>
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include "window.h"
namespace gin {
class XcbDevice;
class XcbWindow final : public Window {
public:
XcbDevice& device;
public:
XcbDevice& device;
xcb_window_t xcb_window;
xcb_colormap_t xcb_colormap;
xcb_window_t xcb_window;
xcb_colormap_t xcb_colormap;
VideoMode video_mode;
std::string window_title;
public:
XcbWindow(XcbDevice& device, xcb_window_t xcb_window, xcb_colormap_t xcb_colormap, const VideoMode& video_mode, std::string_view title_view);
~XcbWindow();
VideoMode video_mode;
std::string window_title;
void show() override;
void hide() override;
public:
XcbWindow(XcbDevice& device, xcb_window_t xcb_window,
xcb_colormap_t xcb_colormap, const VideoMode& video_mode,
std::string_view title_view);
~XcbWindow();
const VideoMode& videoMode() const override;
const std::string_view title() const override;
void show() override;
void hide() override;
const VideoMode& videoMode() const override;
const std::string_view title() const override;
};
}
} // namespace gin

View File

@ -11,3 +11,6 @@ dir_path = Dir('.').abspath
env.sources += sorted(glob.glob(dir_path + "/*.cpp"))
env.headers += sorted(glob.glob(dir_path + "/*.h"))
env.gl_sources += sorted(glob.glob(dir_path + "/gl/*.cpp"))
env.gl_headers += sorted(glob.glob(dir_path + "/gl/*.h"))

View File

@ -8,12 +8,14 @@
namespace gin {
class Device {
public:
virtual ~Device() = default;
public:
virtual ~Device() = default;
virtual Own<Window> createWindow(const VideoMode& mode, std::string_view title_view) = 0;
virtual void flush() = 0;
virtual Own<Window> createWindow(const VideoMode& mode,
std::string_view title_view) = 0;
virtual void flush() = 0;
};
Own<Device> createDevice();
}
class AsyncIoProvider;
Own<Device> createDevice(AsyncIoProvider& provider);
} // namespace gin

View File

@ -1,61 +1,62 @@
#pragma once
#include "gl_window.h"
#include <kelgin/common.h>
#include <string_view>
#include "gl_window.h"
namespace gin {
class GlSettings {
public:
uint8_t gl_major = 3;
uint8_t gl_minor = 3;
public:
uint8_t gl_major = 3;
uint8_t gl_minor = 3;
enum class RenderType : int32_t {
RGBA
};
enum class RenderType : int32_t { RGBA };
RenderType render_type = RenderType::RGBA;
RenderType render_type = RenderType::RGBA;
bool renderable = true;
bool renderable = true;
// gl drawable
bool window_type = true;
// gl drawable
bool window_type = true;
// Pix and PBuffer are currently ignored.
// Pix and PBuffer are currently ignored.
/// @hint don't change this unless you want to change the static cast in
/// glcontext-xcb.cpp and other occurences
/// Alternatively implement bitwise operations & and |
enum class DrawableType : int32_t {
WindowBit = 0x01,
PixMapBit = 0x02,
PBufferBit = 0x04
};
DrawableType drawable_type = DrawableType::WindowBit;
/// @hint don't change this unless you want to change the static cast in
/// glcontext-xcb.cpp and other occurences
/// Alternatively implement bitwise operations & and |
enum class DrawableType : int32_t {
WindowBit = 0x01,
PixMapBit = 0x02,
PBufferBit = 0x04
};
DrawableType drawable_type = DrawableType::WindowBit;
bool double_buffer = true;
bool double_buffer = true;
int red_bits = 8;
int green_bits = 8;
int blue_bits = 8;
int alpha_bits = 8;
int red_bits = 8;
int green_bits = 8;
int blue_bits = 8;
int alpha_bits = 8;
int depth_bits = 24;
int depth_bits = 24;
int stencil_bits = 8;
int stencil_bits = 8;
bool core_profile = true;
bool core_profile = true;
};
class GlContext {
public:
virtual ~GlContext() = default;
public:
virtual ~GlContext() = default;
virtual void bind() = 0;
virtual Own<GlWindow> createWindow(const VideoMode&, std::string_view) = 0;
virtual void bind() = 0;
virtual Own<GlWindow> createWindow(const VideoMode&, std::string_view) = 0;
virtual void flush() = 0;
virtual void flush() = 0;
};
Own<GlContext> createGlContext(const GlSettings&);
}
class AsyncIoProvider;
Own<GlContext> createGlContext(AsyncIoProvider&, const GlSettings&);
} // namespace gin

View File

@ -1,12 +1,14 @@
#pragma once
#include "video_mode.h"
namespace gin {
class GlWindow {
public:
virtual ~GlWindow() = default;
public:
virtual ~GlWindow() = default;
virtual void bind() = 0;
virtual void show() = 0;
virtual void swap() = 0;
virtual void bind() = 0;
virtual void show() = 0;
virtual void swap() = 0;
};
}
} // namespace gin

View File

@ -1,9 +1,11 @@
#pragma once
#include <cstddef>
namespace gin {
class VideoMode {
public:
size_t height = 128;
size_t width = 128;
public:
size_t height = 128;
size_t width = 128;
};
}
} // namespace gin

View File

@ -1,20 +1,20 @@
#pragma once
#include <string_view>
#include <kelgin/common.h>
#include <string_view>
#include "video_mode.h"
namespace gin {
class Window {
public:
virtual ~Window() = default;
public:
virtual ~Window() = default;
virtual void show() = 0;
virtual void hide() = 0;
virtual void show() = 0;
virtual void hide() = 0;
virtual const VideoMode& videoMode() const = 0;
virtual const std::string_view title() const = 0;
virtual const VideoMode& videoMode() const = 0;
virtual const std::string_view title() const = 0;
};
}
} // namespace gin