How to create a texture from an EGLImage in desktop OpenGL? - opengl

For OpenGL ES the OES_EGL_image extension provides a function EGLImageTargetTexture2DOES to create a texture from an EGLImage. Is there an equivalent extension/function for desktop OpenGL (not ES)?

I think GL_OES_EGL_image should work with the Mesa drivers and desktop GL. glxinfo shows the extension as supported with both core and compatibility profiles. I did not see any checks for ES with a quick look at the implementation.
A grep through the Mesa provided GL headers shows no other occurrence of EGLImage, so GL_OES_EGL_image is probably your only choice with the Mesa drivers.
I am not sure though whether this behavior is specific to Mesa or other drivers also follow it.

Related

which opengl version runs on every device?

Using llvm you can write a Programm which runs on PC, Mobile and since WebAssembly even in your Webbrowser. But for an Example Android uses Opengl-ES. Is there any opengl version which can be used on each of these platforms?
There is no single version of OpenGL that runs everywhere, but OpenGL ES 2.0 is pretty close to the lowest common denominator.
WebGL 1.0 is very similar to OpenGL ES 2.0. WebGL 2.0 is a subset of OpenGL ES 3.0, with various restrictions which are required for security.
On desktop systems, there is usually a way to create an OpenGL ES 2.0-compatible context and use the exact same API as on Android. Regular desktop OpenGL has a few incompatibilities with OpenGL ES, see for example this page:
https://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences
Mobile devices almost universally support OpenGL ES 2.0, and most flagship phones support OpenGL ES 3.2. The current distribution of support for OpenGL ES on Android phones is at the bottom of this page: https://developer.android.com/about/dashboards/

Mesa 3D OpenGL 3.2 with software rasterizer

I'm trying to create an OpenGL context 3.2 on a Netbook running Ubuntu 13. Since the hardware isn't capable of hardware-supported Opengl 3.2, I'm wondering if the software rasterizer could provide such functionality.
I'm aware that software mode can be utterly slow, but I just need to test and practice some simple examples.
I couldn't find any definitive information on the Internet that would say it's possible or not, and my knowledge on Mesa is very limited. So my question is, is it possible to create a software-based OpenGL 3.2 context with Mesa or not?
Currently, it isn't. When using one of the software rasterizer backends (the old, deprecated swrast, or the more modern, gallium-based softpipe or llvmpipe drivers), only GL 2.1 will be advertised. The issue is that mesa's software rasterizers do not yet support multisampling, which is a requirement of GL 3.x. There might be also some other minor features missing which are required for GL 3.x.
However, you can still use most of the GL 3.2 features via the extension mechanism, without having a 3.2 context. This also means that you won't be able to get a core profile context, but this shouldn't be a problem either - nothing forces you to actually use the deprecated functionality.

Linux: use OpenGL 4.x

How I can use OpenGL without mesa? It's terrible - supports max. OpenGL 3.1.
I readed about loading openGL.so with dlopen but where is file to load, and how I can hang that?
Ah, I forgot, language is C++
Just linking to libGL.so is all that is necessary to use the hardware graphics driver.
If you have an NVIDIA or AMD graphics card and you have installed the nvidia or fglrx driver, you will get the maximum OpenGL version supported by your video card.
If you instead are using the open source nouveau, radeon, intel, or other graphics driver, Mesa will take over and you will have only the maximum version of OpenGL supported by Mesa (3.1) and the driver for your hardware. It will automatically use all hardware features it's capable of using.
You do not need to do any fancy dlopen tricks or anything else.
OpenGL is an open API to "standardize" the access to graphics pipeline. The graphics pipeline is supposed to be in a GPU! But this is not necessary! Mesa 3D is a an open-source implementation of the OpenGL specification that also contains a software implementation of a graphics pipeline (yes, software-based) that is supposed to deliver the same result of a regular GPU graphics pipeline (except for the speed, of course!).
You don't have to use MESA if you have GPU! In order to try OpenGL, I suggest you to read some basic tutorial of OpenGL:
http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html
http://www.opengl-tutorial.org/
dlopen() is used to load dynamic libraries. If you use helpers like GLFW or GLUT you don't need to care about those details.

