Use opengl in linux

OpenGL

OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics.

Contents

Installation

To run any application that uses OpenGL you will need to install driver(s) for your hardware (either GPUs or CPUs)

  • mesa is an open-source OpenGL implementation, continually updated to support the latest OpenGL specification. It has a collection of open-source drivers for Intel graphics, ATI, AMD, AMD PRO, and NVIDIA GPUs and also provides software rasterizers, The included drivers in the package are
    • i915 : for GMA 916G as well as the i830, i845 and i865 integrated GPU series.
    • i965 : for Intel’s Gen 4 hardware and later. It is officially supported by Intel.
    • iris : for Intel’s Gen 8 hardware and later. It is officially supported by Intel.
    • r100 : for AMD’s Radeon R100 GPU series.
    • r200 : for AMD’s Radeon R200 GPU series.
    • r300 : for AMD’s Radeon R300, R400, and R500 GPU series.
    • r600 : for AMD’s Radeon HD 2000 GPU series and later. It is officially supported by AMD.
    • radeonsi : for AMD’s Southern Island GPUs and later. It is officially supported by AMD.
    • nouveau : Nouveau is the open-source driver for NVIDIA GPUs.
    • virgl : is a virtual GPU driver for sharing a GPU with a host for virtual machines.
    • svga : for VMware virtual GPUs.
    • zink : is a Gallium driver, it can be used to run OpenGL on vulkan.
    • swrast : Legacy software rasterizer.
    • softpipe : Software rasterizer, a reference Gallium driver.
    • llvmpipe : Software rasterizer, uses LLVM for x86 JIT code generation and is multi-threaded.
    • swr : High performance software rasterizer that uses AVX and AVX2 CPU instructions, also known as OpenSWR.
  • nvidia-utils is proprietary driver for NVIDIA GPUs.
  • amdgpu-pro-libglAUR is proprietary driver for AMD PRO GPUs.

Verification

To verify your OpenGL installation you can use mesa-demos glxinfo and you should get output like this :

(with different values depending on your setup of course)

From the same package you can also try glxgears , you should see 3 rotating gears.

Switching between drivers

For Hybrid graphics you might want to see PRIME.

You can override used driver using the following environment variable:

By default mesa searches for drivers in /lib/dri/ you can see the list of drivers by

driver is the name of the driver without _dri.so . If it failed it will fallback to llvmpipe.

You can also use OpenGL software rasterizer drivers by setting the following environment variables:

driver is one of softpipe , llvmpipe , or swr .

Development

Using OpenGL in code requires functions loader, read more at Khronos.

This article or section needs expansion.

OpenGL Hardware Database

GPUInfo provides user reported GPU/driver combinations, supported extensions, capabilities, etc.

Источник

How to Install OpenGL on Ubuntu Linux

