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.
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.
http://dri.freedesktop.org/wiki/
Mesa implements EGL 1.4
Mesa implements OpenGL ES 1.1 and OpenGL ES 2.0
http://mesa3d.org/opengles.html
Mesa 11.0.0 implements the OpenGL 4.1 API. OpenGL 4.1 is only available if requested at context creation because compatibility contexts are not supported.
http://www.mesa3d.org/relnotes/11.0.0.html
Big Picture (DRI)[edit]
Frame Buffer Device Hardware[edit]
Show current connected hardware device
$ xrandr --verbose | egrep '(HDMI|VGA|DVI)' DVI-I-1 disconnected (normal left inverted right x axis y axis) supported: Unknown, DVI-D, DVI-A HDMI-1 disconnected (normal left inverted right x axis y axis) VGA-1 connected primary 1366x768+0+0 (0x65) normal (normal left inverted right x axis y axis) 410mm x 230mm
Show hardware device specifications
$ lspci | grep VGA 01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1)
?=GeForce GT 610
GPU specifications may vary by Add-in-card manufacturer. Refer to the Add-in-card manufacturers' website for actual shipping specifications
http://www.geforce.com/hardware/desktop-gpus/geforce-gt-610/specifications
Graphics Processing Unit NVIDIA GeForce GT 610 Interface PCI Express x16 2.0 Boost / Base Core Clock 550 Memory Size (MB) 1024 Memory Type DDR3 Memory Interface 64bits Memory Clock Speed (MHz) 1000 DVI Connectors 1 D-SUB Connectors 1 HDMI Connectors 1 HDCP Support Y RAMDAC speed (MHz) 400 DirectX Version Support 12 API OpenGL Version Support 4.2 Card Dimension(mm) 160 x 69 x 33mm
http://www.msi.com/product/vga/N610GT-MD1GD3HLP.html#hero-specification
$ dmesg | grep nouveau [ 12.523059] nouveau [ DEVICE][0000:01:00.0] BOOT0 : 0x0d90a0a1 [ 12.523071] nouveau [ DEVICE][0000:01:00.0] Chipset: GF119 (NVD9) [ 12.523078] nouveau [ DEVICE][0000:01:00.0] Family : NVC0 [ 12.681701] nouveau [ VBIOS][0000:01:00.0] using image from PRAMIN [ 12.681807] nouveau [ VBIOS][0000:01:00.0] BIT signature found [ 12.681810] nouveau [ VBIOS][0000:01:00.0] version 75.19.72.00.00 [ 12.682325] nouveau [ PMC][0000:01:00.0] MSI interrupts enabled [ 12.682371] nouveau W[ PFB][0000:01:00.0][0x00000000] reclocking of this ram type unsupported [ 12.682375] nouveau [ PFB][0000:01:00.0] RAM type: DDR3 [ 12.682377] nouveau [ PFB][0000:01:00.0] RAM size: 1024 MiB [ 12.682379] nouveau [ PFB][0000:01:00.0] ZCOMP: 0 tags [ 12.684025] nouveau [ VOLT][0000:01:00.0] GPU voltage: 900000uv [ 12.733441] nouveau [ PTHERM][0000:01:00.0] FAN control: PWM [ 12.733471] nouveau [ PTHERM][0000:01:00.0] fan management: automatic [ 12.733533] nouveau [ PTHERM][0000:01:00.0] internal sensor: yes [ 12.733616] nouveau [ CLK][0000:01:00.0] 07: core 270 MHz memory 405 MHz [ 12.733618] nouveau [ CLK][0000:01:00.0] 0f: core 810 MHz memory 500 MHz [ 12.733784] nouveau [ CLK][0000:01:00.0] --: core 270 MHz memory 405 MHz [ 12.736154] nouveau [ DRM] VRAM: 1024 MiB [ 12.736155] nouveau [ DRM] GART: 1048576 MiB [ 12.736158] nouveau [ DRM] TMDS table version 2.0 [ 12.736159] nouveau [ DRM] DCB version 4.0 [ 12.736160] nouveau [ DRM] DCB outp 00: 02000300 00000000 [ 12.736162] nouveau [ DRM] DCB outp 01: 01000302 00020030 [ 12.736163] nouveau [ DRM] DCB outp 02: 02011362 00020010 [ 12.736164] nouveau [ DRM] DCB outp 03: 04022310 00000000 [ 12.736166] nouveau [ DRM] DCB conn 00: 00001030 [ 12.736167] nouveau [ DRM] DCB conn 01: 00002161 [ 12.736168] nouveau [ DRM] DCB conn 02: 00000200 [ 12.740759] nouveau [ DRM] MM: using COPY0 for buffer copies [ 12.840177] nouveau [ DRM] allocated 1366x768 fb: 0x60000, bo ffff8800cece4000 [ 12.840328] fbcon: nouveaufb (fb0) is primary device [ 12.916611] nouveau 0000:01:00.0: fb0: nouveaufb frame buffer device [ 12.916618] nouveau 0000:01:00.0: registered panic notifier [ 12.924892] [drm] Initialized nouveau 1.2.2 20120801 for 0000:01:00.0 on minor 0
- Video BIOS interfaces software to the video chipset as system BIOS does for the system chipset
https://en.wikipedia.org/wiki/Video_BIOS
?=msi vbios
MSI Live Update 6 Monitor, auto-detects, suggests BIOS/Driver/Utilities
http://us.msi.com/support/vga/N610GT-MD1GD3LP.html/#down-utility&Win7%2064
?=msi vbios 75.19.72.00.00
MSI.GT610.2048.131101.rom
BIOS Internals
GPU Device Id: 0x10DE 0x104A Version: 75.19.72.00.00 NVIDIA GeForce GT 610 VGA BIOS MSINV809MS.FH0 Copyright (C) 1996-2012 NVIDIA Corp. GF119 Board - 13100000 Fan Speed Min: 40% Max: 100% Performance Level 0 Core Clk: 51.00 MHz Mem Clk: 135.00 MHz Shader Clk: 101.00 MHz Performance Level 1 Core Clk: 270.00 MHz Mem Clk: 405.00 MHz Shader Clk: 540.00 MHz Performance Level 3 Core Clk: 810.00 MHz Mem Clk: 500.00 MHz Shader Clk: 1620.00 MHz Memory Support DDR3, Elpida DDR3, Qimonda DDR3, Hynix DDR3, Samsung DDR3, Micron
https://www.techpowerup.com/vgabios/153251/msi-gt610-2048-131101.html
- TMDS table version 2.0. Transition-minimized differential signaling (TMDS), a technology for transmitting high-speed serial data, is used by the DVI & HDMI video interfaces
https://en.wikipedia.org/wiki/Transition-minimized_differential_signaling
- DCB version 4.0 (Device Control Block 4.0 Specification).
- DCBs are static tables used to describe the board topology and connections external to the GPU chip.
- DCBs define the devices connected, specific information needed to configure those devices, and the external electrical connections such as HDMI and Display Port
- DCBs do not try to explain the capabilities of the chip itself. That information is implicit in the VBIOS, firmware and drivers, which are built differently for each chip
ftp://download.nvidia.com/open-gpu-doc/DCB/1/DCB-4.0-Specification.html
Show hardware device chipset & family
$ dmesg | grep DEVICE [ 12.523059] nouveau [ DEVICE][0000:01:00.0] BOOT0 : 0x0d90a0a1 [ 12.523071] nouveau [ DEVICE][0000:01:00.0] Chipset: GF119 (NVD9) [ 12.523078] nouveau [ DEVICE][0000:01:00.0] Family : NVC0
?=NVD9
NVC0 family (Fermi)
NVD9 (GF119) GeForce 410M, 510 (?), GT (520, 520M, 520MX), 610M Quadro NVS 4200M
http://nouveau.freedesktop.org/wiki/CodeNames/
mesa[edit]
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[edit]
- Direct Rendering Infrastructure [V]
Direct Rendering Infrastructure[edit]
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/
https://en.wikipedia.org/wiki/Direct_Rendering_Infrastructure
Checklist[edit]
- debian dri [V]
debian dri[edit]
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
debian linux kernel[edit]
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[edit]
- debian current kernel [V]
- debian kernel module [V]
debian current kernel[edit]
Use the command uname(1). For example : uname -r
https://wiki.debian.org/KernelFAQ
debian kernel module[edit]
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
- 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[edit]
- debian drm [V]
- Nouveau Project [V]
debian drm (drm.ko)[edit]
- 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)
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/
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[edit]
- linux drm [V]
- hardware acceleration [V]
- kernelspace
- userspace
linux drm[edit]
- 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
hardware acceleration[edit]
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
Nouveau Project (nouveau.ko)[edit]
- Show module information
$ /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)
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[edit]
- mesa Gallium3D [V]
mesa Gallium3D[edit]
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/
src/gallium/drivers
d--------- ddebug 275 logplain d--------- freedreno 1743 logplain d--------- i915 1967 logplain d--------- ilo 1987 logplain d--------- llvmpipe 3372 logplain d--------- noop 241 logplain d--------- nouveau 1471 logplain d--------- r300 1971 logplain d--------- r600 1557 logplain d--------- radeon 1381 logplain d--------- radeonsi 1094 logplain d--------- rbug 485 logplain d--------- softpipe 2236 logplain d--------- svga 3715 logplain d--------- trace 674 logplain d--------- vc4 2243 logplain
http://www.mesa3d.org/sourcetree.html
http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers
Mesa3D GL* through EGL & XCB[edit]
OpenGL ABI[edit]
- 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/
Prerequisites[edit]
/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[edit]
/*
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;
}