How To Use Opengl In Windows
OpenGL ES is an embedded version of OpenGL generally used on mobile devices that offer only limited GPU capabilities compared to modern desktop GPUS.
Introduction
Thanks to android, OpenGL ES is very widespread, and equally WebGL is also based on OpenGL ES (ii.0), chances are pretty high you'll get into contact with OpenGL ES at some point during your 3D development efforts.
And at some point you may want to prototype your OpenGL ES applications on a desktop system (windows, linux, mac), or merely distribute a desktop version of your mobile game using OpenGL ES.
Depending on the vendor of your desktop GPU, the way you access OpenGL on your desktop organization differ though. While NVIDIA and INTEL expose OpenGL ES functionality via OpenGL using extensions ([1] [2] [3] [iv]) similar to the ones for OpenGL core and compatibility contests, the state of affairs for AMD (ATI) is very dissimilar, and that'south what this article is about.
Information technology's a starting point for getting OpenGL ES upward and running with AMD GPUs on windows (adopting to linux should exist pretty like shooting fish in a barrel). If you're on NVIDIA or INTEL, you can but use a current glfw version and asking an OpenGL ES context and you're ready.
AMD doesn't expose OpenGL ES on desktops via OpenGL extensions (so you won't find these on any AMD device), but goes the same route as Android devices and exposes OpenGL ES via EGL.
EGL is a native platform interface that connects the windowing systems to ane of Khronos' APIs, e.1000. OpenGL ES.
So earlier getting to OpenGL ES on eastward.m. windows with AMD, yous first have to setup EGL and an EGL render context using OpenGL ES as the client API.
Setup
Earlier y'all can start using EGL on your desktop organisation, you need to get library files and binaries.
You tin go them from :
- PowerVR SDK
- AMD OpenGL ES SDK
- Bending
While the PowerVR SDK is the biggest download, information technology supports the widest range of OpenGL ES versions and operating systems. If you just want to do OpenGL ES 2 on windows, go and take hold of the AMD one. ANGLE is the OpenGL ES backend used in Google's chrome and wraps the OpenGL ES calls (for WebGL) to DirectX.
You also demand the EGL and OpenGL ES headers, which should exist included in the SDK. The latest version can ever be obtained via the Khronos API registry for EGL and OpenGL ES.
If y'all include the headers for EGL and OpenGL ES and tell the linker where to find the libraries, it'south time for some code.
You can detect the whole C++ demo over at my github repository.
The EGL human being pages tin can be accessed hither.
Step 1 - Connecting to the "brandish"
The term display may sound a fleck odd at outset if you're used to Windows, and more than familiar if you're coming from Linux.
A display, in EGL terms, on Windows is just a normal HDC. So just go a device context from your window (or control you want to paint on) and connect it to the EGL display :
| |
Step ii - Bounden to the API
Now that we've got a valid EGL display, nosotros demand to select the client API nosotros desire to utilize. EGL supports OpenGL, OpenGL ES and OpenGL VG. Notation that not all customer APIs may be available on your device. We're going to use OpenGL ES, the version will be selected later on on :
| |
Step three - Selecting a valid config
Like to finding a suitable pixel format for context creating in OpenGL, nosotros demand to notice a valid EGL configuration that supports our requested client API and fits our clarification :
| |
We'll be requesting a pretty basic config with 5 bits for cherry, 6 for green and 5 for blue and 24 bits of depths. Annotation the "EGL_RENDERABLE_TYPE" containing the OpenGL ES two bit nosotros're going to asking a config for. Since OpenGL ES 3 is using the same base as OpenGL ES 2, while OpenGL ES and OpenGL ES 2 greatly differ, you'd use EGL_OPENGL_ES2_BIT fifty-fifty if y'all want to employ OpenGL ES 3.
Values for attributes marked with EGL_DONT_CARE will exist decided by the commuter :
| |
Stride iv - Create a window surface
Once nosotros've got a valid configuration we can create a window surface that'll be used for rendering :
| |
We don't pass any special surface attributes (for more information see here), as nigh of them refer to OpenVG, so the default volition e used, an EGL (back) return buffer.
Step 5 - Create a rendering context
Getting back to OpenGL terminology, we're now gear up to create our OpenGL ES render context, which is also the point at which you can specify the OpenGL ES version you lot want to utilise :
| |
The EGL_CONTEXT_CLIENT_VERSION is (as of at present) the simply valid context creating attribute and determines the OpenGL ES version y'all desire to employ.
Stride half dozen - Render something :)
We're at present ready to put something onto the screen. We simply need to make our EGL context current :
| |
And your adjacent lines can look like this :
| |
Closing words
Using EGL for accessing OpenGL ES on your AMD (ATI) desktop GPU isn't that hard, only since there isn't much data available on the net, probably because the other IHVs get in a bit easer, and the examples from the AMD SDK didn't work for me I decided to wrap my experiences into this pocket-size article.
Source: https://www.saschawillems.de/blog/2015/04/19/using-opengl-es-on-windows-desktops-via-egl/
Posted by: carleyhather.blogspot.com

0 Response to "How To Use Opengl In Windows"
Post a Comment