Class RegionRenderer
- java.lang.Object
-
- com.jogamp.graph.curve.opengl.RegionRenderer
-
public final class RegionRenderer extends Object
OpenGLRegion
renderer AllRegion
rendering operations utilize a RegionRenderer. The RegionRenderer owns itsRenderState
, a composition. The RegionRenderer manages and own all usedShaderProgram
s, a composition. At itsdestruction
, allShaderProgram
s and itsRenderState
will be destroyed and released.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RegionRenderer.GLCallback
May be passed toRegionRenderer ctor
, e.g.
-
Field Summary
Fields Modifier and Type Field Description static RegionRenderer.GLCallback
defaultBlendDisable
DefaultGL.GL_BLEND
disableRegionRenderer.GLCallback
, simply turning-off theGL.GL_BLEND
state and turning-on depth writing viaGL.glDepthMask(boolean)
ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED
is set.static RegionRenderer.GLCallback
defaultBlendEnable
DefaultGL.GL_BLEND
enableRegionRenderer.GLCallback
, turning-off depth writing viaGL.glDepthMask(boolean)
ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED
is set and turning-on theGL.GL_BLEND
state.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RegionRenderer
create()
Create a hardware accelerated RegionRenderer including itsRenderState
composition.static RegionRenderer
create(RegionRenderer.GLCallback enableCallback, RegionRenderer.GLCallback disableCallback)
Create a hardware accelerated RegionRenderer including itsRenderState
composition.static RegionRenderer
create(PMVMatrix sharedPMVMatrix, RegionRenderer.GLCallback enableCallback, RegionRenderer.GLCallback disableCallback)
Create a hardware accelerated RegionRenderer including itsRenderState
composition.void
destroy(GL2ES2 gl)
Deletes allShaderProgram
s and nullifies its references includingRenderState#destroy(GL2ES2)
.void
enable(GL2ES2 gl, boolean enable)
Enabling or disabling theRenderState
's currentshader program
.void
enable(GL2ES2 gl, boolean enable, RegionRenderer.GLCallback enableCB, RegionRenderer.GLCallback disableCB)
Same asenable(GL2ES2, boolean)
but allowing to forceRegionRenderer.GLCallback
s off.int
getHeight()
Return height of current viewportPMVMatrix
getMatrix()
Borrow the currentPMVMatrix
.RenderState
getRenderState()
Return theRenderState
composition.Recti
getViewport()
Borrows the current Rect4i viewport w/o copying.Recti
getViewport(Recti target)
Copies the current Rect4i viewport in given target and returns it for chaining.int
getWidth()
Return width of current viewportvoid
init(GL2ES2 gl)
Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext if not initialized yet.boolean
isInitialized()
boolean
isVBOSupported()
void
reshapeNotify(int x, int y, int width, int height)
No PMVMatrix operation is performed here.void
reshapeOrtho(int width, int height, float near, float far)
Perspective orthogonal, method callsreshapeNotify(int, int, int, int)
.void
reshapePerspective(float angle, int width, int height, float near, float far)
boolean
useShaderProgram(GL2ES2 gl, int renderModes, boolean pass1, int quality, int sampleCount, TextureSequence colorTexSeq)
Generate, selects and caches the desired Curve-GraphShaderProgram
according to the given parameters.
-
-
-
Field Detail
-
defaultBlendEnable
public static final RegionRenderer.GLCallback defaultBlendEnable
DefaultGL.GL_BLEND
enableRegionRenderer.GLCallback
, turning-off depth writing viaGL.glDepthMask(boolean)
ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED
is set and turning-on theGL.GL_BLEND
state.Implementation also sets
RenderState
'sblending bit-hint
, which will causeGLRegion's draw-method
to set the properblend-function
and the clear-color to transparent-black in case ofmultipass
FBO rendering.- See Also:
#create(Vertex.Factory extends Vertex>, RenderState, GLCallback, GLCallback)
,enable(GL2ES2, boolean)
-
defaultBlendDisable
public static final RegionRenderer.GLCallback defaultBlendDisable
DefaultGL.GL_BLEND
disableRegionRenderer.GLCallback
, simply turning-off theGL.GL_BLEND
state and turning-on depth writing viaGL.glDepthMask(boolean)
ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED
is set.Implementation also clears
RenderState
'sblending bit-hint
.- See Also:
#create(Vertex.Factory extends Vertex>, RenderState, GLCallback, GLCallback)
,enable(GL2ES2, boolean)
-
-
Method Detail
-
create
public static RegionRenderer create()
Create a hardware accelerated RegionRenderer including itsRenderState
composition.The optional
RegionRenderer.GLCallback
senableCallback
anddisableCallback
maybe used to issue certain tasks atenable(GL2ES2, boolean)
.
For example, instancesdefaultBlendEnable
anddefaultBlendDisable
can be utilized to enable and disableGL.GL_BLEND
.- Returns:
- an instance of Region Renderer
- See Also:
enable(GL2ES2, boolean)
-
create
public static RegionRenderer create(RegionRenderer.GLCallback enableCallback, RegionRenderer.GLCallback disableCallback)
Create a hardware accelerated RegionRenderer including itsRenderState
composition.The optional
RegionRenderer.GLCallback
senableCallback
anddisableCallback
maybe used to issue certain tasks atenable(GL2ES2, boolean)
.
For example, instancesdefaultBlendEnable
anddefaultBlendDisable
can be utilized to enable and disableGL.GL_BLEND
.- Parameters:
enableCallback
- optionalRegionRenderer.GLCallback
, if notnull
will be issued atinit(gl)
andenable(gl, true)
.disableCallback
- optionalRegionRenderer.GLCallback
, if notnull
will be issued atenable(gl, false)
.- Returns:
- an instance of Region Renderer
- See Also:
enable(GL2ES2, boolean)
-
create
public static RegionRenderer create(PMVMatrix sharedPMVMatrix, RegionRenderer.GLCallback enableCallback, RegionRenderer.GLCallback disableCallback)
Create a hardware accelerated RegionRenderer including itsRenderState
composition.The optional
RegionRenderer.GLCallback
senableCallback
anddisableCallback
maybe used to issue certain tasks atenable(GL2ES2, boolean)
.
For example, instancesdefaultBlendEnable
anddefaultBlendDisable
can be utilized to enable and disableGL.GL_BLEND
.- Parameters:
sharedPMVMatrix
- optional sharedPMVMatrix
to be used for theRenderState
composition.enableCallback
- optionalRegionRenderer.GLCallback
, if notnull
will be issued atinit(gl)
andenable(gl, true)
.disableCallback
- optionalRegionRenderer.GLCallback
, if notnull
will be issued atenable(gl, false)
.- Returns:
- an instance of Region Renderer
- See Also:
enable(GL2ES2, boolean)
-
isInitialized
public final boolean isInitialized()
-
getViewport
public final Recti getViewport(Recti target)
Copies the current Rect4i viewport in given target and returns it for chaining.
-
getViewport
public final Recti getViewport()
Borrows the current Rect4i viewport w/o copying.
-
getWidth
public final int getWidth()
Return width of current viewport
-
getHeight
public final int getHeight()
Return height of current viewport
-
isVBOSupported
public final boolean isVBOSupported()
-
init
public final void init(GL2ES2 gl) throws GLException
Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext if not initialized yet.Leaves the renderer enabled, ie ShaderState.
Shall be called by a
draw()
method, e.g.RegionRenderer#draw(GL2ES2, Region, int)
- Parameters:
gl
- referencing the current GLContext to which the ShaderState is bound to- Throws:
GLException
- if initialization failed
-
destroy
public final void destroy(GL2ES2 gl)
Deletes allShaderProgram
s and nullifies its references includingRenderState#destroy(GL2ES2)
.
-
getRenderState
public final RenderState getRenderState()
Return theRenderState
composition.
-
enable
public final void enable(GL2ES2 gl, boolean enable)
Enabling or disabling theRenderState
's currentshader program
.useShaderProgram(GL2ES2, int, boolean, int, int, TextureSequence)
generates, selects and caches the desired Curve-GraphShaderProgram
andsets it current
in theRenderState
composition.In case enable and disable
RegionRenderer.GLCallback
s are setup via#create(Vertex.Factory extends Vertex>, RenderState, GLCallback, GLCallback)
, they will be called before toggling the shader program.- Parameters:
gl
- current GL objectenable
- if true enable the currentShaderProgram
, otherwise disable.- See Also:
#create(Vertex.Factory extends Vertex>, RenderState, GLCallback, GLCallback)
,useShaderProgram(GL2ES2, int, boolean, int, int, TextureSequence)
,RenderState.setShaderProgram(GL2ES2, ShaderProgram)
,RenderState.getShaderProgram()
-
enable
public final void enable(GL2ES2 gl, boolean enable, RegionRenderer.GLCallback enableCB, RegionRenderer.GLCallback disableCB)
Same asenable(GL2ES2, boolean)
but allowing to forceRegionRenderer.GLCallback
s off.- Parameters:
gl
- current GL objectenable
- if true enable the currentShaderProgram
, otherwise disable.doCallbacks
- if true (default) performRegionRenderer.GLCallback
s, otherwise don't.- See Also:
enable(GL2ES2, boolean)
-
reshapeNotify
public final void reshapeNotify(int x, int y, int width, int height)
No PMVMatrix operation is performed here.
-
reshapePerspective
public final void reshapePerspective(float angle, int width, int height, float near, float far)
-
reshapeOrtho
public final void reshapeOrtho(int width, int height, float near, float far)
Perspective orthogonal, method callsreshapeNotify(int, int, int, int)
.
-
useShaderProgram
public final boolean useShaderProgram(GL2ES2 gl, int renderModes, boolean pass1, int quality, int sampleCount, TextureSequence colorTexSeq)
Generate, selects and caches the desired Curve-GraphShaderProgram
according to the given parameters. The newly generated or cachedShaderProgram
isset current
in theRenderState
composition and can be retrieved viaRenderState.getShaderProgram()
.- Parameters:
gl
-renderModes
-pass1
-quality
-sampleCount
-colorTexSeq
-- Returns:
- true if a new shader program is being used and hence external uniform-data and -location, as well as the attribute-location must be updated, otherwise false.
- See Also:
enable(GL2ES2, boolean)
,RenderState.setShaderProgram(GL2ES2, ShaderProgram)
,RenderState.getShaderProgram()
-
-