28package com.jogamp.opengl.demos.graph.ui;
30import java.io.IOException;
32import com.jogamp.common.util.InterruptSource;
33import com.jogamp.graph.curve.Region;
34import com.jogamp.graph.curve.opengl.GLRegion;
35import com.jogamp.graph.curve.opengl.RegionRenderer;
36import com.jogamp.graph.curve.opengl.RenderState;
37import com.jogamp.graph.ui.GraphShape;
38import com.jogamp.graph.ui.Scene;
39import com.jogamp.graph.ui.Shape;
40import com.jogamp.graph.ui.shapes.Rectangle;
41import com.jogamp.math.Recti;
42import com.jogamp.math.Vec3f;
43import com.jogamp.math.Vec4f;
44import com.jogamp.math.geom.AABBox;
45import com.jogamp.math.util.PMVMatrix4f;
46import com.jogamp.newt.event.KeyAdapter;
47import com.jogamp.newt.event.KeyEvent;
48import com.jogamp.newt.event.WindowAdapter;
49import com.jogamp.newt.event.WindowEvent;
50import com.jogamp.newt.opengl.GLWindow;
51import com.jogamp.opengl.GL;
52import com.jogamp.opengl.GL2ES2;
53import com.jogamp.opengl.GLAutoDrawable;
54import com.jogamp.opengl.GLCapabilities;
55import com.jogamp.opengl.GLEventAdapter;
56import com.jogamp.opengl.GLProfile;
57import com.jogamp.opengl.demos.graph.ui.testshapes.Glyph03FreeMonoRegular_M;
58import com.jogamp.opengl.demos.util.CommandlineOptions;
59import com.jogamp.opengl.util.Animator;
72 public static void main(
final String[] args)
throws IOException, InterruptedException {
73 boolean ok_shape =
false;
74 boolean use_glyph =
false;
75 if( 0 != args.length ) {
76 final int[] idx = { 0 };
77 for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
78 if( options.
parse(args, idx) ) {
80 }
else if(args[idx[0]].equals(
"-ok")) {
82 }
else if(args[idx[0]].equals(
"-glyph")) {
87 System.err.println(options);
88 System.err.println(
"ok_shape "+ok_shape);
90 System.err.println(
"GLProfile: "+reqGLP);
100 System.out.println(
"Requested: " + reqCaps);
114 public void windowDestroyNotify(
final WindowEvent e) {
123 testShape.
setColor(0.8f, 0.8f, 0.8f, 1);
124 testShape.
scale(1000, 1000, 1);
130 region.
draw(gl, renderer);
145 public void keyPressed(
final KeyEvent arg0) {
148 new InterruptSource.Thread( () -> { window.
destroy(); } ).start();
159 animator.
add(window);
163 System.err.println(
"Scene "+sbox);
164 if(
null != rectShape ) {
167 final float w, h, w2, lineWidth, delta;
171 lineWidth = ok_shape ? 1.0f : 1.1f;
176 System.err.printf(
"R_0: w %30.30f x %30.30f%n", w2, h);
180 for(
int i=0; i<300; ++i) {
181 final float wi = w-i*delta;
183 System.err.printf(
"R_1: %d: w %30.30f x %30.30f%n", i, wi, h);
193 private static final class MyMatrixSetup
implements Scene.PMVMatrixSetup {
196 public float getSceneDist() {
201 public float getAngle() {
206 public float getZNear() {
211 public float getZFar() {
217 public void set(
final PMVMatrix4f pmv,
final Recti viewport) {
218 final float ratio = (float) viewport.width() / (float) viewport.height();
220 pmv.orthoP(0, viewport.width(), 0, viewport.height(), getZNear(), getZFar());
222 pmv.translateP(0f, 0f, getSceneDist());
224 pmv.loadMvIdentity();
228 public void setPlaneBox(
final AABBox planeBox,
final PMVMatrix4f pmv,
final Recti viewport) {
229 final float orthoDist = -getSceneDist();
230 final Vec3f obj00Coord =
new Vec3f();
231 final Vec3f obj11Coord =
new Vec3f();
233 Scene.winToPlaneCoord(pmv, viewport, getZNear(), getZFar(), viewport.x(), viewport.y(), orthoDist, obj00Coord);
234 Scene.winToPlaneCoord(pmv, viewport, getZNear(), getZFar(), viewport.width(), viewport.height(), orthoDist, obj11Coord);
236 planeBox.setSize( obj00Coord, obj11Coord );
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
A GLRegion is the OGL binding of one or more OutlineShapes Defined by its vertices and generated tria...
final void draw(final GL2ES2 gl, final RegionRenderer renderer)
Renders the associated OGL objects specifying current width/hight of window for optional multi pass r...
final RenderState getRenderState()
Return the RenderState composition.
final void setColorStatic(final Vec4f rgbaColor)
The RenderState is owned by RegionRenderer.
final void clearDebugBits(final int mask)
static final int DEBUG_LINESTRIP
final void setDebugBits(final int mask)
Graph based GLRegion Shape.
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)...
int setAAQuality(final int v)
Sets RegionRenderer#setAAQuality(int).
void waitUntilDisplayed()
Blocks until first display(GLAutoDrawable) has completed after construction or dispose(GLAutoDrawable...
final void setPMVMatrixSetup(final PMVMatrixSetup setup)
Set a custom PMVMatrixSetup.
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)
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:
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.
final void onDraw(final DrawListener l)
Set a user one-shot initializer callback or custom draw(GL2ES2, RegionRenderer) hook.
final Shape scale(final Vec3f s)
Multiply current scale factor by given scale.
A GraphUI rectangle GraphShape.
void setDimension(final float width, final float height, final float lineWidth)
4D Vector based upon four float components.
Axis Aligned Bounding Box.
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_Q
See VK_A.
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 boolean isNativeValid()
final void setTitle(final String title)
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
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.
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
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.
Specifies the the OpenGL profile.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
Basic UIShape demo using a Scene and Shape.
static void main(final String[] args)
GPU based resolution independent test object.
GLCapabilities getGLCaps()
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)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...