Bug 560 : opengl crashes when depth sorting more than two textured shapes
Last modified: 2007-07-14 20:16




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P2
Severity:
normal

 

Reporter:
ddf
Assigned To:
fry

Attachment Type Created Size Actions
sketch that produces bug application/octet-stream 2007-05-18 13:01 1.28 KB
first image used in attached sketch image/png 2007-05-18 13:02 51.15 KB
second image used in attached sketch image/png 2007-05-18 13:02 177.83 KB
third image used in attached sketch image/png 2007-05-18 13:02 250.68 KB

Description:   Opened: 2007-05-18 13:01
With: P5 124, Win XP, 2.93 Intel dual core, GeForce 8800 GTX vid card (PCI
Express X16), 2 GB ram.

With more than two textured shapes (in my case they all have alpha), opengl
will crash due to a null pointer being passed to bindTexture(), if you have
called hint(ENABLE_DEPTH_SORT).

I've attached the sketch that produces this crash for me.

Stack trace:

Caused by: java.lang.NullPointerException
at processing.opengl.PGraphicsOpenGL.bindTexture(PGraphicsOpenGL.java:702)
at
processing.opengl.PGraphicsOpenGL.render_triangles(PGraphicsOpenGL.java:523)
at processing.core.PGraphics3D.flush(PGraphics3D.java:408)
at processing.opengl.PGraphicsOpenGL.endDraw(PGraphicsOpenGL.java:414)
at processing.core.PApplet.handleDisplay(PApplet.java:1398)
at processing.opengl.PGraphicsOpenGL$1.display(PGraphicsOpenGL.java:221)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at
javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Additional Comment #1 From ddf 2007-05-18 13:01
edit]
sketch that produces bug
Additional Comment #2 From ddf 2007-05-18 13:02
edit]
first image used in attached sketch
Additional Comment #3 From ddf 2007-05-18 13:02
edit]
second image used in attached sketch
Additional Comment #4 From ddf 2007-05-18 13:02
edit]
third image used in attached sketch
Additional Comment #5 From ddf 2007-05-28 15:52
I decided to try a quick fix that address the symptom of trying to
dereference a null pointer and it seems to work. In PGraphicsOpenlGL.java
replace this line:

if ( textureIndex != -1 ) {

with this one:

if ( textureIndex != -1 && textures[textureIndex] != null ) {

This keeps a null texture from being sent to bindTexture where it gets
dereferenced. I also checked the length of textures and found that it was 4
and not the expected 3. However, that shouldn't matter as long as the
triangles have the proper texture index set. In any event, the real fix
lies elsewhere, either in the texture() method or in the construction of
the triangles array.
Additional Comment #6 From fry 2007-06-10 20:18
k, thanks for the report. i suspect it's something dumb and i'll give it a
quick look when i get a chance.
Additional Comment #7 From fry 2007-07-14 20:16
found and fixed for 0125. thanks for the example.

fwiw, you can use tools > archive sketch to make a zip file that bundles up
the sketch as a single attachment for other bug reports.