29package com.jogamp.opengl.demos.graph;
31import com.jogamp.opengl.GL;
32import com.jogamp.opengl.GL2ES2;
33import com.jogamp.opengl.GLAutoDrawable;
34import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
35import com.jogamp.graph.curve.OutlineShape;
36import com.jogamp.graph.curve.Region;
37import com.jogamp.graph.curve.opengl.GLRegion;
38import com.jogamp.graph.curve.opengl.RenderState;
39import com.jogamp.math.Vec4f;
40import com.jogamp.math.geom.plane.Path2F;
41import com.jogamp.math.geom.plane.WindingRule;
42import com.jogamp.math.util.PMVMatrix4f;
43import com.jogamp.graph.curve.opengl.RegionRenderer;
44import com.jogamp.opengl.util.PMVMatrix;
54 final int shape_ctor_mode;
57 public GPURegionGLListener01 (
final int renderModes,
final int sampleCount,
final boolean debug,
final boolean trace) {
61 public GPURegionGLListener01 (
final int shape_ctor_mode,
final int renderModes,
final int aaQuality,
final int sampleCount,
final boolean debug,
final boolean trace) {
63 this.shape_ctor_mode = shape_ctor_mode;
70 private void createTestOutline00(){
71 outlineShape.
addVertex(0.0f,-10.0f,
true);
72 outlineShape.
addVertex(15.0f,-10.0f,
true);
73 outlineShape.
addVertex(10.0f,5.0f,
false);
74 outlineShape.
addVertex(15.0f,10.0f,
true);
75 outlineShape.
addVertex(6.0f,15.0f,
false);
81 outlineShape.
addVertex(10.0f,-5.0f,
false);
87 final float offset = 30;
89 outlineShape.
addVertex(offset+0.0f,-10.0f,
true);
90 outlineShape.
addVertex(offset+17.0f,-10.0f,
true);
91 outlineShape.
addVertex(offset+11.0f,5.0f,
true);
92 outlineShape.
addVertex(offset+16.0f,10.0f,
true);
93 outlineShape.
addVertex(offset+7.0f,15.0f,
true);
94 outlineShape.
addVertex(offset+6.0f,8.0f,
true);
95 outlineShape.
addVertex(offset+0.0f,10.0f,
true);
98 outlineShape.
addVertex(offset+5.0f,0.0f,
true);
99 outlineShape.
addVertex(offset+5.0f,-5.0f,
true);
100 outlineShape.
addVertex(offset+10.0f,-5.0f,
true);
101 outlineShape.
addVertex(offset+10.0f,0.0f,
true);
103 System.err.println(
"createTestOutline00: "+outlineShape);
106 private void createTestOutline01a(){
107 final float lineWidth = 1/2.5f;
108 final float dz = 0.001f;
110 final float width = 1.5f;
111 final float height = 1.5f;
112 final float x1 = -width/2.0f;
113 final float y1 = -height/2.0f;
114 final float x2 = x1 + width;
115 final float y2 = y1 + height;
119 outlineShape.
moveTo(x1, y1, z);
120 outlineShape.
lineTo(x2, y1, z);
121 outlineShape.
lineTo(x2, y2, z);
122 outlineShape.
lineTo(x1, y2, z);
123 outlineShape.
lineTo(x1, y1, z);
130 final float dxy = lineWidth;
131 outlineShape.
moveTo(x1+dxy, y1+dxy, z);
132 outlineShape.
lineTo(x1+dxy, y2-dxy, z);
133 outlineShape.
lineTo(x2-dxy, y2-dxy, z);
134 outlineShape.
lineTo(x2-dxy, y1+dxy, z);
135 outlineShape.
lineTo(x1+dxy, y1+dxy, z);
138 System.err.println(
"createTestOutline01: "+outlineShape);
140 private void createTestOutline01(){
141 outlineShape.
moveTo(0.0f,-10.0f, 0f);
142 outlineShape.
lineTo(15.0f,-10.0f, 0f);
143 outlineShape.
quadTo(10.0f,5.0f,0f, 15.0f,10.0f,0f);
144 outlineShape.
cubicTo(6.0f,15.0f,0f, 5.0f,8.0f,0f, 0.0f,10.0f,0f);
146 outlineShape.
moveTo(5.0f,-5.0f,0f);
147 outlineShape.
quadTo(10.0f,-5.0f,0f, 10.0f,0.0f,0f);
148 outlineShape.
quadTo(5.0f,0.0f,0f, 5.0f,-5.0f,0f);
152 final float offset = 30;
153 outlineShape.
moveTo(offset+0.0f,-10.0f,0f);
154 outlineShape.
lineTo(offset+17.0f,-10.0f,0f);
155 outlineShape.
lineTo(offset+11.0f,5.0f,0f);
156 outlineShape.
lineTo(offset+16.0f,10.0f,0f);
157 outlineShape.
lineTo(offset+7.0f,15.0f,0f);
158 outlineShape.
lineTo(offset+6.0f,8.0f,0f);
159 outlineShape.
lineTo(offset+0.0f,10.0f,0f);
161 outlineShape.
moveTo(offset+5.0f,0.0f,0f);
162 outlineShape.
lineTo(offset+5.0f,-5.0f,0f);
163 outlineShape.
lineTo(offset+10.0f,-5.0f,0f);
164 outlineShape.
lineTo(offset+10.0f,0.0f,0f);
166 System.err.println(
"createTestOutline01b: "+outlineShape);
169 private void createTestOutline02(){
170 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
171 path.moveTo(0.0f,-10.0f);
172 path.lineTo(15.0f,-10.0f);
173 path.quadTo(10.0f,5.0f, 15.0f,10.0f);
174 path.cubicTo(6.0f,15.0f, 5.0f,8.0f, 0.0f,10.0f);
176 path.moveTo(5.0f,-5.0f);
177 path.quadTo(10.0f,-5.0f, 10.0f,0.0f);
178 path.quadTo(5.0f,0.0f, 5.0f,-5.0f);
182 final float offset = 30;
183 path.moveTo(offset+0.0f,-10.0f);
184 path.lineTo(offset+17.0f,-10.0f);
185 path.lineTo(offset+11.0f,5.0f);
186 path.lineTo(offset+16.0f,10.0f);
187 path.lineTo(offset+7.0f,15.0f);
188 path.lineTo(offset+6.0f,8.0f);
189 path.lineTo(offset+0.0f,10.0f);
191 path.moveTo(offset+5.0f,0.0f);
192 path.lineTo(offset+5.0f,-5.0f);
193 path.lineTo(offset+10.0f,-5.0f);
194 path.lineTo(offset+10.0f,0.0f);
197 System.err.println(
"GPURegionGLListener01.createTestOutline02.X: path "+path);
198 path.printSegments(System.err);
199 outlineShape.
addPath(path,
false );
200 System.err.println(
"createTestOutline02: "+outlineShape);
203 private void createTestOutline03(){
205 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
206 path.moveTo(0.0f,-10.0f);
207 path.lineTo(15.0f,-10.0f);
208 path.quadTo(10.0f,5.0f, 15.0f,10.0f);
209 path.cubicTo(6.0f,15.0f, 5.0f,8.0f, 0.0f,10.0f);
211 System.err.println(
"GPURegionGLListener01.createTestOutline03.0: path "+path);
212 path.printSegments(System.err);
214 final Path2F path2 =
new Path2F(WindingRule.NON_ZERO);
215 path2.moveTo(5.0f,-5.0f);
216 path2.quadTo(10.0f,-5.0f, 10.0f,0.0f);
217 path2.quadTo(5.0f,0.0f, 5.0f,-5.0f);
219 System.err.println(
"GPURegionGLListener01.createTestOutline03.0: path2 "+path2);
220 path2.printSegments(System.err);
221 path.append(path2,
false);
222 System.err.println(
"GPURegionGLListener01.createTestOutline03.1: path "+path);
223 path.printSegments(System.err);
225 outlineShape.
addPath(path,
false );
229 final float offset = 30;
230 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
231 path.moveTo(offset+0.0f,-10.0f);
232 path.lineTo(offset+17.0f,-10.0f);
233 path.lineTo(offset+11.0f,5.0f);
234 path.lineTo(offset+16.0f,10.0f);
235 path.lineTo(offset+7.0f,15.0f);
236 path.lineTo(offset+6.0f,8.0f);
237 path.lineTo(offset+0.0f,10.0f);
239 path.moveTo(offset+5.0f,0.0f);
240 path.lineTo(offset+5.0f,-5.0f);
241 path.lineTo(offset+10.0f,-5.0f);
242 path.lineTo(offset+10.0f,0.0f);
244 System.err.println(
"GPURegionGLListener01.createTestOutline03.3: path "+path);
245 path.printSegments(System.err);
246 outlineShape.
addPath(path,
false );
248 System.err.println(
"createTestOutline03: "+outlineShape);
252 private void createTestOutline04(){
253 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
255 path.moveTo(0.0f,10.0f);
256 path.cubicTo(5.0f,8.0f, 6.0f,15.0f, 15.0f,10.0f);
257 path.quadTo(10.0f,5.0f, 15.0f,-10.0f);
258 path.lineTo(0.0f,-10.0f);
260 path.moveTo(5.0f,-5.0f);
261 path.quadTo(5.0f,0.0f, 10.0f,0.0f);
262 path.quadTo(10.0f,-5.0f, 5.0f,-5.0f);
266 final float offset = 30;
267 path.moveTo(offset+0.0f,10.0f);
268 path.lineTo(offset+6.0f,8.0f);
269 path.lineTo(offset+7.0f,15.0f);
270 path.lineTo(offset+16.0f,10.0f);
271 path.lineTo(offset+11.0f,5.0f);
272 path.lineTo(offset+17.0f,-10.0f);
273 path.lineTo(offset+0.0f,-10.0f);
275 path.moveTo(offset+10.0f,0.0f);
276 path.lineTo(offset+10.0f,-5.0f);
277 path.lineTo(offset+5.0f,-5.0f);
278 path.lineTo(offset+5.0f,0.0f);
281 System.err.println(
"GPURegionGLListener01.createTestOutline04.X: path "+path);
282 path.printSegments(System.err);
285 System.err.println(
"createTestOutline04: "+outlineShape);
290 super.init(drawable);
300 switch( shape_ctor_mode ) {
302 createTestOutline00();
305 createTestOutline02();
308 createTestOutline03();
311 createTestOutline04();
314 createTestOutline01();
336 regionRenderer.
enable(gl,
true);
338 regionRenderer.
enable(gl,
false);
A Generic shape objects which is defined by a list of Outlines.
void addPath(final Path2F path, final boolean connect)
Append the given path geometry to this outline shape.
final void addVertex(final Vertex v)
Adds a vertex to the last open outline to the shape's tail.
final void moveTo(final float x, final float y, final float z)
Start a new position for the next line segment at given point x/y (P1).
final void quadTo(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2)
Add a quadratic curve segment, intersecting the last point and the second given point x2/y2 (P2).
final void lineTo(final float x, final float y, final float z)
Add a line segment, intersecting the last point and the given point x/y (P1).
void addPathRev(final Path2F path, final boolean connect)
Append the given path geometry to this outline shape in reverse order.
final void closeLastOutline(final boolean closeTail)
Closes the last outline in the shape.
final void cubicTo(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2, final float x3, final float y3, final float z3)
Add a cubic Bézier curve segment, intersecting the last point and the second given point x3/y3 (P3).
final void closePath()
Closes the current sub-path segment by drawing a straight line back to the coordinates of the last mo...
final void addEmptyOutline()
Add a new empty Outline to the end of this shape's outline list.
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
final void addOutlineShape(final OutlineShape shape, final AffineTransform t, final Vec4f rgbaColor)
Add the given OutlineShape to this region with the given optional AffineTransform.
static final int DEFAULT_AA_QUALITY
Default pass2 AA-quality rendering {@value} for Graph Region AA render-modes: VBAA_RENDERING_BIT.
static boolean hasColorChannel(final int renderModes)
Returns true if render mode has a color channel, i.e.
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...
static GLRegion create(final GLProfile glp, int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit, final int initialVerticesCount, final int initialIndicesCount)
Create a GLRegion using the passed render mode.
final void enable(final GL2ES2 gl, final boolean enable)
Enabling or disabling the RenderState's current shader program.
final void setColorStatic(final Vec4f rgbaColor)
final PMVMatrix4f getMatrix()
Borrow the current PMVMatrix4f.
final int setSampleCount(final int v)
Sets pass2 AA sample count clipped to the range [Region#MIN_AA_SAMPLE_COUNT..Region#MAX_AA_SAMPLE_COU...
static final GLCallback defaultBlendDisable
Default GL#GL_BLEND disable GLCallback, simply turning-off the GL#GL_BLEND state and turning-on depth...
final int setAAQuality(final int v)
Sets pass2 AA-quality rendering value clipped to the range [Region#MIN_AA_QUALITY....
static final GLCallback defaultBlendEnable
Default GL#GL_BLEND enable GLCallback, turning-off depth writing via GL#glDepthMask(boolean) if Rende...
static RegionRenderer create()
Create a hardware accelerated RegionRenderer including its RenderState composition.
final void setWeight(final float v)
final void setHintBits(final int mask)
The RenderState is owned by RegionRenderer.
static final int BITHINT_GLOBAL_DEPTH_TEST_ENABLED
Bitfield hint, if set stating globally enabled GL#GL_DEPTH_TEST, otherwise disabled.
4D Vector based upon four float components.
PMVMatrix4f implements the basic computer graphics Matrix4f pack using projection (P),...
final PMVMatrix4f translateMv(final float x, final float y, final float z)
Translate the modelview matrix.
final PMVMatrix4f rotateMv(final float ang_rad, final float x, final float y, final float z)
Rotate the modelview matrix by the given axis and angle in radians.
final PMVMatrix4f loadMvIdentity()
Load the modelview matrix with the values of the given Matrix4f.
Demonstrate the rendering of multiple outlines into one region/OutlineShape These Outlines are not ne...
GPURegionGLListener01(final int renderModes, final int sampleCount, final boolean debug, final boolean trace)
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
GPURegionGLListener01(final int shape_ctor_mode, final int renderModes, final int aaQuality, final int sampleCount, final boolean debug, final boolean trace)
final float getAngleRad()
final int getRenderModes()
void setMatrix(final float xtrans, final float ytrans, final float zTran, final float angle)
final RegionRenderer getRenderer()
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
GLProfile getGLProfile()
Returns the GLProfile associated with this GL object.
void setSwapInterval(int interval)
Set the swap interval of the current context and attached onscreen GLDrawable.
static final int GL_COLOR_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_COLOR_BUFFER_BIT" wit...
void glClearColor(float red, float green, float blue, float alpha)
Entry point to C language function: void {@native glClearColor}(GLfloat red, GLfloat green,...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expr...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
static final int GL_BLEND
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_BLEND" with expressio...
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...