brandonborkholder / glg2d

Graphics2D wrapper for JOGL
77 stars 31 forks source link

NullPointerException in AbstractColorHelper #17

Closed yuripourre closed 11 years ago

yuripourre commented 11 years ago

Hi @brandonborkholder,

Sometimes (this is a intermittent problem) I'm getting a NullPointerException in setComposite method of AbstractColorHelper, comp (parameter) came as null, so the notImplemented method throws the exception.

As palliative I made a check to see if comp is null.

if(comp!=null){ notImplemented("setComposite(Composite) with " + comp.getClass().getSimpleName()); }

I can't find the cause of the problem.

Caused by: java.lang.NullPointerException at org.jogamp.glg2d.impl.AbstractColorHelper.setComposite(AbstractColorHelper.java:124) at org.jogamp.glg2d.GLGraphics2D.setComposite(GLGraphics2D.java:311) at org.jogamp.glg2d.impl.gl2.GL2ImageDrawer.begin(GL2ImageDrawer.java:51) at org.jogamp.glg2d.impl.AbstractImageHelper.drawImage(AbstractImageHelper.java:124) at org.jogamp.glg2d.GLGraphics2D.drawImage(GLGraphics2D.java:676)

brandonborkholder commented 11 years ago

Can you post the complete stack trace, or give me some additional context of where you're running this? I'd like to know under what circumstances a null Composite is being passed into this method. Graphics2D is not documented as allowing a null value, but maybe I should reset the composite if that's the accepted behavior.

On Mon, Apr 15, 2013 at 9:21 PM, Yuri notifications@github.com wrote:

Hi @brandonborkholder https://github.com/brandonborkholder,

Sometimes (this is a intermittent problem) I'm getting a NullPointerException in setComposite method of AbstractColorHelper, comp (parameter) came as null, so the notImplemented method throws the exception.

As palliative I made a check to see if comp is null.

if(comp!=null){ notImplemented("setComposite(Composite) with " + comp.getClass().getSimpleName()); }

I can't find the cause of the problem.

Caused by: java.lang.NullPointerException at org.jogamp.glg2d.impl.AbstractColorHelper.setComposite(AbstractColorHelper.java:124) at org.jogamp.glg2d.GLGraphics2D.setComposite(GLGraphics2D.java:311) at org.jogamp.glg2d.impl.gl2.GL2ImageDrawer.begin(GL2ImageDrawer.java:51) at org.jogamp.glg2d.impl.AbstractImageHelper.drawImage(AbstractImageHelper.java:124) at org.jogamp.glg2d.GLGraphics2D.drawImage(GLGraphics2D.java:676)

— Reply to this email directly or view it on GitHubhttps://github.com/brandonborkholder/glg2d/issues/17 .

yuripourre commented 11 years ago

I found it, and thats my fault.

I changed in GLGraphics2D the setCanvas(GLAutoDrawable drawable) to public.

And in my GLEventListener class every display(drawable) call I use glGraphics.setCanvas(drawable).

and then draw2D(glGraphics g) to draw my 2D stuff...

some of attributes goes null when I set the canvas, so I get a NullPointer.

I know thats not the best way to mix 2D and 3D. But was the easiest way to Integrate my Engine with GLG2D.

Thank You and Sorry for your time.

brandonborkholder commented 11 years ago

This should not be expecting a null Composite, but the issue was fixed in a6a478a752255a72d38ef0bd25288f4faba708b2.