Skip to content

Commit

Permalink
fixed to not check blend, which somehow messes up display method that…
Browse files Browse the repository at this point in the history
… uses new blending mode to mix layers. some opengl state is not properly saved and restored currently.
  • Loading branch information
Tobi Delbruck authored and Tobi Delbruck committed May 4, 2020
1 parent fc8cf7e commit d5dbe4c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/ch/unizh/ini/jaer/projects/minliu/Speedometer.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,34 @@ synchronized public void annotate(GLAutoDrawable drawable) {
setCursorColor(END_COLOR);
}
}
super.annotate(drawable); //To change body of generated methods, choose Tools | Templates.
// super.annotate(drawable); // TODO messes up so no OFF events show, don't know why
GL2 gl = drawable.getGL().getGL2();
gl.glPushMatrix();
drawCursor(gl, getStartPoint(), START_COLOR);
drawCursor(gl, getEndPoint(), END_COLOR);
gl.glPopMatrix(); // must push pop since drawCursor translates?
if (getStartPoint() != null && getEndPoint() != null) {
gl.glPushMatrix();
gl.glColor3f(1, 1, 0);
gl.glBegin(GL.GL_LINES);
gl.glVertex2f(getStartPoint().x, getStartPoint().y);
gl.glVertex2f(getEndPoint().x, getEndPoint().y);
gl.glEnd();

String s = String.format("Speed: %s pps (%.0fpix/%ss), dx/dy=%d/%d", engFmt.format(speedPps), distance, engFmt.format(1e-6f * deltaTimestamp), (int) Math.abs(endPoint.x - startPoint.x), (int) Math.abs(endPoint.y - startPoint.y));
drawString(drawable, s);
drawString(drawable, s);
gl.glPopMatrix(); // must push pop since drawCursor translates?
} else if (getStartPoint() != null) {
String s = String.format("Left click for end point. Time from IN mark: %ss", engFmt.format(1e-6f * (currentTimestamp - getStartPoint().t)));
gl.glPushMatrix();
drawString(drawable, s);
gl.glPopMatrix(); // must push pop since drawCursor translates?

} else {
String s = "Left click for start point";
gl.glPushMatrix();
drawString(drawable, s);

gl.glPopMatrix(); // must push pop since drawCursor translates?
}
}

Expand All @@ -170,10 +175,10 @@ private void drawCursor(GL2 gl, Point p, float[] color) {
if (p == null) {
return;
}
checkBlend(gl);
// checkBlend(gl); // no OFF events show after setting blending here, interaction with blending in the display method???
gl.glPushMatrix();
gl.glColor4fv(color, 0);
gl.glLineWidth(3f);
gl.glPushMatrix();
gl.glTranslatef(p.x, p.y, 0);
gl.glBegin(GL2.GL_LINES);
gl.glVertex2f(0, -CURSOR_SIZE_CHIP_PIXELS / 2);
Expand Down

0 comments on commit d5dbe4c

Please sign in to comment.