public class FrameBuffer
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static boolean |
OPAQUE_BLITTING
2D texture-blitting into the framebuffer is done by copying the source
1-to-1 into the destination bitmap
|
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 and Description |
---|
FrameBuffer(GL10 glContext,
int x,
int y)
Creates a new framebuffer with a width of x and a height of y.
|
FrameBuffer(int x,
int y)
Creates a new framebuffer with a width of x and a height of y.
|
Modifier and Type | Method and Description |
---|---|
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,
RGBColor 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 |
clear()
Clears the framebuffer and the z-buffer.
|
void |
clear(int rgb)
The same as clear(<Color>) but with an int-value instead of a color
instance.
|
void |
clear(RGBColor col)
Clears the framebuffer with the given color.
|
void |
clearColorBufferOnly(RGBColor col)
Clears only the color bufferr, not the depth buffer.
|
void |
clearZBufferOnly()
Clears only the ZBuffer, not the color buffer.
|
void |
compileShader(GLSLShader shader,
java.util.List<VertexAttributes> attribs)
Compiles the shader and processes it's additional vertex attributes, if
those are used within this shader.
|
void |
display()
Displays the rendered image.
|
void |
dispose()
Should be called before this FrameBuffer won't be used anymore to do some
clean up work.
|
void |
flush()
Flushes the render pipeline.
|
void |
flushBlittingPipeline()
Flushes the blitting pipeline by executing the buffered blits.
|
void |
freeMemory()
Frees some native memory used by the gl context.
|
float |
getCenterX()
Returns the x-coord of the midpoint of the framebuffer.
|
float |
getCenterY()
Returns the y-coord of the midpoint of the framebuffer.
|
int |
getHeight()
Returns the height of the framebuffer.
|
java.lang.Long |
getID()
Returns a unique ID for this FrameBuffer.
|
int |
getMaxTextureSize()
Gets the maximum texture size that the hardware supports.
|
int |
getOpenGLMajorVersion()
Returns the major version of OpenGL that this FrameBuffer uses.
|
int[] |
getPixels()
Returns the raw pixel-data.
|
int[] |
getPixels(int[] toFill)
Returns the raw pixel-data.
|
int |
getWidth()
Returns the width of the framebuffer.
|
boolean |
isInitialized()
Checks if the FrameBuffer and the renderer have been initialized
correctly.
|
void |
removeAllPostProcessors()
Removes all post processors from the framebuffer.
|
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 |
setDepthMapParameters(float nearPlane,
float farPlane,
float bias)
Sets the parameters that should be used for near and far plane as well as
for bias when rendering into a shadow map.
|
void |
setPaintListener(IPaintListener listener)
Adds a listener to the renderer.
|
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.
|
void |
sync()
Synchronizes GPU and CPU and flushes the render pipeline..
|
public static final boolean OPAQUE_BLITTING
public static final boolean TRANSPARENT_BLITTING
public FrameBuffer(GL10 glContext, int x, int y)
glContext
- a valid gl contextx
- the width of the framebuffery
- the height of the framebufferpublic FrameBuffer(int x, int y)
x
- the width of the framebuffery
- the height of the framebufferpublic java.lang.Long getID()
public int getOpenGLMajorVersion()
public boolean isInitialized()
public void setRenderTarget(int texID)
texID
- the ID of the texture to render into.public void setDepthMapParameters(float nearPlane, float farPlane, float bias)
nearPlane
- the depth of the near planefarPlane
- the depth of the far planebias
- the bias (i.e. the depth offset, default is 0.0008);public int getMaxTextureSize()
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.public void setRenderTarget(Texture tex)
tex
- the texture to render intopublic 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 the texture. If
set to false, it will.public 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()
,
IPostProcessor
public void removePostProcessor(IPostProcessor proc)
proc
- The post processor to be removedIPostProcessor
public void removeAllPostProcessors()
IPostProcessor
public void runPostProcessors()
IPostProcessor
public void setBlittingShader(GLSLShader shader)
shader
- the shader, default is nullpublic void setPaintListener(IPaintListener listener)
listener
- IPaintListener the listener or null to clear itpublic void dispose()
public void freeMemory()
public int getWidth()
public int getHeight()
public float getCenterX()
public float getCenterY()
public void resize(int width, int height)
width
- the new widthheight
- the new heightpublic void clear()
public void clearZBufferOnly()
public void clearColorBufferOnly(RGBColor col)
col
- the fill colorpublic void clear(RGBColor col)
col
- the color the framebuffer is filled withpublic void clear(int rgb)
rgb
- the color the framebuffer is filled withpublic int[] getPixels()
#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 int[] getPixels(int[] toFill)
toFill
- the array to fill#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 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 unless your texture specifies its own alpha
channel.TRANSPARENT_BLITTING
,
OPAQUE_BLITTING
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, Color.WHITE is taken insteadpublic 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 defaultpublic 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
public void compileShader(GLSLShader shader, java.util.List<VertexAttributes> attribs)
public void display()
public void sync()
public void flush()
public void flushBlittingPipeline()