How is Mesa different from OpenGL drivers?

What exactly does it mean to say that Mesa is an implementation of OpenGL? Don't the drivers of my Nvidia card implement all the OpenGL functions, etc.? So given that the drivers of my Nvidia card are taking Opengl calls and handing them off to the hardware, what exactly does Mesa do? Can someone clarify the distinction between Mesa and drivers?
Can someone clarify the distinction between Mesa and drivers?
Mesa provides the client side OpenGL interface for the open source GPU drivers based on the DRI2/DRM architecture. Or in other words: It's also a part of a driver.
If you've got the proprietary drivers from NVidia or AMD installed you don't need Mesa. If you want to use the open source drivers (nouveau, radeon, radeonhd, intel) you need Mesa.
I believe LinuxQuestions.org forum member geeman2.0 provided a good explanation for this matter:
OpenGL and Mesa aren't really two separate choices, but rather Mesa is a specific type of OpenGL.
OpenGL is simply an interface that defines a standard set of functions needed for drawing 3d graphics. It doesn't involve the actual code that makes these functions happen, it only specifies what the functions are called and what they are supposed to do.
An openGL implementation provides the actual code that runs the methods specified by the OpenGL standard. Without an implementation installed, you cannot run any opengl programs.
Mesa is just one of many OpenGL implementations, and is the most standard one included in linux distributions. It does all the work in software, which is why it is slow.
When you install Nvidia or ATI drivers for a fancy graphics card, these drivers provide a new OpenGL implementation that runs on the graphics card. This implementation would take the place of the Mesa implementation, but it is still an openGL implementation. That is, all of Mesa/ATI/NVidia drivers implement the same set of functions, they just do it in different ways, and they are all openGL.
Source
What exactly does it mean to say that Mesa is an implementation of
OpenGL?
First of all, OpenGL is an API Specification created between Khronos and the videocard manufacturer (Nvidia, ATI, Intel, etc), it's like an agreement on what functions the hardware is capable of.
Mesa is a software library for 3D computer graphics that provides a generic Khronos-compliant OpenGL implementation for rendering three-dimensional graphics on multiple platforms. So, for example, if you are running Linux you will probably have to install Mesa in order to generate any kind of graphics. For Microsoft Windows there is already an implementation installed.
Don't the drivers of my Nvidia card implement all the OpenGL
functions, etc.?
Yes, your Nvidia card driver implements OpenGL functions.
So given that the drivers of my Nvidia card are taking Opengl calls
and handing them off to the hardware, what exactly does Mesa do?
Your program communicates to Mesa, Mesa to your video card's driver, the driver to the actual GPU, the GPU sends the signal to the monitor for you to finally watch the drawing.

How do I know which version of OpenGL I am using?

I started writing programs, in C (for now) using GLFW and OpenGL. The question I have is that, how do I know which version of OpenGL my program will use? My laptop says that my video card has OpenGL 3.3. Typing "glxinfo | grep -i opengl" returns:
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 9600M GT/PCI/SSE2
OpenGL version string: 3.3.0 NVIDIA 285.05.09
OpenGL shading language version string: 3.30 NVIDIA via Cg compiler
OpenGL extensions:
So is OpenGL 3.3 automatically being used ?
Just call glGetString(GL_VERSION) (once the context is initialized, of course) and put out the result (which is actually the same that glxinfo does, I suppose):
printf("%s\n", glGetString(GL_VERSION));
Your program should automatically use the highest possible version your hardware and driver support, which in your case seems to be 3.3. But for creating a core-profile context for OpenGL 3+ (one where deprecated functionality has been completely removed) you have to take special measures. But since version 2.7 GLFW has means for doing this, using the glfwOpenWindowHint function. But if you don't want to explicitly disallow deprecated functionality, you can just use the context given to you by the default context creation functions of GLFW, which will as said support the highest possible version for your hardware and drivers.
But also keep in mind that for using OpenGL functionality higher than version 1.1 you need to retrieve the corresponding function pointers or use a library that handles this for you, like GLEW.