Too late rendering

Started by bLAZY, January 17, 2012, 11:15:06 AM

Previous topic - Next topic

bLAZY

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?


bLAZY

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.

EgonOlsen


bLAZY

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:

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:

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?

EgonOlsen

If that happens, sky is null for some reason. Check your code...

bLAZY

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.

EgonOlsen

Maybe your skybox was to narrow, so that the rest of the world clips at it. Try to use a bigger skybox.

bLAZY

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?

EgonOlsen

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).

bLAZY

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

EgonOlsen

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.

bLAZY

I have satysfying effect thanks appropriate SkyBox size adjusting.
Thanks a lot for help.