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.
Programming in Opengl-es 2.0 in ubuntu 10.10
I think you can use the following threads as a starting point:
Recommended practice environment for OpenGL ES 2.0?
Create an OpenGL ES 2.0 context on a "standard" Linux system
I use SDL 1.3 with the PVRSDK. You could also use the Mesa OpenGL ES wrapper libraries from the software repositories.
And in OpenGL 4.1 there also is the GL_ARB_es2_compatibility
extension which should allow you to use the OpenGL ES functionality without the extra libraries.
I prefer to test with the PVRSDK though since that is the one that my Android device uses.
Create an OpenGL ES 2.0 context on a standard Linux system
You don't need a GL ES 2.0 context on PC, you can use OpenGL 4.1, which has the GL_ARB_es2_compatibility
, which adds the OpenGL ES functions that weren't in OpenGL, making them API compatible.
Any GLES examples, in C++, on x86 Linux?
Mesa demos!
- http://cgit.freedesktop.org/mesa/demos
- http://cgit.freedesktop.org/mesa/demos/tree/src/egl/opengles2
- http://cgit.freedesktop.org/mesa/demos/tree/src/egl/opengles2/es2tri.c
How to write opengl ES 2.0/3.0 in Common Lisp?
GL_INVALID_ENUM
probably means you passed the wrong constant somewhere, and it says this happened in DRAW-ARRAYS
. I haven't used cl-opengl or Common Lisp before, but glDrawArrays' first parameter should be the type of primitive (both in GL and GL ES), e.g. GL_TRIANGLES
. If cl-opengl is a 1:1 mapping to the GL API, then I assume your (gl:draw-arrays vertex-buffer 0 3)
line is wrong, and should be something more like (gl:draw-arrays gl:triangles 0 3)
?
Also (gl:vertex-attrib-pointer attribute-coord2d 2 :float :false 0 vertex-buffer)
is suspicious to me. I think that last parameter should be 0. It's notionally a pointer, but in modern OpenGL and OpenGL ES (when you're using an array buffer like you are) it's actually an offset into the buffer.
How to create a window and fill it with color using OpenES 2.0 + X11?
Create Window:
Window root;
XSetWindowAttributes swa;
XSetWindowAttributes xattr;
Atom wm_state;
XWMHints hints;
XEvent xev;
EGLConfig ecfg;
EGLint num_config;
Window win;
/*
* X11 native display initialization
*/
x_display = XOpenDisplay(NULL);
if ( x_display == NULL )
{
return EGL_FALSE;
}
root = DefaultRootWindow(x_display);
swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;
win = XCreateWindow(
x_display, root,
0, 0, esContext->width, esContext->height, 0,
CopyFromParent, InputOutput,
CopyFromParent, CWEventMask,
&swa );
xattr.override_redirect = FALSE;
XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &xattr );
hints.input = TRUE;
hints.flags = InputHint;
XSetWMHints(x_display, win, &hints);
// make the window visible on the screen
XMapWindow (x_display, win);
XStoreName (x_display, win, title);
// get identifiers for the provided atom name strings
wm_state = XInternAtom (x_display, "_NET_WM_STATE", FALSE);
memset ( &xev, 0, sizeof(xev) );
xev.type = ClientMessage;
xev.xclient.window = win;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1;
xev.xclient.data.l[1] = FALSE;
XSendEvent (
x_display,
DefaultRootWindow ( x_display ),
FALSE,
SubstructureNotifyMask,
&xev );
Set color:
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
// Set the viewport
glViewport ( 0, 0, esContext->width, esContext->height );
// Clear the color buffer
glClear ( GL_COLOR_BUFFER_BIT );
Sources:
- https://github.com/danginsburg/opengles-book-samples/blob/master/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c
- https://github.com/danginsburg/opengles-book-samples/blob/master/LinuxX11/Common/esUtil.c
- https://github.com/danginsburg/opengles-book-samples/blob/master/LinuxX11/Common/esUtil.h
Opengl shader compatibility with opengl es 2.0
What was the reason for that?
Precision qualifiers are only supported in OpenGL ES, not in desktop OpenGL.
Can I still run this shader both on linux and android?
No (at least not directly), because of the reason explained above. You'll have to make two shaders. One for desktop OpenGL and one for OpenGL ES.
OpenGL ES 2.0
is not the same thing as OpenGL 2.0
.
See here for more information:
https://stackoverflow.com/a/10390965/1907004
Edit:
As pointed out by other people: You can use precision qualifiers in desktop OpenGL, but they will be ignored by the compiler. See here:
https://stackoverflow.com/a/20131165/1907004
For that to work, you need to specify a GLSL version for your shader using #version XXX
, which you seem to lack. Regardless of what you do, you should always specify the GLSL version of your shader.
Recommended practice environment for OpenGL ES 2.0?
If you register as a developer at the iOS Developer Center (free), you can download Xcode and the iOS SDK (again, for free when you get Xcode 3), which includes a simulator capable of OpenGL ES 2.0. This of course assumes you have a Mac to run that all on.
Once you have the SDK, you can simply start up Xcode and create a new application based on the OpenGL ES Application template. This application will be a fully functional OpenGL ES 1.1 and 2.0 iOS application that you can build and run in the simulator. You can ignore all of the iOS-specific setup code and focus on the -drawFrame
method in the xxxViewController.m
class, which is where the OpenGL ES 2.0 drawing code lies.
This can be a pretty quick environment to set up for playing with OpenGL ES 2.0 shaders. I've also tried out the PowerVR SDK package that trenki suggests, and it is a little more involved to get something set up with that. If you're on Windows, it will be a lot more viable of a solution than the Mac-based iOS SDK I describe here.
One other shader development tool that can come in handy for prototyping on the Mac is Quartz Composer. It comes along with Xcode, and provides a visual prototyping environment for all sorts of effects, including OpenGL shaders. I demonstrate an example of doing this kind of prototyping in an article I wrote here. Desktop GLSL and the implementation in OpenGL ES differs slightly, but much is the same between the two.
While targeted at iOS, I taught a class on OpenGL ES 2.0 recently as part of a course that can be downloaded from iTunes U for free. It might helpful in getting up to speed on shaders.
Related Topics
Redirecting Output to a File in C
How to Make a Bash Shell Script Interact with Another Command Line Program
How to Toggle Cr/Lf in Gnu Screen
How to Create a JSON Web Token (Jwt) Using Openssl Shell Commands
Linux Synchronization with Fifo Waiting Queue
How to Give Highest Priority to Ethernet Interrupt in Linux
Use Sed to Delete All Leading/Following Blank Spaces in a Text File
How to Change the Size of a Named Pipe on Linux
Can't Read Variable That Was Stored from Within a While Loop, When Out of the While Loop
Awk and Special Brackets Delimiters
Can't Get Private Key with Openssl (No Start Line:Pem_Lib.C:703:Expecting: Any Private Key)
How to Run the Cron Job as a User Instead of Root User
Add Blank Line After Every Result in Grep
Differencebetween Alpine Docker Image and Busybox Docker Image
Telnet to Login with Username and Password to Mail Server
Perf Stat Does Not Count Memory-Loads But Counts Memory-Stores
Any Porting Available of Backtrace for Uclibc
How to Respond to Prompts in a Linux Bash Script Automatically