From 2569c1a030486c4378a43354bb43dc33067b2b4c Mon Sep 17 00:00:00 2001 From: Bastien Date: Sat, 22 Sep 2018 18:19:28 +0200 Subject: [PATCH] add missing files --- src/context.inl | 69 +++++++++++++++++++++++++++++++++++++++++++++++ src/context_EGL.c | 0 src/context_EGL.h | 0 src/rendering.c | 1 + src/rendering.h | 5 ++++ 5 files changed, 75 insertions(+) create mode 100644 src/context.inl create mode 100644 src/context_EGL.c create mode 100644 src/context_EGL.h create mode 100644 src/rendering.c create mode 100644 src/rendering.h diff --git a/src/context.inl b/src/context.inl new file mode 100644 index 0000000..b26de11 --- /dev/null +++ b/src/context.inl @@ -0,0 +1,69 @@ +#include +#include + +static inline bool create_context(EGLenum platform, EGLNativeDisplayType nativeDisplay, EGLNativeWindowType nativeWindow, const EGLint * config_attribs, const EGLint * context_attribs, const EGLint * surface_attribs, EGLDisplay * outDisplay, EGLContext * outContext, EGLSurface * outSurface) +{ + // + // get an EGL display connection + EGLDisplay display = eglGetPlatformDisplay(platform, nativeDisplay, (EGLAttrib*)0); + + if (EGL_NO_DISPLAY == display) + { + return false; + } + + // + // initialize the EGL display connection + EGLint major, minor; + + if (!eglInitialize(display, &major, &minor)) + { + return false; + } + + // + // bind OpenGL API + eglBindAPI(EGL_OPENGL_API); + + // + // get an appropriate EGL frame buffer configuration + EGLint num_config; + EGLConfig configs[128]; + + if (!eglChooseConfig(display, config_attribs, configs, 128, &num_config)) + { + return false; + } + + EGLConfig config = configs[0]; // FIXME + + // + // create context + EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribs); + + if (EGL_NO_CONTEXT == context) + { + return false; + } + + // + // Create Surface + EGLSurface surface = eglCreateWindowSurface(display, config, nativeWindow, surface_attribs); + if (EGL_NO_SURFACE == surface) + { + return false; + } + + // + // Set current context + if (!eglMakeCurrent(display, surface, surface, context)) + { + return false; + } + + *outDisplay = display; + *outContext = context; + *outSurface = surface; + + return true; +} diff --git a/src/context_EGL.c b/src/context_EGL.c new file mode 100644 index 0000000..e69de29 diff --git a/src/context_EGL.h b/src/context_EGL.h new file mode 100644 index 0000000..e69de29 diff --git a/src/rendering.c b/src/rendering.c new file mode 100644 index 0000000..f9982c8 --- /dev/null +++ b/src/rendering.c @@ -0,0 +1 @@ +#include "rendering.h" diff --git a/src/rendering.h b/src/rendering.h new file mode 100644 index 0000000..6ec72c0 --- /dev/null +++ b/src/rendering.h @@ -0,0 +1,5 @@ +#ifndef LINUX_VR_COMPOSITOR_RENDERING_H +#define LINUX_VR_COMPOSITOR_RENDERING_H + + +#endif // LINUX_VR_COMPOSITOR_RENDERING_H