28package com.jogamp.opengl.demos.graph;
30import java.io.IOException;
32import com.jogamp.opengl.GL2ES2;
33import com.jogamp.opengl.GLAutoDrawable;
34import com.jogamp.opengl.GLEventListener;
35import com.jogamp.common.util.StringUtil;
36import com.jogamp.graph.curve.Region;
37import com.jogamp.graph.curve.opengl.GLRegion;
38import com.jogamp.graph.curve.opengl.RenderState;
39import com.jogamp.graph.curve.opengl.RegionRenderer;
40import com.jogamp.graph.curve.opengl.TextRegionUtil;
41import com.jogamp.graph.font.Font;
42import com.jogamp.graph.font.FontFactory;
43import com.jogamp.graph.font.FontScale;
44import com.jogamp.graph.font.FontSet;
45import com.jogamp.math.geom.plane.AffineTransform;
46import com.jogamp.math.util.PMVMatrix4f;
47import com.jogamp.newt.Window;
55 private boolean exclusivePMVMatrix =
true;
57 private RegionRenderer.GLCallback enableCallback=
null, disableCallback=
null;
70 boolean flipVerticalInGLOrientation =
false;
78 public static Font getFont(
final int fontSet,
final int fontFamily,
final int fontStylebits) {
81 }
catch (
final IOException e) {
94 this.pass2SampleCount = sampleCount;
109 this.sharedPMVMatrix = pmv;
119 this.enableCallback = enable;
120 this.disableCallback = disable;
132 exclusivePMVMatrix =
null == sharedPMVMatrix;
143 if( upObj instanceof
Window ) {
154 if( exclusivePMVMatrix ) {
191 final Font font,
final float pixelSize,
final CharSequence text,
192 final int column,
final float tx,
final float ty,
final float tz,
final boolean cacheRegion) {
193 final int row = lastRow + 1;
194 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, cacheRegion,
null);
198 final Font font,
final float pixelSize,
final CharSequence text,
199 final int column,
final float tx,
final float ty,
final float tz,
final GLRegion region) {
200 final int row = lastRow + 1;
201 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz,
false, region);
218 final Font font,
final float pixelSize,
final CharSequence text,
219 final int column,
final int row,
220 final float tx,
final float ty,
final float tz,
final boolean cacheRegion) {
221 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, cacheRegion,
null);
225 final Font font,
final float pixelSize,
final CharSequence text,
226 final int column,
final int row,
227 final float tx,
final float ty,
final float tz,
final GLRegion region) {
228 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz,
false, region);
232 final Font font,
final float pixelSize,
final CharSequence text,
233 final int column,
final int row,
234 final float tx,
final float ty,
final float tz,
final boolean cacheRegion,
final GLRegion region) {
241 if( !exclusivePMVMatrix ) {
248 final int newLineCount = StringUtil.getLineCount(text);
251 dy -= sxy * lineHeight * ( row + 1 );
253 final PMVMatrix4f pmvMatrix =
getMatrix();
254 if( !exclusivePMVMatrix ) {
257 pmvMatrix.loadMvIdentity();
259 pmvMatrix.translateMv(dx, dy, tz);
260 if( flipVerticalInGLOrientation && drawable.
isGLOriented() ) {
261 pmvMatrix.scaleMv(sxy, -1f*sxy, 1.0f);
263 pmvMatrix.scaleMv(sxy, sxy, 1.0f);
268 }
else if(
null != region ) {
275 if( !exclusivePMVMatrix ) {
278 lastRow = row + newLineCount;
282 final Font font,
final float pixelSize,
283 final int column,
final int row,
284 final float tx,
final float ty,
final float tz,
final GLRegion region) {
291 if( !exclusivePMVMatrix ) {
300 dy -= sxy * lineHeight * ( row + 1 );
303 if( !exclusivePMVMatrix ) {
306 pmvMatrix.loadMvIdentity();
308 pmvMatrix.translateMv(dx, dy, tz);
309 if( flipVerticalInGLOrientation && drawable.
isGLOriented() ) {
310 pmvMatrix.scaleMv(sxy, -1f*sxy, 1.0f);
312 pmvMatrix.scaleMv(sxy, sxy, 1.0f);
318 if( !exclusivePMVMatrix ) {
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
static final int DEFAULT_AA_QUALITY
Default pass2 AA-quality rendering {@value} for Graph Region AA render-modes: VBAA_RENDERING_BIT.
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 void enable(final GL2ES2 gl, final boolean enable)
Enabling or disabling the RenderState's current shader program.
final void reshapeOrtho(final int width, final int height, final float near, final float far)
Orthogonal projection, method also calls reshapeNotify(int, int, int, int).
final void setColorStatic(final Vec4f rgbaColor)
final PMVMatrix4f getMatrix()
Borrow the current PMVMatrix4f.
final void reshapeNotify(final int x, final int y, final int width, final int height)
No PMVMatrix4f operation is performed here.
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...
final int setAAQuality(final int v)
Sets pass2 AA-quality rendering value clipped to the range [Region#MIN_AA_QUALITY....
final void init(final GL2ES2 gl)
Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext if no...
static RegionRenderer create()
Create a hardware accelerated RegionRenderer including its RenderState composition.
final void destroy(final GL2ES2 gl)
Deletes all ShaderPrograms and nullifies its references including RenderState#destroy(GL2ES2).
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.
Text Type Rendering Utility Class adding the Font.Glyphs OutlineShape to a GLRegion.
AABBox drawString3D(final GL2ES2 gl, final RegionRenderer renderer, final Font font, final CharSequence str, final Vec4f rgbaColor)
Render the string in 3D space w.r.t.
The optional property jogamp.graph.font.ctor allows user to specify the FontConstructor implementatio...
static final FontSet get(final int font)
Simple static font scale methods for unit conversions.
static float[] ppmmToPPI(final float[] ppmm)
Converts [1/mm] to [1/inch] in place.
PMVMatrix4f implements the basic computer graphics Matrix4f pack using projection (P),...
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final CharSequence text, final int column, final int row, final float tx, final float ty, final float tz, final GLRegion region)
void renderRegion(final GLAutoDrawable drawable, final Font font, final float pixelSize, final int column, final int row, final float tx, final float ty, final float tz, final GLRegion region)
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final CharSequence text, final int column, final float tx, final float ty, final float tz, final boolean cacheRegion)
final TextRegionUtil getTextRenderUtil()
final int pass2SampleCount
final RegionRenderer getRenderer()
TextRendererGLELBase(final int renderModes, final int sampleCount)
final AffineTransform tempT2
void setFlipVerticalInGLOrientation(final boolean v)
TextRegionUtil textRenderUtil
void setRendererCallbacks(final RegionRenderer.GLCallback enable, final RegionRenderer.GLCallback disable)
See RegionRenderer#create(Vertex.Factory<? extends Vertex>, RenderState, com.jogamp....
static Font getFont(final int fontSet, final int fontFamily, final int fontStylebits)
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void setSharedPMVMatrix(final PMVMatrix4f pmv)
In exclusive mode, impl.
float pixelScale
scale pixel, default is 1f
void reshape(final GLAutoDrawable drawable, 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.
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final CharSequence text, final int column, final int row, final float tx, final float ty, final float tz, final boolean cacheRegion)
final AffineTransform tempT1
final float[] staticRGBAColor
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final CharSequence text, final int column, final float tx, final float ty, final float tz, final GLRegion region)
abstract void display(GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
float dpiH
dpi display resolution, queried at init(GLAutoDrawable) if NEWT, otherwise 96.
May be passed to RegionRenderer ctor, e.g.
Font get(int family, int stylebits)
Interface wrapper for font implementation.
float getLineHeight()
Returns line height, baseline-to-baseline in em-size [0..1], composed from ‘hhea’ table entries.
int getGlyphID(final char codepoint)
Returns the Glyph ID mapped to given UTF16 (unicode) codepoint symbol.
float getAdvanceWidth(final int glyphID)
Returns advance-width of given glyphID in font em-size [0..1], sourced from hmtx table - same as Glyp...
Specifying NEWT's Window functionality:
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,...
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
boolean isGLOriented()
Returns true if the drawable is rendered in OpenGL's coordinate system, origin at bottom left.
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.