28package com.jogamp.opengl.demos.graph.ui;
31import java.io.IOException;
32import java.util.ArrayList;
33import java.util.Arrays;
35import java.util.Locale;
37import com.jogamp.common.os.Clock;
38import com.jogamp.common.util.IOUtil;
39import com.jogamp.graph.curve.OutlineShape;
40import com.jogamp.graph.curve.Region;
41import com.jogamp.graph.curve.opengl.RenderState;
42import com.jogamp.graph.font.Font;
43import com.jogamp.graph.font.Font.Glyph;
44import com.jogamp.graph.font.FontFactory;
45import com.jogamp.graph.ui.Group;
46import com.jogamp.graph.ui.Scene;
47import com.jogamp.graph.ui.Shape;
48import com.jogamp.graph.ui.TooltipShape;
49import com.jogamp.graph.ui.TooltipText;
50import com.jogamp.graph.ui.layout.Alignment;
51import com.jogamp.graph.ui.layout.BoxLayout;
52import com.jogamp.graph.ui.layout.Gap;
53import com.jogamp.graph.ui.layout.GridLayout;
54import com.jogamp.graph.ui.layout.Margin;
55import com.jogamp.graph.ui.layout.Padding;
56import com.jogamp.graph.ui.shapes.GlyphShape;
57import com.jogamp.graph.ui.shapes.Label;
58import com.jogamp.graph.ui.shapes.Rectangle;
59import com.jogamp.graph.ui.widgets.RangeSlider;
60import com.jogamp.graph.ui.widgets.RangedGroup;
61import com.jogamp.graph.ui.widgets.RangedGroup.SliderParam;
62import com.jogamp.math.FloatUtil;
63import com.jogamp.math.Vec2f;
64import com.jogamp.math.Vec3f;
65import com.jogamp.math.Vec4f;
66import com.jogamp.math.geom.AABBox;
67import com.jogamp.newt.MonitorDevice;
68import com.jogamp.newt.Window;
69import com.jogamp.newt.event.KeyAdapter;
70import com.jogamp.newt.event.KeyEvent;
71import com.jogamp.newt.event.MouseEvent;
72import com.jogamp.newt.event.WindowAdapter;
73import com.jogamp.newt.event.WindowEvent;
74import com.jogamp.newt.opengl.GLWindow;
75import com.jogamp.opengl.GL;
76import com.jogamp.opengl.GL2ES2;
77import com.jogamp.opengl.GLAutoDrawable;
78import com.jogamp.opengl.GLCapabilities;
79import com.jogamp.opengl.GLCapabilitiesImmutable;
80import com.jogamp.opengl.GLEventListener;
81import com.jogamp.opengl.GLPipelineFactory;
82import com.jogamp.opengl.GLProfile;
83import com.jogamp.opengl.JoglVersion;
84import com.jogamp.opengl.demos.graph.FontSetDemos;
85import com.jogamp.opengl.demos.graph.MSAATool;
86import com.jogamp.opengl.demos.util.CommandlineOptions;
87import com.jogamp.opengl.demos.util.MiscUtils;
88import com.jogamp.opengl.util.Animator;
89import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser;
111 public static void main(
final String[] args)
throws IOException {
112 boolean showUnderline =
false;
113 boolean showLabel =
false;
114 boolean perfanal =
false;
115 float mmPerCell = 8f;
116 String fontFilename =
null;
117 int gridColumns = -1;
119 if( 0 != args.length ) {
120 final int[] idx = { 0 };
121 for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
122 if( options.
parse(args, idx) ) {
124 }
else if(args[idx[0]].equals(
"-font")) {
126 fontFilename = args[idx[0]];
127 }
else if(args[idx[0]].equals(
"-mmPerCell")) {
130 }
else if(args[idx[0]].equals(
"-gridCols")) {
133 }
else if(args[idx[0]].equals(
"-showUnderline")) {
134 showUnderline =
true;
135 }
else if(args[idx[0]].equals(
"-showLabel")) {
137 }
else if(args[idx[0]].equals(
"-perf")) {
139 }
else if(args[idx[0]].equals(
"-max")) {
141 max_glyph_count =
MiscUtils.
atoi(args[idx[0]], max_glyph_count);
146 System.err.println(options);
149 demo.showUnderline = showUnderline;
150 demo.showLabel = showLabel;
151 demo.mmPerCell = mmPerCell;
152 demo.gridColumns = gridColumns;
155 System.out.println(
"Requested: " + caps);
168 animator.
add(window);
177 public void windowDestroyNotify(
final WindowEvent e) {
183 System.err.println(
"Press enter to continue");
193 private static final float GlyphGridWidth = 3/4f;
194 private static final float GlyphGridBorderThickness = 0.02f;
195 private static final Vec4f GlyphGridBorderColorComplex =
new Vec4f(0.2f, 0.2f, 0.2f, 1);
196 private static final Vec4f GlyphGridBorderColorSimple =
new Vec4f(0.2f, 0.2f, 0.7f, 1);
198 private static int max_glyph_count = 10000;
200 private static boolean VERBOSE_GLYPHS =
false;
201 private static boolean VERBOSE_UI =
false;
203 private boolean showUnderline =
false;
204 private boolean showLabel =
false;
205 private boolean debug =
false;
206 private boolean trace =
false;
207 private final Font font, fontStatus, fontInfo;
208 private float dpiY = 96;
209 private float pixPerMMY;
211 private final Scene scene;
213 private int maxGlyphCount = Integer.MAX_VALUE;
214 private float mmPerCell = 8f;
215 private int gridColumns = -1;
216 private boolean firstReshape =
true;
218 Group mainView =
null;
219 Label infoLabel =
null;
220 int lastCodepoint = 0;
226 this(
null, renderModes,
false,
false);
229 private FontView01(
final String fontFilename,
final int renderModes,
final boolean debug,
final boolean trace) {
233 FontView01.options.renderModes = renderModes;
236 if(
null == fontFilename ) {
237 font =
FontFactory.
get(IOUtil.getResource(
"fonts/freefont/FreeSerif.ttf",
244 fontStatus = FontFactory.get(IOUtil.getResource(
"fonts/freefont/FreeMono.ttf", FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(),
true);
245 fontInfo = FontFactory.get(FontFactory.UBUNTU).getDefault();
248 }
catch (
final IOException ioe) {
249 throw new RuntimeException(ioe);
253 scene.
setClearParams(
new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
268 final int glyphGridRowsPerPage;
271 final float[] pixPerMMXY, dpiXY;
272 if( upObj instanceof
Window ) {
276 public void mouseWheelMoved(
final MouseEvent e) {
284 final float s = 1f+r/200f;
289 mainView.
scale(s, s, 1);
291 mainView.
move(s1.x()*dw/2f, s1.y()*dh/2f, 0);
292 System.err.println(
"scale +"+s+
" = "+s1);
297 final float tmp = rot.x(); rot.
setX( rot.y() ); rot.
setY( tmp );
304 public void keyReleased(
final KeyEvent e) {
316 pixPerMMY = pixPerMMXY[1];
320 System.err.println(
"HiDPI PixelScale: "+hasSurfacePixelScale1[0]+
"x"+hasSurfacePixelScale1[1]+
" (has)");
321 System.err.println(
"Monitor detected: "+monitor);
322 System.err.println(
"Monitor dpi: "+monitorDPI[0]+
" x "+monitorDPI[1]);
324 System.err.println(
"HiDPI PixelScale: "+hasSurfacePixelScale1[0]+
"x"+hasSurfacePixelScale1[1]+
" (has)");
327 dpiXY =
new float[] { dpiY, dpiY };
329 pixPerMMXY =
new float[] { pixPerMMY, pixPerMMY };
330 System.err.println(
"Using default DPI of "+dpiY);
332 glyphGridRowsPerPage = (int)( ( glad.
getSurfaceHeight() / pixPerMMXY[1] ) / mmPerCell );
333 if( 0 >= gridColumns ) {
334 gridColumns = (int)( ( glad.
getSurfaceWidth() * GlyphGridWidth / pixPerMMXY[0] ) / mmPerCell );
338 System.err.println(
"Surface dpi "+dpiXY[0]+
" x "+dpiXY[1]);
339 System.err.println(
"Surface pixPerMM: "+pixPerMMXY[0]+
" x "+pixPerMMXY[1]);
340 System.err.println(
"mmPerCell "+mmPerCell+
", glyphGridRowsPerPage "+glyphGridRowsPerPage+
", gridColumns "+gridColumns);
344 System.err.println(
"AUTO RenderMode: dpi "+dpiY+
", threshold "+options.
noAADPIThreshold+
349 System.err.println(
"FontView01: init (1.1)");
353 System.err.println(
"FontView01: init (1.0)");
364 System.err.println(
"VSync Swap Interval: "+gl.getSwapInterval());
365 System.err.println(
"Chosen: "+glad.getChosenGLCapabilities());
368 gl.setSwapInterval(1);
373 final float glyphGridCellSize = GlyphGridWidth / gridColumns;
374 final Vec2f glyphGridSize =
new Vec2f(GlyphGridWidth, glyphGridRowsPerPage * glyphGridCellSize);
376 final long t0 = Clock.currentNanos();
378 final GridDim gridDim =
new GridDim(font, gridColumns, glyphGridRowsPerPage, 1, maxGlyphCount);
379 final Vec2f glyphGridTotalSize =
new Vec2f(glyphGridSize.x(), gridDim.rows * glyphGridCellSize);
380 System.err.println(gridDim);
381 System.err.println(
"GlyphGrid[pgsz "+glyphGridSize+
", totsz "+glyphGridTotalSize+
", cellSz "+glyphGridCellSize+
"]");
383 lastCodepoint = gridDim.contourChars.get(0);
384 final Shape.PointerListener glyphHoverListener;
388 glyphShapeHolder.
setName(
"GlyphShapeHolderInfo");
389 glyphShapeBox.
addShape( glyphShapeHolder );
393 setGlyphInfo(fontStatus, glyphInfo, font.
getGlyph(
'A' ));
394 glyphInfo.
setColor(0.1f, 0.1f, 0.1f, 1.0f);
399 System.err.println(
"XXX: Hover: "+s+
", event "+e);
408 final GlyphShape old = (GlyphShape) glyphShapeHolder.getShapeByIdx(0);
410 if( old.getGlyph().getCodepoint() == g0.getGlyph().getCodepoint() ) {
414 glyphShapeHolder.removeShape(old);
424 setGlyphInfo(fontStatus, glyphInfo, g0.
getGlyph());
430 final GLCapabilitiesImmutable reqCaps = glad.getRequestedGLCapabilities();
431 final Group glyphInfoView =
new Group(
new GridLayout(2, 0f, 0f, Alignment.None));
434 final Group glyphGrid =
new Group(
new GridLayout(gridDim.columns, glyphGridCellSize*0.9f, glyphGridCellSize*0.9f, Alignment.FillCenter,
435 new Gap(glyphGridCellSize*0.1f)));
436 glyphGrid.setInteractive(
true).setDragAndResizable(
false).setToggleable(
false).setName(
"GlyphGrid");
437 addGlyphs(reqCaps.getGLProfile(), font, glyphGrid, gridDim, showUnderline, showLabel, fontStatus, fontInfo, glyphHoverListener);
438 glyphGrid.setRelayoutOnDirtyShapes(
false);
440 glyphGrid.validate(reqCaps.getGLProfile());
441 System.err.println(
"GlyphGrid "+glyphGrid);
442 System.err.println(
"GlyphGrid "+glyphGrid.getLayout());
445 final GlyphShape gs = getGlyphShape( glyphGrid );
450 final RangedGroup glyphView =
new RangedGroup( options.
renderModes, glyphGrid, glyphGridSize,
452 new SliderParam(
new Vec2f(glyphGridCellSize/4f, glyphGridSize.y()), glyphGridCellSize/10f,
true ) );
453 glyphView.getVertSlider().setColor(0.3f, 0.3f, 0.3f, 0.7f).setName(
"GlyphView");
455 glyphView.getVertSlider().addChangeListener((
final RangeSlider w,
final float old_val,
final float val,
final float old_val_pct,
final float val_pct,
final Vec3f pos,
final MouseEvent e) -> {
456 final Vec2f minmax = w.getMinMax();
457 final float row_f = val / glyphGridCellSize;
458 System.err.println(
"VertSlider: row["+row_f+
".."+(row_f+gridDim.rowsPerPage-1)+
"]/"+gridDim.rows+
459 ", val["+old_val+
" -> "+val+
"]/"+minmax.y()+
", pct["+(100*old_val_pct)+
"% -> "+(100*val_pct)+
"%], cellSz "+glyphGridCellSize);
460 System.err.println(
"VertSlider: "+w.getDescription());
463 glyphView.getVertSlider().receiveKeyEvents(glyphGrid);
466 glyphView.validate(reqCaps.getGLProfile());
467 System.err.println(
"GlyphView "+glyphView);
469 glyphInfoView.addShape(glyphView);
472 final float infoCellWidth = ( 1f - glyphGridSize.x() ) * 1.15f;
473 final float infoCellHeight = glyphGridSize.y() * 0.5f;
474 final Group infoGrid =
new Group(
new GridLayout(1, infoCellWidth, infoCellHeight * 1f, Alignment.FillCenter,
new Gap(infoCellHeight*0.001f, 0)) );
475 infoGrid.setPaddding(
new Padding(0, 0, 0, 0.01f) );
479 infoGrid.validate(reqCaps.getGLProfile());
480 System.err.println(
"InfoGrid "+infoGrid);
481 System.err.println(
"InfoGrid "+infoGrid.getLayout());
482 System.err.println(
"GlyphShapeBox "+glyphShapeBox);
484 glyphInfoView.addShape(infoGrid);
486 glyphInfoView.setPaddding(
new Padding(glyphGridCellSize/6f, 0, 0));
488 glyphInfoView.validate(reqCaps.getGLProfile());
489 System.err.println(
"GlyphInfoGrid "+glyphInfoView);
490 System.err.println(
"GlyphInfoGrid "+glyphInfoView.getLayout());
493 mainView =
new Group(
new GridLayout(1, 0f, 0f, Alignment.None));
496 final String infoHelp =
"Click on a Glyph for a big tooltip view.\n"+
497 "Key-Up/Down or Slider-Mouse-Scroll to move through glyphs.\n"+
498 "Page-Up/Down or Control + Slider-Mouse-Scroll to page faster.\n"+
499 "Mouse-Scroll over left-half of Window rotates and holding control zooms.";
500 infoLabel =
new Label(options.
renderModes, fontInfo,
"Not yet");
501 infoLabel.
setColor(0.1f, 0.1f, 0.1f, 1f);
502 infoLabel.
setTooltip(
new TooltipText(infoHelp, fontInfo, 8f));
504 final float h = glyphGridCellSize * 0.4f;
505 final Group labelBox =
new Group(
new BoxLayout(1.0f, h,
new Alignment(Alignment.Bit.Fill.value | Alignment.Bit.CenterVert.value),
506 new Margin(0, 0.005f)));
507 labelBox.addShape(infoLabel);
511 mainView.
validate(reqCaps.getGLProfile());
512 System.err.println(
"MainView "+mainView);
513 System.err.println(
"MainView "+mainView.
getLayout());
523 final long t1 = Clock.currentNanos();
524 final long total = t1 - t0;
525 final float nsPerGlyph = total / gridDim.glyphCount;
526 System.err.println(
"PERF: Total took "+(total/1000000.0)+
"ms, per-glyph "+(nsPerGlyph/1000000.0)+
"ms, glyphs "+gridDim.glyphCount);
531 OutlineShape.printPerf(System.err);
545 scene.
reshape(glad, x, y, width, height);
547 firstReshape =
false;
553 final float sxy = Math.min(sx, sy);
554 System.err.println(
"SceneBox "+sceneBox);
555 System.err.println(
"MainViewBox "+mainViewBox);
556 System.err.println(
"scale sx "+sx+
", sy "+sy+
", sxy "+sxy);
572 static class GridDim {
573 final List<Character> contourChars;
574 final int glyphCount;
576 final int columnsNet;
578 final int rowsPerPage;
580 int complexGlyphCount;
583 public GridDim(
final Font font,
final int columns,
final int rowsPerPage,
final int xReserved,
final int maxGlyphCount) {
584 this.contourChars =
new ArrayList<Character>();
585 this.glyphCount = Math.min(maxGlyphCount, scanContourGlyphs(font));
586 this.columns = columns;
587 this.columnsNet = columns - xReserved;
588 this.rows = (int)Math.ceil((
double)glyphCount / (double)columnsNet);
589 this.rowsPerPage = rowsPerPage;
590 this.elemCount = glyphCount + ( rows * xReserved );
594 public int reserverColumns() {
return columns - columnsNet; }
596 private int scanContourGlyphs(
final Font font) {
597 final long t0 = Clock.currentNanos();
598 contourChars.clear();
599 complexGlyphCount = 0;
601 final int[] max = { max_glyph_count };
602 font.forAllGlyphs((
final Glyph fg) -> {
603 if( !fg.isNonContour() && max[0]-- > 0 ) {
604 contourChars.add( fg.getCodepoint() );
605 if( null != fg.getShape() && fg.getShape().isComplex() ) {
608 maxNameLen = Math.max(maxNameLen, fg.getName().length());
611 final long t1 = Clock.currentNanos();
612 final long total = t1 - t0;
613 final float nsPerGlyph = total / contourChars.size();
614 System.err.println(
"PERF: GlyphScan took "+(total/1000000.0)+
"ms, per-glyph "+(nsPerGlyph/1000000.0)+
"ms, glyphs "+contourChars.size());
615 return contourChars.size();
618 public String toString() {
return "GridDim[contours "+glyphCount+
", complex "+complexGlyphCount+
" ("+((float)complexGlyphCount/(
float)glyphCount)*100+
"%), "+columns+
"x"+rows+
"="+(columns*rows)+
">="+elemCount+
", rows/pg "+rowsPerPage+
"]"; }
621 static Group getGlyphShapeHolder(
final Shape shape0) {
622 if( !( shape0 instanceof Group ) ) {
625 return (Group)((Group)shape0).getShapeByName(
"GlyphHolder");
627 static GlyphShape getGlyphShape(
final Shape shape0) {
628 final Group gsh = getGlyphShapeHolder(shape0);
629 if(
null != gsh && gsh.getShapeCount() > 0 ) {
630 return (GlyphShape) gsh.getShapeByIdx(0);
639 static void addGlyphs(
final GLProfile glp,
final Font font,
final Group sink,
640 final GridDim gridDim,
final boolean showUnderline,
final boolean showLabel,
641 final Font fontStatus,
final Font fontInfo,
final Shape.PointerListener hoverHandler) {
642 final AABBox tmpBox =
new AABBox();
643 final long t0 = Clock.currentNanos();
645 for(
int idx = 0; idx < gridDim.glyphCount; ++idx) {
646 final char codepoint = gridDim.contourChars.get(idx);
647 final Font.Glyph fg = font.getGlyph(codepoint);
648 final boolean isComplex =
null != fg.getShape() ? fg.getShape().isComplex() :
false;
650 final GlyphShape g =
new GlyphShape(options.
renderModes, fg, 0, 0);
651 g.setColor(0.1f, 0.1f, 0.1f, 1).setName(
"GlyphShape");
652 g.setInteractive(
false).setDragAndResizable(
false);
653 g.setName(
"cp_0x"+Integer.toHexString(fg.getCodepoint()) );
655 final Group c0 =
new Group(
"GlyphHolder",
null,
null, g);
656 c0.setInteractive(
false).setDragAndResizable(
false);
659 final AABBox gbox = fg.getBounds(tmpBox);
660 final boolean addUnderline = showUnderline && gbox.getMinY() < 0f;
661 final Group c1 =
new Group(
new BoxLayout( 1f, 1f, addUnderline ? Alignment.None : Alignment.Center) );
662 c1.setBorder(GlyphGridBorderThickness).setBorderColor(isComplex ? GlyphGridBorderColorComplex : GlyphGridBorderColorSimple)
663 .setInteractive(
true).setDragAndResizable(
false).setName(
"GlyphHolder2");
665 final Shape underline =
new Rectangle(options.
renderModes, 1f, gbox.getMinY(), 0.01f).setInteractive(
false).setColor(0f, 0f, 1f, 0.25f);
666 c1.addShape(underline);
670 c1.onHover(hoverHandler);
671 sink.receiveKeyEvents(c1);
673 c1.setTooltip(
new TooltipShape(
new Vec4f(1, 1, 1, 1),
new Vec4f(0, 0, 0, 1), 0.01f,
674 new Padding(0.05f),
new Vec2f(14,14), 0, options.
renderModes,
675 g, TooltipShape.NoOpDtor) );
676 c1.onClicked((
final Shape s,
final Vec3f pos,
final MouseEvent e) -> {
677 System.err.println(
"XXX: Clicked: "+s+
", event "+e);
678 if( e.getPointerType(0).getPointerClass() == MouseEvent.PointerClass.Onscreen ) {
679 hoverHandler.run(s, pos, e);
681 c1.getTooltip().now();
685 if( 0 < gridDim.reserverColumns() && 0 == idx % gridDim.columnsNet ) {
686 addLabel(sink, fontStatus, String.format(
"%04x", (
int)codepoint));
689 final Group c2 =
new Group(
new GridLayout( 1, 0, 0, Alignment.None) );
690 c2.addShape(c1.setName(
"GlyphHolder3"));
692 final Label l =
new Label(options.
renderModes, fontInfo, fg.getName());
694 final float sxy = 1f/7f;
695 c2.addShape( l.scale(sxy, sxy, 1).setColor(0, 0, 0, 1).setInteractive(
false).setDragAndResizable(
false) );
704 final long t1 = Clock.currentNanos();
705 final long total = t1 - t0;
706 final float nsPerGlyph = total / gridDim.glyphCount;
707 System.err.println(
"PERF: GlyphAdd took "+(total/1000000.0)+
"ms, per-glyph "+(nsPerGlyph/1000000.0)+
"ms, glyphs "+gridDim.glyphCount);
709 static void addLabel(
final Group c,
final Font font,
final String text) {
710 c.addShape(
new Label(options.
renderModes, font, text).setColor(0, 0, 0, 1).setInteractive(
false).setDragAndResizable(
false) );
713 static void setGlyphInfo(
final Font font,
final Label label,
final Font.Glyph g) {
714 label.setText( getGlyphInfo(g) );
715 if( VERBOSE_GLYPHS ) {
716 System.err.println( label.getText() );
720 static String getGlyphInfo(
final Font.Glyph g) {
721 final OutlineShape os = g.getShape();
722 final boolean isComplex =
null != os ? os.isComplex() :
false;
723 final int osVertices =
null != os ? os.getVertexCount() : 0;
724 final String name_s =
null != g.getName() ? g.getName() :
"";
725 final AABBox bounds = g.getBounds();
726 final String box_s = String.format(
"Box %+.3f/%+.3f%n %+.3f/%+.3f", bounds.getLow().x(), bounds.getLow().y(), bounds.getHigh().x(), bounds.getHigh().y());
727 return String.format((Locale)
null,
"%s%nHeight: %1.3f%nLine Height: %1.3f%n%nSymbol: %04x, id %04x%nName: '%s'%nDim %1.3f x %1.3f%n%s%nAdvance %1.3f%nLS Bearings: %1.3f%nVertices: %03d%n%s",
728 g.getFont().getFullFamilyName(),
729 g.getFont().getMetrics().getAscent() - g.getFont().getMetrics().getDescent(),
730 g.getFont().getLineHeight(),
731 (
int)g.getCodepoint(), g.getID(), name_s,
732 bounds.getWidth(), bounds.getHeight(), box_s,
734 g.getLeftSideBearings(),
735 osVertices, isComplex?
"Complex Shape":
"Simple Shape");
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
static String getRenderModeString(final int renderModes)
Returns a unique technical description string for renderModes as follows:
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
final void setHintBits(final int mask)
The optional property jogamp.graph.font.ctor allows user to specify the FontConstructor implementatio...
static final FontSet get(final int font)
Group of Shapes, optionally utilizing a Group.Layout.
int getShapeCount()
Returns number of Shapes, see getShapes().
void addShape(final Shape s)
Adds a Shape.
Layout getLayout()
Return current Group.Layout.
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
void setRelayoutOnDirtyShapes(final boolean v)
Set relayout on dirty shapes mode, defaults to true.
void addShape(final Shape s)
Adds a Shape.
final void setClearParams(final float[] clearColor, final int clearMask)
Sets the clear parameter for glClearColor(..) and glClear(..) to be issued at display(GLAutoDrawable)...
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
RegionRenderer getRenderer()
Returns the associated RegionRenderer.
final void setPMvCullingEnabled(final boolean v)
Enable or disable Project-Modelview (PMv) frustum culling per Shape for this container.
int setAAQuality(final int v)
Sets RegionRenderer#setAAQuality(int).
void dispose(final GLAutoDrawable drawable)
Disposes all added Shapes.
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
synchronized void attachInputListenerTo(final GLWindow window)
boolean invoke(final boolean wait, final GLRunnable glRunnable)
Enqueues a one-shot GLRunnable, which will be executed within the next GLAutoDrawable#display() call ...
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Reshape scene using setupMatrix(PMVMatrix4f, int, int, int, int) using PMVMatrixSetup.
String getStatusText(final GLAutoDrawable glad, final int renderModes, final float dpi)
Return a formatted status string containing avg fps and avg frame duration.
File nextScreenshotFile(final String dir, final String prefix, final int renderModes, final GLCapabilitiesImmutable caps, final String contentDetail)
Return the unique next technical screenshot PNG File instance as follows:
Convenient adapter combining dummy implementation for MouseListener and GestureListener.
Generic Shape, potentially using a Graph via GraphShape or other means of representing content.
Shape setColor(final float r, final float g, final float b, final float a)
Set base color.
Shape setName(final String name)
Set a symbolic name for this shape for identification.
final Shape move(final float dtx, final float dty, final float dtz)
Move about scaled distance.
final Vec3f getScale()
Returns scale Vec3f reference.
final Shape moveTo(final float tx, final float ty, final float tz)
Move to scaled position.
final Quaternion getRotation()
Returns Quaternion for rotation.
final Shape validate(final GL2ES2 gl)
Validates the shape's underlying GLRegion.
final Shape setRotation(final Quaternion q)
Sets the rotation Quaternion.
final void destroy(final GL2ES2 gl, final RegionRenderer renderer)
Destroys all data.
final Shape scale(final Vec3f s)
Multiply current scale factor by given scale.
Tooltip setTooltip(final Tooltip newTooltip)
Set's a new Tooltip for this shape.
final Shape setBorderColor(final float r, final float g, final float b, final float a)
Set border color.
final Shape setBorder(final float thickness)
Sets the thickness of the border, which is included in getBounds() and is outside of getPadding().
Immutable layout alignment options, including Bit#Fill.
static final Alignment FillCenter
Bit#Fill, Bit#CenterHoriz and Bit#CenterVert alignment constant.
GraphUI Stack Group.Layout.
GraphUI CSS property Margin, scaled space between or around elements and not included in the element'...
Representing a single Font.Glyph as a GraphShape.
Glyph getGlyph()
Returns the Font.Glyph to be rendered.
A GraphUI text label GraphShape.
boolean setText(final CharSequence text)
Set the text to be rendered.
Basic Float math utility functions.
static final float PI
The value PI, i.e.
final Quaternion rotateByEuler(final Vec3f angradXYZ)
Rotates this quaternion from the given Euler rotation array angradXYZ in radians.
2D Vector based upon two float components.
3D Vector based upon three float components.
Vec3f scale(final float s)
this = this * s, returns this.
4D Vector based upon four float components.
Axis Aligned Bounding Box.
final Vec3f getLow()
Returns the minimum left-bottom-far (xyz) coordinate.
final AABBox scale(final float s)
Scale this AABBox by a constant around fixed center.
Visual output device, i.e.
static float[] mmToInch(final float[] result, final float[] ppmm)
Converts [1/mm] to [1/inch] from ppmm into result.
static float[] inchToMM(final float[] result, final float[] ppinch)
Converts [1/inch] to [1/mm] in place.
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter value according to the current mode's surface resolution.
static final short VK_F4
Constant for the F4 function key.
static final short VK_ESCAPE
Constant for the ESCAPE function key.
final short getKeySymbol()
Returns the virtual key symbol reflecting the current keyboard layout.
static final short VK_S
See VK_A.
static final short VK_Q
See VK_A.
Pointer event of type PointerType.
final float[] getRotation()
Returns a 3-component float array filled with the values of the rotational axis in the following orde...
final int getX()
See details for multiple-pointer events.
final void setConsumed(final boolean consumed)
If consumed is true, this event is marked as consumed, ie.
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
final void setTitle(final String title)
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
CapabilitiesChooser setCapabilitiesChooser(final CapabilitiesChooser chooser)
Set the CapabilitiesChooser to help determine the native visual type.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
Factory for pipelining GL instances.
static final GL create(final String pipelineClazzBaseName, final Class<?> reqInterface, final GL downstream, final Object[] additionalArgs)
Creates a pipelined GL instance using the given downstream downstream and optional arguments addition...
static JoglVersion getInstance()
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
StringBuilder toString(final GL gl, StringBuilder sb)
This may become a little font viewer application, having FontForge as its role model.
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
FontView01(final int renderModes)
void setMMPerCell(final float v)
void setMaxGlyphCount(final int v)
void init(final GLAutoDrawable glad)
Called by the drawable immediately after the OpenGL context is initialized.
void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
static void main(final String[] args)
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
GLCapabilities getGLCaps()
int fixDefaultAARenderModeWithDPIThreshold(final float dpiV)
Changes default AA rendering bit if not modified via parse(), i.e.
int graphAASamples
Sample count for Graph Region AA render-modes: Region#VBAA_RENDERING_BIT or Region#MSAA_RENDERING_BIT...
int graphAAQuality
Pass2 AA-quality rendering for Graph Region AA render-modes: VBAA_RENDERING_BIT.
void parse(final String[] args)
static void waitForKey(final String preMessage)
static int atoi(final String str, final int def)
static void destroyWindow(final GLAutoDrawable glad)
static float atof(final String str, final float def)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final synchronized Thread setExclusiveContext(final Thread t)
Dedicate all GLAutoDrawable's context to the given exclusive context thread.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
Custom GLCapabilitiesChooser, filtering out all full screen anti-aliasing (FSAA, multisample) capabil...
char getCodepoint()
Returns this glyph's mapped (unicode) codepoint symbol.
Interface wrapper for font implementation.
Glyph getGlyph(final String name)
Returns the Glyph mapped to given name.
String getFullFamilyName()
Shall return the family and subfamily name, separated a dash.
int getSurfaceWidth()
Returns the width of the client area excluding insets (window decorations) in pixel units.
float[] getMaximumSurfaceScale(final float[] result)
Returns the maximum pixel scale of the associated NativeSurface.
float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
Specifying NEWT's Window functionality:
void addKeyListener(KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter of this window's NativeSurface according to the main monitor's curr...
void addMouseListener(MouseListener l)
Appends the given MouseListener to the end of the list.
MonitorDevice getMainMonitor()
Returns the MonitorDevice with the highest viewport coverage of this window.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
Object getUpstreamWidget()
Method may return the upstream UI toolkit object holding this GLAutoDrawable instance,...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
GLContext getContext()
Returns the GLContext associated which this GL object.
Specifies an immutable set of OpenGL capabilities.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expression '0x0B71',...