What Is OpenGL?
OpenGL is a Graphics rendering API which is operating system independent, window system independent and has high-quality color images composed of geometric and image primitives.
OpenGL APIs can use following …

  • Gl
    • OpenGL API implementation (http://www.opengl.org)
  • Glu
    • OpenGL Utility
  • Glut – GLUT (OpenGL Utility Toolkit) – Glut is portable windowing API and it is not officially part of OpenGL.
    • OpenGL Utility Toolkit (http://www.opengl.org/resources/libraries/glut/)
  • FLTK
    • FlashLight ToolKit (http://www.fltk.org/)
  • GLEW
Читайте также:  Управление строкой состояния windows

Now lets see How to install OpenGL on out Ubuntu OS.

Now because GLUT (OpenGL Utility Toolkit) depends upon OpenGL and a number of other related libraries, if we install GLUT then OpenGL will be automatically be installed.

Run the following commands to install OpenGL.

Now to test if OpenGl libraries are working fine on our Linux, we will create a C++ program and test it.

So create a following C++ Program.

Now give the command below to compile your code.

Now run your OpenGl program with following command

If a window pops up when you run the program, then OpenGL is working on your Ubuntu OS.

Источник

OpenGL Programming/Installation/Linux

Contents

OpenGL Installation on Linux [ edit | edit source ]

Most Linux distributions rely on the Mesa3D project to provide their OpenGL implementation. This supplies libraries for regular OpenGL as well as OpenGL ES 1.x and 2.0.

The exact names of the packages you need to install are highly dependent on distribution. Referring to your distro’s packages can save you a lot of time and headache in installation. Use your favorite package manager and search for the package name. You may need to install packages that come with a dev suffix, these are development packages (usually header files). Also look for packages with a lib prefix, which refer to libraries.

Install the GCC C/C++ compilers and associated tools such as make.

All in all, install Mesa, Make and GCC/g++:

Libraries [ edit | edit source ]

In this wikibooks, we’ll make great use of GLEW, SDL2 (+SDL2_Image), GLM and FreeType. Make sure you install the development libraries:

If GLM is not available in your distribution repository, you have the option to install it manually. Make sure the headers end in the /usr/include/glm directory. Since it’s a headers-only library, you do not need to compile a .so library — just copy the code there.

Drivers [ edit | edit source ]

OpenGL is the primary 3D graphics API on GNU/Linux-based systems. If your device supports 3D acceleration on GNU/Linux, it probably includes an OpenGL distribution.

OpenGL is included in drivers, so you’ll have to make sure drivers are properly installed if you want to enjoy programs using OpenGL. Open source drivers actually make use of Mesa’s OpenGL implementation. Proprietary drivers embed their own OpenGL library.

Proprietary options [ edit | edit source ]

Nvidia provides generally excellent but non-open source drivers via the nvidia driver from their website. fglrx drives many modern AMD devices; it is also closed-source, and available from AMD’s website.

Free/Open-Source options [ edit | edit source ]

If your CPU is an Intel one with built-in graphics, then the necessary open-source drivers come as a standard part of the Linux kernel.

If you have one of the newest chips, you may be forced to use the mediocre fglrx driver. However since AMD released the specifications for their chips, the open source ‘radeon’ made its way to become a full-featured 2D and 3D driver.

As of June 2013, most AMD chips will run well with the open source ‘radeon’ driver. 3D performance is still better with the AMD Catalyst driver on modern cards, but this may change in the future. Check the feature matrix for a completion status.

The open-source nouveau driver supports nVidia chipsets, but at the time of writing is not as complete as nVidia’s closed-source drivers, 3D support may not be satisfactory.

The OpenGL driver on Linux systems consists of two files:

  • libGL.so for the GL itself; libGL.so must be accessible to the Linux library loader (refer to man pages for ldconfig);
  • glx.so (this name may vary) for Xorg support for OpenGL; glx.so will be in Xorg’s extensions path and must be loaded by xorg.conf (refer to man pages for xorg.conf).
Читайте также:  User account control windows 10 что это

Many OpenGL applications require libGLU.so as well; GLU operations are not hardware-accelerated, so the implementation provided by Mesa is an excellent option.

Check your OpenGL installation [ edit | edit source ]

Type this in a terminal to get much info about your OpenGL driver, including supported extensions:

IDEs [ edit | edit source ]

The tutorials will mostly rely on simple Makefile s to build the code, and let you edit the source with your favorite text editor, such as Emacs, vim, gedit, kwrite, etc.

Several IDEs exist for GNU/Linux, such as:

  • Code::Blocks
  • Anjuta
  • KDevelop
  • Eclipse CDT (can interface with Make)

It is very simple to adapt the Makefiles to these environments.

Источник

OpenGL программирование/Установка/Linux

Содержание

Установка OpenGL на Linux [ править ]

Большинство дистрибутивов Linux опираются на Mesa3D проект что бы обеспечить реализацию OpenGL. Они регулярно поставляют OpenGL библиотеки, а так же OpenGL ES 1.x и 2.0.

Точные имена пакетов необходимых для установки сильно зависят от дистрибутива. Ссылаясь на пакеты вашего дистрибутива, вы можете спасти себя от траты времени и головной боли в установке. Используйте ваш любимый менеджер пакетов и поиск по названию пакета. Вам, возможно, потребуется установить пакеты, с DEV суффиксом, это пакеты разработки (обычно файлы заголовков). Также смотрите в пакетах с lib-префиксом, которые относятся к библиотекам.

Установите GCC C/C++ компиляторы и связанные с ними инструменты, такие как make.

В общем, установите следущее:

Библиотеки [ править ]

В этом Викиучебнике, мы будем использовать GLEW, FreeGLUT и GLM, убедитесь, что вы установите библиотеки разработчика (примечание переводчика dev библиотеки):

Если GLM не доступен в вашем репозитории, у вас есть возможность установить его вручную. Убедитесь, что заголовки размещены в каталоге /usr/include/glm . Так как это только заголовки библиотеки, вам не нужно компилировать .so библиотеки — просто скопируйте код.

Драйверы [ править ]

OpenGL является основным API 3D-графики в GNU/Linux-based системах. Если ваше устройство поддерживает 3D ускорение на GNU/Linux, оно, вероятно, включает в себя OpenGL.

OpenGL включается в драйверах, так что вы должны убедиться, что драйверы были установлены корректно, если вы хотите запускать программы с использованием OpenGL. Драйверы с открытым исходным кодом, на самом деле, используют реализацию Mesa в OpenGL. Фирменные драйверы поставляют собственную библиотеку OpenGL.

Фирменные варианты [ править ]

Компания Nvidia обеспечивает в целом хороший, но не свободный драйвер nvidia. fglrx драйвер для многих современных устройств AMD; он также имеет закрытый исходный код и доступен на сайте AMD.

Свободные/Open-Source варианты. [ править ]

Если ваш процессор Intel с встроенной графикой, то необходимые драйверы с открытым исходным кодом поставляются в качестве стандартной части ядра Linux.

Если у вас установлен один из новейших чипов, вам возможно придётся использовать посредственный fglrx драйвер. Однако AMD выпустила спецификации для своих чипов, ‘Radeon’ с открытым исходным кодом сделал свой путь, для того чтобы стать полнофункциональным 2D и 3D драйвером.

По состоянию на июнь 2013 года, большинство чипов AMD хорошо работают с исходным драйвером «Radeon». 3D производительность с драйвером AMD Catalyst на современных картах еще лучше, но это может измениться в будущем. Можете проверить таблицу характеристик.

Nouveau драйвер с открытым исходным кодом поддерживает чипсеты NVIDIA, но в момент написания не так полон, как драйвера с закрытым исходным кодом от NVIDIA, поддержка 3D может быть не удовлетворительна.

Драйвер OpenGL на Linux-системах состоит из двух файлов:

А так же многие OpenGL приложения требуют libGLU.so; Операции GLU не могут быть аппаратно ускоренны, поэтому реализация Mesa является отличным вариантом.

Проверьте ваши сведения о OpenGL [ править ]

Введите это в терминале, чтобы получить больше информации о вашем OpenGL драйвере, включая поддерживаемые расширения:

IDEs [ править ]

The tutorials will mostly rely on simple Makefile s to build the code, and let you edit the source with your favorite text editor, such as Emacs, vim, gedit, kwrite, etc.

Существует несколько IDE для GNU/Linux, такие как:

Очень просто преспособить Мейкфайлы к этим системам.

Installing your own OpenGL headers [ править ]

In the unlikely event that your distribution does not supply packages for Mesa3D, you can build it from source with the usual

Читайте также:  Ламповый плеер для windows

installation procedure; however, be careful of conflicting opengl libraries.

Mesa’s software implementation may override your distribution’s libraries or libraries manually installed, such as the nvidia or fglrx OpenGL binaries. When this happens, search all directories listed with

for libGL.so. The following command should output all the different OpenGL libraries available on your system:

It is usually OK if you have one the mesa library plus the proprietary library. On 64-bits systems, you may also have the lib32 library. Additional copies of libGL.so found in the ld search path (specified in /etc/lf.so.conf by default), if not referring to the same file, usually indicates a conflict. Remove all but the copy you want executed.

The headers will be installed to $PREFIX/include/GL (usually /usr/include/GL when installed from a packaged, or /usr/local/include/GL when installed manually from source).

«Official» OpenGL headers are available from SGI, however, they are hopelessly out of date.

Источник

A Beginner’s Guide to Setup OpenGL in Linux (Debian)

Step-by-step guide for setting up OpenGL in Ubuntu along with the installation of required libraries: GLFW and GLAD.

So you wanna get started with OpenGL in Linux, but couldn’t find enough resources on the net to set it up? Don’t worry, I got you covered!
This article would provide simple instructions for setting up OpenGL environment in Ubuntu and other Debian-based Linux Distributions without using VS Code. We’ll also be installing the required libraries GLFW and GLAD.

For a tutorial on how to use OpenGL, I’d recommend this website which teaches it from the very basics using easy-to-understand examples. If you prefer video tutorials, you might want to check this out.

Introduction

OpenGL is a cross-platform, cross-language API that provides us with a large set of functions that we may use to render 2D and 3D vector graphics. The API is typically used to interact with the GPU, to achieve hardware-accelerated rendering.

However, OpenGL by itself is not an API, but merely a specification. It is just a description of what exactly the result/output of each function should be and how it should perform. It is already implemented inside your driver, by manufacturers, following the specification. Hence, there is no such thing as “installing” OpenGL. But, we do need to install libraries, that would help us interact with the operating system to access the implementation and set up the windowing system & OpenGL context.

OpenGL Setup: Installing dependencies

Before installing the required libraries, we’ll first have to install a few dependencies. So open your terminal and run the following commands:

OpenGL Setup: GLFW Library

Before you start with creating stunning graphics, you need to initialize an OpenGL context and create an application window to draw in. We’ll do this using a popular C library: GLFW(Graphics Library Framework). This library also helps us handle the input from the joystick, keyboard, and mouse.

Running the below commands would install GLFW in your system:

OpenGL Setup: GLAD Library

As we know, OpenGL is only really a specification that is implemented insider of the driver that your graphics card supports. Since there are many different versions of OpenGL drivers, the location of most of its functions is not known at compile-time and needs to be queried at run-time. Now it’s a cumbersome process to retrieve the location of the function and load that in function pointers, for each function we need. Thankfully, there’s a library that can save us the hassle: GLAD.

GLAD (Multi-language Loader Generator) is an open-source library that uses a web service where we can tell GLAD for which version of OpenGL we’d like to define and load all relevant OpenGL functions according to that version.

So to install this library, perform the following steps:

Источник

Оцените статью