29package com.jogamp.opengl.test.junit.graph;
31import com.jogamp.opengl.GL;
32import com.jogamp.opengl.GL2ES2;
33import com.jogamp.opengl.GLAutoDrawable;
34import com.jogamp.graph.curve.OutlineShape;
35import com.jogamp.graph.curve.Region;
36import com.jogamp.graph.curve.opengl.GLRegion;
37import com.jogamp.graph.curve.opengl.RenderState;
38import com.jogamp.math.Vec4f;
39import com.jogamp.math.geom.plane.Path2F;
40import com.jogamp.math.geom.plane.WindingRule;
41import com.jogamp.math.util.PMVMatrix4f;
42import com.jogamp.graph.curve.opengl.RegionRenderer;
52 final int shape_ctor_mode;
55 public GPURegionGLListener01 (
final int renderModes,
final int aaQuality,
final int sampleCount,
final boolean debug,
final boolean trace) {
56 this(1, renderModes, aaQuality, sampleCount, debug, trace);
59 public GPURegionGLListener01 (
final int shape_ctor_mode,
final int renderModes,
final int aaQuality,
final int sampleCount,
final boolean debug,
final boolean trace) {
61 this.shape_ctor_mode = shape_ctor_mode;
68 private void createTestOutline00(){
69 outlineShape.
addVertex(0.0f,-10.0f,
true);
70 outlineShape.
addVertex(15.0f,-10.0f,
true);
71 outlineShape.
addVertex(10.0f,5.0f,
false);
72 outlineShape.
addVertex(15.0f,10.0f,
true);
73 outlineShape.
addVertex(6.0f,15.0f,
false);
79 outlineShape.
addVertex(10.0f,-5.0f,
false);
85 final float offset = 30;
87 outlineShape.
addVertex(offset+0.0f,-10.0f,
true);
88 outlineShape.
addVertex(offset+17.0f,-10.0f,
true);
89 outlineShape.
addVertex(offset+11.0f,5.0f,
true);
90 outlineShape.
addVertex(offset+16.0f,10.0f,
true);
91 outlineShape.
addVertex(offset+7.0f,15.0f,
true);
92 outlineShape.
addVertex(offset+6.0f,8.0f,
true);
93 outlineShape.
addVertex(offset+0.0f,10.0f,
true);
96 outlineShape.
addVertex(offset+5.0f,0.0f,
true);
97 outlineShape.
addVertex(offset+5.0f,-5.0f,
true);
98 outlineShape.
addVertex(offset+10.0f,-5.0f,
true);
99 outlineShape.
addVertex(offset+10.0f,0.0f,
true);
103 private void createTestOutline01(){
104 outlineShape.
moveTo(0.0f,-10.0f, 0f);
105 outlineShape.
lineTo(15.0f,-10.0f, 0f);
106 outlineShape.
quadTo(10.0f,5.0f,0f, 15.0f,10.0f,0f);
107 outlineShape.
cubicTo(6.0f,15.0f,0f, 5.0f,8.0f,0f, 0.0f,10.0f,0f);
109 outlineShape.
moveTo(5.0f,-5.0f,0f);
110 outlineShape.
quadTo(10.0f,-5.0f,0f, 10.0f,0.0f,0f);
111 outlineShape.
quadTo(5.0f,0.0f,0f, 5.0f,-5.0f,0f);
115 final float offset = 30;
116 outlineShape.
moveTo(offset+0.0f,-10.0f,0f);
117 outlineShape.
lineTo(offset+17.0f,-10.0f,0f);
118 outlineShape.
lineTo(offset+11.0f,5.0f,0f);
119 outlineShape.
lineTo(offset+16.0f,10.0f,0f);
120 outlineShape.
lineTo(offset+7.0f,15.0f,0f);
121 outlineShape.
lineTo(offset+6.0f,8.0f,0f);
122 outlineShape.
lineTo(offset+0.0f,10.0f,0f);
124 outlineShape.
moveTo(offset+5.0f,0.0f,0f);
125 outlineShape.
lineTo(offset+5.0f,-5.0f,0f);
126 outlineShape.
lineTo(offset+10.0f,-5.0f,0f);
127 outlineShape.
lineTo(offset+10.0f,0.0f,0f);
131 private void createTestOutline02(){
132 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
133 path.moveTo(0.0f,-10.0f);
134 path.lineTo(15.0f,-10.0f);
135 path.quadTo(10.0f,5.0f, 15.0f,10.0f);
136 path.cubicTo(6.0f,15.0f, 5.0f,8.0f, 0.0f,10.0f);
138 path.moveTo(5.0f,-5.0f);
139 path.quadTo(10.0f,-5.0f, 10.0f,0.0f);
140 path.quadTo(5.0f,0.0f, 5.0f,-5.0f);
144 final float offset = 30;
145 path.moveTo(offset+0.0f,-10.0f);
146 path.lineTo(offset+17.0f,-10.0f);
147 path.lineTo(offset+11.0f,5.0f);
148 path.lineTo(offset+16.0f,10.0f);
149 path.lineTo(offset+7.0f,15.0f);
150 path.lineTo(offset+6.0f,8.0f);
151 path.lineTo(offset+0.0f,10.0f);
153 path.moveTo(offset+5.0f,0.0f);
154 path.lineTo(offset+5.0f,-5.0f);
155 path.lineTo(offset+10.0f,-5.0f);
156 path.lineTo(offset+10.0f,0.0f);
159 System.err.println(
"GPURegionGLListener01.createTestOutline02.X: path "+path);
160 path.printSegments(System.err);
161 outlineShape.
addPath(path,
false );
164 private void createTestOutline03(){
166 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
167 path.moveTo(0.0f,-10.0f);
168 path.lineTo(15.0f,-10.0f);
169 path.quadTo(10.0f,5.0f, 15.0f,10.0f);
170 path.cubicTo(6.0f,15.0f, 5.0f,8.0f, 0.0f,10.0f);
172 System.err.println(
"GPURegionGLListener01.createTestOutline03.0: path "+path);
173 path.printSegments(System.err);
175 final Path2F path2 =
new Path2F(WindingRule.NON_ZERO);
176 path2.moveTo(5.0f,-5.0f);
177 path2.quadTo(10.0f,-5.0f, 10.0f,0.0f);
178 path2.quadTo(5.0f,0.0f, 5.0f,-5.0f);
180 System.err.println(
"GPURegionGLListener01.createTestOutline03.0: path2 "+path2);
181 path2.printSegments(System.err);
182 path.append(path2,
false);
183 System.err.println(
"GPURegionGLListener01.createTestOutline03.1: path "+path);
184 path.printSegments(System.err);
186 outlineShape.
addPath(path,
false );
190 final float offset = 30;
191 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
192 path.moveTo(offset+0.0f,-10.0f);
193 path.lineTo(offset+17.0f,-10.0f);
194 path.lineTo(offset+11.0f,5.0f);
195 path.lineTo(offset+16.0f,10.0f);
196 path.lineTo(offset+7.0f,15.0f);
197 path.lineTo(offset+6.0f,8.0f);
198 path.lineTo(offset+0.0f,10.0f);
200 path.moveTo(offset+5.0f,0.0f);
201 path.lineTo(offset+5.0f,-5.0f);
202 path.lineTo(offset+10.0f,-5.0f);
203 path.lineTo(offset+10.0f,0.0f);
205 System.err.println(
"GPURegionGLListener01.createTestOutline03.3: path "+path);
206 path.printSegments(System.err);
207 outlineShape.
addPath(path,
false );
212 private void createTestOutline04(){
213 final Path2F path =
new Path2F(WindingRule.NON_ZERO);
215 path.moveTo(0.0f,10.0f);
216 path.cubicTo(5.0f,8.0f, 6.0f,15.0f, 15.0f,10.0f);
217 path.quadTo(10.0f,5.0f, 15.0f,-10.0f);
218 path.lineTo(0.0f,-10.0f);
220 path.moveTo(5.0f,-5.0f);
221 path.quadTo(5.0f,0.0f, 10.0f,0.0f);
222 path.quadTo(10.0f,-5.0f, 5.0f,-5.0f);
226 final float offset = 30;
227 path.moveTo(offset+0.0f,10.0f);
228 path.lineTo(offset+6.0f,8.0f);
229 path.lineTo(offset+7.0f,15.0f);
230 path.lineTo(offset+16.0f,10.0f);
231 path.lineTo(offset+11.0f,5.0f);
232 path.lineTo(offset+17.0f,-10.0f);
233 path.lineTo(offset+0.0f,-10.0f);
235 path.moveTo(offset+10.0f,0.0f);
236 path.lineTo(offset+10.0f,-5.0f);
237 path.lineTo(offset+5.0f,-5.0f);
238 path.lineTo(offset+5.0f,0.0f);
241 System.err.println(
"GPURegionGLListener01.createTestOutline04.X: path "+path);
242 path.printSegments(System.err);
248 super.init(drawable);
258 switch( shape_ctor_mode ) {
260 createTestOutline00();
263 createTestOutline02();
266 createTestOutline03();
269 createTestOutline04();
272 createTestOutline01();
294 regionRenderer.
enable(gl,
true);
296 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.
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 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...
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
GPURegionGLListener01(final int renderModes, final int aaQuality, final int sampleCount, final boolean debug, final boolean trace)
GPURegionGLListener01(final int shape_ctor_mode, final int renderModes, final int aaQuality, final int sampleCount, final boolean debug, final boolean trace)
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
final float getAngleRad()
void setMatrix(final float xtrans, final float ytrans, final float zTran, final float angle)
final int getRenderModes()
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...