Merge pull request #28 from bkuker/master
Capture JOGL debug information
This commit is contained in:
commit
02927d0f2d
@ -26,6 +26,8 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
import com.jogamp.opengl.JoglVersion;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.communication.BugReporter;
|
import net.sf.openrocket.communication.BugReporter;
|
||||||
import net.sf.openrocket.gui.components.SelectableLabel;
|
import net.sf.openrocket.gui.components.SelectableLabel;
|
||||||
@ -273,6 +275,7 @@ public class BugReportDialog extends JDialog {
|
|||||||
sb.append("OpenRocket version: " + BuildProperties.getVersion() + "\n");
|
sb.append("OpenRocket version: " + BuildProperties.getVersion() + "\n");
|
||||||
sb.append("OpenRocket source: " + BuildProperties.getBuildSource() + "\n");
|
sb.append("OpenRocket source: " + BuildProperties.getBuildSource() + "\n");
|
||||||
sb.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n");
|
sb.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n");
|
||||||
|
sb.append("JOGL version: " + JoglVersion.getInstance().getImplementationVersion() + "\n");
|
||||||
sb.append("Current default locale: " + Locale.getDefault() + "\n");
|
sb.append("Current default locale: " + Locale.getDefault() + "\n");
|
||||||
sb.append("System properties:\n");
|
sb.append("System properties:\n");
|
||||||
|
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package net.sf.openrocket.gui.figure3d;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects system err into OpenRocket's log.debug() if openrocket.debug is enabled.
|
||||||
|
* This lets me capture JOGL debug as log events, which can be included in error reports etc.
|
||||||
|
* I wish I could get the JOGL debug log on a separate printstream, so I do not have to take
|
||||||
|
* over all of ERR.
|
||||||
|
*
|
||||||
|
* @author bkuker
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
final class JoglDebugAdaptor {
|
||||||
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
|
final static void plumbJoglDebug() {
|
||||||
|
if (RocketFigure3d.is3dEnabled() && System.getProperty("openrocket.debug") != null) {
|
||||||
|
System.setProperty("jogl.debug", "all");
|
||||||
|
|
||||||
|
System.setErr(new PrintStream(new OutputStream() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void write(int b) throws IOException {
|
||||||
|
if (b == '\r' || b == '\n') {
|
||||||
|
if (sb.toString().trim().length() > 0){
|
||||||
|
String s = sb.toString();
|
||||||
|
if ( Character.isWhitespace(s.charAt(0))){
|
||||||
|
log.verbose(sb.toString());
|
||||||
|
} else {
|
||||||
|
log.debug(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb = new StringBuilder();
|
||||||
|
} else {
|
||||||
|
sb.append((char) b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -52,6 +52,8 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
JoglDebugAdaptor.plumbJoglDebug();
|
||||||
|
|
||||||
//this allows the GL canvas and things like the motor selection
|
//this allows the GL canvas and things like the motor selection
|
||||||
//drop down to z-order themselves.
|
//drop down to z-order themselves.
|
||||||
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
||||||
@ -370,12 +372,12 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose(GLAutoDrawable drawable) {
|
public void dispose(GLAutoDrawable drawable) {
|
||||||
log.verbose("GL - dispose() called");
|
log.verbose("GL - dispose()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(GLAutoDrawable drawable) {
|
public void init(GLAutoDrawable drawable) {
|
||||||
log.verbose("GL - init() called");
|
log.verbose("GL - init()");
|
||||||
rr.init(drawable);
|
rr.init(drawable);
|
||||||
|
|
||||||
GL2 gl = drawable.getGL().getGL2();
|
GL2 gl = drawable.getGL().getGL2();
|
||||||
@ -400,13 +402,11 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
|
|
||||||
extrasOverlay = new Overlay(drawable);
|
extrasOverlay = new Overlay(drawable);
|
||||||
caretOverlay = new Overlay(drawable);
|
caretOverlay = new Overlay(drawable);
|
||||||
|
|
||||||
log.verbose("GL - init() complete");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
|
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
|
||||||
log.verbose("GL - reshape() called");
|
log.verbose("GL - reshape()");
|
||||||
GL2 gl = drawable.getGL().getGL2();
|
GL2 gl = drawable.getGL().getGL2();
|
||||||
GLU glu = new GLU();
|
GLU glu = new GLU();
|
||||||
|
|
||||||
@ -419,7 +419,6 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
||||||
|
|
||||||
redrawExtras = true;
|
redrawExtras = true;
|
||||||
log.verbose("GL - reshape() complete");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -458,7 +457,6 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupView(GL2 gl, GLU glu) {
|
private void setupView(GL2 gl, GLU glu) {
|
||||||
log.verbose("GL - setupView() called");
|
|
||||||
gl.glLoadIdentity();
|
gl.glLoadIdentity();
|
||||||
|
|
||||||
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_POSITION,
|
gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_POSITION,
|
||||||
@ -494,8 +492,6 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
gl.glScaled(-1, 1, 1);
|
gl.glScaled(-1, 1, 1);
|
||||||
gl.glTranslated(-1, 0, 0);
|
gl.glTranslated(-1, 0, 0);
|
||||||
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
||||||
|
|
||||||
log.verbose("GL - setupView() complete");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -508,19 +504,15 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void internalRepaint() {
|
private void internalRepaint() {
|
||||||
log.verbose("GL - internalRepaint() called");
|
|
||||||
super.repaint();
|
super.repaint();
|
||||||
if (canvas != null)
|
if (canvas != null)
|
||||||
canvas.display();
|
canvas.display();
|
||||||
log.verbose("GL - internalRepaint() complete");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void repaint() {
|
public void repaint() {
|
||||||
log.verbose("GL - repaint() called");
|
|
||||||
redrawExtras = true;
|
redrawExtras = true;
|
||||||
internalRepaint();
|
internalRepaint();
|
||||||
log.verbose("GL - repaint() complete");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<RocketComponent> selection = new HashSet<RocketComponent>();
|
private Set<RocketComponent> selection = new HashSet<RocketComponent>();
|
||||||
@ -551,7 +543,6 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
// ///////////// Extra methods
|
// ///////////// Extra methods
|
||||||
|
|
||||||
private Coordinate project(Coordinate c, GL2 gl, GLU glu) {
|
private Coordinate project(Coordinate c, GL2 gl, GLU glu) {
|
||||||
log.verbose("GL - project() called");
|
|
||||||
double[] mvmatrix = new double[16];
|
double[] mvmatrix = new double[16];
|
||||||
double[] projmatrix = new double[16];
|
double[] projmatrix = new double[16];
|
||||||
int[] viewport = new int[4];
|
int[] viewport = new int[4];
|
||||||
@ -564,7 +555,6 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
glu.gluProject(c.x, c.y, c.z, mvmatrix, 0, projmatrix, 0, viewport, 0,
|
glu.gluProject(c.x, c.y, c.z, mvmatrix, 0, projmatrix, 0, viewport, 0,
|
||||||
out, 0);
|
out, 0);
|
||||||
|
|
||||||
log.verbose("GL - project() complete");
|
|
||||||
return new Coordinate(out[0], out[1], out[2]);
|
return new Coordinate(out[0], out[1], out[2]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user