|
Aviatrix3D 2.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.j3d.aviatrix3d.SceneGraphObject
org.j3d.aviatrix3d.NodeComponent
org.j3d.aviatrix3d.Texture
org.j3d.aviatrix3d.OffscreenTexture2D
public class OffscreenTexture2D
Describes the texture that is rendered to an offscreen buffer, using OpenGL pBuffers.
Since the format information is provided as part of the GLCapabilities instance, there is no need for it to be passed into the constructor like the other texture types do.
This implementation is somewhat shaky right now as the documentation on how to use the GLPbuffer class is very poor. The class may change drastically once we really work out what is going on.
Since an offscreen rendering process has a completely different set of viewing parameters to the main scene, we have to include almost everything here as well. A complete viewing environment must be set up to deal with the texture rendering.
For repainting updates, the logic is as-follows. On the first time this
TODO:
If the scene is set but without root geometry, then the root geometry added
later, then the update handler is not correctly dealt with. It never gets
set. To overcome this, make sure you set a root group node before setting the
scene, even if it is just a proxy value.
Field Summary |
---|
Fields inherited from class org.j3d.aviatrix3d.NodeComponent |
---|
lastParent, liveCount, parentList |
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
alive, LISTENER_SET_NOT_LIVE_MESSAGE, updateHandler, WRITE_TIMING_MSG |
Fields inherited from interface org.j3d.aviatrix3d.TextureSource |
---|
FORMAT_BGR, FORMAT_BGRA, FORMAT_INTENSITY_ALPHA, FORMAT_RGB, FORMAT_RGBA, FORMAT_SINGLE_COMPONENT |
Constructor Summary | |
---|---|
OffscreenTexture2D(javax.media.opengl.GLCapabilities caps,
int width,
int height)
Constructs an offscreen texture that fits the given setup. |
Method Summary | |
---|---|
void |
bindBuffer(javax.media.opengl.GLContext context)
Bind the underlying source buffer for the offscreen rendering. |
protected void |
checkForCyclicChild(SceneGraphObject parent)
Check to see if this node is the same reference as the passed node that is a parent of this node. |
int |
compareTo(Texture tex)
Compares this object with the specified object for order. |
boolean |
equals(Texture tex)
Compares this object with the specified object to check for equivalence. |
int |
getBoundaryModeT()
Get the current boundary handling for the S parameter. |
javax.media.opengl.GLPbuffer |
getBuffer(java.lang.Object obj)
Get the currently registered pBuffer for the given key object. |
void |
getClearColor(float[] col)
Set the background colour that this surface should be cleared to before the drawing step. |
LayerCullable |
getCullableLayer(int layerIndex)
Get the cullable layer child that for the given layer index. |
int |
getFormat(int level)
Get the format for this texture. |
javax.media.opengl.GLCapabilities |
getGLSetup()
Get the requested buffer setup that describes this offscreen texture. |
int |
getHeight()
Get the height of the texture in pixels. |
void |
getLayers(Layer[] layers)
Fetch the current layers that are set. |
int |
getNumLevels()
Get the number of levels for the mipmapping in this source. |
boolean |
isRepaintRequired()
Get the current state of the repainting enabled flag. |
int |
numCullableChildren()
Returns the number of valid cullable children to process. |
int |
numLayers()
Get the number of layers that are currently set. |
void |
postRender(javax.media.opengl.GL gl)
Restore all openGL state to the given drawable |
void |
registerBuffer(java.lang.Object obj,
javax.media.opengl.GLPbuffer buffer)
Register a pBuffer for a given key object. |
void |
render(javax.media.opengl.GL gl)
Issue ogl commands needed for this component |
void |
setBoundaryModeT(int mode)
Set the boundary handling for the T parameter. |
void |
setClearColor(float r,
float g,
float b,
float a)
Set the background colour that this surface should be cleared to before the drawing step. |
void |
setLayers(Layer[] layers,
int numLayers)
Set the collection of geometry that should be rendered to this texture. |
protected void |
setLive(boolean state)
Notification that this object is live now. |
void |
setRepaintRequired(boolean enable)
Set this texture as requiring a repaint for the next frame. |
void |
setSources(int mipMapMode,
int format,
TextureSource[] texSources,
int num)
Set the images for this texture, overridden to provide an empty implementation as this is handled by the pBuffer directly. |
protected void |
setUpdateHandler(NodeUpdateHandler handler)
Set the scenegraph update handler for this node. |
void |
unbindBuffer(javax.media.opengl.GLContext context)
Unbind the underlying source buffer for the offscreen rendering. |
void |
unregisterBuffer(java.lang.Object obj)
Remove an already registered pBuffer for a given key object. |
Methods inherited from class org.j3d.aviatrix3d.NodeComponent |
---|
addParent, getParents, hasChanged, numParents, removeParent |
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
checkForCyclicParent, dataChanged, getUserData, isLive, setUserData |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.j3d.aviatrix3d.TextureSource |
---|
getWidth |
Constructor Detail |
---|
public OffscreenTexture2D(javax.media.opengl.GLCapabilities caps, int width, int height)
Method Detail |
---|
public LayerCullable getCullableLayer(int layerIndex)
getCullableLayer
in interface OffscreenCullable
public int numCullableChildren()
numCullableChildren
in interface OffscreenCullable
public void setSources(int mipMapMode, int format, TextureSource[] texSources, int num) throws InvalidWriteTimingException
setSources
in class Texture
mipMapMode
- Flag stating the type of texture mode to useformat
- Image format to use for grayscale imagestexSources
- The source data to use, single for base levelnum
- The valid number of images to use from the array
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic int getFormat(int level)
getFormat
in interface TextureSource
level
- The mipmap level to get the format for
public int getNumLevels()
getNumLevels
in interface TextureSource
public void render(javax.media.opengl.GL gl)
render
in interface ObjectRenderable
gl
- The gl context to draw withpublic void postRender(javax.media.opengl.GL gl)
postRender
in interface ObjectRenderable
gl
- The gl context to draw withprotected void checkForCyclicChild(SceneGraphObject parent) throws InvalidWriteTimingException, CyclicSceneGraphStructureException
checkForCyclicChild
in class SceneGraphObject
parent
- The reference to check against this class
CyclicSceneGraphStructureException
- Equal parent and child
InvalidWriteTimingException
protected void setLive(boolean state)
setLive
in class Texture
state
- true if this should be marked as live nowprotected void setUpdateHandler(NodeUpdateHandler handler)
setUpdateHandler
in class Texture
handler
- The instance to use as a handlerpublic javax.media.opengl.GLCapabilities getGLSetup()
getGLSetup
in interface PBufferTextureSource
public javax.media.opengl.GLPbuffer getBuffer(java.lang.Object obj)
getBuffer
in interface PBufferTextureSource
obj
- The key used to register the buffer with
public void registerBuffer(java.lang.Object obj, javax.media.opengl.GLPbuffer buffer)
registerBuffer
in interface PBufferTextureSource
obj
- The key used to register the buffer withbuffer
- The buffer instance to use here.public void unregisterBuffer(java.lang.Object obj)
unregisterBuffer
in interface PBufferTextureSource
obj
- The key used to register the buffer withpublic void setLayers(Layer[] layers, int numLayers) throws InvalidWriteTimingException, CyclicSceneGraphStructureException
setLayers
in interface PBufferTextureSource
layers
- The collection of layers, in order, to rendernumLayers
- The number of valid layers to use
CyclicSceneGraphStructureException
- Equal parent and child
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic void bindBuffer(javax.media.opengl.GLContext context)
bindBuffer
in interface PBufferTextureSource
context
- The containing context to bind frompublic void unbindBuffer(javax.media.opengl.GLContext context)
unbindBuffer
in interface PBufferTextureSource
context
- The containing context to bind frompublic int numLayers()
numLayers
in interface PBufferTextureSource
public void getLayers(Layer[] layers) throws java.lang.IllegalArgumentException
numLayers()
in length. If not, this method does nothing (the
provided array will be unchanged).
getLayers
in interface PBufferTextureSource
layers
- An array to copy the values into
java.lang.IllegalArgumentException
- The array provided is too small or nullpublic boolean isRepaintRequired()
isRepaintRequired
in interface OffscreenTextureSource
isRepaintRequired
in interface OffscreenCullable
public int getHeight()
getHeight
in interface OffscreenTextureSource
public void getClearColor(float[] col)
getClearColor
in interface OffscreenTextureSource
col
- An array of at least length 4 to copy values intopublic void setRepaintRequired(boolean enable)
enable
- true to have this repaint the next framepublic void setBoundaryModeT(int mode) throws InvalidWriteTimingException
mode
- The new mode.
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic int getBoundaryModeT()
public void setClearColor(float r, float g, float b, float a) throws InvalidWriteTimingException
r
- The red component of the background clear colourg
- The green component of the background clear colourb
- The blue component of the background clear coloura
- The alpha component of the background clear colour
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic int compareTo(Texture tex)
compareTo
in class Texture
tex
- The texture instance to be compared
public boolean equals(Texture tex)
equals
in class Texture
tex
- The texture instance to be compared
|
Aviatrix3D 2.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |