OpenGL window surface
This commit is contained in:
@@ -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
|
||||||
|
28
projects/apis/opengl/src/surface/opengl_surface.c
Normal file
28
projects/apis/opengl/src/surface/opengl_surface.c
Normal 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
|
13
projects/apis/opengl/src/surface/opengl_surface.h
Normal file
13
projects/apis/opengl/src/surface/opengl_surface.h
Normal 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
|
Reference in New Issue
Block a user