28package com.jogamp.opengl.test.junit.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.opengl.GLRegion;
37import com.jogamp.graph.curve.opengl.RenderState;
38import com.jogamp.graph.curve.opengl.RegionRenderer;
39import com.jogamp.graph.curve.opengl.TextRegionUtil;
40import com.jogamp.graph.font.Font;
41import com.jogamp.graph.font.FontFactory;
42import com.jogamp.graph.font.FontScale;
43import com.jogamp.graph.font.FontSet;
44import com.jogamp.math.geom.plane.AffineTransform;
45import com.jogamp.math.util.PMVMatrix4f;
46import com.jogamp.newt.Window;
54 private boolean exclusivePMVMatrix =
true;
56 private RegionRenderer.GLCallback enableCallback=
null, disableCallback=
null;
69 boolean flipVerticalInGLOrientation =
false;
77 public static Font getFont(
final int fontSet,
final int fontFamily,
final int fontStylebits) {
80 }
catch (
final IOException e) {
93 this.vbaaSampleCount = sampleCount;
108 this.sharedPMVMatrix = pmv;
118 this.enableCallback = enable;
119 this.disableCallback = disable;
128 exclusivePMVMatrix =
null == sharedPMVMatrix;
137 if( upObj instanceof
Window ) {
148 if( exclusivePMVMatrix ) {
185 final Font font,
final float pixelSize,
final String text,
186 final int column,
final float tx,
final float ty,
final float tz,
final boolean cacheRegion) {
187 final int row = lastRow + 1;
188 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, cacheRegion,
null);
192 final Font font,
final float pixelSize,
final String text,
193 final int column,
final float tx,
final float ty,
final float tz,
final GLRegion region) {
194 final int row = lastRow + 1;
195 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz,
false, region);
212 final Font font,
final float pixelSize,
final String text,
213 final int column,
final int row,
214 final float tx,
final float ty,
final float tz,
final boolean cacheRegion) {
215 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz, cacheRegion,
null);
219 final Font font,
final float pixelSize,
final String text,
220 final int column,
final int row,
221 final float tx,
final float ty,
final float tz,
final GLRegion region) {
222 renderStringImpl(drawable, font, pixelSize, text, column, row, tx, ty, tz,
false, region);
226 final Font font,
final float pixelSize,
final CharSequence text,
227 final int column,
final int row,
228 final float tx,
final float ty,
final float tz,
final boolean cacheRegion,
final GLRegion region) {
235 if( !exclusivePMVMatrix ) {
242 final int newLineCount = StringUtil.getLineCount(text);
245 dy -= sxy * lineHeight * ( row + 1 );
248 if( !exclusivePMVMatrix ) {
254 if( flipVerticalInGLOrientation && drawable.
isGLOriented() ) {
255 pmvMatrix.
scaleMv(sxy, -1f*sxy, 1.0f);
257 pmvMatrix.
scaleMv(sxy, sxy, 1.0f);
262 }
else if(
null != region ) {
269 if( !exclusivePMVMatrix ) {
272 lastRow = row + newLineCount;
A GLRegion is the OGL binding of one or more OutlineShapes Defined by its vertices and generated tria...
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 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),...
final PMVMatrix4f translateMv(final float x, final float y, final float z)
Translate the modelview matrix.
final PMVMatrix4f scaleMv(final float x, final float y, final float z)
Scale the modelview matrix.
final PMVMatrix4f loadMvIdentity()
Load the modelview matrix with the values of the given Matrix4f.
final PMVMatrix4f pushMv()
Push the modelview matrix to its stack, while preserving its values.
final RegionRenderer getRenderer()
final AffineTransform tempT2
TextRegionUtil textRenderUtil
TextRendererGLELBase(final int renderModes, final int[] sampleCount)
final AffineTransform tempT1
float pixelScale
scale pixel, default is 1f
void setFlipVerticalInGLOrientation(final boolean v)
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final String text, final int column, final float tx, final float ty, final float tz, final GLRegion region)
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final String text, final int column, final int row, final float tx, final float ty, final float tz, final boolean cacheRegion)
final float[] staticRGBAColor
final TextRegionUtil getTextRenderUtil()
void setSharedPMVMatrix(final PMVMatrix4f pmv)
In exclusive mode, impl.
final int[] vbaaSampleCount
static Font getFont(final int fontSet, final int fontFamily, final int fontStylebits)
abstract void display(GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
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.
float dpiH
dpi display resolution, queried at init(GLAutoDrawable) if NEWT, otherwise 96.
void setRendererCallbacks(final RegionRenderer.GLCallback enable, final RegionRenderer.GLCallback disable)
See RegionRenderer#create(Vertex.Factory<? extends Vertex>, RenderState, com.jogamp....
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final String text, final int column, final float tx, final float ty, final float tz, final boolean cacheRegion)
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final String text, final int column, final int row, final float tx, final float ty, final float tz, final GLRegion region)
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.