May 20, 2011 Replies: 90 Android 2.2 and later support OpenGL 2.0 ES as well as OpenGL 1.0 ES. Having produced an OpenGL library for 1.0 I thought I may as well do one for 2.0 as well so here it is! The included "demo" is not really a demo at all and does little more than test the device OpenGL capability and initialise a drawing surface. It needs someone more interested in graphics than I to take it further. Note that the demo needs my Threading library. EDIT:- Version 1.1 posted. See post #12 for details. EDIT:- Version 1.2 posted. See post #16 for details. EDIT:- Version 1.3 posted. See post #35 for details. EDIT:- Version 1.4 posted. See post #61 for details. EDIT:- Version 1.5 posted. See post #83 for details. User @walterf25 has added two methods to the the library to create version 1.5. The new jar and xml are posted below in OpenGL2_v1.5_lib.zip. I have left version 1.4 as the zip for that contains a somewhat trivial demo program. Just use the new v1.5 libs and ignore the v1.4 ones. Attachments OpenGL2_1.4.zip OpenGL2_1.4.zip 43.7 KB · Views: 2,046 OpenGL2_v1.5_lib.zip OpenGL2_v1.5_lib.zip 38.2 KB · Views: 1,254 Last edited: Sep 29, 2019 Click to expand...
Android 2.2 and later support OpenGL 2.0 ES as well as OpenGL 1.0 ES. Having produced an OpenGL library for 1.0 I thought I may as well do one for 2.0 as well so here it is! The included "demo" is not really a demo at all and does little more than test the device OpenGL capability and initialise a drawing surface. It needs someone more interested in graphics than I to take it further. Note that the demo needs my Threading library. EDIT:- Version 1.1 posted. See post #12 for details. EDIT:- Version 1.2 posted. See post #16 for details. EDIT:- Version 1.3 posted. See post #35 for details. EDIT:- Version 1.4 posted. See post #61 for details. EDIT:- Version 1.5 posted. See post #83 for details. User @walterf25 has added two methods to the the library to create version 1.5. The new jar and xml are posted below in OpenGL2_v1.5_lib.zip. I have left version 1.4 as the zip for that contains a somewhat trivial demo program. Just use the new v1.5 libs and ignore the v1.4 ones.
G GDO Member Licensed User Longtime User Mar 8, 2013 #21 Hello, I don't know what is wrong but gl.Version always return 1.2 and all functions needed by opengl es 2 (1.5 , I suppose) are logged like that : called unimplemented OpenGL ES API My AVD is 4.1 and android.jar is from android-17 What can I do ?
Hello, I don't know what is wrong but gl.Version always return 1.2 and all functions needed by opengl es 2 (1.5 , I suppose) are logged like that : called unimplemented OpenGL ES API My AVD is 4.1 and android.jar is from android-17 What can I do ?
agraham Expert Licensed User Longtime User Mar 8, 2013 #22 The Version property is the library version number and not the OpenGL version. The next version will be 1.3. What functions give that error and what is the exact error message?
The Version property is the library version number and not the OpenGL version. The next version will be 1.3. What functions give that error and what is the exact error message?
G GDO Member Licensed User Longtime User Mar 8, 2013 #23 Many ... gl.glGenBuffers gl.glBindBuffer gl.glBufferDataF and all the functions with shader (glCreateShader, glShaderSource, etc ...)
Many ... gl.glGenBuffers gl.glBindBuffer gl.glBufferDataF and all the functions with shader (glCreateShader, glShaderSource, etc ...)
G GDO Member Licensed User Longtime User Mar 8, 2013 #24 In the documention there is GL1 : Events: Click LongClick Draw(gl As GL1) 'The view wants to be drawn using the supplied GL10 SurfaceChanged(gl As GL1, width As Int, height As Int) 'Called when the surface has changed size. SurfaceCreated(gl As GL1) 'Called when the surface is created or recreated. Is it an error in the documentation or in the code?
In the documention there is GL1 : Events: Click LongClick Draw(gl As GL1) 'The view wants to be drawn using the supplied GL10 SurfaceChanged(gl As GL1, width As Int, height As Int) 'Called when the surface has changed size. SurfaceCreated(gl As GL1) 'Called when the surface is created or recreated. Is it an error in the documentation or in the code?
agraham Expert Licensed User Longtime User Mar 8, 2013 #25 Are you using the emulator or a real device? Apparently the emulator doesn't support OpenGL and give that error.
Are you using the emulator or a real device? Apparently the emulator doesn't support OpenGL and give that error.
G GDO Member Licensed User Longtime User Mar 8, 2013 #26 Emulator AND real device (Galaxy Note Version 4.0.4)
agraham Expert Licensed User Longtime User Mar 8, 2013 #27 GDO said: Is it an error in the documentation or in the code? Click to expand... If you mean "gl As GL1" then it is a documentation error. It should be "gl As GL2".
GDO said: Is it an error in the documentation or in the code? Click to expand... If you mean "gl As GL1" then it is a documentation error. It should be "gl As GL2".
agraham Expert Licensed User Longtime User Mar 8, 2013 #28 You can try putting this in your manifest that should check at runtime if OpenGL 2 is present. <uses-feature android:glEsVersion="0x00020000" android:required="true" /> Click to expand... Can your post your project (File -> Export as Zip) and I will see if I can see anything in the logs when it fails. However if some of the functions succeed but others fail I presently have no idea what the problem could be.
You can try putting this in your manifest that should check at runtime if OpenGL 2 is present. <uses-feature android:glEsVersion="0x00020000" android:required="true" /> Click to expand... Can your post your project (File -> Export as Zip) and I will see if I can see anything in the logs when it fails. However if some of the functions succeed but others fail I presently have no idea what the problem could be.
G GDO Member Licensed User Longtime User Mar 8, 2013 #29 Hi, I had already changed the manifest and it was not ok with the emulator. I tried with the real device and it is not ok. I changed my program (little program) to add more log("...") and now it is clear that the only functions that are OK are defined inside your libraries opengl 2 AND opengl 1. The functions that are only defined in the opengl 2 library are not working. I think the EGL_CONTEXT is not initialized for opengl 2 but for opengl 1 but I don't know why. Thanks Log : ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** mCBPickerDialog enter case. MSG_DISMISS_DIALOG Hide Clipboard dialog at Starting input: finished by someone else... ! mCBPickerDialog enter case. MSG_DISMISS_DIALOG id=290 Removed main idx=4 Map Size=5 id=291(2) createSurface 0x32944 (800x1280),1 flag=0, main id=290 Removed main idx=-2 Map Size=6 id=292(3) createSurface 0x44efc (800x1134),1 flag=0, SurfaceView loaded /system/lib/egl/libEGL_mali.so loaded /system/lib/egl/libGLESv1_CM_mali.so loaded /system/lib/egl/libGLESv2_mali.so Device driver API match Device driver API version: 10 User space API version: 10 mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Fri May 4 10:32:42 KST 2012 Displayed shortComponentName: +310ms Hide Clipboard dialog at Starting input: finished by someone else... ! mCBPickerDialog enter case. MSG_DISMISS_DIALOG Created Create Triangle glGenBuffers glBindBuffer glBufferDataF glBindBuffer Shader glCreateProgram called unimplemented OpenGL ES API glCreateShader called unimplemented OpenGL ES API glShaderSource called unimplemented OpenGL ES API glCompileShader called unimplemented OpenGL ES API glCompileShader called unimplemented OpenGL ES API glAttachShader called unimplemented OpenGL ES API glBindAttribLocation called unimplemented OpenGL ES API glLinkProgram called unimplemented OpenGL ES API Changed Clear UseProgram called unimplemented OpenGL ES API BindBuffer VertexAttribPointer called unimplemented OpenGL ES API EnableVertexAttribArray called unimplemented OpenGL ES API VertexAttrib3f called unimplemented OpenGL ES API DrawArrays DisableVertexAttribArray called unimplemented OpenGL ES API BindBuffer UseProgram called unimplemented OpenGL ES API
Hi, I had already changed the manifest and it was not ok with the emulator. I tried with the real device and it is not ok. I changed my program (little program) to add more log("...") and now it is clear that the only functions that are OK are defined inside your libraries opengl 2 AND opengl 1. The functions that are only defined in the opengl 2 library are not working. I think the EGL_CONTEXT is not initialized for opengl 2 but for opengl 1 but I don't know why. Thanks Log : ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** mCBPickerDialog enter case. MSG_DISMISS_DIALOG Hide Clipboard dialog at Starting input: finished by someone else... ! mCBPickerDialog enter case. MSG_DISMISS_DIALOG id=290 Removed main idx=4 Map Size=5 id=291(2) createSurface 0x32944 (800x1280),1 flag=0, main id=290 Removed main idx=-2 Map Size=6 id=292(3) createSurface 0x44efc (800x1134),1 flag=0, SurfaceView loaded /system/lib/egl/libEGL_mali.so loaded /system/lib/egl/libGLESv1_CM_mali.so loaded /system/lib/egl/libGLESv2_mali.so Device driver API match Device driver API version: 10 User space API version: 10 mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Fri May 4 10:32:42 KST 2012 Displayed shortComponentName: +310ms Hide Clipboard dialog at Starting input: finished by someone else... ! mCBPickerDialog enter case. MSG_DISMISS_DIALOG Created Create Triangle glGenBuffers glBindBuffer glBufferDataF glBindBuffer Shader glCreateProgram called unimplemented OpenGL ES API glCreateShader called unimplemented OpenGL ES API glShaderSource called unimplemented OpenGL ES API glCompileShader called unimplemented OpenGL ES API glCompileShader called unimplemented OpenGL ES API glAttachShader called unimplemented OpenGL ES API glBindAttribLocation called unimplemented OpenGL ES API glLinkProgram called unimplemented OpenGL ES API Changed Clear UseProgram called unimplemented OpenGL ES API BindBuffer VertexAttribPointer called unimplemented OpenGL ES API EnableVertexAttribArray called unimplemented OpenGL ES API VertexAttrib3f called unimplemented OpenGL ES API DrawArrays DisableVertexAttribArray called unimplemented OpenGL ES API BindBuffer UseProgram called unimplemented OpenGL ES API
G GDO Member Licensed User Longtime User Mar 8, 2013 #30 I read that opengl 2 is now supported with emulator but of course I will only test with a real device. Thank you for your help.
I read that opengl 2 is now supported with emulator but of course I will only test with a real device. Thank you for your help.
agraham Expert Licensed User Longtime User Mar 9, 2013 #31 Are you using GLSurfaceView2.Initialize or GLSurfaceView2.Initialize2. If using GLSurfaceView2.Initialize2 then try GLSurfaceView2.Initialize instead.
Are you using GLSurfaceView2.Initialize or GLSurfaceView2.Initialize2. If using GLSurfaceView2.Initialize2 then try GLSurfaceView2.Initialize instead.
G GDO Member Licensed User Longtime User Mar 9, 2013 #32 Hello, Yes I used GLSurfaceView2.Initialize2 (I use your demo and try to add the display of a triangle). Now, with GLSurfaceView2.Initialize, all the errors disappeared but I can not see my triangle (on a real device). I don't know, for now, what I have to change in my code to make it work with Initialize. What I needed was RGBA_8888 and a 16 bits depth buffer (Initialize2 was perfect). I'll be back ... ;-) Once again, thank you for your help.
Hello, Yes I used GLSurfaceView2.Initialize2 (I use your demo and try to add the display of a triangle). Now, with GLSurfaceView2.Initialize, all the errors disappeared but I can not see my triangle (on a real device). I don't know, for now, what I have to change in my code to make it work with Initialize. What I needed was RGBA_8888 and a 16 bits depth buffer (Initialize2 was perfect). I'll be back ... ;-) Once again, thank you for your help.
agraham Expert Licensed User Longtime User Mar 9, 2013 #33 I missed setting GLSurfaceView.setEGLContextClientVersion(2) in Initialize2 which is why I suggested trying Initialize which does have it. I'll post an update with Initialize2 corrected tomorrow as it's getting a bit late here now (17:30) and it's my turn to cook dinner tonight.
I missed setting GLSurfaceView.setEGLContextClientVersion(2) in Initialize2 which is why I suggested trying Initialize which does have it. I'll post an update with Initialize2 corrected tomorrow as it's getting a bit late here now (17:30) and it's my turn to cook dinner tonight.
agraham Expert Licensed User Longtime User Mar 10, 2013 #35 Version 1.3 now posted has some new Initialize methods to let you control the configuration better. Initialize3 uses the default settings for OpenGL2 The following partial initializers can be used sequentially in place of Initialize, Initialize2 or Initialize3 to create a custom initialisation. InitializeGL - must be called and called first to set up OpenGL 2 InitializeConfig - if called should be called second to initialise the EGLConfigChooser InitializeHolder - if called should be called third to initialise the pixel format InitializeRender - must be called and called last to set up the Renderer
Version 1.3 now posted has some new Initialize methods to let you control the configuration better. Initialize3 uses the default settings for OpenGL2 The following partial initializers can be used sequentially in place of Initialize, Initialize2 or Initialize3 to create a custom initialisation. InitializeGL - must be called and called first to set up OpenGL 2 InitializeConfig - if called should be called second to initialise the EGLConfigChooser InitializeHolder - if called should be called third to initialise the pixel format InitializeRender - must be called and called last to set up the Renderer
G GDO Member Licensed User Longtime User Mar 10, 2013 #36 Hi, glsv.Initialize2(glsv.RENDERMODE_WHEN_DIRTY, "glsv", 16, 0) or glsv.Initialize3(glsv.RENDERMODE_WHEN_DIRTY, "glsv") seems OK but glsv..InitializeGL2("glsv") glsv.InitializeConfig(8, 8, 8, 8, 16, 0) glsv..InitializeHolder(glsv.PixelFormat.RGBA_8888) glsv.InitializeRender(glsv.RENDERMODE_WHEN_DIRTY) are KO InitializeGL not defined (I suppose it's InitializeGL2) InitializeHolder not defined
Hi, glsv.Initialize2(glsv.RENDERMODE_WHEN_DIRTY, "glsv", 16, 0) or glsv.Initialize3(glsv.RENDERMODE_WHEN_DIRTY, "glsv") seems OK but glsv..InitializeGL2("glsv") glsv.InitializeConfig(8, 8, 8, 8, 16, 0) glsv..InitializeHolder(glsv.PixelFormat.RGBA_8888) glsv.InitializeRender(glsv.RENDERMODE_WHEN_DIRTY) are KO InitializeGL not defined (I suppose it's InitializeGL2) InitializeHolder not defined
agraham Expert Licensed User Longtime User Mar 10, 2013 #37 Sorry I changed the name but the original one stuck in my mind when I wrote that post. I also made a stupid oversight in the code that I have now fixed. Download version 1.3 again and it should work. Notice that you need the int value of PixelFormat that you can get from the link in the help. Code: Copy glsv.InitializeGL2("glsv") glsv.InitializeConfig(8, 8, 8, 8, 16, 0) glsv.InitializeFormat(1) ' 1 is the int value of PixelFormat.RGBA_8888 glsv.InitializeRender(glsv.RENDERMODE_WHEN_DIRTY)
Sorry I changed the name but the original one stuck in my mind when I wrote that post. I also made a stupid oversight in the code that I have now fixed. Download version 1.3 again and it should work. Notice that you need the int value of PixelFormat that you can get from the link in the help. Code: Copy glsv.InitializeGL2("glsv") glsv.InitializeConfig(8, 8, 8, 8, 16, 0) glsv.InitializeFormat(1) ' 1 is the int value of PixelFormat.RGBA_8888 glsv.InitializeRender(glsv.RENDERMODE_WHEN_DIRTY)
G GDO Member Licensed User Longtime User Mar 10, 2013 #38 Hi, Now,everything looks fine in your library. But my triangle display is not OK. I am looking what's wrong in my code... Thanks
Hi, Now,everything looks fine in your library. But my triangle display is not OK. I am looking what's wrong in my code... Thanks
agraham Expert Licensed User Longtime User Mar 10, 2013 #39 :sign0060: I got it drawing a gray frame and capturing and displaying it. Attachments OpenGL2DemoGrayFrame.zip OpenGL2DemoGrayFrame.zip 7.3 KB · Views: 712
G GDO Member Licensed User Longtime User Mar 11, 2013 #40 Hello, It was a log way to go but I can now see my triangle ! Thank you for your help.