Author Topic: Too late rendering  (Read 4941 times)

Offline bLAZY

  • byte
  • *
  • Posts: 18
    • View Profile
Too late rendering
« on: January 17, 2012, 11:15:06 am »
Hi,

I'm trying to do a game where object moves "into the screen" and object is always in the middle. Some hurdles will be showed and I want they appear also in the middle and become more and more bigger when are closer. It's situation almost like in AlienRunner. My problem is that hurdles appear too late, suddenly on the scrren, when they are too close. As it's initial phase I use only primitives as hurdles so they are not big things to render. What could be the problem?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net

Offline bLAZY

  • byte
  • *
  • Posts: 18
    • View Profile
Re: Too late rendering
« Reply #2 on: January 17, 2012, 07:47:32 pm »
Thanks a lot. Now I see difference. Unfortunately I test it on emulator so I have hope it will work much better on real device.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Too late rendering
« Reply #3 on: January 17, 2012, 08:18:29 pm »

Offline bLAZY

  • byte
  • *
  • Posts: 18
    • View Profile
Re: Too late rendering
« Reply #4 on: January 28, 2012, 08:38:31 pm »
Finally I found problem, when I removed SkyBox everything show up very fast and I can control it with mentioned Config.farPlane.
But now problem with SkyBox. To be honest I don't need all the sky. Better way for me could be some "static" background in every frame. Why "static"? I'd like to change it with some preset time (to look like blinking).
And this is next thing I can't deal with. I tried this:

Code: [Select]
frameBuffer.clear();
frameBuffer.blit(sky,0,0,0,0,512,512,FrameBuffer.OPAQUE_BLITTING);

world.renderScene(frameBuffer);
world.draw(frameBuffer);

frameBuffer.display();

sky is the texture added to TextureManager and has size 512x512. But I get:

Code: [Select]
01-28 19:03:39.921: E/AndroidRuntime(893): FATAL EXCEPTION: GLThread 8
01-28 19:03:39.921: E/AndroidRuntime(893): java.lang.NullPointerException
01-28 19:03:39.921: E/AndroidRuntime(893): at com.threed.jpct.GLRenderer.blit(GLRenderer.java:1453)
01-28 19:03:39.921: E/AndroidRuntime(893): at com.threed.jpct.GLRenderer.execute(GLRenderer.java:1892)
01-28 19:03:39.921: E/AndroidRuntime(893): at com.threed.jpct.FrameBuffer.blit(FrameBuffer.java:587)
01-28 19:03:39.921: E/AndroidRuntime(893): at my.game.GameActivity$MyRenderer.onDrawFrame(GameActivity.java:870)
01-28 19:03:39.921: E/AndroidRuntime(893): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
01-28 19:03:39.921: E/AndroidRuntime(893): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)

How could I fix it to have this background?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Too late rendering
« Reply #5 on: January 28, 2012, 08:53:02 pm »
If that happens, sky is null for some reason. Check your code...

Offline bLAZY

  • byte
  • *
  • Posts: 18
    • View Profile
Re: Too late rendering
« Reply #6 on: January 28, 2012, 09:17:04 pm »
Of course you were right EgonOlsen :) . I should send you big beer when I will finish my game :D

However this static background looks lousy  :-\ Need to back to SkyBox and find out how to set it correctly.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Too late rendering
« Reply #7 on: January 28, 2012, 09:37:26 pm »
Maybe your skybox was to narrow, so that the rest of the world clips at it. Try to use a bigger skybox.

Offline bLAZY

  • byte
  • *
  • Posts: 18
    • View Profile
Re: Too late rendering
« Reply #8 on: January 28, 2012, 09:55:45 pm »
Probably it was. BTW is it possible to manage the texture's alpha ? It could help me to make this background less borring in case when I will have still problem with SkyBox. I set in texture creator boolean useAlpha as true but what to do now?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Too late rendering
« Reply #9 on: January 28, 2012, 10:06:28 pm »
Alpha for a skybox? What is supposed to shine through...as unicolored background? Apart from that, you can set a transparency by accessing the skybox object from the skybox' world instance. You'll find information about this in the forum (maybe in the desktop jPCT section) and you can create an alpha channel in your prefered image editor and save it as png (jpg doesn't support alpha).

Offline bLAZY

  • byte
  • *
  • Posts: 18
    • View Profile
Re: Too late rendering
« Reply #10 on: January 28, 2012, 10:30:28 pm »
No. Sorry for obscurity. Alpha for a texture used in blitting. I thought about blittnig two skies, one dark blue blit all the time and one with stars with changed alpha from 0 to 255 and back. Then stars could appear and disappear smoothly :D   I saw texture.add function which pass alpha of the second texture. So I created the second by this public Texture(int width, int height, int alpha) and added it with weight = 1 to star_sky. Of course I change alpha. But it doesn't work :D

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Too late rendering
« Reply #11 on: January 28, 2012, 10:43:27 pm »
You have to use blitting with transparency. Just assigning an alpha channel does nothing unless you enable transparency. You don't have to assign an alpha value to the texture for that. You might want to tweak the transparency formula in Config.

Offline bLAZY

  • byte
  • *
  • Posts: 18
    • View Profile
Re: Too late rendering
« Reply #12 on: January 30, 2012, 04:32:21 pm »
I have satysfying effect thanks appropriate SkyBox size adjusting.
Thanks a lot for help.