Author Topic: Exception when rendering  (Read 11254 times)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« on: May 19, 2006, 08:53:08 am »
Hi, I am receiving this exceptions, and they continue to the infinite.

I add a cube primitive to the World, and when rendering they began to appear this.

I have 4 FrameBuffers. The World is static, on the RenderThread I render the 4 FrameBuffers one by one separated by a sleep (10);

Please help
Java version is: 1.5.0
-> support for BufferedImage
-> using BufferedImage
Software renderer (legacy mode) initialized
Software renderer disposed
Java version is: 1.5.0
-> support for BufferedImage
-> using BufferedImage
Software renderer (legacy mode) initialized
Software renderer disposed
Java version is: 1.5.0
-> support for BufferedImage
-> using BufferedImage
Software renderer (legacy mode) initialized
Software renderer disposed
Java version is: 1.5.0
-> support for BufferedImage
-> using BufferedImage
Software renderer (legacy mode) initialized
Software renderer disposed
Driver is: ati2dvag/6.14.10.6601
OpenGL renderer initialized (using 4 texture stages)
Driver is: ati2dvag/6.14.10.6601
OpenGL renderer initialized (using 4 texture stages)
Driver is: ati2dvag/6.14.10.6601
OpenGL renderer initialized (using 4 texture stages)
Driver is: ati2dvag/6.14.10.6601
OpenGL renderer initialized (using 4 texture stages)
Pressed
Released
Clicked
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.NullPointerException
        at com.threed.jpct.AWTJPCTCanvas.paintGL(Unknown Source)
        at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:256)
        at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
        at sun.awt.RepaintArea.paint(RepaintArea.java:224)
        at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
        at java.awt.Component.dispatchEventImpl(Component.java:4031)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.lang.NullPointerException
        at com.threed.jpct.AWTGLRenderer.drawVertexArray(Unknown Source)
        ... 13 more
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: From thread Thread[AWT-EventQueue-0,6,main]: Thread[AWT-EventQueue-0,6,] already has the context current
        at org.lwjgl.opengl.Context.checkAccess(Context.java:169)
        at org.lwjgl.opengl.Context.makeCurrent(Context.java:176)
        at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:251)
        at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
        at sun.awt.RepaintArea.paint(RepaintArea.java:224)
        at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
        at java.awt.Component.dispatchEventImpl(Component.java:4031)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: ......
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Exception when rendering
« Reply #1 on: May 19, 2006, 09:35:19 am »
These exceptions are all caused by the first one, this:

Code: [Select]

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.NullPointerException
at com.threed.jpct.AWTJPCTCanvas.paintGL(Unknown Source)
at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:256)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
at java.awt.Component.dispatchEventImpl(Component.java:4031)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.lang.NullPointerException
at com.threed.jpct.AWTGLRenderer.drawVertexArray(Unknown Source)


Don't know what causes this. Can you provide me with a test case?

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« Reply #2 on: May 19, 2006, 02:41:13 pm »
Yeah, I send you a mail with my code. Hope it helps to find where the error is? Thanks.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« Reply #3 on: May 19, 2006, 02:56:07 pm »
here is the code for everyone can test it. Thanks a lot.

http://www.giga-comp.com/archivos/RGB.zip
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Exception when rendering
« Reply #4 on: May 19, 2006, 08:38:47 pm »
Ok, i think i've at least found the problem but i haven't got a clever solution for it ATM. The problem is caused by the fact that you are using one World, which means one VisList but you are rendering to multiple buffers. The AWTGLRenderer does a kind of buffering to be thread safe and so does the VisLIst. When using multiple Canvas', this isn't sufficient.
Finding a solution for this is not that easy because they all have some drawbacks. I think i'm going to add an alternative draw()-method that takes its own VisList instead of that from the World. Not nice, but better than everything else that came to my mind. I'm going to add this on monday if all goes well and see if it helps.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« Reply #5 on: May 19, 2006, 10:39:29 pm »
The exception appears when calling to canvas.repaint (); What would be the weakness of the new draw method that will be implemented on monday?

