Author Topic: Version updates!  (Read 78527 times)

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Version updates!
« Reply #300 on: March 01, 2012, 08:38:48 am »
With a little fun I finally got it to work. Here is the code if anyone wants to do the same :)

Code: [Select]
boolean isOpenGl2 = false;
try {
Method setEGLContextClientVersion = GLSurfaceView.class.getMethod(
                   "setEGLContextClientVersion", int.class );
           /* success, this is a newer device */

setEGLContextClientVersion.invoke(mGLView, 2);
mGLView.setEGLConfigChooser(new AAConfigChooser(mGLView));
isOpenGl2 = true;
Log.d("WW", "Using OpenGL 2.0");
} catch (NoSuchMethodException e) {
Log.d("WW", "Fail to find setEGLContextClientVersion, must be an older device.");
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
if(!isOpenGl2){
Log.d("WW", "Using OpenGL 1.1");
}

However with AA it slowed even my Galaxy Nexus to 17fps, so looks like that is off the table :( Though it looked a lot nicer!

Then it was crashing when I removed the AA line.

Quote
03-01 20:32:12.204: D/WW(28677): Using OpenGL 2.0
03-01 20:32:12.266: D/libEGL(28677): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
03-01 20:32:12.266: D/libEGL(28677): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
03-01 20:32:12.266: D/libEGL(28677): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
03-01 20:32:12.384: D/OpenGLRenderer(28677): Enabling debug mode 0
03-01 20:32:12.407: W/dalvikvm(28677): threadid=11: thread exiting with uncaught exception (group=0x40a721f8)
03-01 20:32:12.407: E/AndroidRuntime(28677): FATAL EXCEPTION: GLThread 1182
03-01 20:32:12.407: E/AndroidRuntime(28677): java.lang.RuntimeException: createContext failed: EGL_BAD_CONFIG
03-01 20:32:12.407: E/AndroidRuntime(28677):    at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1164)
03-01 20:32:12.407: E/AndroidRuntime(28677):    at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1156)
03-01 20:32:12.407: E/AndroidRuntime(28677):    at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1003)
03-01 20:32:12.407: E/AndroidRuntime(28677):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1348)
03-01 20:32:12.407: E/AndroidRuntime(28677):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1202)
03-01 20:32:12.743: D/OpenGLRenderer(28677): Flushing caches (mode 0)
03-01 20:32:13.009: D/OpenGLRenderer(28677): Flushing caches (mode 1)
03-01 20:32:15.837: I/Process(28677): Sending signal. PID: 28677 SIG: 9

Why would it crash just from removing this line?
Code: [Select]
mGLView.setEGLConfigChooser(new AAConfigChooser(mGLView));
« Last Edit: March 01, 2012, 08:41:03 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: Version updates!
« Reply #301 on: March 01, 2012, 10:36:03 am »
Because of this:
Quote
EGL_BAD_CONFIG
. I'm not sure why, but it somehow thinks that your default config is wrong. But that's out of the scope of jPCT-AE. How you create the context is totally up to you. You might want to look at the HelloShader-example and see that runs on this device. If it does, just do what it does in your code.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Version updates!
« Reply #302 on: March 01, 2012, 10:53:51 am »
Oh silly me, I didn't realise you didnt need to do
Code: [Select]
mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {...That problem is solved  :)


With the 400 lines (yes we need to support that many lines) OpenGL 2.0(No AA) is still very slow compared to 1.1. I'm going about 17-22 fps on my Galaxy Nexus. No trouble in 1.1 (smooth 60fps).

However OpenGL 2.0 + AA seems to be smooth also when there is no lines.

Is there any optimisations you can do with OpenGL 2.0 and lines? No big problem if you can't.
« Last Edit: March 01, 2012, 11:15:37 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: Version updates!
« Reply #303 on: March 01, 2012, 11:06:24 am »
However with AA it slowed even my Galaxy Nexus to 17fps, so looks like that is off the table :( Though it looked a lot nicer!
But lines without AA in ES 2.0 are fine?

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Version updates!
« Reply #304 on: March 01, 2012, 11:08:45 am »
Quote
But lines without AA in ES 2.0 are fine?
Other than still being just about as slow, yep they were fine.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: Version updates!
« Reply #305 on: March 01, 2012, 11:14:28 am »
I see...i'm using a custom shader in ES 2.0 mode for rendering the lines and i did the state management in a very naive way to get things working. It should be possible to improve this. I'll create myself a test case this evening and see if i can improve it.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Version updates!
« Reply #306 on: March 01, 2012, 11:25:37 am »
Quote
It should be possible to improve this. I'll create myself a test case this evening and see if i can improve it.
Awesome stuff.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: Version updates!
« Reply #307 on: March 01, 2012, 09:35:35 pm »
Please re-download the jar. I've updated it with one that should be faster in both modes. The ES 2.0 mode still isn't as fast as the 1.0 mode, but on the Nexus S, it went up from 10fps to 40fps when drawing 501 lines. The performance drop comes from the additional overhead introduced by setting the shader's uniform for each line and sadly can't be reduced.

Now on to transparency...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: Version updates!
« Reply #308 on: March 01, 2012, 10:10:28 pm »
...transparency has been added. The colors alpha value will be taken into account, a new setter for transparency mode is in Polyline. Please download the jar again and let me know if it works/helps.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Version updates!
« Reply #309 on: March 02, 2012, 02:13:44 am »
You are awesome. Smooth as butter. I have it now using OpenGL 2.0 on mid range devices and turning AA on for high end.

Now to do some testing on all the devices around here.

Edit: Smooth all around and looks better than the iphone version :)
« Last Edit: March 02, 2012, 02:30:31 am by zammbi »

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Version updates!
« Reply #310 on: May 18, 2012, 11:25:42 pm »
Egon, how it seems with support of post-processing effects? If I'm correct, it's render scene to texture, render plane with texture and fragment shader and display... I want depth of field (another project than I sent to you) :)

