我有兴趣制作一个不依赖于X11的OpenGL应用程序.正如我所见,这应该可以通过EGL实现.互联网上甚至还有一些例子.但是我如何控制上下文版本?下面的示例代码创建了一个版本为2.1的OpenGL上下文(在路上),但是在我的计算机上,它显示支持的最高OpenGL版本是3.3(这样的上下文可以使用glXCreateContextAttribsARB在X服务器中使用GLX和xlib创建).所以我的问题是:我可以通过EGL以某种方式创建一个具有更高版本的OpenGL上下文,如果是,如何?
示例代码:
#include <wayland-client.h>
#include <wayland-egl.h>
#include <EGL/egl.h>
#include <GL/gl.h>
#include <string.h>
#include <stdio.h>
#define WIDTH 256
#define HEIGHT 256
static struct wl_display *display;
static struct wl_compositor *compositor = NULL;
static struct wl_shell *shell = NULL;
static EGLDisplay egl_display;
static char running = 1;
struct window {
EGLContext egl_context;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct wl_egl_window *egl_window;
EGLSurface egl_surface;
};
// listeners
static void registry_add_object (void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) {
if …Run Code Online (Sandbox Code Playgroud)