|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.threed.jpct.FrameBuffer
The FrameBuffer class provides a buffer into which jPCT renders the scene. The result is basically an Image which could be displayed or modified even further using some post-processing. The FrameBuffer's constructor automatically distinguishes between JAVA2 and earlier versions. JAVA2 and higher will use a BufferedImage as FrameBuffer while JAVA1.1 will use a MemoryImageSource. When using support for OpenGL hardware rendering only, the image is not rendered into the FrameBuffer's internal pixel-array but directly into the video-RAM of the graphics card. Therefor, some methods within this class will execute quite slow if they have to access the VRAM. This will be mentioned in these methods.
| Field Summary | |
static int |
BLITTING_TARGET_BACK
Blitting is done into the back buffer. |
static int |
BLITTING_TARGET_FRONT
Blitting is done into the front buffer. |
static boolean |
BOUNDINGBOX_NOT_USED
Don't use a 2D bounding box. |
static boolean |
BOUNDINGBOX_USED
Use a 2D bounding box for speeding up blitting (only useful when the rendered scene doesn't cover the whole framebuffer) |
static int |
BUFFER_ACCESS_COMBINED
Access the framebuffer in one way (default)... |
static int |
BUFFER_ACCESS_SPLITTED
Access the framebuffer in another way)... |
static int |
BUFFEREDIMAGE
The type of this FrameBuffer is a BufferedImage (JAVA2) |
static int |
MEMORYIMAGESOURCE
The type of this FrameBuffer is a MemoryImageSource (JAVA1.1) |
static boolean |
OPAQUE_BLITTING
2D texture-blitting into the framebuffer is done by copying the source 1-to-1 into the destination bitmap |
static int |
SAMPLINGMODE_GL_AA_2X
Use 2x anti aliasing when using the OpenGL renderer. |
static int |
SAMPLINGMODE_GL_AA_4X
Use 4x anti aliasing when using the OpenGL renderer. |
static int |
SAMPLINGMODE_HARDWARE_ONLY
A special sampling mode that indicates, that no software rendering will be used on this framebuffer. |
static int |
SAMPLINGMODE_NORMAL
Normal sampling mode (1-to-1) |
static int |
SAMPLINGMODE_OGSS
Use 2x2 oriented grid oversampling (FSAA using supersampling) for the software renderer. |
static int |
SAMPLINGMODE_OGSS_FAST
Use 1.5x1.5 oriented grid oversampling (FSAA using supersampling) for the software renderer. |
static int |
SAMPLINGMODE_OGUS
Use 0.5x0.5 oriented grid undersampling (to upsample an image rendered at a lower resolution) |
static java.lang.String |
SUPPORT_FOR_RGB_SCALING
Use this to check if all the currently enabled renderers support RGB-scaling |
static java.lang.String |
SUPPORT_FOR_SHADOW_MAPPING
Use this to check if all the currently enabled renderers support shadow mapping |
static java.lang.Object |
SYNCHRONIZER
An Object to which jPCT synchronizes all critical calls to Display, Mouse and Keyboard from LWJGL to. |
static boolean |
TRANSPARENT_BLITTING
2D texture-blitting into the framebuffer is done by copying the source into the destination bitmap only at places where the sources bitmap has none-zero color-values. |
| Constructor Summary | |
FrameBuffer(int x,
int y,
int oversample)
Creates a new framebuffer with a width of x and a height of y using the given samplingmode. |
|
| Method Summary | |
void |
addPostProcessor(IPostProcessor proc)
Adds an IPostProcessor to run a post processing on the framebuffer. |
void |
blit(int[] src,
int srcWidth,
int srcHeight,
float srcX,
float srcY,
float destX,
float destY,
float width,
float height,
boolean transparent)
Copies a part of a bitmap (taken from an int[] containing pixels in RGB-format and with no alpha) into the framebuffer. |
void |
blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float width,
float height,
boolean transparent)
Copies a part of a bitmap (taken from a Texture in this case) into the framebuffer. |
void |
blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float sourceWidth,
float sourceHeight,
float destWidth,
float destHeight,
int transValue,
boolean additive)
Special version of blit() that allows for scaling, i.e. it doesn't make 1-to-1 copies but can up- or down-scale. |
void |
blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float sourceWidth,
float sourceHeight,
float destWidth,
float destHeight,
int transValue,
boolean additive,
java.awt.Color addColor)
Special version of blit() that allows for scaling, i.e. it doesn't make 1-to-1 copies but can up- or down-scale. |
void |
blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float sourceWidth,
float sourceHeight,
float destWidth,
float destHeight,
int transValue,
boolean additive,
RGBColor addColor)
Method to maintain compatibility with jPCT-AE. |
void |
clear()
Clears the framebuffer, the optiZ-buffer, the hsr-buffer and the regular z-buffer if required. |
void |
clear(java.awt.Color col)
Clears the framebuffer, the optiZ-buffer, the hsr-buffer and the regular z-buffer if required. |
void |
clear(int rgb)
The same as clear(<Color>) but with an int-value instead of a color instance. |
void |
clearColorBufferOnly(java.awt.Color col)
Clears only the color bufferr, not the depth buffer. |
void |
clearZBufferOnly()
Clears only the ZBuffer, not the color buffer. |
void |
disableRenderer(int renderer)
Disables a renderer for this framebuffer. |
void |
display()
The same as displayGLOnly. |
void |
display(java.awt.Graphics g)
Displays the output Image onto the component with the given Graphics context. |
void |
display(java.awt.Graphics g,
int yOffset)
Displays the output Image onto the component with the given Graphics context. |
void |
display(java.awt.Graphics g,
int xOffset,
int yOffset)
Displays the output Image onto the component with the given Graphics context. |
void |
displayGLOnly()
Displays the output image produced by OpenGL compatible hardware if OpenGL rendering is in use. |
void |
dispose()
Has to be called before this FrameBuffer won't be used anymore to do some clean up work. |
java.awt.Canvas |
enableGLCanvasRenderer()
Enables an OpenGL renderer that will render into a canvas. |
void |
enableRenderer(int renderer)
Enables a renderer (OpenGL or software) in OpenGL-lighting mode. |
void |
enableRenderer(int renderer,
int mode)
Enables a renderer (OpenGL or software) in the desired mode. |
void |
flush()
Does nothing. |
void |
flushBlittingPipeline()
Flushes the blitting pipeline by executing the buffered blits. |
java.awt.Graphics |
getGraphics()
Returns the Graphics object of the output buffer to allow the use of JAVA's standard graphic methods on the rendered image (like drawString). |
int |
getHeight()
The same as getOutputHeight(). |
java.lang.Long |
getID()
Returns a unique ID for this FrameBuffer. |
java.lang.Object |
getLock()
Returns the lock object for the frame buffer. |
int |
getMaxTextureSize()
Gets the maximum texture size that the current renderers support. |
float |
getMiddleX()
Returns the x-coord of the midpoint of the framebuffer. |
float |
getMiddleY()
Returns the y-coord of the midpoint of the framebuffer. |
java.awt.Image |
getOutputBuffer()
Returns the Image that represents the output-buffer of the framebuffer. |
int |
getOutputHeight()
Returns the height of the framebuffer. |
int |
getOutputWidth()
Returns the width of the framebuffer. |
int[] |
getPixels()
Returns the raw pixel-data. |
int |
getSamplingMode()
Returns the used sampling mode for this framebuffer. |
int |
getType()
Returns the type of this FrameBuffer. |
static VideoMode[] |
getVideoModes(int renderer)
Static method to get the video modes a renderer (i.e. the hardware it's running on) supports. |
int |
getWidth()
The same as getOutputWidth(). |
boolean |
isInitialized()
Checks if the FrameBuffer and all its enabled renderers have been initialized correctly. |
void |
optimizeBufferAccess()
This method tries to pick the most optimal buffer access mode for the system jPCT is currently running on. |
void |
refresh()
Forces the framebuffer to update its content with what's in the pixels-array. |
void |
removeAllPostProcessors()
Removes all post processors from the framebuffer. |
void |
removeClippingPlane(int number)
Removes an additional clipping plane. |
void |
removePostProcessor(IPostProcessor proc)
Removes a post processor from the framebuffer. |
void |
removeRenderTarget()
Removes the render target from the framebuffer. |
void |
resize(int width,
int height)
Does a resize of the FrameBuffer in case that the output window's size has changed. |
void |
runPostProcessors()
Runs all post processors that have been added to this framebuffer. |
void |
setBlittingShader(GLSLShader shader)
Sets a shader that should be used for blitting instead of the fixed function pipeline. |
void |
setBlittingTarget(int target)
Sets the blitting target to either the front (default) or the back buffer. |
void |
setBoundingBoxMode(boolean bmode)
Sets the bounding box mode for the framebuffer. |
void |
setBufferAccess(int mode)
When using the software renderer, the framebuffer can be accessed in different ways. |
void |
setClippingPlane(int number,
Plane plane)
Sets an additional clipping plane. |
void |
setPaintListener(IPaintListener listener)
Adds a listener to all currently used renderers. |
void |
setPaintListenerState(boolean isActive)
Sets the state of the paint listener. |
void |
setRenderTarget(int texID)
Sets the render target of the framebuffer to a texture. |
void |
setRenderTarget(int texID,
int left,
int top,
int right,
int bottom,
boolean clearAll)
Sets the render target of the framebuffer to a texture. |
void |
setRenderTarget(Texture tex)
Sets the render target of the framebuffer to a texture. |
void |
setRenderTarget(Texture tex,
int left,
int top,
int right,
int bottom,
boolean clearAll)
Sets the render target of the framebuffer to a texture. |
void |
setVirtualDimensions(int width,
int height)
This has a meaning only if a render target has been set. |
boolean |
supports(java.lang.String feature)
Checks if a feature is supported by all the renderers of this framebuffer. |
void |
sync()
Does nothing. |
void |
update()
Updates the output buffer of the framebuffer with the new data from the backbuffer. |
boolean |
usesRenderer(int renderer)
Tests if the given renderer is used by this framebuffer. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int MEMORYIMAGESOURCE
public static final int BUFFEREDIMAGE
public static final int SAMPLINGMODE_GL_AA_4X
public static final int SAMPLINGMODE_GL_AA_2X
public static final int SAMPLINGMODE_OGSS
public static final int SAMPLINGMODE_OGSS_FAST
public static final int SAMPLINGMODE_OGUS
public static final int SAMPLINGMODE_NORMAL
public static final int SAMPLINGMODE_HARDWARE_ONLY
public static final boolean BOUNDINGBOX_USED
public static final boolean BOUNDINGBOX_NOT_USED
public static final boolean OPAQUE_BLITTING
public static final boolean TRANSPARENT_BLITTING
public static final java.lang.String SUPPORT_FOR_RGB_SCALING
Lights.setRGBScale(int),
supports(java.lang.String),
Constant Field Valuespublic static final java.lang.String SUPPORT_FOR_SHADOW_MAPPING
supports(java.lang.String),
Constant Field Valuespublic static final int BUFFER_ACCESS_COMBINED
setBufferAccess(int),
Constant Field Valuespublic static final int BUFFER_ACCESS_SPLITTED
setBufferAccess(int),
Constant Field Valuespublic static final int BLITTING_TARGET_FRONT
public static final int BLITTING_TARGET_BACK
public static final java.lang.Object SYNCHRONIZER
| Constructor Detail |
public FrameBuffer(int x,
int y,
int oversample)
x - the width of the framebuffery - the height of the framebufferoversample - the samplingmodeSAMPLINGMODE_OGSS,
SAMPLINGMODE_OGSS_FAST,
SAMPLINGMODE_OGUS,
SAMPLINGMODE_NORMAL,
SAMPLINGMODE_HARDWARE_ONLY,
SAMPLINGMODE_GL_AA_2X,
SAMPLINGMODE_GL_AA_4X,
getVideoModes(int)| Method Detail |
public java.lang.Long getID()
public static VideoMode[] getVideoModes(int renderer)
renderer - the renderer (only IRenderer.RENDERER_OPENGL makes sense at
the moment)
IRenderer,
Config.glColorDepth,
Config.glZBufferDepth,
Config.glRefreshpublic boolean isInitialized()
public void setBlittingTarget(int target)
target - the blitting targetBLITTING_TARGET_FRONT,
BLITTING_TARGET_BACKpublic void setBlittingShader(GLSLShader shader)
shader - the shader, default is nullpublic void enableRenderer(int renderer)
renderer - the renderer that should be used to render this framebufferdisableRenderer(int),
enableRenderer(int, int),
IRendererpublic java.awt.Canvas enableGLCanvasRenderer()
disableRenderer(int),
enableRenderer(int),
enableGLCanvasRenderer(),
AWTGLRenderer
public void enableRenderer(int renderer,
int mode)
renderer - the renderer that should be used to render this framebuffermode - the mode the renderer should usedisableRenderer(int),
enableRenderer(int),
IRendererpublic void setRenderTarget(int texID)
texID - the ID of the texture to render into.Config.glUseFBO,
Config.glFlipRenderTargets
public void setRenderTarget(int texID,
int left,
int top,
int right,
int bottom,
boolean clearAll)
texID - the ID of the texture to render into.left - the width of the left bordertop - the width of the upper borderright - the width of the right borderbottom - the width of the lower borderclearAll - if true, the border won't affect the clearing of texture. If
set to false, it will.Config.glUseFBO,
Config.glFlipRenderTargetspublic void setRenderTarget(Texture tex)
tex - the texture to render intoConfig.glUseFBO,
Config.glFlipRenderTargets
public void setRenderTarget(Texture tex,
int left,
int top,
int right,
int bottom,
boolean clearAll)
tex - the texture to render intoleft - the width of the left bordertop - the width of the upper borderright - the width of the right borderbottom - the width of the lower borderclearAll - if true, the border won't affect the clearing of texture. If
set to false, it will.Config.glUseFBO,
Config.glFlipRenderTargetspublic void removeRenderTarget()
public void setVirtualDimensions(int width,
int height)
width - the virtual width of the render targetheight - the virtual height of the render targetpublic void addPostProcessor(IPostProcessor proc)
proc - the post processorrunPostProcessors(),
IPostProcessorpublic void removePostProcessor(IPostProcessor proc)
proc - The post processor to be removedIPostProcessorpublic void removeAllPostProcessors()
IPostProcessorpublic void runPostProcessors()
IPostProcessorpublic void setPaintListener(IPaintListener listener)
listener - IPaintListener the listener or null to clear itpublic void setPaintListenerState(boolean isActive)
isActive - is it active or sleeping?public void disableRenderer(int renderer)
renderer - the rendererIRendererpublic void dispose()
public boolean usesRenderer(int renderer)
renderer - the renderer to test
IRendererpublic int getMaxTextureSize()
public boolean supports(java.lang.String feature)
feature - the feature that may be supported
SUPPORT_FOR_RGB_SCALING,
SUPPORT_FOR_SHADOW_MAPPINGpublic int getSamplingMode()
SAMPLINGMODE_NORMAL,
SAMPLINGMODE_OGSS,
SAMPLINGMODE_OGSS_FAST,
SAMPLINGMODE_OGUS,
SAMPLINGMODE_HARDWARE_ONLY,
SAMPLINGMODE_GL_AA_2X,
SAMPLINGMODE_GL_AA_4Xpublic int getOutputWidth()
public int getOutputHeight()
public int getHeight()
public int getWidth()
public float getMiddleX()
public float getMiddleY()
public void setBoundingBoxMode(boolean bmode)
bmode - the bounding box modeBOUNDINGBOX_NOT_USED,
BOUNDINGBOX_USEDpublic void clear()
public void clearZBufferOnly()
public void clearColorBufferOnly(java.awt.Color col)
col - the fill colorpublic void clear(java.awt.Color col)
col - the color the framebuffer is filled withpublic void clear(int rgb)
rgb - the color the framebuffer is filled withpublic void update()
public void setBufferAccess(int mode)
mode - the buffer access modeoptimizeBufferAccess(),
BUFFER_ACCESS_COMBINED,
BUFFER_ACCESS_SPLITTEDpublic void optimizeBufferAccess()
setBufferAccess(int)public java.awt.Image getOutputBuffer()
display(java.awt.Graphics g)public int[] getPixels()
update(),
refresh(),
#blit(com.threed.jpct.Texture src, int srcX, int srcY, int destX,
int destY, int width, int height, boolean transparent),
#blit(int[] src, int srcWidth, int srcHeight, int srcX, int srcY,
int destX, int destY, int width, int height, boolean transparent)public void refresh()
getPixels()
public void resize(int width,
int height)
width - the new widthheight - the new heightpublic java.lang.Object getLock()
public java.awt.Graphics getGraphics()
public int getType()
MEMORYIMAGESOURCE,
BUFFEREDIMAGE
public void blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float width,
float height,
boolean transparent)
src - the texture that contains the source bitmapsrcX - the starting x-position in the source bitmapsrcY - the starting y-position in the source bitmapdestX - the starting x-position in the destination bitmapdestY - the starting y-position in the destination bitmapwidth - the width of the region to copyheight - the height of the region to copytransparent - black (or at least almost black) pixels won't be copied if
this is set to TRANSPARENT_BLITTING. Any color-value which
leads to a result of zero when "anded" with #f0f0f0 will be
taken as black.TRANSPARENT_BLITTING,
OPAQUE_BLITTING,
Config.glFixedBlitting
public void blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float sourceWidth,
float sourceHeight,
float destWidth,
float destHeight,
int transValue,
boolean additive)
src - the texture that contains the source bitmapsrcX - the starting x-position in the source bitmapsrcY - the starting y-position in the source bitmapdestX - the starting x-position in the destination bitmapdestY - the starting y-position in the destination bitmapsourceWidth - the width of the source region to copysourceHeight - the height of the source region to copydestWidth - the width of the copied region in the destination bitmapdestHeight - the height of the copied region in the destination bitmaptransValue - the transparency value, -1 is none, 0 is highest transparency.
Higher values mean less transparency.additive - if true, the blending is additive, otherwise defaultConfig.glFixedBlitting
public void blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float sourceWidth,
float sourceHeight,
float destWidth,
float destHeight,
int transValue,
boolean additive,
java.awt.Color addColor)
src - the texture that contains the source bitmapsrcX - the starting x-position in the source bitmapsrcY - the starting y-position in the source bitmapdestX - the starting x-position in the destination bitmapdestY - the starting y-position in the destination bitmapsourceWidth - the width of the source region to copysourceHeight - the height of the source region to copydestWidth - the width of the copied region in the destination bitmapdestHeight - the height of the copied region in the destination bitmaptransValue - the transparency value, -1 is none, 0 is highest transparency.
Higher values mean less transparency.additive - if true, the blending is additive, otherwise defaultaddColor - an additional color. If null, Color.WHITE is taken insteadConfig.glFixedBlitting
public void blit(Texture src,
float srcX,
float srcY,
float destX,
float destY,
float sourceWidth,
float sourceHeight,
float destWidth,
float destHeight,
int transValue,
boolean additive,
RGBColor addColor)
src - the texture that contains the source bitmapsrcX - the starting x-position in the source bitmapsrcY - the starting y-position in the source bitmapdestX - the starting x-position in the destination bitmapdestY - the starting y-position in the destination bitmapsourceWidth - the width of the source region to copysourceHeight - the height of the source region to copydestWidth - the width of the copied region in the destination bitmapdestHeight - the height of the copied region in the destination bitmaptransValue - the transparency value, -1 is none, 0 is highest transparency.
Higher values mean less transparency.additive - if true, the blending is additive, otherwise defaultaddColor - an additional color. If null, RGBColor.WHITE is taken instead
public void blit(int[] src,
int srcWidth,
int srcHeight,
float srcX,
float srcY,
float destX,
float destY,
float width,
float height,
boolean transparent)
src - the int-array that contains the source bitmapsrcWidth - the width of the source bitmapsrcHeight - the height of the source bitmapsrcX - the starting x-position in the source bitmapsrcY - the starting y-position in the source bitmapdestX - the starting x-position in the destination bitmapdestY - the starting y-position in the destination bitmapwidth - the width of the region to copyheight - the height of the region to copytransparent - black (or at least almost black) pixels won't be copied if
this is set to TRANSPARENT_BLITTING. Any color-value which
leads to a result of zero when "anded" with #f0f0f0 will be
taken as black.getPixels(),
TRANSPARENT_BLITTING,
OPAQUE_BLITTING,
Config.glUseIgnorantBlits,
Config.glFixedBlittingpublic void display(java.awt.Graphics g)
g - the Graphics context of the compontent onto which the Image
should be drawn (ignored when using OpenGL only)getOutputBuffer()
public void display(java.awt.Graphics g,
int yOffset)
g - the Graphics context of the compontent onto which the Image
should be drawn (ignored when using OpenGL only)yOffset - the offset in y-direction (ignored when using OpenGL)getOutputBuffer()
public void display(java.awt.Graphics g,
int xOffset,
int yOffset)
g - the Graphics context of the compontent onto which the Image
should be drawn (ignored when using OpenGL only)xOffset - the offset in x-direction (ignored when using OpenGL)yOffset - the offset in y-direction (ignored when using OpenGL)getOutputBuffer()public void displayGLOnly()
public void display()
public void setClippingPlane(int number,
Plane plane)
number - the number of the clipping plane (0..5)plane - the planepublic void removeClippingPlane(int number)
number - the number of the planepublic void sync()
public void flush()
public void flushBlittingPipeline()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||