Class RegionRenderer
- java.lang.Object
-
- com.jogamp.graph.curve.opengl.RegionRenderer
-
public final class RegionRenderer extends Object
OpenGLRegionrenderer AllRegionrendering operations utilize a RegionRenderer. The RegionRenderer owns itsRenderState, a composition. The RegionRenderer manages and own all usedShaderPrograms, a composition. At itsdestruction, allShaderPrograms and itsRenderStatewill be destroyed and released.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceRegionRenderer.GLCallbackMay be passed toRegionRenderer ctor, e.g.
-
Field Summary
Fields Modifier and Type Field Description static RegionRenderer.GLCallbackdefaultBlendDisableDefaultGL.GL_BLENDdisableRegionRenderer.GLCallback, simply turning-off theGL.GL_BLENDstate and turning-on depth writing viaGL.glDepthMask(boolean)ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLEDis set.static RegionRenderer.GLCallbackdefaultBlendEnableDefaultGL.GL_BLENDenableRegionRenderer.GLCallback, turning-off depth writing viaGL.glDepthMask(boolean)ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLEDis set and turning-on theGL.GL_BLENDstate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearHintBits(int mask)static RegionRenderercreate()Create a hardware accelerated RegionRenderer including itsRenderStatecomposition.static RegionRenderercreate(RegionRenderer.GLCallback enableCallback, RegionRenderer.GLCallback disableCallback)Create a hardware accelerated RegionRenderer including itsRenderStatecomposition.static RegionRenderercreate(com.jogamp.math.util.PMVMatrix4f sharedPMVMatrix, RegionRenderer.GLCallback enableCallback, RegionRenderer.GLCallback disableCallback)Create a hardware accelerated RegionRenderer including itsRenderStatecomposition.voiddestroy(GL2ES2 gl)Deletes allShaderPrograms and nullifies its references includingRenderState#destroy(GL2ES2).voidenable(GL2ES2 gl, boolean enable)Enabling or disabling theRenderState's currentshader program.voidenable(GL2ES2 gl, boolean enable, RegionRenderer.GLCallback enableCB, RegionRenderer.GLCallback disableCB)Same asenable(GL2ES2, boolean)but allowing to forceRegionRenderer.GLCallbacks off.intgetAAQuality()Returns pass2 AA-quality rendering value for Graph Region AArender-modes:Region.VBAA_RENDERING_BIT.com.jogamp.math.geom.FrustumgetClipFrustum()Returns the optional Mv-premultiplied clippingFrustumor null if unused.com.jogamp.math.Vec4fgetColorStatic(com.jogamp.math.Vec4f rgbaColor)intgetHeight()Return height of current viewportcom.jogamp.math.util.PMVMatrix4fgetMatrix()Borrow the currentPMVMatrix4f.RenderStategetRenderState()Return theRenderStatecomposition.intgetSampleCount()Returns pass2 AA sample count for Graph Region AArender-modes:#VBAA_RENDERING_BITorRegion.MSAA_RENDERING_BIT.com.jogamp.math.RectigetViewport()Borrows the current Rect4i viewport w/o copying.com.jogamp.math.RectigetViewport(com.jogamp.math.Recti target)Copies the current Rect4i viewport in given target and returns it for chaining.floatgetWeight()intgetWidth()Return width of current viewportbooleanhintBitsSet(int mask)voidinit(GL2ES2 gl)Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext if not initialized yet.booleanisInitialized()booleanisVBOSupported()voidreshapeNotify(int x, int y, int width, int height)No PMVMatrix4f operation is performed here.voidreshapeOrtho(int width, int height, float near, float far)Orthogonal projection, method also callsreshapeNotify(int, int, int, int).voidreshapePerspective(float angle_rad, int width, int height, float near, float far)Perspective projection, method also callsreshapeNotify(int, int, int, int).intsetAAQuality(int v)Sets pass2 AA-quality rendering value clipped to the range [Region.MIN_AA_QUALITY..Region.MAX_AA_QUALITY] for Graph Region AArender-modes:Region.VBAA_RENDERING_BIT.voidsetClipFrustum(com.jogamp.math.geom.Frustum clipFrustum)Set the optional clippingFrustum, which shall be pre-multiplied with the Mv-matrix or null to disable.voidsetColorStatic(float r, float g, float b, float a)voidsetColorStatic(com.jogamp.math.Vec4f rgbaColor)voidsetHintBits(int mask)intsetSampleCount(int v)Sets pass2 AA sample count clipped to the range [Region.MIN_AA_SAMPLE_COUNT..Region.MAX_AA_SAMPLE_COUNT] for Graph Region AArender-modes:#VBAA_RENDERING_BITorRegion.MSAA_RENDERING_BIT.voidsetWeight(float v)booleanuseShaderProgram(GL2ES2 gl, int renderModes, boolean pass1, TextureSequence colorTexSeq)Generate, selects and caches the desired Curve-GraphShaderProgramaccording to the given parameters.
-
-
-
Field Detail
-
defaultBlendEnable
public static final RegionRenderer.GLCallback defaultBlendEnable
DefaultGL.GL_BLENDenableRegionRenderer.GLCallback, turning-off depth writing viaGL.glDepthMask(boolean)ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLEDis set and turning-on theGL.GL_BLENDstate.Implementation also sets
RenderState'sblending bit-hint, which will causeGLRegion's draw-methodto set the properblend-functionand the clear-color to transparent-black in case ofmultipassFBO rendering.
-
defaultBlendDisable
public static final RegionRenderer.GLCallback defaultBlendDisable
DefaultGL.GL_BLENDdisableRegionRenderer.GLCallback, simply turning-off theGL.GL_BLENDstate and turning-on depth writing viaGL.glDepthMask(boolean)ifRenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLEDis set.Implementation also clears
RenderState'sblending bit-hint.
-
-
Method Detail
-
create
public static RegionRenderer create()
Create a hardware accelerated RegionRenderer including itsRenderStatecomposition.The optional
RegionRenderer.GLCallbacksenableCallbackanddisableCallbackmaybe used to issue certain tasks atenable(GL2ES2, boolean).
For example, instancesdefaultBlendEnableanddefaultBlendDisablecan 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 itsRenderStatecomposition.The optional
RegionRenderer.GLCallbacksenableCallbackanddisableCallbackmaybe used to issue certain tasks atenable(GL2ES2, boolean).
For example, instancesdefaultBlendEnableanddefaultBlendDisablecan be utilized to enable and disableGL.GL_BLEND.- Parameters:
enableCallback- optionalRegionRenderer.GLCallback, if notnullwill be issued atinit(gl)andenable(gl, true).disableCallback- optionalRegionRenderer.GLCallback, if notnullwill be issued atenable(gl, false).- Returns:
- an instance of Region Renderer
- See Also:
enable(GL2ES2, boolean)
-
create
public static RegionRenderer create(com.jogamp.math.util.PMVMatrix4f sharedPMVMatrix, RegionRenderer.GLCallback enableCallback, RegionRenderer.GLCallback disableCallback)
Create a hardware accelerated RegionRenderer including itsRenderStatecomposition.The optional
RegionRenderer.GLCallbacksenableCallbackanddisableCallbackmaybe used to issue certain tasks atenable(GL2ES2, boolean).
For example, instancesdefaultBlendEnableanddefaultBlendDisablecan be utilized to enable and disableGL.GL_BLEND.- Parameters:
sharedPMVMatrix- optional sharedPMVMatrix4fto be used for theRenderStatecomposition.enableCallback- optionalRegionRenderer.GLCallback, if notnullwill be issued atinit(gl)andenable(gl, true).disableCallback- optionalRegionRenderer.GLCallback, if notnullwill be issued atenable(gl, false).- Returns:
- an instance of Region Renderer
- See Also:
enable(GL2ES2, boolean)
-
isInitialized
public final boolean isInitialized()
-
getViewport
public final com.jogamp.math.Recti getViewport(com.jogamp.math.Recti target)
Copies the current Rect4i viewport in given target and returns it for chaining.
-
getViewport
public final com.jogamp.math.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.Disables the renderer via
enable(GL2ES2, boolean)to remove any side-effects, ie ShaderState incl. shader program.Shall be called once before at initialization before a
draw()method, e.g.RegionRenderer#draw(GL2ES2, Region)- 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 allShaderPrograms and nullifies its references includingRenderState#destroy(GL2ES2).
-
getRenderState
public final RenderState getRenderState()
Return theRenderStatecomposition.
-
getMatrix
public final com.jogamp.math.util.PMVMatrix4f getMatrix()
Borrow the currentPMVMatrix4f.
-
getWeight
public final float getWeight()
-
setWeight
public final void setWeight(float v)
-
getColorStatic
public final com.jogamp.math.Vec4f getColorStatic(com.jogamp.math.Vec4f rgbaColor)
-
setColorStatic
public final void setColorStatic(com.jogamp.math.Vec4f rgbaColor)
-
setColorStatic
public final void setColorStatic(float r, float g, float b, float a)
-
setAAQuality
public final int setAAQuality(int v)
Sets pass2 AA-quality rendering value clipped to the range [Region.MIN_AA_QUALITY..Region.MAX_AA_QUALITY] for Graph Region AArender-modes:Region.VBAA_RENDERING_BIT.
-
getAAQuality
public final int getAAQuality()
Returns pass2 AA-quality rendering value for Graph Region AArender-modes:Region.VBAA_RENDERING_BIT.
-
setSampleCount
public final int setSampleCount(int v)
Sets pass2 AA sample count clipped to the range [Region.MIN_AA_SAMPLE_COUNT..Region.MAX_AA_SAMPLE_COUNT] for Graph Region AArender-modes:#VBAA_RENDERING_BITorRegion.MSAA_RENDERING_BIT.
-
getSampleCount
public final int getSampleCount()
Returns pass2 AA sample count for Graph Region AArender-modes:#VBAA_RENDERING_BITorRegion.MSAA_RENDERING_BIT.
-
setClipFrustum
public final void setClipFrustum(com.jogamp.math.geom.Frustum clipFrustum)
Set the optional clippingFrustum, which shall be pre-multiplied with the Mv-matrix or null to disable.
-
getClipFrustum
public final com.jogamp.math.geom.Frustum getClipFrustum()
Returns the optional Mv-premultiplied clippingFrustumor null if unused.
-
hintBitsSet
public final boolean hintBitsSet(int mask)
-
setHintBits
public final void setHintBits(int mask)
-
clearHintBits
public final void clearHintBits(int mask)
-
enable
public final void enable(GL2ES2 gl, boolean enable)
Enabling or disabling theRenderState's currentshader program.useShaderProgram(GL2ES2, int, boolean, TextureSequence)generates, selects and caches the desired Curve-GraphShaderProgramandsets it currentin theRenderStatecomposition.In case enable and disable
RegionRenderer.GLCallbacks 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, 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.GLCallbacks off.- Parameters:
gl- current GL objectenable- if true enable the currentShaderProgram, otherwise disable.enableCB- explicitRegionRenderer.GLCallbackfor enabledisableCB- explicitRegionRenderer.GLCallbackfor disable- See Also:
enable(GL2ES2, boolean)
-
reshapeNotify
public final void reshapeNotify(int x, int y, int width, int height)No PMVMatrix4f operation is performed here.
-
reshapePerspective
public final void reshapePerspective(float angle_rad, int width, int height, float near, float far)Perspective projection, method also callsreshapeNotify(int, int, int, int).- Parameters:
angle_rad- perspective angle in radianswidth- viewport widthheight- viewport heightnear- projection z-nearfar- projection z-far
-
reshapeOrtho
public final void reshapeOrtho(int width, int height, float near, float far)Orthogonal projection, method also callsreshapeNotify(int, int, int, int).- Parameters:
width- viewport widthheight- viewport heightnear- projection z-nearfar- projection z-far
-
useShaderProgram
public final boolean useShaderProgram(GL2ES2 gl, int renderModes, boolean pass1, TextureSequence colorTexSeq)
Generate, selects and caches the desired Curve-GraphShaderProgramaccording to the given parameters. The newly generated or cachedShaderProgramisset currentin theRenderStatecomposition and can be retrieved viaRenderState.getShaderProgram().- Parameters:
gl-renderModes-pass1-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()
-
-