Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Using OpenGL for Image Processing - Setting up an OpenGL context

You don't have to use a GLSurfaceView. GLSurfaceView is a convenience class written purely in Java. It simplifies the setup part for applications that want to use OpenGL rendering in Android, but all of its functionality is also available through lower level interfaces in the Android frameworks.

For purely offscreen rendering, you can use the EGL interfaces to create contexts, surfaces, etc. Somewhat confusingly, there are two versions in completely different parts of the Android frameworks:

  • EGL10 and EGL11 in the javax.microedition.khronos.egl package, available since API level 1.
  • EGL14 in the android.opengl package, available since API level 17.

They are fairly similar, but the newer EGL14 obviously has some more features. If you're targeting at least API level 17, I would go with the newer version.

Using the methods in the EGL14 class, you can then create contexts, surfaces, etc. For offscreen rendering, one option is to create a Pbuffer surface for rendering. To complete the setup, you will typically use functions like:


The Android documentation does not really describe these functions, but you can find the actual documentation at the Khronos web site:

Categories : Android

Related to : Using OpenGL for Image Processing - Setting up an OpenGL context
Cannot rotate my image around it's center in openGL
Matrix-Operations and thus glTranslatef/glRotatef are applied in reversed order. So when your rotation center is c=(x,y), you have to translate along -c first, then rotate and then translate along c. In your case, you have to exchange the two translate lines to the following: glTranslatef(x, y, 0); //Translate back glRotatef(10, 0, 0, 1); //Rotate glTranslatef(-x, -y, 0); //Translate first along

Categories : C++
OpenGL + Qt using CMake
After fighting for days with this problem, I found out that it was the -O3 flag. Apparently, Qt is using -O3 -O2 and it is taking the last one, and for the final linking it is using -O1. I changed the flags to use -O2 and everything started to work as fast as it should be and using a normal amount of RAM.

Categories : C++
SpotLight is not seen - OpenGL
The order of a couple of members of the LightSourceProp struct in the C++ code is different from the one in the uniform block. Last two members of the uniform block: uniform float cutOffExponent; uniform float spotCutoff; }; Last two members of C++ struct: float spotlightCutoffAngle; float cutOffExponent; }; These two values are swapped. Also, the cutoff angle looks suspic

Categories : C++
Antialiasing in OpenGL ES 2.0?
A lot of devices support MSAA (Multi-Sample Anti-Aliasing). To take advantage of this feature, you have to choose a EGLConfig that has multisampling. On Android, if you use GLSurfaceView, you will have to implement your own EGLConfigChooser. You can then use EGL functions, particularly eglChooseConfig() to find a config you like. The following code is untested, but it should at least sketch how

Categories : Android
OpenGL restart scene
My approach might take some time on restructuring things, but it surely makes things really simple and convenient to deal with in the long run. You would have all your logic contained inside one object called Game. It is separated from the OpenGL code which is stored inside the Window. Every time you need to restart the game you simply destroy Game and create a band new Game object. class Windo

Categories : C++
Recently Add
Duplicate zip entry [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])
Android Opengl Vertex greater than 1
Not able to upload image from gallery in Android 4.4
Passing JSONObject to another activity via Intent
Fabric maven repo causes slow gradle builds
java.lang.NullPointerException - onModifiedTouchEvent
Black backgrounds are transparent on Lollipop until app is installed a second time
Android RecyclerView Removing Item - 2 Animation Issues
Disable hamburger to back arrow animation on Toolbar
Gradle 14.4 Fails to Build - Gradle DSL method not found 'packageName()'
Android setParameters failed
Android MultiDex - Questions on Inner Workings
Android camera crash, repeating images, native nav buttons messed up
Location Listener Can't Reach Location
onclick checkbox in listview
Multithreaded Server via Arduino
How to handle backstack referencing deleted items
How to make the overflow popup menu avoid obstructing the action bar?
How to disable screen rotation in Android?
why my application use all memory and get OutOfMemoryError: Failed to allocate?
Setting Toolbar using setSupportActionBar() when resuming a Fragment
Unable to get AppCompat ActionBar/Toolbar to become an overlay
'preferenceCategory' style background isn't working in Lollipop
Android, Expandable List View, Remove child from single entry
Button with getBackground().setAlpha on version 5 - lollipop isn't working correctly
Fill listview from array of objects
Move image across screen with variables calculated at runtime
Android Chrome table border issue
Android Unable to load '.so.1' file
cursor is deactivated prior to calling this method
© Copyright 2017 Publishing Limited. All rights reserved.