Platform specifics: Linux
This Section explains how to install Drivers to make OpenGL Programs run under Linux and how to use different Libraries/Toolkits to create Opengl Programs.
The standard OpenGL implementation used on Linux systems is Mesa3D. As of this writing, it provides implementations of OpenGL (up to version 3.0), as well as OpenGL ES, both versions 1.1 and 2.0. It includes a software-only implementation of the entire GL stack, but can also use hardware-specific drivers.
Big Picture (DRI)
mesa
Mesa is an open-source implementation of the OpenGL specification - a system for rendering interactive 3D graphics
Mesa ties into several other open-source projects: the Direct Rendering Infrastructure and X.org to provide OpenGL support to users of X on Linux, FreeBSD and other operating systems
http://www.mesa3d.org/intro.html
Checklist
- Direct Rendering Infrastructure [V]
Direct Rendering Infrastructure
Direct Rendering Infrastructure (DRI) is a framework for allowing direct access to graphics hardware under the X Window System in a safe, efficient way.[5] The main use of DRI is to provide hardware acceleration for the Mesa implementation of OpenGL
https://en.wikipedia.org/wiki/Direct_Rendering_Infrastructure
Mesa is an open-source OpenGL implementation, continually updated to support the latest OpenGL specification
Direct Rendering Infrastructure, also known as the DRI, is a framework for allowing direct access to graphics hardware under the X Window System in a safe and efficient manner. It includes changes to the X server, to several client libraries, and to the kernel (DRM, Direct Rendering Manager)
http://dri.freedesktop.org/wiki/
Checklist
- debian dri [?]
- Direct Rendering Manager [V]
debian dri
libgl1-mesa-dri (10.6.5-1 and others)
OpenGL API -- DRI modules
Mesa provides GLX and DRI capabilities: it is capable of both direct and indirect rendering. For direct rendering, it can use DRI modules from the libgl1-mesa-dri package to accelerate drawing
does not include the OpenGL library itself, only the DRI modules
dep: libdrm-nouveau2 Userspace interface to nouveau-specific kernel DRM services -- runtime
dep: libdrm2 Userspace interface to kernel DRM services -- runtime
Similar packages:
- libgl1-mesa-glx
- libegl1-mesa
https://packages.debian.org/sid/libgl1-mesa-dri
libegl1-mesa (10.6.5-1 and others)
EGL API -- runtime
contains the EGL native platform graphics interface library. EGL provides a platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES
contains modules to interface with the existing system GLX or DRI2 drivers to provide OpenGL via EGL
https://packages.debian.org/sid/libegl1-mesa
/usr/lib/x86_64-linux-gnu/libEGL.so.1 /usr/lib/x86_64-linux-gnu/libEGL.so.1.0.0
https://packages.debian.org/sid/amd64/libegl1-mesa/filelist
Direct Rendering Manager
Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for interfacing with GPUs of modern video cards. DRM exposes an API that user space programs can use to send commands and data to the GPU, and perform operations such as configuring the mode setting of the display. DRM was first developed as the kernel space component of the X Server's Direct Rendering Infrastructure
https://en.wikipedia.org/wiki/Direct_Rendering_Manager
DRM is a kernel module that gives direct hardware access to DRI clients
module deals with DMA, AGP memory management, resource locking, and secure hardware access.
DRM supports the DRI in three major ways:
- DRM provides synchronized access to the graphics hardware
- DRM enforces the DRI security policy for access to the graphics hardware
- DRM provides a generic DMA engine
http://dri.freedesktop.org/wiki/DRM/
Checklist
- debian drm [V]
debian drm
libdrm2 (2.4.64-1 and others)
Userspace interface to kernel DRM services -- runtime
DRM stands for "Direct Rendering Manager", which is the kernelspace portion of the "Direct Rendering Infrastructure" (DRI). The DRI is currently used on Linux to provide hardware-accelerated OpenGL drivers
Similar packages: ...
- libdrm-nouveau2
...
https://packages.debian.org/sid/libdrm2
/usr/lib/x86_64-linux-gnu/libdrm.so.2 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
https://packages.debian.org/sid/amd64/libdrm2/filelist
libdrm-nouveau2 (2.4.64-1 and others)
interface to nouveau-specific kernel DRM services -- runtime
implements the userspace interface to the kernel DRM services. DRM stands for "Direct Rendering Manager", which is the kernelspace portion of the "Direct Rendering Infrastructure" (DRI). The DRI is currently used on Linux to provide hardware-accelerated OpenGL drivers
https://packages.debian.org/sid/libdrm-nouveau2
/usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2 /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
https://packages.debian.org/sid/amd64/libdrm-nouveau2/filelist
Checklist
- linux drm [V]
- hardware acceleration [V]
- kernelspace
- userspace
linux drm
- DRM Core
- Introduction
- DRM Internals
- Driver Initialization
- Memory management
- Mode Setting
- KMS Initialization and Cleanup
- Mode Setting Helper Functions
- KMS Properties
- Vertical Blanking
- Open/Close, File Operations and IOCTLs
- Legacy Support Code
- Userland interfaces
- DRM Drivers
https://www.kernel.org/doc/htmldocs/drm/
hardware acceleration
hardware acceleration is the use of computer hardware to perform some functions faster than is possible in software running on a more general-purpose CPU. Examples of hardware acceleration include blitting acceleration functionality in graphics processing units (GPUs)
https://en.wikipedia.org/wiki/Hardware_acceleration
debian linux kernel
linux-image-4.1.0-2-amd64 (4.1.6-1)
Linux kernel 4.1 and modules for use on PCs with AMD64
https://packages.debian.org/sid/linux-image-4.1.0-2-amd64
/boot/System.map-4.1.0-2-amd64 /boot/config-4.1.0-2-amd64 /boot/vmlinuz-4.1.0-2-amd64 /lib/modules/4.1.0-2-amd64/kernel/arch/x86/crypto/aes-x86_64.ko /lib/modules/4.1.0-2-amd64/kernel/arch/x86/crypto/aesni-intel.ko /lib/modules/4.1.0-2-amd64/kernel/arch/x86/crypto/blowfish-x86_64.ko ...
https://packages.debian.org/sid/amd64/linux-image-4.1.0-2-amd64/filelist
Checklist
- debian current kernel [V]
- debian kernel module [V]
debian current kernel
Use the command uname(1). For example : uname -r
https://wiki.debian.org/KernelFAQ
debian kernel module
ModulesAll - Full List of Kernel Modules for the Debian's Linux Kernel
Manpages : modprobe, lsmod, modinfo, update-modules, insmod, depmod, rmmod, depmod.conf, modules, modules.dep and modprobe.conf
https://wiki.debian.org/Modules#Kernel_Modules
MODINFO(8)
modinfo extracts information from the Linux Kernel modules given on the command line, as is also done by modprobe(8) when loading kernel modules
modinfo by default lists each attribute of the module in form fieldname : value
http://man7.org/linux/man-pages/man8/modinfo.8.html
- What is current kernel
$ uname -r 4.1.0-2-amd64
- Show kernel drm modules
$ find /lib/modules/4.1.0-2-amd64/ | egrep drm | sort -u /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/ast /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/ast/ast.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/bochs /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/bochs/bochs-drm.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/cirrus /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/cirrus/cirrus.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/drm_kms_helper.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/drm.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/gma500 /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/gma500/gma500_gfx.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/i2c /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/i2c/ch7006.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/i2c/sil164.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/i915 /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/i915/i915.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/mga /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/mgag200 /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/mgag200/mgag200.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/mga/mga.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/qxl /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/qxl/qxl.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/r128 /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/r128/r128.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/radeon /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/radeon/radeon.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/savage /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/savage/savage.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/sis /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/sis/sis.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/tdfx /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/tdfx/tdfx.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/ttm /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/ttm/ttm.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/udl /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/udl/udl.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/vgem /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/vgem/vgem.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/via /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/via/via.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/vmwgfx /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/vmwgfx/vmwgfx.ko
- Show module information
$ /sbin/modinfo /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/drm.ko filename: /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/drm.ko license: GPL and additional rights description: DRM shared core routines author: Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl license: GPL and additional rights description: DRM bridge infrastructure author: Ajay Kumar <ajaykumar.rs@samsung.com> license: GPL and additional rights description: DRM panel infrastructure author: Thierry Reding <treding@nvidia.com> depends: intree: Y vermagic: 4.1.0-2-amd64 SMP mod_unload modversions parm: edid_fixup:Minimum number of valid EDID header bytes (0-8, default 6) (int) parm: debug:Enable debug output (int) parm: atomic:Enable experimental atomic KMS API (bool) parm: vblankoffdelay:Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately) (int) parm: timestamp_precision_usec:Max. error on timestamps [usecs] (int) parm: timestamp_monotonic:Use monotonic timestamps (int)
$ /sbin/modinfo /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko filename: /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko license: GPL and additional rights description: nVidia Riva/TNT/GeForce/Quadro/Tesla author: Nouveau Project alias: pci:v000012D2d*sv*sd*bc03sc*i* alias: pci:v000010DEd*sv*sd*bc03sc*i* depends: drm,drm_kms_helper,ttm,mxm-wmi,button,wmi,video,i2c-algo-bit intree: Y vermagic: 4.1.0-2-amd64 SMP mod_unload modversions parm: tv_norm:Default TV norm. Supported: PAL, PAL-M, PAL-N, PAL-Nc, NTSC-M, NTSC-J, hd480i, hd480p, hd576i, hd576p, hd720p, hd1080i. Default: PAL *NOTE* Ignored for cards with external TV encoders. (charp) parm: vram_pushbuf:Create DMA push buffers in VRAM (int) parm: nofbaccel:Disable fbcon acceleration (int) parm: tv_disable:Disable TV-out detection (int) parm: ignorelid:Ignore ACPI lid status (int) parm: duallink:Allow dual-link TMDS (default: enabled) (int) parm: pstate:enable sysfs pstate file, which will be moved in the future (int) parm: config:option string to pass to driver core (charp) parm: debug:debug string to pass to driver core (charp) parm: noaccel:disable kernel/abi16 acceleration (int) parm: modeset:enable driver (default: auto, 0 = disabled, 1 = enabled, 2 = headless) (int) parm: runpm:disable (0), force enable (1), optimus only default (-1) (int) parm: agpmode:AGP mode (0 to disable AGP) (int)
- What is the module file format
$ file /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), BuildID[sha1]=09a3962068d911b31e3c606a03024333cab7e97a, not stripped
- What package provides this file
$ dpkg -S /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko linux-image-4.1.0-2-amd64: /lib/modules/4.1.0-2-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko
Checklist
- Nouveau Project [V]
Nouveau Project
Nouveau is composed of a:
- Linux kernel KMS driver (nouveau)
- Gallium3D drivers in Mesa
- Xorg DDX (xf86-video-nouveau)
http://nouveau.freedesktop.org/wiki/
Checklist
- mesa Gallium3D [V]
mesa Gallium3D
Gallium3D is a new architecture for building 3D graphics drivers; Initially supporting Mesa and Linux graphics drivers
http://www.freedesktop.org/wiki/Software/gallium/
- Gallium3D Architecture (Keith Whitwell) Video Slides
- Gallium3D Version 1 Components and Status (Brian Paul) Video Slides
- OpenGL-ES State Tracker Status (Brian Paul) Video Slides
http://www.freedesktop.org/wiki/Software/gallium/GAOnlineWorkshop/
egl: Windowing system trackers similar to dri of EGL standard
nouveau: This is not actually a driver, but a set of routines common to all nv pipes
http://www.x.org/wiki/GalliumStatus/
drivers - Gallium3D device drivers
- i915 - Driver for Intel i915/i945.
- llvmpipe - Software driver using LLVM for runtime code generation.
- nv* - Drivers for NVIDIA GPUs.
- radeonsi - Driver for AMD Southern Island.
- r300 - Driver for ATI R300 - R500.
- r600 - Driver for ATI/AMD R600 - Northern Island.
- softpipe - Software reference driver.
- svga - Driver for VMware's SVGA virtual GPU.
- trace - Driver for tracing Gallium calls.
- XXX more
http://www.mesa3d.org/sourcetree.html
Mesa3D GL* through EGL & XCB
OpenGL ABI
- ABI (Application Binary Interface) and runtime environment for applications using OpenGL under X11 on Linux enable applications using the OpenGL API for rendering to run on a variety of underlying implementations transparently. The intent is to address all of open source, commercial closed binary, OpenGL SI-based, and Mesa-based implementations.
- SDK for developing apps using OpenGL. This includes header file locations, conventions for use of extensions, etc.
https://www.opengl.org/registry/ABI/
Some Linux distributions may include support for hardware acceleration. Also, some GPUs have Open Source drivers developed by the community even though a closed source driver may be available from the manufacturer.
Prerequisites
/usr/lib/x86_64-linux-gnu/libEGL.so.1 /usr/lib/x86_64-linux-gnu/libEGL.so.1.0.0 /usr/share/bug/libegl1-mesa/control /usr/share/bug/libegl1-mesa/script /usr/share/doc/libegl1-mesa/changelog.Debian.gz /usr/share/doc/libegl1-mesa/copyright /usr/share/lintian/overrides/libegl1-mesa
https://packages.debian.org/sid/amd64/libegl1-mesa/filelist
/usr/include/EGL/egl.h /usr/include/EGL/eglext.h /usr/include/EGL/eglextchromium.h /usr/include/EGL/eglmesaext.h /usr/include/EGL/eglplatform.h /usr/include/KHR/khrplatform.h /usr/lib/x86_64-linux-gnu/libEGL.so /usr/lib/x86_64-linux-gnu/libwayland-egl.so /usr/lib/x86_64-linux-gnu/pkgconfig/egl.pc /usr/lib/x86_64-linux-gnu/pkgconfig/wayland-egl.pc /usr/share/bug/libegl1-mesa-dev/control /usr/share/bug/libegl1-mesa-dev/script /usr/share/doc/libegl1-mesa-dev/changelog.Debian.gz /usr/share/doc/libegl1-mesa-dev/copyright
https://packages.debian.org/sid/amd64/libegl1-mesa-dev/filelist
/usr/lib/x86_64-linux-gnu/libGLESv2.so.2 /usr/lib/x86_64-linux-gnu/libGLESv2.so.2.0.0 /usr/share/bug/libgles2-mesa/control /usr/share/bug/libgles2-mesa/script /usr/share/doc/libgles2-mesa/changelog.Debian.gz /usr/share/doc/libgles2-mesa/copyright /usr/share/lintian/overrides/libgles2-mesa
https://packages.debian.org/sid/amd64/libgles2-mesa/filelist
/usr/include/GLES2/gl2.h /usr/include/GLES2/gl2ext.h /usr/include/GLES2/gl2platform.h /usr/include/GLES3/gl3.h /usr/include/GLES3/gl31.h /usr/include/GLES3/gl3ext.h /usr/include/GLES3/gl3platform.h /usr/lib/x86_64-linux-gnu/libGLESv2.so /usr/lib/x86_64-linux-gnu/pkgconfig/glesv2.pc /usr/share/bug/libgles2-mesa-dev/control /usr/share/bug/libgles2-mesa-dev/script /usr/share/doc/libgles2-mesa-dev/changelog.Debian.gz /usr/share/doc/libgles2-mesa-dev/copyright
https://packages.debian.org/sid/amd64/libgles2-mesa-dev/filelist
Source Code
/*
MIT License
Copyright (c) 2015 Alex Cham
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Very Dirty Code! Test Purposes Only!
Why XCB?
X protocol C-language Binding (XCB) is a replacement for Xlib
http://xcb.freedesktop.org/
Basic Graphics Programming With The XCB Library
http://www.x.org/releases/X11R7.6/doc/libxcb/tutorial/index.html
Introduction to managing client API rendering through the EGL API.
https://www.khronos.org/registry/egl/sdk/docs/man/html/eglIntro.xhtml
Linking
Invoking: GCC C++ Linker
g++ -o "EGL14XCBGLES20MakeCurrentContext" ./src/EGL14XCBGLES20MakeCurrentContext.o -lxcb -lEGL -lGLESv2
See Also:
Documentation for the X Window System
http://www.x.org/releases/X11R7.6/doc/
*/
#include <stdlib.h>
//
#include <EGL/egl.h>
#include <GLES2/gl2.h>
//
#include <xcb/xcb.h>
xcb_window_t makeXcbWindow(uint16_t width, uint16_t height,
xcb_visualid_t eglConfAttrVisualID) {
xcb_connection_t *c;
xcb_screen_t *screen;
xcb_window_t win;
/* Open the connection to the X server */
c = xcb_connect(NULL, NULL);
/* Get the first screen */
screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
/* Ask for our window's Id */
win = xcb_generate_id(c);
/* Create the window */
xcb_create_window(c,
XCB_COPY_FROM_PARENT, win, screen->root, 0, 0, width, height, 10,
XCB_WINDOW_CLASS_INPUT_OUTPUT, eglConfAttrVisualID, 0,
NULL);
/* Map the window on the screen */
xcb_map_window(c, win);
/* Make sure commands are sent before we pause, so window is shown */
xcb_flush(c);
return win;
}
int main(int argc, char ** argv) {
//@FIXME Black screen & cursor problems sometimes...
/* get an EGL display connection */
EGLDisplay display;
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
/* initialize the EGL display connection */
eglInitialize(display, NULL, NULL);
/* get an appropriate EGL frame buffer configuration */
/*
All attributes in attrib_list, including boolean attributes, are immediately
followed by the corresponding desired value. The list is terminated with EGL_NONE
https://www.khronos.org/registry/egl/sdk/docs/man/html/eglChooseConfig.xhtml
*/
static EGLint const attribute_list[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_NONE };
EGLConfig config;
EGLint num_config;
eglChooseConfig(display, attribute_list, &config, 1, &num_config);
/* create an EGL rendering context */
/*
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENGL_API 0x30A2
*/
eglBindAPI(EGL_OPENGL_ES_API);
/*
eglCreateContext — create a new EGL rendering context
attrib_list specifies a list of attributes for the context.
The list has the same structure as described for eglChooseConfig
https://www.khronos.org/registry/egl/sdk/docs/man/html/eglCreateContext.xhtml
*/
static const EGLint ctx_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE };
EGLContext context;
context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctx_attribs);
//Request eglVisualID for native window
EGLint eglConfAttrVisualID;
if (!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID,
&eglConfAttrVisualID)) {
//printf("Error: eglGetConfigAttrib() failed\n");
exit(1);
}
///////////////////////////////////////////////////////////////////////////////
/* create a native window */
//native_window = createNativeWindow();
uint16_t width = 640;
uint16_t height = 480;
NativeWindowType nativeWindow;
nativeWindow = makeXcbWindow(width, height,
(xcb_visualid_t) eglConfAttrVisualID);
///////////////////////////////////////////////////////////////////////////////
/* create an EGL window surface */
EGLSurface surface;
surface = eglCreateWindowSurface(display, config, nativeWindow, NULL);
/* connect the context to the surface */
eglMakeCurrent(display, surface, surface, context);
/* clear the color buffer */
while (1) {
glViewport(0, 0, (GLsizei) width, (GLsizei) height);
glClearColor(0., 0., 1., 0.);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
eglSwapBuffers(display, surface);
}
return EXIT_SUCCESS;
}