@ThreadSafe public class JOGLDisplay extends Display3D
A JOGL implementation of Display3D
.
In addition to providing direct access to the OpenGL context, this class
implements immediate-mode rendering for Java3D scene graphs (partial
support) and/or JOGLGeometry
and Widget
s.
Some parts of Java3D, for example the loaders, may still be useful even
when JOGLDisplay
is used for all rendering. To prevent Java3D code
from trying to load its own native libraries, which has been observed even
when not directly using the Java3D renderer, do this before making any
Java3D calls: J3DUtils.setPreferredPipeline("noop");
or J3DUtils.setPreferredPipeline("jogl");
J3DUtils.restoreJOGLSingleThreading()
.
Though this class contains significant generic rendering code for Widget
s, JOGLGeometry
, and Java3D Geometry
and Appearance
s, it is also possible for a subclass to provide a custom impl of
Display3D.renderImpl()
which does not use this generic code, or which mixes in
custom OGL calls on gl
. In the latter case care must be taken when
modifying OGL state, since the generic render code caches some state to
reduce JNI. In general, the custom code should call the setGL*()
,
enableGL*()
, and applyAttrs(*)
APIs where they exist rather
than directly mutating the OGL state, since these also update the cached
values.
This class is designed to be thread safe. The lock acquisition order for
deadlock avoidance is the same as Display3D
.
If by-ref geometry (e.g. JOGLGeometry
) is rendered then it is
important that its data is not mutated until after the subsequent glFinish()
. See finishPending
, scheduleGeometryMutator(java.lang.Runnable)
,
and the doPreFinish and doPostFinish constructor
arguments.
CompressedGeometry, Raster, Text3D
Copyright (C) 2007 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Display3D.Driver, Display3D.QueuedGeometry
Modifier and Type | Field and Description |
---|---|
protected int |
accumAlphaBits
extra OGL canvas config state
|
protected int |
accumBlueBits
extra OGL canvas config state
|
protected boolean |
accumBufferAvailable
accum buffer status
|
protected boolean |
accumBufferClearEnabled
enable for indicated option in
clearDrawingBuffer() |
protected boolean |
accumBufferGood
accum buffer status
|
protected int |
accumGreenBits
extra OGL canvas config state
|
protected int |
accumRedBits
extra OGL canvas config state
|
protected java.util.List<TimeMetrics> |
allJOGLExtendedRenderMetrics
all JOGL-specific extended render metrics
|
protected int |
alphaBits
extra OGL canvas config state
|
protected float |
ambientLightIntensity
current bg and light params
|
protected boolean |
ambientLightIntensityChangePending
dirty flags for bg and light params
|
protected javax.media.j3d.Appearance[] |
appearanceState
|
protected boolean |
appliedFirstAppearance
Whether any appearance has ever been applied to the current OGL
context.
|
protected TimeMetrics |
applyAppearanceMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected int[] |
arrayCount
Temp storage for geometry array counts.
|
protected float[] |
backgroundColor
current bg and light params
|
protected boolean |
backgroundColorChangePending
dirty flags for bg and light params
|
protected boolean |
blendEnabled
cache of OGL state
|
protected javax.vecmath.Color3f |
cC3f
Temp storage.
|
protected double[] |
cmtMatrix
Temp storage for applying
Display3D.cmtRX and Display3D.cmtScale to
OGL. |
protected java.nio.FloatBuffer |
colorBuf
Temp storage for vertex data.
|
protected javax.media.j3d.ColoringAttributes[] |
coloringAttrs
|
protected boolean |
colorMaterialEnabled
cache of OGL state
|
protected boolean |
consedConfinedStateGL
Whether the various render-thread confined state has been consed
yet.
|
static int |
CURRENT
appearance collection indices
|
protected int |
currentColorMaterial
cache of OGL state
|
protected RX |
currentModelViewRX
cache of OGL state
|
protected float |
currentModelViewScale
cache of OGL state
|
protected java.util.concurrent.CountDownLatch |
currentRenderLatch
renderLatch that was current at start of render. |
private static java.lang.String |
cvsid |
static int |
DEF_MIN_ACCUM_ALPHA_BITS
additional canvas defaults
|
static int |
DEF_MIN_ACCUM_BLUE_BITS
additional canvas defaults
|
static int |
DEF_MIN_ACCUM_GREEN_BITS
additional canvas defaults
|
static int |
DEF_MIN_ACCUM_RED_BITS
additional canvas defaults
|
static int |
DEFAULT
appearance collection indices
|
protected boolean |
depthTestEnabled
cache of OGL state
|
protected boolean |
differentThreadsWarningIssued
Whether the indicated warning has already been issued.
|
protected float[] |
directionalLightDirection
current bg and light params
|
protected boolean |
directionalLightDirectionChangePending
dirty flags for bg and light params
|
protected float |
directionalLightIntensity
current bg and light params
|
protected boolean |
directionalLightIntensityChangePending
dirty flags for bg and light params
|
static float |
DISABLE_ACCUM_BUFFER_FACTOR
If the rendering time is greater than
DISABLE_ACCUM_BUFFER_THRESHOLD and has increased by more than
DISABLE_ACCUM_BUFFER_FACTOR upon first render of a frame with
masked geometries using the accumulation buffer (e.g. |
static float |
DISABLE_ACCUM_BUFFER_THRESHOLD
|
protected boolean |
doPostFinish
|
protected boolean |
doPreFinish
|
protected TimeMetrics |
drawArraysMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
drawDisableColorWrite
enable for indicated option in
drawGeometry(Geometry, float) |
protected boolean |
drawDisableDepthTest
enable for indicated option in
drawGeometry(Geometry, float) |
protected boolean |
drawDisableDepthWrite
enable for indicated option in
drawGeometry(Geometry, float) |
protected TimeMetrics |
drawElementsMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
drawGeometryAccessorMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
drawGeometryArrayMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
drawGeometryMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
drawGeometryMultiTextureWarningIssued
Whether the indicated warning has already been issued.
|
protected boolean |
drawGeometryVertexAttrsWarningIssued
Whether the indicated warning has already been issued.
|
protected java.util.Set<java.lang.Class> |
drawGeometryWarningsIssued
Unhandled geometry classes for which warnings have already been
issued.
|
protected TimeMetrics |
drawJOGLGeometryMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
drawUnoptimizedMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected java.util.concurrent.CountDownLatch |
finishLatch
used to block thread calling
finish(boolean, boolean) until render complete |
protected java.lang.Object |
finishLock
synchronization object for
finishLatch and finishPending read-modify-write. |
protected TimeMetrics |
finishMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
finishPending
Whether
finish(boolean, boolean) should really do a glFinish() . |
protected boolean |
finishWarningIssued
Whether the indicated warning has already been issued.
|
protected boolean |
forceDisableAccumBuffer
accum buffer status
|
static java.lang.String |
FRAME_SAVE_FILE_EXT
filename extension for
grabAndSaveFrame(java.io.File, java.lang.String, int, boolean) |
static java.text.DecimalFormat |
FRAME_SAVE_INDEX_FORMAT
filename index format for
grabAndSaveFrame(java.io.File, java.lang.String, int, boolean) |
protected boolean |
frameDroppingEnabled
enable for indicated option
|
protected java.util.Queue<java.lang.Runnable> |
geometryMutators
currently queued geometry mutator tasks, see class header doc
|
protected javax.media.opengl.GL2 |
gl
The current JOGL object.
|
protected javax.media.opengl.awt.GLCanvas |
glCanvas
the JOGL canvas
|
protected javax.media.opengl.GLContext |
glContext
The current JOGL rendering context.
|
protected boolean |
glDrawingEnabled
enable for indicated option
|
protected javax.media.opengl.GLEventListener |
glEventListener
the JOGL event listener on
glCanvas |
protected java.lang.String |
glRendererString
OGL version info
|
protected java.lang.String |
glVendorString
OGL version info
|
protected java.lang.String |
glVersionString
OGL version info
|
protected boolean |
ignoreNullAppearance
Enable for indicated option in
applyAppearance(Appearance,
boolean, float, boolean, boolean) . |
static int |
INITIAL_ARRAY_COUNT_CAPACITY
initial capacity for the
arrayCount array |
static int |
INITIAL_BUF_CAPACITY
initial capacity for buffers
|
protected boolean |
isOpenGLThreadWarningIssued
Whether the indicated warning has already been issued.
|
protected boolean |
j3d14Available
Whether Java3D version >= 1.4 is available
|
protected boolean |
jogl2Available
Whether JOGL version >= 2.0 is available
|
protected TimeMetrics |
joglRenderDepthOnlyMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
joglRenderTransparentMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
lightingEnabled
cache of OGL state
|
protected javax.media.j3d.LineAttributes[] |
lineAttrs
|
protected javax.media.j3d.Material[] |
materialAttrs
|
protected javax.vecmath.Color3f |
nC3f
Temp storage.
|
protected java.nio.FloatBuffer |
normalBuf
Temp storage for vertex data.
|
protected int |
numDroppedFrames
number of dropped frames, iff
frameDroppingEnabled |
protected int |
numJOGLGeometries
scene metrics, collected on each
render() |
protected int |
numMaskedGeometriesWas
prev num masked geometries, see
DISABLE_ACCUM_BUFFER_FACTOR |
protected int |
numOptimizedGeometries
scene metrics, collected on each
render() |
protected int |
numVisiblePrims
scene metrics, collected on each
render() |
protected javax.media.j3d.PointAttributes[] |
pointAttrs
|
protected boolean |
pointLineAAWarningIssued
Whether the indicated warning has already been issued.
|
protected javax.media.j3d.PolygonAttributes[] |
polygonAttrs
|
protected boolean |
primCountingEnabled
enable for indicated option
|
protected boolean |
releaseRenderCallingThreadBeforeSwap
Whether to release the thread calling
render() at the beginning
of swapBuffers() . |
protected TimeMetrics |
renderCallMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
renderImplMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected javax.media.j3d.RenderingAttributes[] |
renderingAttrs
|
protected java.util.concurrent.CountDownLatch |
renderLatch
used to block thread calling
render() until render complete |
protected boolean |
renderOngoing
whether a render is currently underway
|
protected java.lang.Thread |
renderThread
The JOGL render thread.
|
protected TimeMetrics |
renderWaitMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
requestDelayMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected TimeMetrics |
requestRepaintMetrics
JOGL-specific extended render metrics, if compiled with
Display3D.ENABLE_EXTENDED_RENDER_METRICS . |
protected boolean |
screenDoorWarningIssued
Whether the indicated warning has already been issued.
|
protected boolean |
shaderWarningIssued
Whether the indicated warning has already been issued.
|
protected boolean |
singleThreadedWarningIssued
Whether the indicated warning has already been issued.
|
protected boolean[] |
tempB4
Temp storage.
|
protected javax.vecmath.Color3f |
tempC3f
Temp storage.
|
protected javax.vecmath.Color4f |
tempC4f
Temp storage.
|
protected int[] |
tempI3
Temp storage.
|
protected int[] |
tempI4
Temp storage.
|
protected int[] |
tempI5
Temp storage.
|
protected float[] |
tempV3
Temp storage.
|
protected float[] |
tempV4
Temp storage.
|
protected java.nio.FloatBuffer |
texCoordBuf
Temp storage for vertex data.
|
protected boolean |
textureWarningIssued
Whether the indicated warning has already been issued.
|
static int |
TRACE_GL_EN
trace flags
|
static int |
TRACE_JOGL_EN
trace flags
|
static int |
TRACE_VERTICES_EN
trace flags
|
protected int |
traceFlagsPending
trace flags waiting to be set on next
render() |
protected javax.media.j3d.TransparencyAttributes[] |
transparencyAttrs
|
protected boolean |
tryEnableAccumBuffer
accum buffer status
|
protected java.util.Set<java.util.List<java.lang.Object>> |
vertexAcessorWarningIssued
Classes with no implemented vertex accessors for which warnings have
already been issued.
|
protected java.nio.FloatBuffer |
vertexBuf
Temp storage for vertex data.
|
static long |
WAIT_TIMEOUT_MS
timeout for thread waits
|
accumPass1Metrics, accumPass2Metrics, ALL_COMPONENTS, allExtendedRenderMetrics, ambientAlpha, applyProjectionPending, applyWidgetRX, blueBits, canvas, canvasMouseLock, canvasMouseX, canvasMouseY, canvasSize, clearMetrics, cmtRX, cmtScale, COORD_ONLY, dbgAppearance, dbgSceneExtentsEnabled, dbgSceneExtentsRect, DEF_AMBIENT_LIGHT_INTENSITY, DEF_DIRECTIONAL_LIGHT_DIRECTION, DEF_DIRECTIONAL_LIGHT_INTENSITY, DEF_HIGHLIGHT_COLOR, DEF_HIGHLIGHT_FACTOR, DEF_MASK_ALPHA, DEF_PICK_THRESHOLD_PIXELS, DEF_VIEW_SCALE, DEF_Z_CLIP, defaultHighlightedAppearance, defaultHighlightedMaterial, defaultRotationCenter, defaultTransparentAppearance, defaultViewScale, defaultViewTXEM, depthBits, depthOnlyAppearance, depthRenderMaskedQueueEnabled, depthSortTransparentEnabled, drawingEnabled, dumpRenderMetricsPending, dumpSceneMetricsPending, emissiveColorWas, ENABLE_EXTENDED_RENDER_METRICS, ensureWidgetBoundingSpheresInViewEnabled, environmentLock, fitPending, frameSaveCount, frameSaveDirectory, frameSaveFPS, frameSaveLastTime, frameSaveLock, frameSaveMetrics, frameSaveNextIndex, frameSaveNextTime, frameSavePrefix, frameSaveStartTime, frameSaveWithCursor, frameTime, freezeSceneMetrics, freezeTransparentQueue, freezeWidgetBounds, frustumCullEnabled, greenBits, highlightColor, highlightFactor, highlightingEnabled, indexAccessors, lastFrameEndTime, LOCAL_TO_WORLD_STACK_INITIAL_CAPACITY, localToWorldRX, localToWorldStack, localToWorldStackSize, longFrameWarningThreshold, maskAlpha, maskedQueue, maskedQueueSize, maskingEnabled, MAX, MIN, navigationEnabled, newEmissiveColor, NUM_RECENT_METRICS, numDisabledWidgetGeometries, numFrames, numHighlightedGeometries, numMaskedGeometries, numPickableGeometries, numPickBoundsHits, numPickedGeometries, numPickGeometryHits, numSamples, numSceneGeometries, numSceneWidgets, numTransparentGeometries, numVisibleGeometries, passAlpha, pickBoundsOnly, pickExtentInLocal, pickExtentInView, pickGeometryMetrics, pickingEnabled, pickSegmentInLocalDirty, pickSegmentIntersectionsOnly, pickSegmentInViewPerpCanvas, pickSegmentLock, pickStartInLocal, pickStartInView, pickThresholdPixels, pickVisibleBoundsOnly, postRenderMetrics, premultipliedHighlightColor, premultiplyPassAlpha, preRenderMetrics, primitiveIterators, projectionLock, QUEUE_INITIAL_CAPACITY, recentCycleTime, recentCycleTimeWriteIndex, recentFrameTime, recentFrameTimeWriteIndex, redBits, renderDepthOnlyMetrics, renderDepthOnlyQueueMetrics, renderGeometryMetrics, renderHighlightedMetrics, renderImplPostSceneMetrics, renderImplPreSceneMetrics, renderInViewMetrics, renderMaskedGeometry, renderMetricsLock, renderSceneMetrics, renderTransparentMetrics, renderTransparentQueue1Metrics, renderTransparentQueue2Metrics, renderWidgetGeometryMetrics, renderWidgetMetrics, resetPickMetricsEveryRender, resetRenderMetricsPending, rxsInteractor, rxsInterpolator, sceneAABBInView, sceneMetricsLock, SCREEN_METERS_PER_PIXEL, SQRT3F, stencilBits, swapMetrics, TRACE_GENERIC_EN, TRACE_PICKING_EN, traceFlags, traceStream, transformWidgetBounds, transparentQueue, transparentQueueSize, unsetPickSegmentAfterRender, unsetPickSegmentOnProjectionChange, unsetPickSegmentOnWorldToViewChange, updateNavMetrics, updateProjectionMetrics, vertexAccessors, viewAABB, viewToCanvasScale, worldToViewRX, worldToViewRXTemp, worldToViewScale
Constructor and Description |
---|
JOGLDisplay(java.awt.GraphicsDevice device,
int width,
int height,
int minRedBits,
int minGreenBits,
int minBlueBits,
int minDepthBits,
int minStencilBits,
int minNumSamples,
int minAccumRedBits,
int minAccumGreenBits,
int minAccumBlueBits,
int minAccumAlphaBits,
boolean doPreFinish,
boolean doPostFinish)
Makes a new
JOGLDisplay with the given specs. |
Modifier and Type | Method and Description |
---|---|
protected void |
accumPass()
This impl does a
glAccum(GL_ACCUM, passAlpha) if accumBufferGood and not Display3D.premultiplyPassAlpha . |
protected void |
applyAppearance(javax.media.j3d.Appearance a)
Covers
applyAppearance(Appearance, boolean, float, boolean,
boolean) , diff only, with color write, no vertex colors, no extra
alpha. |
protected void |
applyAppearance(javax.media.j3d.Appearance a,
boolean diffOnly,
float extraAlpha,
boolean hasVertexColors)
Covers
applyAppearance(Appearance, boolean, float, boolean,
boolean) , with color write. |
protected void |
applyAppearance(javax.media.j3d.Appearance a,
boolean diffOnly,
float extraAlpha,
boolean hasVertexColors,
boolean noColorWrite)
Apply an appearance to OGL.
|
protected void |
applyAppearance(javax.media.j3d.Appearance a,
float extraAlpha)
Covers
applyAppearance(Appearance, boolean, float, boolean,
boolean) , diff only, with color write, no vertex colors. |
protected void |
applyAppearance(javax.media.j3d.Appearance a,
float extraAlpha,
boolean hasVertexColors)
Covers
applyAppearance(Appearance, boolean, float, boolean,
boolean) , diff only, with color write. |
protected void |
applyAttrs(javax.media.j3d.ColoringAttributes na)
Covers
applyAttrs(ColoringAttributes, boolean, float) , diff
only and no extra alpha. |
protected boolean |
applyAttrs(javax.media.j3d.ColoringAttributes na,
boolean diffOnly,
float extraAlpha)
Apply appearance attributes to OGL.
|
protected void |
applyAttrs(javax.media.j3d.ColoringAttributes na,
float extraAlpha)
Covers
applyAttrs(ColoringAttributes, float) , diff only. |
protected void |
applyAttrs(javax.media.j3d.LineAttributes na)
covers
applyAttrs(LineAttributes, boolean) , diff only |
protected boolean |
applyAttrs(javax.media.j3d.LineAttributes na,
boolean diffOnly)
Apply appearance attributes to OGL.
|
protected void |
applyAttrs(javax.media.j3d.Material nm)
Covers
applyAttrs(Material, boolean, float, boolean) , diff
only, no extra alpha, do not allow color material. |
protected boolean |
applyAttrs(javax.media.j3d.Material nm,
boolean diffOnly,
float extraAlpha,
boolean allowColorMaterial)
Apply appearance attributes to OGL.
|
protected void |
applyAttrs(javax.media.j3d.Material nm,
float extraAlpha)
Covers
applyAttrs(Material, boolean, float, boolean) , diff
only, do not allow color material. |
protected void |
applyAttrs(javax.media.j3d.Material nm,
float extraAlpha,
boolean allowColorMaterial)
Covers
applyAttrs(Material, boolean, float, boolean) , diff
only. |
protected void |
applyAttrs(javax.media.j3d.PointAttributes na)
Covers
applyAttrs(PointAttributes, boolean) , diff only. |
protected boolean |
applyAttrs(javax.media.j3d.PointAttributes na,
boolean diffOnly)
Apply appearance attributes to OGL.
|
protected void |
applyAttrs(javax.media.j3d.PolygonAttributes na)
Covers
applyAttrs(PolygonAttributes, boolean) , diff only. |
protected boolean |
applyAttrs(javax.media.j3d.PolygonAttributes na,
boolean diffOnly)
Apply appearance attributes to OGL.
|
protected void |
applyAttrs(javax.media.j3d.RenderingAttributes na)
Covers
applyAttrs(RenderingAttributes, boolean) , diff
only. |
protected boolean |
applyAttrs(javax.media.j3d.RenderingAttributes na,
boolean diffOnly)
Apply appearance attributes to OGL.
|
protected void |
applyAttrs(javax.media.j3d.TransparencyAttributes na)
Covers
applyAttrs(TransparencyAttributes, boolean) , diff
only. |
protected boolean |
applyAttrs(javax.media.j3d.TransparencyAttributes na,
boolean diffOnly)
Apply appearance attributes to OGL.
|
protected void |
applyCMT()
this impl applies
Display3D.cmtRX and Display3D.cmtScale to OGL |
protected void |
applyMaterialColor(int property,
javax.vecmath.Color3f c,
float alpha)
Apply a material color to OGL.
|
protected void |
applyProjection()
This impl applies the projection matrix to OGL, leaving the OGL matrix
mode in
GL_MODELVIEW . |
protected boolean |
blendedTransparencyMode(int transparencyMode)
Check if transparencyMode is to be implemented with alpha
blending (vs screen door).
|
protected void |
clearDrawingBuffer()
This impl clears the OGL color, depth, and stencil buffers.
|
protected boolean |
compositeCursorOntoBGR(int width,
int height,
java.nio.ByteBuffer bgr,
boolean yUp,
java.awt.Cursor cursor)
Composite cursor onto a BGR buffer representing the canvas, at
the current mouse location.
|
protected boolean |
dbgPipelineEnabled()
Hook to enable the debug pipeline at time of canvas init.
|
void |
disableAccumBuffer()
Forcibly disable use of the accumulation buffer, even if available and
currently considered usable.
|
protected void |
doFinish(boolean runPendingMutators)
Issue a
glFinish() . |
protected void |
draw(RX cmt,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float extraAlpha)
This is the JOGL-specific impl of the central
Display3D.draw(RX,
float, Geometry, Appearance, float) call in the generic renderer. |
protected void |
drawArrays(int mode,
int na,
int[] arrayCount)
draw un-indexed geometry already in vertex arrays to OGL
|
protected void |
drawElements(int mode,
int na,
int[] arrayCount,
int initialIndexIndex,
int[] indices)
draw indexed geometry already in vertex arrays to OGL
|
protected boolean |
drawEnable(javax.media.j3d.Geometry g)
Check for early-out of
drawGeometry(Geometry, float) . |
protected void |
drawGeometry(javax.media.j3d.Geometry g)
covers
drawGeometry(Geometry, float) , no extra alpha |
protected void |
drawGeometry(javax.media.j3d.GeometryArray a,
int mode,
int vf,
int na,
int[] arrayCount,
float geometryAlpha,
boolean applyVertexColors,
boolean indexed,
int numColorComponents,
boolean hasNormals)
Impl of
drawGeometry(Geometry, float) for GeometryArray s. |
protected void |
drawGeometry(javax.media.j3d.Geometry g,
float extraAlpha)
Do the actual drawing in a
draw(RX, float, Geometry,
Appearance, float) call. |
protected void |
drawGeometry(J3DVertexAccessor va,
int mode,
int na,
int[] arrayCount,
float geometryAlpha,
boolean applyVertexColors)
Draw a geometry to OGL vertex-by-vertex.
|
protected float |
drawGeometryAlpha(javax.media.j3d.Geometry g)
Figure out the alpha that
drawGeometry(Geometry, float) should
use for g, not including any extra alpha. |
protected javax.vecmath.Color4f |
drawGetUnlitColor(javax.media.j3d.Geometry g,
javax.vecmath.Color4f c)
Figure out the color that
drawGeometry(Geometry, float) should
use for g if unlit, not including any extra alpha. |
protected void |
drawUnoptimized(javax.media.j3d.Geometry g,
boolean indexed,
int mode,
int na,
int[] arrayCount,
float geometryAlpha,
boolean applyVertexColors)
Handles un-optimzed cases in
drawGeometry(Geometry, float) and
drawGeometry(GeometryArray, int, int, int, int[], float, boolean,
boolean, int, boolean) . |
protected boolean |
drawVertexColors(javax.media.j3d.Geometry g)
Check whether
drawGeometry(Geometry, float) should apply the
per-vertex colors of g, if any. |
void |
dumpCanvasProperties(java.io.PrintStream s)
extends super to dump additional properties
|
protected void |
dumpRenderMetricsImpl(java.io.PrintStream s)
extends super to dump additional metrics
|
protected void |
dumpSceneMetricsImpl(java.io.PrintStream s)
extends super to dump additional metrics
|
void |
enableAccumBufferIfAvailable()
Try enabling the accum buffer, if it is available.
|
protected boolean |
enableGLBlend(boolean enable)
Potentially mutate the OGL blend enable.
|
protected boolean |
enableGLColorMaterial(boolean enable)
Potentially mutate the OGL color material enable.
|
protected boolean |
enableGLDepthTest(boolean enable)
Potentially mutate the OGL depth test enable.
|
void |
enableGLDrawing(boolean enable)
enable or disable lowest-level OGL drawing calls
|
protected boolean |
enableGLLighting(boolean enable)
Potentially mutate the OGL lighting enable.
|
void |
enablePrimCounting(boolean enable)
enable primitive counting in scene metrics
|
protected void |
ensureConfinedStateGL()
If not
consedConfinedStateGL then cons all render-thread
confined heap-allocated state. |
protected java.nio.FloatBuffer |
fillBuffer(java.nio.FloatBuffer b,
float[] a,
int n)
Copy the first n elements of array a to the beginning of
buffer b.
|
void |
finish()
Covers
finish(boolean, boolean) , iff pending, does not
initiate. |
void |
finish(boolean initiate)
covers
finish(boolean, boolean) , iff pending |
void |
finish(boolean iffPending,
boolean initiate)
Block the calling thread until the renderer to hits the next
glFinish() . |
int |
getAccumAlphaBits()
get the bit width of the accum alpha buffer
|
int |
getAccumBlueBits()
get the bit width of the accum blue buffer
|
int |
getAccumGreenBits()
get the bit width of the accum green buffer
|
int |
getAccumRedBits()
get the bit width of the accum red buffer
|
protected int |
getAllRenderTraceFlags()
Hook to get combination of all trace flags that apply to the render
algorithm.
|
int |
getAlphaBits()
get the bit width of the alpha buffer
|
protected void |
getGLColorMask(boolean[] colorMask)
get current color buffer writemask from OGL
|
protected boolean |
getGLDepthMask()
get current depth buffer writemask from OGL
|
protected javax.vecmath.Color3f |
getGLMaterial(int property,
javax.vecmath.Color3f value)
covers
getGLMaterial(int, float[]) |
protected javax.vecmath.Color4f |
getGLMaterial(int property,
javax.vecmath.Color4f value)
covers
getGLMaterial(int, float[]) |
protected float[] |
getGLMaterial(int property,
float[] value)
Get a material color from OGL.
|
protected int |
getGLStencilMask()
get current stencil buffer writemask from OGL
|
protected int |
getPickCullFace(javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
Hook called by the smaller
pickGeometry(...) APIs to get the
pick cull face for the given geometry. |
protected boolean |
getPropertyOverride(java.lang.String property,
boolean def)
covers
getPropertyOverride(String, String) , gets a boolean |
protected int |
getPropertyOverride(java.lang.String property,
int def)
covers
getPropertyOverride(String, String) , gets an int |
protected java.lang.String |
getPropertyOverride(java.lang.String property,
java.lang.String def)
Get the value the indicated system property, prefixed with the
full name of this class.
|
protected int |
getVertexFormat(javax.media.j3d.Geometry g)
Get the vertex format of g for
drawGeometry(Geometry,
float) . |
protected java.io.File |
grabAndSaveFrame(java.io.File directory,
java.lang.String basename,
int index,
boolean withCursor)
Implementation hook to grab and save a frame.
|
boolean |
hasAccumBuffer()
check if OGL reports any accum buffer available
|
protected boolean |
hasVertexColors(javax.media.j3d.Geometry geometry)
check if geometry includes per-vertex colors
|
protected void |
issueDrawGeometryWarningMaybe(java.lang.Class c)
Issue an unhandled warning for geometry class c iff this is the
first time we've seen it.
|
protected int |
j3dToGLBlendFunc(int j3dBlendFunc)
convert a blend function from J3D to OGL
|
protected int |
j3dToGLLogicOp(int j3dLogicOp)
convert a logic op from J3D to OGL
|
protected int |
j3dToGLPolygonOffsetMode(int j3dPolygonMode)
convert a polygon offset mode from J3D to OGL
|
protected int |
j3dToGLStencilOp(int j3dStencilOp)
convert a stencil op from J3D to OGL
|
protected int |
j3dToGLTestFunc(int j3dTestFunc)
convert a test function from J3D to OGL
|
static void |
main(java.lang.String[] arg)
runs the interactive test driver
|
protected java.awt.Canvas |
makeCanvas(java.awt.GraphicsDevice device,
int minRedBits,
int minGreenBits,
int minBlueBits,
int minDepthBits,
int minStencilBits,
int minNumSamples)
uses [@link #DEF_MIN_ACCUM_RED_BITS} etc
|
protected java.awt.Canvas |
makeCanvas(java.awt.GraphicsDevice device,
int minRedBits,
int minGreenBits,
int minBlueBits,
int minDepthBits,
int minStencilBits,
int minNumSamples,
int minAccumRedBits,
int minAccumGreenBits,
int minAccumBlueBits,
int minAccumAlphaBits)
makes the canvas
|
protected void |
postRender(double renderTimeSoFar)
|
protected void |
preRender()
This impl does a
doFinish(boolean) iff doPreFinish , and
applies any pending bg or light changes. |
void |
render()
This impl blocks till any prior render cycle is complete, unless
frameDroppingEnabled , issues a repaint call on glCanvas , and
then blocks till the new render is complete, which is either when the
renderer has reached swapBuffers() , if releaseRenderCallingThreadBeforeSwap is set, or when the renderer has
reached the end of Display3D.renderImpl() otherwise. |
protected void |
renderDepthOnly(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance)
optimized with
drawDisableColorWrite |
protected void |
renderTransparent(RX cmtRX,
float cmtScale,
javax.media.j3d.Geometry geometry,
javax.media.j3d.Appearance appearance,
float extraAlpha,
boolean disableDepthWrite)
Optimized with
drawDisableDepthWrite , unless both highlighted
and has extra alpha. |
protected void |
resetRenderMetricsImpl()
extends super to reset additional metrics
|
protected void |
resetSceneMetrics(boolean resetPickMetrics)
extends super to reset additional metrics
|
protected void |
runGeometryMutators()
execute any pending
geometryMutators |
void |
scheduleGeometryMutator(java.lang.Runnable task)
Schedule task to run in a context where by-ref (e.g.
|
void |
setAmbientLightIntensity(float intensity)
this impl sets
ambientLightIntensity |
void |
setBackgroundColor(float... color)
this impl sets
backgroundColor |
void |
setDirectionalLightDirection(float... direction)
this impl sets
directionalLightDirection |
void |
setDirectionalLightIntensity(float intensity)
this impl sets
directionalLightIntensity |
protected boolean |
setGLColorMaterial(int mode)
Potentially mutate the OGL
GL_FRONT_AND_BACK color material
parameter. |
protected boolean |
setGLModelView(RX rx,
float scale)
Potentially mutate the OGL
GL_MODELVIEW matrix. |
protected void |
setTraceFlags(int flags)
hook to set
Display3D.traceFlags |
protected void |
swapBuffers()
This impl swaps the OGL buffers.
|
void |
traceNextFrame(boolean tracePicking,
boolean traceGeneric,
boolean traceJOGL,
boolean traceGL,
boolean traceVertices)
Enable tracing for next frame with given options.
|
protected boolean |
tracePipelineEnabled()
Hook to enable the trace pipeline at time of canvas init.
|
boolean |
usingAccumBuffer()
check if the accum buffer is currently considered usable
|
protected void |
writeToTargaFile(java.io.File file,
int width,
int height,
boolean withCursor)
Based on
com.sun.opengl.util.Screenshot.WriteToTargaFile(File,
int, int, boolean) but reimplimented to optionally composite cursor. |
addCanvasListeners, addToSceneMetrics, autoAddListenersToRXSInteractor, canvasToLocal, canvasToLocal, canvasToView, canvasToView, clearCMT, clearLocalToWorld, clearLocalToWorld, clearQueue, compareQueued, disableLongFrameWarningThreshold, doFit, draw, draw, draw, draw, draw, dump, dump, dumpAABB, dumpCanvasProperties, dumpCMT, dumpCMT, dumpHelp, dumpHelp, dumpHelp, dumpHelp, dumpInteractor, dumpInteractor, dumpLocalToWorld, dumpLocalToWorld, dumpPendingMetrics, dumpPickSegment, dumpPickSegment, dumpProjection, dumpProjection, dumpRenderMetrics, dumpRenderMetrics, dumpSceneMetrics, dumpSceneMetrics, dumpStats, dumpStats, dumpWorldToView, dumpWorldToView, enableDBGSceneExtents, enableDepthSortTransparent, enableDrawing, enableEnsureWidgetBoundingSpheresInView, enableFrustumCull, enableHighlighting, enableMasking, enableNavigation, enablePicking, enqueue, enqueueMaskedGeometry, enqueueTransparentGeometry, ensureDBGAppearance, fitView, getAmbientAlpha, getAvgRecentFPS, getBlueBits, getCanvas, getCanvasMouseLocation, getCanvasMouseLocation, getDefaultRotationCenter, getDefaultViewScale, getDefaultViewTXEM, getDepthBits, getGreenBits, getHighlightColor, getHighlightColor, getHighlightFactor, getIndexAccessorFor, getInfo, getLocalTranslationRXToPixel, getLocalTranslationRXToPixel, getLocalTranslationRXToPixel, getLocalTranslationRXToPixel, getMaskAlpha, getNumFrames, getNumFramesSaved, getNumSamples, getPickThreshold, getPickThresholdPixels, getPrimitiveIteratorFor, getPrimitiveIteratorFor, getRedBits, getStencilBits, getTranslationRXToPixel, getTranslationRXToPixel, getTranslationRXToPixel, getTranslationRXToPixel, getVertexAccessorFor, getVertexAccessorFor, getViewToCanvasScale, getZCenterInView, interpolateOnPickSegmentInLocal, interpolateOnPickSegmentInLocal, interpolateOnPickSegmentInView, interpolateOnPickSegmentInView, isDepthSortTransparentEnabled, isDrawingEnabled, isFrustumCullEnabled, isHighlighted, isHighlightingEnabled, isMasked, isMaskingEnabled, isNavigationEnabled, isPickable, isPickingEnabled, isPickSegmentSet, isSphereVisible, isTransparent, localToCanvas, localToCanvas, localToView, localToView, localToView, localToWorld, localToWorld, navigateToDefaultView, navigateToDefaultView, navigateToDefaultView, navigateToView, navigateToView, navigateToView, navigateToView, picked, pickGeometry, pickGeometry, pickGeometry, pickSphereInView, pickSphereInView, popLocalToWorld, popLocalToWorld, postMasking, postScene, postSwap, prependInverseLocalToWorld, prependInverseLocalToWorld, prependLocalToWorld, prependLocalToWorld, preSwap, projectionChanged, pushLocalToWorld, recenterZ, recenterZ, render, render, render, render, render, render, render, render, renderAccept, renderDepthOnly, renderDepthOnly, renderHighlighted, renderImpl, renderInView, renderScene, renderTransparent, renderTransparent, renderTransparent, rePicking, resetPendingMetrics, resetPickMetrics, resetRenderMetrics, rotateAboutDefaultCenter, saveFrame, saveFrame, saveFrame, saveFrameFailed, saveFrameFinished, saveNextFrame, saveNextFrame, saveNextFrame, setAmbientAlpha, setCanvas, setCanvasSize, setCanvasSize, setCMT, setDefaultRotationCenter, setDefaultView, setDefaultViewScale, setDefaultViewTXEM, setDefaultViewTXEMS, setHighlightColor, setHighlightFactor, setLocalToWorld, setLocalToWorld, setLongFrameWarningThreshold, setMaskAlpha, setPickPointOnCanvas, setPickSegmentInView, setPickThresholdPixels, setSymmetricZClip, setTraceOptions, setTraceOptions, setViewInMeters, setViewInPixels, setViewToCanvasScale, setZClip, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, startSavingFrames, stopSavingFrames, traceNextFrame, traceNextFrame, traceNextPickingFrame, unsetPickSegment, updateCMT, updateHighlightedMaterial, updatePickSegmentInLocal, updateProjection, updateWorldToView, updateWorldToView, viewToCanvas, viewToCanvas, viewToLocal, viewToLocal, viewToLocal, viewToWorld, viewToWorld, viewToWorld, worldToLocal, worldToLocal, worldToView, worldToView, worldToView, worldToViewChanged, worldToViewDirty
private static final java.lang.String cvsid
public static final java.text.DecimalFormat FRAME_SAVE_INDEX_FORMAT
grabAndSaveFrame(java.io.File, java.lang.String, int, boolean)
public static final java.lang.String FRAME_SAVE_FILE_EXT
grabAndSaveFrame(java.io.File, java.lang.String, int, boolean)
public static final int INITIAL_ARRAY_COUNT_CAPACITY
arrayCount
arraypublic static final int INITIAL_BUF_CAPACITY
public static final int DEF_MIN_ACCUM_RED_BITS
public static final int DEF_MIN_ACCUM_GREEN_BITS
public static final int DEF_MIN_ACCUM_BLUE_BITS
public static final int DEF_MIN_ACCUM_ALPHA_BITS
public static final int DEFAULT
public static final int CURRENT
public static final int TRACE_JOGL_EN
public static final int TRACE_GL_EN
public static final int TRACE_VERTICES_EN
public static final float DISABLE_ACCUM_BUFFER_FACTOR
If the rendering time is greater than DISABLE_ACCUM_BUFFER_THRESHOLD
and has increased by more than
DISABLE_ACCUM_BUFFER_FACTOR
upon first render of a frame with
masked geometries using the accumulation buffer (e.g. b/c the accum buffer
is not hw accel), we automatically disable it.
public static final float DISABLE_ACCUM_BUFFER_THRESHOLD
public static final long WAIT_TIMEOUT_MS
protected volatile javax.media.opengl.awt.GLCanvas glCanvas
protected volatile javax.media.opengl.GLEventListener glEventListener
glCanvas
protected javax.media.opengl.GLContext glContext
The current JOGL rendering context.
This is automatically set prior to each render.
Confined to the render thread.
protected javax.media.opengl.GL2 gl
The current JOGL object.
This is automatically set prior to each render.
Confined to the render thread.
protected float[] backgroundColor
protected float[] directionalLightDirection
protected float ambientLightIntensity
protected float directionalLightIntensity
protected boolean directionalLightDirectionChangePending
protected boolean directionalLightIntensityChangePending
protected boolean ambientLightIntensityChangePending
protected boolean backgroundColorChangePending
protected volatile int alphaBits
protected volatile int accumRedBits
protected volatile int accumGreenBits
protected volatile int accumBlueBits
protected volatile int accumAlphaBits
protected volatile java.lang.String glVendorString
protected volatile java.lang.String glRendererString
protected volatile java.lang.String glVersionString
protected int numOptimizedGeometries
render()
protected int numJOGLGeometries
render()
protected int numVisiblePrims
render()
protected volatile java.util.concurrent.CountDownLatch renderLatch
render()
until render completeprotected java.util.concurrent.CountDownLatch currentRenderLatch
renderLatch
that was current at start of render.
Confined to the render thread.
protected volatile java.util.concurrent.CountDownLatch finishLatch
finish(boolean, boolean)
until render completeprotected volatile boolean finishPending
Whether finish(boolean, boolean)
should really do a glFinish()
.
protected final java.lang.Object finishLock
synchronization object for finishLatch
and finishPending
read-modify-write.
protected final java.util.Queue<java.lang.Runnable> geometryMutators
protected volatile int traceFlagsPending
render()
protected volatile boolean renderOngoing
protected volatile boolean primCountingEnabled
protected volatile boolean glDrawingEnabled
protected volatile boolean frameDroppingEnabled
protected volatile boolean drawDisableDepthTest
drawGeometry(Geometry, float)
protected volatile boolean drawDisableDepthWrite
drawGeometry(Geometry, float)
protected volatile boolean drawDisableColorWrite
drawGeometry(Geometry, float)
protected volatile boolean ignoreNullAppearance
Enable for indicated option in applyAppearance(Appearance,
boolean, float, boolean, boolean)
.
protected volatile boolean accumBufferClearEnabled
clearDrawingBuffer()
protected boolean appliedFirstAppearance
Whether any appearance has ever been applied to the current OGL context.
Confined to the render thread.
protected RX currentModelViewRX
cache of OGL state
Confined to the render thread.
protected float currentModelViewScale
cache of OGL state
Confined to the render thread.
protected boolean lightingEnabled
cache of OGL state
Confined to the render thread.
protected boolean colorMaterialEnabled
cache of OGL state
Confined to the render thread.
protected int currentColorMaterial
cache of OGL state
Confined to the render thread.
protected boolean depthTestEnabled
cache of OGL state
Confined to the render thread.
protected boolean blendEnabled
cache of OGL state
Confined to the render thread.
protected double[] cmtMatrix
Temp storage for applying Display3D.cmtRX
and Display3D.cmtScale
to
OGL.
Confined to the render thread.
protected javax.vecmath.Color3f nC3f
Temp storage.
Confined to the render thread.
protected javax.vecmath.Color3f cC3f
Temp storage.
Confined to the render thread.
protected javax.vecmath.Color3f tempC3f
Temp storage.
Confined to the render thread.
protected javax.vecmath.Color4f tempC4f
Temp storage.
Confined to the render thread.
protected int[] tempI3
Temp storage.
Confined to the render thread.
protected int[] tempI4
Temp storage.
Confined to the render thread.
protected int[] tempI5
Temp storage.
Confined to the render thread.
protected boolean[] tempB4
Temp storage.
Confined to the render thread.
protected float[] tempV3
Temp storage.
Confined to the render thread.
protected float[] tempV4
Temp storage.
Confined to the render thread.
protected javax.media.j3d.ColoringAttributes[] coloringAttrs
protected javax.media.j3d.LineAttributes[] lineAttrs
protected javax.media.j3d.Material[] materialAttrs
protected javax.media.j3d.PointAttributes[] pointAttrs
protected javax.media.j3d.PolygonAttributes[] polygonAttrs
protected javax.media.j3d.RenderingAttributes[] renderingAttrs
protected javax.media.j3d.TransparencyAttributes[] transparencyAttrs
protected javax.media.j3d.Appearance[] appearanceState
protected int[] arrayCount
Temp storage for geometry array counts.
Confined to the render thread.
protected java.nio.FloatBuffer texCoordBuf
Temp storage for vertex data.
Confined to the render thread.
protected java.nio.FloatBuffer colorBuf
Temp storage for vertex data.
Confined to the render thread.
protected java.nio.FloatBuffer normalBuf
Temp storage for vertex data.
Confined to the render thread.
protected java.nio.FloatBuffer vertexBuf
Temp storage for vertex data.
Confined to the render thread.
protected java.util.Set<java.lang.Class> drawGeometryWarningsIssued
Unhandled geometry classes for which warnings have already been issued.
Confined to the render thread.
protected java.util.Set<java.util.List<java.lang.Object>> vertexAcessorWarningIssued
Classes with no implemented vertex accessors for which warnings have already been issued.
Confined to the render thread.
protected boolean drawGeometryMultiTextureWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean drawGeometryVertexAttrsWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean shaderWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean textureWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean pointLineAAWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean screenDoorWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean differentThreadsWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean singleThreadedWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean isOpenGLThreadWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected boolean finishWarningIssued
Whether the indicated warning has already been issued.
Confined to the render thread.
protected volatile boolean accumBufferAvailable
protected volatile boolean accumBufferGood
protected volatile boolean forceDisableAccumBuffer
protected volatile boolean tryEnableAccumBuffer
protected volatile boolean releaseRenderCallingThreadBeforeSwap
Whether to release the thread calling render()
at the beginning
of swapBuffers()
.
protected final boolean doPreFinish
Whether to finish(boolean, boolean)
in preRender()
and postRender(double)
, respectively.
protected final boolean doPostFinish
Whether to finish(boolean, boolean)
in preRender()
and postRender(double)
, respectively.
protected int numMaskedGeometriesWas
DISABLE_ACCUM_BUFFER_FACTOR
protected boolean consedConfinedStateGL
Whether the various render-thread confined state has been consed yet.
Confined to the render thread.
protected java.lang.Thread renderThread
The JOGL render thread.
Confined to the render thread.
protected int numDroppedFrames
frameDroppingEnabled
protected final boolean j3d14Available
protected final boolean jogl2Available
protected TimeMetrics renderCallMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics requestRepaintMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics requestDelayMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderImplMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics renderWaitMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics finishMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics applyAppearanceMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics drawGeometryMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics drawGeometryArrayMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics drawElementsMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics drawArraysMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics drawJOGLGeometryMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics drawUnoptimizedMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics drawGeometryAccessorMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics joglRenderTransparentMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected TimeMetrics joglRenderDepthOnlyMetrics
JOGL-specific extended render metrics, if compiled with Display3D.ENABLE_EXTENDED_RENDER_METRICS
.
protected java.util.List<TimeMetrics> allJOGLExtendedRenderMetrics
public JOGLDisplay(java.awt.GraphicsDevice device, int width, int height, int minRedBits, int minGreenBits, int minBlueBits, int minDepthBits, int minStencilBits, int minNumSamples, int minAccumRedBits, int minAccumGreenBits, int minAccumBlueBits, int minAccumAlphaBits, boolean doPreFinish, boolean doPostFinish)
Makes a new JOGLDisplay
with the given specs.
device
- the graphics device on which to make the canvas, or null to
use J3DUtils.getDefaultGD()
doPreFinish
- if set then a potential call to finish(boolean, boolean)
is
enabled at the beginning of preRender()
. The finish(boolean, boolean)
will
only be called if either finishPending
is set or geometryMutators
is not empty. Any geometryMutators
will be
run after the finish(boolean, boolean)
.doPostFinish
- similar to doPreFinish but applies to postRender(double)
.public int getAlphaBits()
public int getAccumRedBits()
public int getAccumGreenBits()
public int getAccumBlueBits()
public int getAccumAlphaBits()
public void setBackgroundColor(float... color)
backgroundColor
setBackgroundColor
in class Display3D
public void setAmbientLightIntensity(float intensity)
ambientLightIntensity
setAmbientLightIntensity
in class Display3D
public void setDirectionalLightIntensity(float intensity)
directionalLightIntensity
setDirectionalLightIntensity
in class Display3D
public void setDirectionalLightDirection(float... direction)
directionalLightDirection
setDirectionalLightDirection
in class Display3D
public void scheduleGeometryMutator(java.lang.Runnable task)
Schedule task to run in a context where by-ref (e.g. JOGLGeometry
) mutation is safe.
In the default renderer, geometry mutator tasks are only guaranteed to
run when either doPreFinish
or doPostFinish
is set.
protected void runGeometryMutators()
geometryMutators
protected void resetSceneMetrics(boolean resetPickMetrics)
resetSceneMetrics
in class Display3D
protected void dumpSceneMetricsImpl(java.io.PrintStream s)
dumpSceneMetricsImpl
in class Display3D
protected void dumpRenderMetricsImpl(java.io.PrintStream s)
dumpRenderMetricsImpl
in class Display3D
protected void resetRenderMetricsImpl()
resetRenderMetricsImpl
in class Display3D
public void dumpCanvasProperties(java.io.PrintStream s)
dumpCanvasProperties
in class Display3D
public void render()
This impl blocks till any prior render cycle is complete, unless frameDroppingEnabled
, issues a repaint call on glCanvas
, and
then blocks till the new render is complete, which is either when the
renderer has reached swapBuffers()
, if releaseRenderCallingThreadBeforeSwap
is set, or when the renderer has
reached the end of Display3D.renderImpl()
otherwise.
If the calling thread is interrupted during any of the possible waits,
the InterruptedException
will be swallowed (since it cannot be
thrown due to the superclass signature of Display3D.render()
, but
the interrupt status of the calling thread will be set on exit.
public void finish(boolean iffPending, boolean initiate) throws java.lang.InterruptedException
Block the calling thread until the renderer to hits the next glFinish()
.
iffPending
- only wait if the renderer has flagged that a finish is
pendingjava.lang.InterruptedException
public void finish(boolean initiate) throws java.lang.InterruptedException
finish(boolean, boolean)
, iff pendingjava.lang.InterruptedException
public void finish() throws java.lang.InterruptedException
Covers finish(boolean, boolean)
, iff pending, does not
initiate.
java.lang.InterruptedException
protected void doFinish(boolean runPendingMutators)
Issue a glFinish()
.
Resets finishPending
and counts down finishLatch
, if
any.
See class header doc for details.
public void traceNextFrame(boolean tracePicking, boolean traceGeneric, boolean traceJOGL, boolean traceGL, boolean traceVertices)
Enable tracing for next frame with given options.
traceJOGL
- whether to emit JOGL-specific render algorithm dbgtraceGL
- whether to emit dbg for every OGL API calltraceVertices
- whether to emit dbg for every vertex renderedprotected void setTraceFlags(int flags)
Display3D.traceFlags
This impl sets traceFlagsPending
.
setTraceFlags
in class Display3D
protected int getAllRenderTraceFlags()
Hook to get combination of all trace flags that apply to the render algorithm.
This impl adds TRACE_JOGL_EN
to superclass impl.
getAllRenderTraceFlags
in class Display3D
public void disableAccumBuffer()
Forcibly disable use of the accumulation buffer, even if available and currently considered usable.
public void enableAccumBufferIfAvailable()
Try enabling the accum buffer, if it is available.
public boolean usingAccumBuffer()
usingAccumBuffer
in class Display3D
public boolean hasAccumBuffer()
hasAccumBuffer
in class Display3D
public void enablePrimCounting(boolean enable)
public void enableGLDrawing(boolean enable)
protected java.io.File grabAndSaveFrame(java.io.File directory, java.lang.String basename, int index, boolean withCursor) throws java.io.IOException
Implementation hook to grab and save a frame.
The file format is implementation dependent; the implementation should generate the full name of the save destination file as directory/basenameindex.ext where ext is appropriate for the frame save format.
If the destination file exists it should not be overridden.
Default impl throws an IOException wrapping an UnsupportedOperationException.
This impl saves Targa format.
grabAndSaveFrame
in class Display3D
directory
- the destination directory or null for current dirbasename
- the file basenameindex
- the frame index, or negative if nonejava.io.IOException
- (possibly wrapping another exception) if the save
fails for any reason, including would overwriteprotected void writeToTargaFile(java.io.File file, int width, int height, boolean withCursor) throws java.io.IOException
Based on com.sun.opengl.util.Screenshot.WriteToTargaFile(File,
int, int, boolean)
but reimplimented to optionally composite cursor.
java.io.IOException
protected boolean compositeCursorOntoBGR(int width, int height, java.nio.ByteBuffer bgr, boolean yUp, java.awt.Cursor cursor)
Composite cursor onto a BGR buffer representing the canvas, at the current mouse location.
Uses CursorUtils
to get the cursor image.
width
- buffer image width in pixelsheight
- buffer image height in pixelsprotected java.awt.Canvas makeCanvas(java.awt.GraphicsDevice device, int minRedBits, int minGreenBits, int minBlueBits, int minDepthBits, int minStencilBits, int minNumSamples)
protected java.awt.Canvas makeCanvas(java.awt.GraphicsDevice device, int minRedBits, int minGreenBits, int minBlueBits, int minDepthBits, int minStencilBits, int minNumSamples, int minAccumRedBits, int minAccumGreenBits, int minAccumBlueBits, int minAccumAlphaBits)
protected void applyProjection()
This impl applies the projection matrix to OGL, leaving the OGL matrix
mode in GL_MODELVIEW
.
applyProjection
in class Display3D
protected void applyCMT()
Display3D.cmtRX
and Display3D.cmtScale
to OGLprotected boolean setGLModelView(RX rx, float scale)
Potentially mutate the OGL GL_MODELVIEW
matrix.
The OGL call is only made if the passed transform differs from the
current one cached in currentModelViewRX
, currentModelViewScale
.
Assumes that the OGL matrix mode is already GL_MODELVIEW
.
protected void clearDrawingBuffer()
This impl clears the OGL color, depth, and stencil buffers.
The buffers are cleared even if currently masked in OGL.
clearDrawingBuffer
in class Display3D
protected void swapBuffers()
This impl swaps the OGL buffers.
Prior to swapping the accum buffer contents are copied to the drawing
buffer if enabled and if masked geometry has been rendered. Before that,
the thread that called render()
is released from waiting iff releaseRenderCallingThreadBeforeSwap
is set.
swapBuffers
in class Display3D
protected void preRender()
This impl does a doFinish(boolean)
iff doPreFinish
, and
applies any pending bg or light changes.
protected void postRender(double renderTimeSoFar)
This impl does a doFinish(boolean)
iff doPostFinish
, and
implements DISABLE_ACCUM_BUFFER_FACTOR
.
postRender
in class Display3D
protected void draw(RX cmt, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float extraAlpha)
This is the JOGL-specific impl of the central Display3D.draw(RX,
float, Geometry, Appearance, float)
call in the generic renderer.
It boils down to a combination of Display3D.setCMT(vona.math.RX, float)
, hasVertexColors(javax.media.j3d.Geometry)
, applyAppearance(Appearance, boolean, float,
boolean, boolean)
, and drawGeometry(Geometry, float)
.
draw
in class Display3D
cmt
- the rigid part of the CMT to set prior to drawing, or null to
leave the current CMT in effectcmtScale
- the scale part of the CMT to set prior to drawing, ignored
if Display3D.cmtRX
is nullgeometry
- the geometry to drawappearance
- the appearance to set, or null to set the default
appearanceextraAlpha
- if in the range [0.0, 1.0) then this multiplies the
alpha used for renderingprotected boolean hasVertexColors(javax.media.j3d.Geometry geometry)
protected void issueDrawGeometryWarningMaybe(java.lang.Class c)
Issue an unhandled warning for geometry class c iff this is the first time we've seen it.
protected void applyAppearance(javax.media.j3d.Appearance a, boolean diffOnly, float extraAlpha, boolean hasVertexColors, boolean noColorWrite)
Apply an appearance to OGL.
a
- the Appearance to applydiffOnly
- whether to only apply differences between a and the
CURRENT
appearance to OGLextraAlpha
- if in the range [0.0f, 1.0f] then this is an extra
multiplicative alpha that is applied to any existing alpha components in
ahasVertexColors
- whether the geometry to be rendered has per-vertex
colors, iff so and if they are not specified to be ignored by a and
if lighting is enabled then the OGL color-material option will be enablednoColorWrite
- whether color buffer will not be written; if so
then only appearance attributes which affect rasterization are appliedprotected void applyAppearance(javax.media.j3d.Appearance a, boolean diffOnly, float extraAlpha, boolean hasVertexColors)
Covers applyAppearance(Appearance, boolean, float, boolean,
boolean)
, with color write.
protected void applyAppearance(javax.media.j3d.Appearance a, float extraAlpha, boolean hasVertexColors)
Covers applyAppearance(Appearance, boolean, float, boolean,
boolean)
, diff only, with color write.
protected void applyAppearance(javax.media.j3d.Appearance a, float extraAlpha)
Covers applyAppearance(Appearance, boolean, float, boolean,
boolean)
, diff only, with color write, no vertex colors.
protected void applyAppearance(javax.media.j3d.Appearance a)
Covers applyAppearance(Appearance, boolean, float, boolean,
boolean)
, diff only, with color write, no vertex colors, no extra
alpha.
protected boolean applyAttrs(javax.media.j3d.ColoringAttributes na, boolean diffOnly, float extraAlpha)
Apply appearance attributes to OGL.
diffOnly
- whether to only apply differences between the new
attributes and the CURRENT
appearance to OGLextraAlpha
- if in the range [0.0f, 1.0f] then this is an extra
multiplicative alpha that is applied to any existing alpha components in
aprotected void applyAttrs(javax.media.j3d.ColoringAttributes na, float extraAlpha)
Covers applyAttrs(ColoringAttributes, float)
, diff only.
protected void applyAttrs(javax.media.j3d.ColoringAttributes na)
Covers applyAttrs(ColoringAttributes, boolean, float)
, diff
only and no extra alpha.
protected boolean applyAttrs(javax.media.j3d.LineAttributes na, boolean diffOnly)
Apply appearance attributes to OGL.
diffOnly
- whether to only apply differences between the new
attributes and the CURRENT
appearance to OGLprotected void applyAttrs(javax.media.j3d.LineAttributes na)
applyAttrs(LineAttributes, boolean)
, diff onlyprotected boolean applyAttrs(javax.media.j3d.Material nm, boolean diffOnly, float extraAlpha, boolean allowColorMaterial)
Apply appearance attributes to OGL.
diffOnly
- whether to only apply differences between the new
attributes and the CURRENT
appearance to OGLextraAlpha
- if in the range [0.0f, 1.0f] then this is an extra
multiplicative alpha that is applied to any existing alpha components in
aallowColorMaterial
- whether to enable the OGL color-material option
if lighting is enabledprotected boolean enableGLLighting(boolean enable)
Potentially mutate the OGL lighting enable.
The OGL call is only made if the passed value differs from the
current one cached in lightingEnabled
.
protected boolean setGLColorMaterial(int mode)
Potentially mutate the OGL GL_FRONT_AND_BACK
color material
parameter.
The OGL call is only made if the passed value differs from the
current one cached in currentColorMaterial
.
protected boolean enableGLColorMaterial(boolean enable)
Potentially mutate the OGL color material enable.
The OGL call is only made if the passed mode differs from the
current one cached in colorMaterialEnabled
.
protected void applyMaterialColor(int property, javax.vecmath.Color3f c, float alpha)
Apply a material color to OGL.
property
- the material property for which to set the colorprotected void applyAttrs(javax.media.j3d.Material nm, float extraAlpha, boolean allowColorMaterial)
Covers applyAttrs(Material, boolean, float, boolean)
, diff
only.
protected void applyAttrs(javax.media.j3d.Material nm, float extraAlpha)
Covers applyAttrs(Material, boolean, float, boolean)
, diff
only, do not allow color material.
protected void applyAttrs(javax.media.j3d.Material nm)
Covers applyAttrs(Material, boolean, float, boolean)
, diff
only, no extra alpha, do not allow color material.
protected boolean applyAttrs(javax.media.j3d.PointAttributes na, boolean diffOnly)
Apply appearance attributes to OGL.
diffOnly
- whether to only apply differences between the new
attributes and the CURRENT
appearance to OGLprotected void applyAttrs(javax.media.j3d.PointAttributes na)
Covers applyAttrs(PointAttributes, boolean)
, diff only.
protected boolean applyAttrs(javax.media.j3d.PolygonAttributes na, boolean diffOnly)
Apply appearance attributes to OGL.
diffOnly
- whether to only apply differences between the new
attributes and the CURRENT
appearance to OGLprotected void applyAttrs(javax.media.j3d.PolygonAttributes na)
Covers applyAttrs(PolygonAttributes, boolean)
, diff only.
protected boolean applyAttrs(javax.media.j3d.RenderingAttributes na, boolean diffOnly)
Apply appearance attributes to OGL.
diffOnly
- whether to only apply differences between the new
attributes and the CURRENT
appearance to OGLprotected boolean enableGLDepthTest(boolean enable)
Potentially mutate the OGL depth test enable.
The OGL call is only made if the passed value differs from the
current one cached in depthTestEnabled
.
protected void applyAttrs(javax.media.j3d.RenderingAttributes na)
Covers applyAttrs(RenderingAttributes, boolean)
, diff
only.
protected boolean applyAttrs(javax.media.j3d.TransparencyAttributes na, boolean diffOnly)
Apply appearance attributes to OGL.
diffOnly
- whether to only apply differences between the new
attributes and the CURRENT
appearance to OGLprotected boolean enableGLBlend(boolean enable)
Potentially mutate the OGL blend enable.
The OGL call is only made if the passed mode differs from the
current one cached in blendEnabled
.
protected boolean blendedTransparencyMode(int transparencyMode)
Check if transparencyMode is to be implemented with alpha blending (vs screen door).
protected void applyAttrs(javax.media.j3d.TransparencyAttributes na)
Covers applyAttrs(TransparencyAttributes, boolean)
, diff
only.
protected void drawGeometry(javax.media.j3d.Geometry g, float extraAlpha)
Do the actual drawing in a draw(RX, float, Geometry,
Appearance, float)
call.
extraAlpha
- if in the range [0.0f, 1.0f] then this is an extra
multiplicative alpha that is applied to any existing alpha components in
vertex colors of gprotected void drawGeometry(javax.media.j3d.Geometry g)
drawGeometry(Geometry, float)
, no extra alphaprotected boolean drawEnable(javax.media.j3d.Geometry g)
Check for early-out of drawGeometry(Geometry, float)
.
Default impl checks that the CURRENT
renderingAttrs
specify that the geometry is visible.
protected float drawGeometryAlpha(javax.media.j3d.Geometry g)
Figure out the alpha that drawGeometry(Geometry, float)
should
use for g, not including any extra alpha.
Default impl gets the transparency value from the CURRENT
transparencyAttrs
, iff blendedTransparencyMode(int)
, else
1.0.
protected int getVertexFormat(javax.media.j3d.Geometry g)
Get the vertex format of g for drawGeometry(Geometry,
float)
.
protected boolean drawVertexColors(javax.media.j3d.Geometry g)
Check whether drawGeometry(Geometry, float)
should apply the
per-vertex colors of g, if any.
Default impl checks that the CURRENT
renderingAttrs
specify that the vertex colors are not ignored.
protected javax.vecmath.Color4f drawGetUnlitColor(javax.media.j3d.Geometry g, javax.vecmath.Color4f c)
Figure out the color that drawGeometry(Geometry, float)
should
use for g if unlit, not including any extra alpha.
Default impl gets the color from the CURRENT
coloringAttrs
.
protected void drawGeometry(javax.media.j3d.GeometryArray a, int mode, int vf, int na, int[] arrayCount, float geometryAlpha, boolean applyVertexColors, boolean indexed, int numColorComponents, boolean hasNormals)
Impl of drawGeometry(Geometry, float)
for GeometryArray
s.
protected void drawElements(int mode, int na, int[] arrayCount, int initialIndexIndex, int[] indices)
protected void drawArrays(int mode, int na, int[] arrayCount)
protected void drawUnoptimized(javax.media.j3d.Geometry g, boolean indexed, int mode, int na, int[] arrayCount, float geometryAlpha, boolean applyVertexColors)
Handles un-optimzed cases in drawGeometry(Geometry, float)
and
drawGeometry(GeometryArray, int, int, int, int[], float, boolean,
boolean, int, boolean)
.
This boils down to Display3D.getVertexAccessorFor(javax.media.j3d.Geometry, boolean...)
and Display3D.getIndexAccessorFor(javax.media.j3d.Geometry)
g, then drawGeometry(J3DVertexAccessor, int, int, int[], float, boolean)
.
protected void drawGeometry(J3DVertexAccessor va, int mode, int na, int[] arrayCount, float geometryAlpha, boolean applyVertexColors)
Draw a geometry to OGL vertex-by-vertex.
This is always correct even in the presence of non-nil geometryAlpha (i.e. alpha in the half-open range [0.0, 1.0)) and false applyVertexColors, though it is likely slower than other methods that use vertex arrays due to additional JNI.
Note that this works even for indexed geometry, in that case set up an index accessor on va prior to call.
A further feature, to support JOGLGeometry
, is that negative
entries c in arrayCount are taken as indication to skip
rather than draw -c vertices.
protected void renderTransparent(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance, float extraAlpha, boolean disableDepthWrite)
Optimized with drawDisableDepthWrite
, unless both highlighted
and has extra alpha.
renderTransparent
in class Display3D
extraAlpha
- if in the range [0.0, 1.0) then this multiplies the
alpha used for renderingdisableDepthWrite
- if true then temporarily disable depth buffer
writeprotected void accumPass()
This impl does a glAccum(GL_ACCUM, passAlpha)
if accumBufferGood
and not Display3D.premultiplyPassAlpha
.
protected void renderDepthOnly(RX cmtRX, float cmtScale, javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
drawDisableColorWrite
renderDepthOnly
in class Display3D
protected int getPickCullFace(javax.media.j3d.Geometry geometry, javax.media.j3d.Appearance appearance)
Hook called by the smaller pickGeometry(...)
APIs to get the
pick cull face for the given geometry.
Default impl returns the cull face of the PolygonAttributes
of
appearance, if any, else PolygonAttributes.CULL_BACK
.This impl returns the cull face of the PolygonAttributes
of
appearance, if any, else the current cull face.
getPickCullFace
in class Display3D
protected int j3dToGLTestFunc(int j3dTestFunc)
protected int j3dToGLLogicOp(int j3dLogicOp)
protected int j3dToGLStencilOp(int j3dStencilOp)
protected int j3dToGLBlendFunc(int j3dBlendFunc)
protected int j3dToGLPolygonOffsetMode(int j3dPolygonMode)
protected java.nio.FloatBuffer fillBuffer(java.nio.FloatBuffer b, float[] a, int n)
Copy the first n elements of array a to the beginning of buffer b.
If b is null or not large enough a new buffer will be consed by
doubling the size of the existing buffer until it is larger than n
(if the existing buffer is null then the doubling begins at INITIAL_BUF_CAPACITY
; unless n is zero, in which case no new
buffer is allocated).
The buffer is left positioned at its start, with limit = capacity.
protected void getGLColorMask(boolean[] colorMask)
protected boolean getGLDepthMask()
protected int getGLStencilMask()
protected float[] getGLMaterial(int property, float[] value)
Get a material color from OGL.
property
- the material property for which to get the colorprotected javax.vecmath.Color4f getGLMaterial(int property, javax.vecmath.Color4f value)
getGLMaterial(int, float[])
protected javax.vecmath.Color3f getGLMaterial(int property, javax.vecmath.Color3f value)
getGLMaterial(int, float[])
protected void ensureConfinedStateGL()
If not consedConfinedStateGL
then cons all render-thread
confined heap-allocated state.
protected boolean dbgPipelineEnabled()
Hook to enable the debug pipeline at time of canvas init.
Default impl returns the value of the system property "classname.dbgpipelineenabled", if set, or false otherwise.
protected boolean tracePipelineEnabled()
Hook to enable the trace pipeline at time of canvas init.
Default impl returns the value of the system property "classname.tracepipelineenabled", if set, or false otherwise.
protected java.lang.String getPropertyOverride(java.lang.String property, java.lang.String def)
Get the value the indicated system property, prefixed with the full name of this class.
def
- the default value to return if the property is not found or if
there was a SecurityException in trying to get itprotected boolean getPropertyOverride(java.lang.String property, boolean def)
getPropertyOverride(String, String)
, gets a booleanprotected int getPropertyOverride(java.lang.String property, int def)
getPropertyOverride(String, String)
, gets an intpublic static void main(java.lang.String[] arg)