I need to take the Objects3d from the World to move or rotate them, also for changing it textures. Can I continue with the rest of the programation until monday or the alternative draw method will affect the Interact2D mehods??
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Exception when rendering
« Reply #6 on: May 20, 2006, 12:11:44 am »
Quote from: "Melssj5"
What would be the weakness of the new draw method that will be implemented on monday?
It won't be very intuitive to use,i.e. you'll have to know when to use it and why. I would like to hide this away from the user but i'm afraid i can't. Well, we'll see if and how it works....

Quote from: "Melssj5"
I need to take the Objects3d from the World to move or rotate them, also for changing it textures. Can I continue with the rest of the programation until monday or the alternative draw method will affect the Interact2D mehods??
No, whatever i add to handle this problem shouldn't hurt Interact2D or similar stuff.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Exception when rendering
« Reply #7 on: May 22, 2006, 06:07:49 pm »
Ok, i tried to add a solution to this problem that is hidden away from the user, so you don't have to change anything in your code. It's not fully tested, so take care...: http://www.jpct.net/download/beta/jpctapi112_pre2.zip

BTW: When doing picking (or anything else that requires access to the VisList), make sure that you are using the correct one. The new version will create one for each FrameBuffer that a World is rendered into. World.getVisibilityList() will always return the most current one, i.e. the one from the laster render of this world into whatever framebuffer.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« Reply #8 on: May 22, 2006, 06:13:39 pm »
ok, Thanks a lot. I will test it tonight and post anything I found.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« Reply #9 on: May 23, 2006, 09:36:36 am »
Hi, It worked but how can I do to select further objectsd. I mean, it only select the objects if they are near but at a certaing distance, it dont select them.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Exception when rendering
« Reply #10 on: May 23, 2006, 05:08:06 pm »
Every polygon in the VisList that belongs to a selectable Object3D should be pickable. If it's not, it...

a) ...is maybe not selectable
b) ...is hidden by some other selectable polygon (even is transparent)
c) ...the current VisList is not the correct one (make sure that you are using the one which belong to the render of, let's say, the upper left canvas if you are picking in the upper left canvas.)

If these three points don't apply, please provide me with a test case, so i can check this out.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« Reply #11 on: May 23, 2006, 09:51:08 pm »
No, they arent.

I left here a link to an updated problem, just darw a 3d object, select them and use the buttons to move it, when is far enough try selecting it again.

http://comunidad3d.webcindario.com/Archivos/rgb.zip
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Exception when rendering
« Reply #12 on: May 24, 2006, 12:10:47 am »
I have the feeling that they do apply... :wink: Looks like c) is what you see here. You are calling World.getVisibilityList() which means, that you are working with the last rendered VisList. This is usually not the one that is valid for the lower left canvas but for the right one and you can pick the right object (virtually) on the left canvas. At least it looks like that.
Keep in mind: This version of jPCT doesn't any longer maintain ONE VisList but one per FrameBuffer/Canvas. To get it for a specific canvas, call getVisibilityList() right after calling draw() for that canvas/framebuffer like so:



Code: [Select]

fb1.draw(...);
VisList vl1=world.getVisibilityList();
...
fb2.draw(...);
VisList vl2=world.getVisibilityList();
...
fb3.draw(...);
VisList vl3=world.getVisibilityList();
...etc...

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Exception when rendering
« Reply #13 on: May 25, 2006, 05:02:43 am »
:oops:  Hi, I undestarnd what you say (80%) but I dont see how can it solve my problem. Which is the purpose of getting the reference of the VisList of a current FrameBuffer on a VisList object. I mean, will it fix my problem just by adding the getVisList () method without using it?
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Exception when rendering
« Reply #14 on: May 25, 2006, 10:58:08 am »
You have to get the reference to the current VisList from the World after rendering the canvas to which the picking should be applied, keep that reference somewhere and use it for picking when needed.