Author Topic: Combine JPCT and OpenGL ES API  (Read 2348 times)

Offline mazelin

  • byte
  • *
  • Posts: 4
    • View Profile
Combine JPCT and OpenGL ES API
« on: July 28, 2013, 03:42:12 pm »
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!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Combine JPCT and OpenGL ES API
« Reply #1 on: July 28, 2013, 08:12:06 pm »
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?

Offline mazelin

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Combine JPCT and OpenGL ES API
« Reply #2 on: July 29, 2013, 02:38:12 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Combine JPCT and OpenGL ES API
« Reply #3 on: July 29, 2013, 08:27:44 am »
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...

Offline mazelin

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Combine JPCT and OpenGL ES API
« Reply #4 on: July 29, 2013, 12:30:49 pm »
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!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12297
    • View Profile
    • http://www.jpct.net
Re: Combine JPCT and OpenGL ES API
« Reply #5 on: July 29, 2013, 12:45:48 pm »
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.

Offline mazelin

  • byte
  • *
  • Posts: 4
    • View Profile
Re: Combine JPCT and OpenGL ES API
« Reply #6 on: July 29, 2013, 03:35:31 pm »
OK, TKS.