Learning OpenGL in Ubuntu
The first thing to do is install the OpenGL libraries. I recommend:
freeglut3
freeglut3-dev
libglew1.5
libglew1.5-dev
libglu1-mesa
libglu1-mesa-dev
libgl1-mesa-glx
libgl1-mesa-dev
Once you have them installed, link to them when you compile:
g++ -lglut -lGL -lGLU -lGLEW example.cpp -o example
In example.cpp, include the OpenGL libraries like so:
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
Then, to enable the more advanced opengl options like shaders, place this after your glutCreateWindow Call:
GLenum err = glewInit();
if (GLEW_OK != err)
{
fprintf(stderr, "Error %s\n", glewGetErrorString(err));
exit(1);
}
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
if (GLEW_ARB_vertex_program)
fprintf(stdout, "Status: ARB vertex programs available.\n");
if (glewGetExtension("GL_ARB_fragment_program"))
fprintf(stdout, "Status: ARB fragment programs available.\n");
if (glewIsSupported("GL_VERSION_1_4 GL_ARB_point_sprite"))
fprintf(stdout, "Status: ARB point sprites available.\n");
That should enable all OpenGL functionality, and if it doesn't, then it should tell you the problems.
Good OpenGL tutorial for Linux/Ubuntu?
OpenGL is the same in Linux, Windows and MacOSX, the difference is the windowing system. If you just want to get quickly into building multi-platform OpenGL applications, take a look at GLUT (open-source alternatives, Ubuntu comes with freeglut). GLUT is source-compatible between operating systems, so you can compile the same code, without modifications (theoretically), in Windows and Linux.
If you need something more elaborate, you should start using either GTK+ or Qt to build your application GUI. GTK+ has a GtkGLExt extension that creates a widget that contains a OpenGL context you can draw. Qt comes with the QtOpenGL module, which provides the QGLWidget widget.
How do you compile an OpenGL program on Ubuntu?
you may have to install libxmu-dev
try:
sudo apt-get install libxmu-dev libxmu6
How to develop OpenGL ES (GLES) 2.0 applications on Linux?
Update:
You can (still) use PowerVR SDK and now it supports Vulkan as well. Updated links:
- PowerVR SDK page: https://www.imgtec.com/developers/powervr-sdk-tools/powervr-sdk/
- Installers download page: https://www.imgtec.com/developers/powervr-sdk-tools/installers/
- Github repo: https://github.com/powervr-graphics/Native_SDK
At the time of my original answer, PowerVR SDK was the most complete solution (Mesa gained full OpenGL ES 2.0 support with its 3.1 release according to its Wikipedia page).
Now, Mesa and Mali SDK can also be a choice. For detailed info on those, please refer to this detailed answer by Ciro Santilli 冠状病毒审查六四事件法轮功
Original Answer:
You can use POWERVR SDK to emulate Opengl es on your PC. You can download the SDK here. The archive provides the necessary steps to install the emulation libraries as a documentation file and includes tutorials and demo applications with source codes.
Setting up OpenGL on Ubuntu
To setup OpenGL and SDL you should open the terminal and issue the command:
sudo apt-get update && sudo apt-get install libgl sdl
This will install the basic libraries you need to run OGL/SDL applications, after entering the root password.
I suggest you to google for synaptic and learn how to use it.
Linux is always a good place to develop something.
Starting to learn OpenGL. On modern Linux, how are all these concepts related?
OpenGL is an interface. To use it, you need an implementation. There are many implementations of OpenGL. Because each implementation is different, your program will behave differently when you run it with different implementations, even though your program is the same. A typical OpenGL implementation with a hardware renderer will consist of some code that runs in user space (a dynamic library), code that runs in the kernel (the device driver), code that runs in your X.org server (the DDX driver), and code that runs on the graphics card itself (the firmware). That's four different pieces of code!
AMD and nVidia provide proprietary OpenGL implementations for Linux. These implementations have closed-source drivers which taint the kernel, which means that if something goes wrong, the Linux developers can't help you. They support recent OpenGL versions (e.g. 4.5, if your hardware is capable) with the full compatibility profile support.
Mesa provides an open-source OpenGL implementation for Linux. This implementation can use the Noveau or Radeon open-source drivers, which do not taint the kernel. Mesa also has a software implementation, called llvmpipe, which runs on your CPU only and doesn't need drivers. It's impressively fast for what it is, but it is much slower than even an outdated hardware implementation. Mesa recently started supporting OpenGL 4.x series, but it will take some time before it filters through distro release cycles, so you're more likely to see OpenGL 3.3--and that's only for the core profile, you're limited to 3.0 with the compatibility profile (similar to how it works on OS X).
Because Mesa developers have limited access to documentation about the graphics cards, and limited development resources, the Mesa implementation on your AMD or nVidia card is usually slower than the vendor's implementation, and it usually supports fewer OpenGL extensions. However, the Mesa implementation is very solid, it doesn't taint your kernel, and some of the Mesa implementations are even Valgrind-clean.
Installing OpenGL just means installing an OpenGL implementation on your system (you know, with dnf
or apt
or whatever). This usually means a choice between the vendor implementation and the Mesa implementation... except for Intel integrated graphics, where Mesa is the vendor implementation.
Related Topics
Vs: Unexpected Optimization Behavior with _Bitscanreverse64 Intrinsic
Combining Two Lists by Key Using Thrust
Convert Hexadecimal String with Leading "0X" to Signed Short in C++
Why Do C++ Template Definitions Need to Be in the Header
C++ CSV Line with Commas and Strings Within Double Quotes
Enum Class Constructor C++ , How to Pass Specific Value
Capture _Line_ and _File_ Without #Define
What Happen to Pointers When Vectors Need More Memory and Realocate Memory
Breaking Out from Socket Select
How to Pass a Vector to Execvp
Why Isn't Memcpy Guaranteed to Be Safe for Non-Pod Types
Why Do I Need to Repeat Template Arguments of My Base Class in Member Initalizer List
Error Lnk2019 Unresolved External Symbol
What Are Consequences of Forcing Qobject as a Parent of Qwidget
How Would One Call Std::Forward on All Arguments in a Variadic Function