Combine JPCT and OpenGL ES API

Started by mazelin, July 28, 2013, 03:42:12 PM

Previous topic - Next topic

mazelin

Hi, all
    When I use JPCT API, can i also use OpenGL ES API.For examples, I want to use follow code to update PROJECTION View.
gl.glMatrixMode(GL10.GL_PROJECTION);
FloatBuffer floatBuffer = FloatBuffer.wrap(new float[]{//data......});
gl.glLoadMatrixf(floatBuffer);
It will work?
Thanks!

EgonOlsen

No, that won't work. You might be able to do in the beforeRendering()-method of an IRenderHook, if you do it per object. But it will interfere with the gross culling of the engine if it's too far away from the actual projection matrix. Why do you want to do this anyway?

mazelin

Hi,
   Thank you for reply. I want to change camera PROJECTION View, but I can't find the interface from JPCT-AE.
I calibration camera for android and compute the camera matrix. Then I want to configure PROJECTION View. How can I do it in JPCT-AE?
Thank you again.

EgonOlsen

I'm not sure what a projection matrix has to do with the device's camera. You can set the fov in the Camera class, if that is what you are looking for...

mazelin

I mean like this:
public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);

    // make adjustments for screen ratio
    float ratio = (float) width / height;
    gl.glMatrixMode(GL10.GL_PROJECTION);        // set matrix to projection mode
    gl.glLoadIdentity();                                        // reset the matrix to its default state
    gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7);           // apply the projection matrix   //The data will change for different device's camera.
}
So, I can't do it like this, if i use JPCT-AE?
Thank you!

EgonOlsen

No, not that way. It wouldn't make any sense to provide a high level API and still support direct gl calls of that kind. How should the rest of the API know that you've just changed the projection matrix from the outside? But as said, you can change the fov in Camera and the clipping planes in World. You might have to set Config.glIgnoreNearPlane=false; in addition to make your new near plane have an effect. These are all the parameter you need, the call to glFrustum doesn't do anything more than that.