OpenGL window surface

This commit is contained in:
Gregory Wells
2025-07-10 08:40:38 -04:00
parent 255a8e36e9
commit f8bae555cf
3 changed files with 47 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#include "opengl_loader.h" #include "opengl_loader.h"
#include "instance/opengl_instance.h" #include "instance/opengl_instance.h"
#include "surface/opengl_surface.h"
gnInstanceFunctions loadOpenGLInstanceFunctions() { gnInstanceFunctions loadOpenGLInstanceFunctions() {
return (gnInstanceFunctions){ return (gnInstanceFunctions){
@@ -9,6 +10,11 @@ gnInstanceFunctions loadOpenGLInstanceFunctions() {
// ._gnQueueCanPresentToSurface = metalCanQueuePresentToSurface, // ._gnQueueCanPresentToSurface = metalCanQueuePresentToSurface,
// ._gnCreateOutputDevice = createMetalOutputDevice, // ._gnCreateOutputDevice = createMetalOutputDevice,
// ._gnDestroyOutputDevice = destroyMetalOutputDevice, // ._gnDestroyOutputDevice = destroyMetalOutputDevice,
#ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11
._gnCreateX11WindowSurface = createGLXContext,
#endif
#endif
// ._gnCreateMacOSWindowSurface = createMetalSurface, // ._gnCreateMacOSWindowSurface = createMetalSurface,
// ._gnDestroyWindowSurface = destroyMetalWindowSurface, // ._gnDestroyWindowSurface = destroyMetalWindowSurface,
// ._gnGetSurfaceDetails = getMetalSurfaceDetails // ._gnGetSurfaceDetails = getMetalSurfaceDetails

View File

@@ -0,0 +1,28 @@
#include "opengl_surface.h"
#ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11
#include <X11/Xlib.h>
gnReturnCode createGLXContext(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, gnX11WindowSurfaceInfo createInfo) {
windowSurface->windowSurface = malloc(sizeof(gnPlatformWindowSurface));
int attribs[] = {
GLX_RGBA,
GLX_DEPTH_SIZE, 24,
GLX_DOUBLEBUFFER,
None
};
XVisualInfo* vi = glXChooseVisual(createInfo.display, 0, attribs);
windowSurface->windowSurface->context = glXCreateContext(createInfo.display, vi, NULL, GL_TRUE);
if (glXMakeCurrent(createInfo.display, createInfo.window, windowSurface->windowSurface->context) == GL_FALSE)
return GN_FAILED_TO_ATTACH_WINDOW;
return GN_SUCCESS;
}
#endif
#ifdef GN_WINFDOW_WAYLAND
gnReturnCode gnCreateWaylandWindowSurface(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, gnWaylandWindowSurfaceInfo createInfo) {
return GN_FAILED_TO_ATTACH_WINDOW;
}
#endif
#endif

View File

@@ -0,0 +1,13 @@
#pragma once
#include <window_surface/gryphn_surface.h>
#include "core/src/window_surface/gryphn_surface_create_functions.h"
#ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11
#include <GL/glx.h>
typedef struct gnPlatformWindowSurface_t {
GLXContext context;
} gnPlatformWindowSurface;
gnReturnCode createGLXContext(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, gnX11WindowSurfaceInfo createInfo);
#endif
#endif