edit: In this demo working render to texture without any problem. Zip contains also source code.
http://dl.dropbox.com/u/26148874/render%20to%20texture.zip
« Last Edit: May 19, 2012, 10:17:09 am by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: Version updates!
« Reply #311 on: June 06, 2012, 10:15:11 pm »
Version 1.25 has been released!

Change log:
Quote
Fixed a bug in the texture matrix support of the OpenGL ES 2.0 renderer. Added the ShaderLocator class to allow for different shader locations. Added a method to SimpleVector to calculate a reflection vector. Added setRotationPivot() to Overlay.
Added the option to use an alpha channel to the AAConfigChooser. Added a method to lock a mesh to Mesh. Added a method to Object3D to share texture data between objects.  Fixed a flaw when trying to set non-existent uniforms and attributes in a shader.
Fixed replacement shaders in GLSLShader. Serialized objects can now contain an octree. Object3D.clearRotation() now also resets the scale. Added compile(boolean)-method to Object3D for compatibility with desktop jPCT. Fixed a problem when deserializing objects with diffuse colors. jPCT now automatically detects the default thread, so there's usually no need to set it in World.
Added an additional optimization to ellipsoid collision detection; setting collision detection to optimized now has an affect on ellipsoid collision detection. Added a calcAngleFast()-method to SimpleVector. Optimized compress() in Texture-class. Added a Virtualizer class to support swapping texture data to disk.
Fixed a bug that screwed up textures when sharing meshes of objects that use multiple textures and were stripped. Reduced objects created by collision detection, shader support and fogging support. Fixed context recovering for animated objects. Fixed an inaccuracy in the Overlay when the camera matrix wasn't 100% orthogonal.
Fixed a bug with not correctly managing states when using tangent verctors. Fixed a bug in the visibility detection for objects that consist of only one or two polygons. Fixed setOrientation() on scaled objects. Added the option to override the calculated distance of a light to an object. Fixed fogging when used in multiple worlds in one frame.
Fixed a bug that occured when recovering the from a context change on a floating point VBO. Added basic support for primitive lines with the new Polyline-class. Deprecated Texture.enableGLClamping() and replaced it with Texture.setClamping(<boolean>). Fixed compression ratio calculation for zipped textures. Changed mip mapping default to true.
Changed behaviour of animated objects that share compiled data. Now, the parent object doesn't have to touched to update the animation if a child has been animated. Added getProgram() to GLSLShader. Fixed behaviour of build() when used on models on which calcNormals() has been called before. Added support for setting a maximum number of lights for an Object3D.
Serialized objects now include the name of the object. The rotation pivot will now be deserialized if it's part of the file. Fixed Loader.readTextureNames3DS to actually read texture names. Fixed loading of flawed .mtl-files. General performance improvements.

Some additional info: http://www.jpct.net/forum2/index.php/topic,2791.0.html
« Last Edit: June 06, 2012, 10:17:49 pm by EgonOlsen »

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Version updates!
« Reply #312 on: June 07, 2012, 02:18:50 pm »
Could you explain a little more detail on the Virtualizer?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: Version updates!
« Reply #313 on: June 07, 2012, 07:48:19 pm »
Could you explain a little more detail on the Virtualizer?
Sure! The engine has to keep texture and mesh data to be able to upload it again onto the gpu in case of an OpenGL context switch. By default, this happens in the VM's memory reducing free memory for the actual application. With the Virtualizer, you can swap this data to disk/card. Just create a Virtualizer, set the current Context and assign it to either the TextureManager or the Object3Ds in questions. For textures, you have to call TextureManager.virtualize(<Texture>); in addition. For Object3Ds, it happens automagically. jPCT-AE will then swap the memory to disk/card and reload it from there if needed.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Version updates!
« Reply #314 on: June 07, 2012, 11:47:43 pm »
Sounds awesome. Though since I need to keep resume times fast doesn't sound like I can use it.

Isn't also ETC1 texture compression new in this version?