Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EGL+OpenGLES 3.0 examples #1945

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guangli0510
Copy link

Signed-off-by: Guangli Li guangli.li@intel.com

  • If you are adding a feature, please explain the context of the change: what do you need the feature for?
  • Try to attach screenshots to clarify the context and demonstrate the feature at a glance.
  • Make sure you create a branch for the pull request. In Git, 1 PR is associated to 1 branch. If you keep pushing to the same branch after you submitted the PR, your new commits will appear in the PR.
  • You can read CONTRIBUTING.md for more details.

(Clear this form before submitting your PR)

Signed-off-by: Guangli Li <guangli.li@intel.com>
@ocornut
Copy link
Owner

ocornut commented Jul 13, 2018

Hello @guangli0510. Thanks for your PR.

I don't quite understand the approach you used - you completely duplicated imgui_impl_opengl3.cpp and made no sensible change to it (the only change being a default GLSL version that can already be setup through the initialization parameter, and which you did setup in main.cpp). Therefore the entirely of the new imgui_impl_opengles3.cpp file is unnecessary.

More over, none of the description/commentary were updated.

It looks like the change should be:

  • update gl3w to be GL friendly
  • update the existing examples/example_glfw_opengl3 to support a define that would use GL ES 3 and remove all the code duplication
  • update comments/documentation
  • Is __EGL__ a standard define for the purpose of selecting GL ES? If there a possibly more standard define to use?

The good news is that the simplicity of this change suggests that the recent changes to support shader variations (applied in #1938) are indeed allowing GL ES 3 to work.

@guangli0510
Copy link
Author

guangli0510 commented Jul 16, 2018

Hello @ocornut ,
I only add an example of EGL and OpenGL ES. Because we are working on linux and want to communicate with android app. As it is known, android uses EGL+OpenGL ES, but I don't find any examples in imGUI folder, so I complete this usage and submit this to your git.

  1. EGL only defines to choose EGL and OpenGL ES, not just for OpenGL ES. In EGL version, it should use eglGetProcAddress to get proc address, not use glXGetProcAddress.
  2. I install egl and GLES library, and only find GLES version 100 is runnable for OpenGL ES3.0, so I change the GLSL version to 100.

The patch comment is as below:
diff:

+#ifdef __EGL__
+#include <stdio.h>
+#include <EGL/egl.h>  // this is for eglGetProcAddress
+#include <stdlib.h>
+#else
 #include <GL/glx.h>  //just use opengl API to get proc address.
+#endif
 
-static void *libgl;
+static void *libgl = NULL;
 
 static void open_libgl(void)
 {
-       libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
+#ifdef __EGL__   //use libGLESv2.so to get all the APIs proc
+       libgl = dlopen("libGLESv2.so", RTLD_LAZY | RTLD_GLOBAL);
+    if(NULL == libgl) {
+           fprintf(stderr, "open libGLESv2.so failed\n");
+    }
+#else  //default
+    libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
+    if(NULL == libgl) {
+        fprintf(stderr, "open libGL.so failed\n");
+    }
+#endif
 }


-       void *res;
-       res = (void*)glXGetProcAddress((const GLubyte *) proc);
+       void *res = NULL;
+#ifdef __EGL__  // use eglGetProcAddress  to get API proc
+       res = eglGetProcAddress(proc);
+#else
+    res = (void*)glXGetProcAddress((const GLubyte *) proc);
+#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants