NullPointerException when calling to renderScene

Started by Melssj5, March 03, 2008, 06:18:52 PM

Previous topic - Next topic

Melssj5

Hi, I am getting a NullPointerException when calling to renderScene (buffer)

I am sure than neither the world nor the FrameBufer is null, so the problem must be a bug os something becausse it happens sometimes. not always.

I have tested the app on 2 machines. and this happens mostly on my P3 laptop with a GForce 2. on my P4 qith a fx 5600 almost never happens this.

this is the stackTrace:

Java version is: 1.6.0
-> support for BufferedImage
Version helper for 1.2+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Current mode:800 x 600 x 32 @60Hz
Driver is: nv4_disp/5.13.1.1533 on NVIDIA Corporation / GeForce2 MX/AGP/SSE
FBO not supported or disabled!
OpenGL renderer initialized (using 2 texture stages)
Software renderer disposed
Exception in thread "Thread-3" java.lang.NullPointerException
        at com.threed.jpct.Object3D.render(Unknown Source)
        at com.threed.jpct.World.renderScene(Unknown Source)
        at Flier_Match.FMCliente.video.RenderThread.mostrarImagen(RenderThread.j
ava:175)
        at Flier_Match.FMCliente.video.RenderThread.run(RenderThread.java:148)
Conexion establecida con: lrocha en el puerto: 8888
Recibiendo identificador del jugador y su nave
Identificador recibido: 2

Basicly this happens when I want to switch Worlds for rendering.
Nada por ahora

EgonOlsen

Looks like a threading issue to me. You are either switching video modes or are manipulating objects that jPCT is still rendering from outside the rendering thread. Keep in mind that jPCT isn't thread safe. When rendering in one thread, don't work with jPCT objects in another without synchronizing this.

Melssj5

Yes, actually, I am using 2 threads, one for the rendering and another one for managing the events and the network iterarions as you suggested me some time ago. How can I sync them.
Nada por ahora

EgonOlsen

Hard to tell without knowing what exactly you are doing in that event/network parts and if it needs synchronization, but basically, you shouldn't modify jPCT related objects like (the World, all Object3Ds...) from another thread then the rendering thread or you have to put a synchronized-block around these parts as well as around the rendering part and synchronize this with some generic sync-object (or whatever is appropriate in that situation). You may want to have a look at the advanced example in the download section. It has some client/server-code that does this. However, albeit its documented, it may take a time to get a grasp on it.

Melssj5

well, yes, I am affecting objects in the world. When a new player begans to play the server has to add it on the world and to remove when it quits from the game. I never have so any syncronizated threads before.
Nada por ahora

EgonOlsen

You always have. The fact that it worked before is just a coincidence.

Melssj5

well, I guess I can add some checking changes methoids for my eventmanager class. On that way I can call this checking methods from the rendewrThread and then the affecting world methods will be on the renderThread. Anyway this happens just sometimes so I will do it and the end of my project.
Nada por ahora

Melssj5

well, I did some changed and efectively the problem was that I was adding and building objects to the world on another thread while was rendering. No I added some checking methods for doing this things from inside the rendering Thread loop and worked well.
Nada por ahora