codeanticode.glgraphics
Class GLGraphicsOffScreen

java.lang.Object
  extended by PGraphicsOpenGL
      extended by codeanticode.glgraphics.GLGraphicsOffScreen
All Implemented Interfaces:
GLConstants

public class GLGraphicsOffScreen
extends PGraphicsOpenGL
implements GLConstants

This class implements OpenGL renderer for off-screen rendering. The result of the frame rendering is available as a texture that can be obtained by calling the


Field Summary
 
Fields inherited from interface codeanticode.glgraphics.GLConstants
BACKGROUND_ALPHA, CG_CONTEXT, CG_EFFECT, CG_PROGRAM, COLOR, DOUBLE, FLOAT, FRAGMENT_PROGRAM, GEOMETRY_PROGRAM, GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8, GL_FRAME_BUFFER, GL_PIXEL_BUFFER, GL_RENDER_BUFFER, GL_TEXTURE_OBJECT, GL_UNSIGNED_INT_24_8, GL_VERTEX_BUFFER, GLGRAPHICS, GLSL_PROGRAM, GLSL_SHADER, IDENTITY_MATRIX, INVERSE_MATRIX, INVERSE_TRANSPOSE_MATRIX, LINE_ADJACENCY, LINEAR_MIPMAP_LINEAR, LINEAR_MIPMAP_NEAREST, LINEAR_SAMPLING, NEAREST_MIPMAP_LINEAR, NEAREST_MIPMAP_NEAREST, NEAREST_SAMPLING, SHADER_VAR_ARRAY, SHADER_VAR_FLOAT, SHADER_VAR_INT, SHADER_VAR_MAT2, SHADER_VAR_MAT3, SHADER_VAR_MAT4, SHADER_VAR_MODELVIEW_MAT, SHADER_VAR_MODELVIEW_PROJECTION_MAT, SHADER_VAR_PROJECTION_MAT, SHADER_VAR_TEXTURE_MAT, SHADER_VAR_TEXTURE_SAMPLER, SHADER_VAR_VEC2, SHADER_VAR_VEC3, SHADER_VAR_VEC4, TEX_BYTE, TEX_INT, TEX_NORM, TEX_ONEDIM, TEX_RECT, TRANSPOSE_MATRIX, TRIANGLE_ADJACENCY, VERTEX_PROGRAM
 
Constructor Summary
GLGraphicsOffScreen(processing.core.PApplet parent, int iwidth, int iheight)
          Creates an instance of GLGraphicsOffScreen with specified size, without mulisampling.
GLGraphicsOffScreen(processing.core.PApplet parent, int iwidth, int iheight, boolean multi)
          Creates an instance of GLGraphicsOffScreen with specified size and enabled/disabled multisampling, according to the value of the argument multi.
GLGraphicsOffScreen(processing.core.PApplet parent, int iwidth, int iheight, boolean multi, int level)
          Creates an instance of GLGraphicsOffScreen with specified size and enabled/disabled multisampling and multisampling level, according to the values of the arguments multi and level.
GLGraphicsOffScreen(processing.core.PApplet parent, int iwidth, int iheight, GLTextureParameters params)
          Creates an instance of GLGraphicsOffScreen with specified size and parameters for the drawing texture.
GLGraphicsOffScreen(processing.core.PApplet parent, int iwidth, int iheight, GLTextureParameters params, boolean multi)
          Creates an instance of GLGraphicsOffScreen with specified size and parameters for the destination texture.
GLGraphicsOffScreen(processing.core.PApplet parent, int iwidth, int iheight, GLTextureParameters params, boolean multi, int level)
          Creates an instance of GLGraphicsOffScreen with specified size and parameters for the destination texture.
 
Method Summary
 void ambientLight(float r, float g, float b)
          Add an ambient light based on the current color mode.
 void ambientLight(float r, float g, float b, float x, float y, float z)
          Add an ambient light based on the current color mode.
 void beginDraw()
          Prepares the renderer for drawing a new frame.
 GL beginGL()
          Starts a block of direct OpenGL calls.
 void camera()
           
 void camera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
           
 void clear(float gray)
           
 void clear(float gray, float alpha)
           
 void clear(float x, float y, float z)
           
 void clear(float x, float y, float z, float a)
           
 void clear(int gray)
           
 void clear(int rgb, float alpha)
           
 void clear(int gray, int alpha)
           
 void clear(int x, int y, int z)
           
 void clear(int x, int y, int z, int a)
           
 void delete()
          Frees all OpenGL resources associated to this renderer.
 void directionalLight(float r, float g, float b, float nx, float ny, float nz)
           
 void disableMultisampling()
          Switches multisampling off when the renderer was created with multisampling enabled.
 void enableMultisampling()
          Switches multisampling back on when the renderer was created with multisampling enabled.
 void endCamera()
           
 void endDraw()
          Cleans-up the drawing of last frame.
 void endGL()
          Ends a block of direct OpenGL calls.
 void frustum(float left, float right, float bottom, float top, float near, float far)
           
 GLCapabilities getCapabilities()
          Returns the current OpenGL capabilities associated to this renderer.
 GLTexture getTexture()
          Returns the texture where this offscreen renderer draws to.
 void lightFalloff(float constant, float linear, float quadratic)
          Set the light falloff rates for the last light that was created.
 void lights()
           
 void lightSpecular(float x, float y, float z)
          Set the specular color of the last light created.
 void loadPixels()
          Creates the pixels array for the surface and the internal texture.
 void loadTexture()
          It copies the contents of the internal texture to both pixels arrays of the surface and the texture object.
 void model(GLModel model)
           
 void model(GLModel model, GLModelEffect effect)
           
 void model(GLModel model, int first, int last)
           
 void model(GLModel model, int first, int last, GLModelEffect effect)
           
 void noBlend()
           
 void noLights()
           
 void ortho()
           
 void ortho(float left, float right, float bottom, float top, float near, float far)
           
 void perspective()
           
 void perspective(float fov, float aspect, float near, float far)
           
 void pointLight(float r, float g, float b, float x, float y, float z)
           
 void popMatrix()
          Restores the modelview matrix saved with the last call to
 void pushMatrix()
          Saves the current modelview matrix.
 void restoreLights()
           
 void rotate(float angle)
           
 void rotate(float angle, float vx, float vy, float vz)
           
 void rotateX(float angle)
           
 void rotateY(float angle)
           
 void rotateZ(float angle)
           
 void saveLights()
           
 void scale(float s)
           
 void scale(float sx, float sy)
           
 void scale(float x, float y, float z)
           
 void setBlendMode(int MODE)
           
 void setDefaultBlend()
           
 void setDepthMask(boolean value)
          Enables/disables the use of the depth mask.
 void setSize(int iwidth, int iheight)
          Sets the size of the renderer's drawing surface.
 void spotLight(float r, float g, float b, float x, float y, float z, float nx, float ny, float nz, float angle, float concentration)
           
 void translate(float tx, float ty)
           
 void translate(float tx, float ty, float tz)
           
 void updatePixels()
          It copies the contents of surface's pixels to the internal texture.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLGraphicsOffScreen

public GLGraphicsOffScreen(processing.core.PApplet parent,
                           int iwidth,
                           int iheight)
Creates an instance of GLGraphicsOffScreen with specified size, without mulisampling.

Parameters:
parent - the PApplet object of the calling sketch
iwidth - desired width of the offscreen canvas.
iheight - desired height of the offscreen canvas.

GLGraphicsOffScreen

public GLGraphicsOffScreen(processing.core.PApplet parent,
                           int iwidth,
                           int iheight,
                           boolean multi)
Creates an instance of GLGraphicsOffScreen with specified size and enabled/disabled multisampling, according to the value of the argument multi. If multisampling is enabled the multisampling level is set by default to 4x.

Parameters:
parent - the PApplet object of the calling sketch
iwidth - desired width of the offscreen canvas.
iheight - desired height of the offscreen canvas.
multi - true or false to enable/disable multisampling.

GLGraphicsOffScreen

public GLGraphicsOffScreen(processing.core.PApplet parent,
                           int iwidth,
                           int iheight,
                           boolean multi,
                           int level)
Creates an instance of GLGraphicsOffScreen with specified size and enabled/disabled multisampling and multisampling level, according to the values of the arguments multi and level.

Parameters:
parent - the PApplet object of the calling sketch
iwidth - desired width of the offscreen canvas.
iheight - desired height of the offscreen canvas.
multi - true or false to enable/disable multisampling.
level - multisampling level (usually 2 or 4).

GLGraphicsOffScreen

public GLGraphicsOffScreen(processing.core.PApplet parent,
                           int iwidth,
                           int iheight,
                           GLTextureParameters params)
Creates an instance of GLGraphicsOffScreen with specified size and parameters for the drawing texture. Multisampling is disabled.

Parameters:
parent - the PApplet object of the calling sketch
iwidth - desired width of the offscreen canvas.
iheight - desired height of the offscreen canvas.
params - parameters of the texture used as drawing surface

GLGraphicsOffScreen

public GLGraphicsOffScreen(processing.core.PApplet parent,
                           int iwidth,
                           int iheight,
                           GLTextureParameters params,
                           boolean multi)
Creates an instance of GLGraphicsOffScreen with specified size and parameters for the destination texture. Multisampling is enabled/disabled according to the value of the argument multi. If multisampling is enabled, the multisampling level is set by default to 4x.

Parameters:
parent - the PApplet object of the calling sketch
iwidth - desired width of the offscreen canvas.
iheight - desired height of the offscreen canvas.
params - parameters of the texture used as drawing surface
multi - true or false to enable/disable multisampling.

GLGraphicsOffScreen

public GLGraphicsOffScreen(processing.core.PApplet parent,
                           int iwidth,
                           int iheight,
                           GLTextureParameters params,
                           boolean multi,
                           int level)
Creates an instance of GLGraphicsOffScreen with specified size and parameters for the destination texture. Multisampling is enabled/disabled according to the value of the argument multi, and its level is contolled by the argument level.

Parameters:
parent - the PApplet object of the calling sketch
iwidth - desired width of the offscreen canvas.
iheight - desired height of the offscreen canvas.
params - parameters of the texture used as drawing surface
multi - true or false to enable/disable multisampling.
level - multisampling level (usually 2 or 4).
Method Detail

getTexture

public GLTexture getTexture()
Returns the texture where this offscreen renderer draws to.

Returns:
GLTexture object used as drawing surface

getCapabilities

public GLCapabilities getCapabilities()
Returns the current OpenGL capabilities associated to this renderer.

Returns:
JOGL capabilities object

setSize

public void setSize(int iwidth,
                    int iheight)
Sets the size of the renderer's drawing surface.

Parameters:
iwidth - new width
iwidth - new height

delete

public void delete()
Frees all OpenGL resources associated to this renderer.


beginGL

public GL beginGL()
Starts a block of direct OpenGL calls. Saves the projection and modelview matrices.


endGL

public void endGL()
Ends a block of direct OpenGL calls.


beginDraw

public void beginDraw()
Prepares the renderer for drawing a new frame.


endDraw

public void endDraw()
Cleans-up the drawing of last frame.


setDepthMask

public void setDepthMask(boolean value)
Enables/disables the use of the depth mask.

Parameters:
value - the desired state for the use of depth masking.

enableMultisampling

public void enableMultisampling()
Switches multisampling back on when the renderer was created with multisampling enabled.


disableMultisampling

public void disableMultisampling()
Switches multisampling off when the renderer was created with multisampling enabled. This can be useful when trying to draw piece of geometry without antialiasing on a multisampled offscreen surface.


pushMatrix

public void pushMatrix()
Saves the current modelview matrix.


popMatrix

public void popMatrix()
Restores the modelview matrix saved with the last call to

See Also:
pushMatrix.

translate

public void translate(float tx,
                      float ty)

translate

public void translate(float tx,
                      float ty,
                      float tz)

rotate

public void rotate(float angle)

rotateX

public void rotateX(float angle)

rotateY

public void rotateY(float angle)

rotateZ

public void rotateZ(float angle)

rotate

public void rotate(float angle,
                   float vx,
                   float vy,
                   float vz)

scale

public void scale(float s)

scale

public void scale(float sx,
                  float sy)

scale

public void scale(float x,
                  float y,
                  float z)

lights

public void lights()

saveLights

public void saveLights()

restoreLights

public void restoreLights()

noLights

public void noLights()

ambientLight

public void ambientLight(float r,
                         float g,
                         float b)
Add an ambient light based on the current color mode.


ambientLight

public void ambientLight(float r,
                         float g,
                         float b,
                         float x,
                         float y,
                         float z)
Add an ambient light based on the current color mode. This version includes an (x, y, z) position for situations where the falloff distance is used.


directionalLight

public void directionalLight(float r,
                             float g,
                             float b,
                             float nx,
                             float ny,
                             float nz)

pointLight

public void pointLight(float r,
                       float g,
                       float b,
                       float x,
                       float y,
                       float z)

spotLight

public void spotLight(float r,
                      float g,
                      float b,
                      float x,
                      float y,
                      float z,
                      float nx,
                      float ny,
                      float nz,
                      float angle,
                      float concentration)

lightFalloff

public void lightFalloff(float constant,
                         float linear,
                         float quadratic)
Set the light falloff rates for the last light that was created. Default is lightFalloff(1, 0, 0).


lightSpecular

public void lightSpecular(float x,
                          float y,
                          float z)
Set the specular color of the last light created.


endCamera

public void endCamera()

camera

public void camera()

camera

public void camera(float eyeX,
                   float eyeY,
                   float eyeZ,
                   float centerX,
                   float centerY,
                   float centerZ,
                   float upX,
                   float upY,
                   float upZ)

ortho

public void ortho()

ortho

public void ortho(float left,
                  float right,
                  float bottom,
                  float top,
                  float near,
                  float far)

perspective

public void perspective()

perspective

public void perspective(float fov,
                        float aspect,
                        float near,
                        float far)

frustum

public void frustum(float left,
                    float right,
                    float bottom,
                    float top,
                    float near,
                    float far)

model

public void model(GLModel model)

model

public void model(GLModel model,
                  GLModelEffect effect)

model

public void model(GLModel model,
                  int first,
                  int last)

model

public void model(GLModel model,
                  int first,
                  int last,
                  GLModelEffect effect)

noBlend

public void noBlend()

setDefaultBlend

public void setDefaultBlend()

setBlendMode

public void setBlendMode(int MODE)

clear

public void clear(int gray)

clear

public void clear(float gray)

clear

public void clear(int gray,
                  int alpha)

clear

public void clear(int rgb,
                  float alpha)

clear

public void clear(float gray,
                  float alpha)

clear

public void clear(int x,
                  int y,
                  int z)

clear

public void clear(float x,
                  float y,
                  float z)

clear

public void clear(int x,
                  int y,
                  int z,
                  int a)

clear

public void clear(float x,
                  float y,
                  float z,
                  float a)

loadPixels

public void loadPixels()
Creates the pixels array for the surface and the internal texture. But it doesn't copy the contents of the texture to them.


loadTexture

public void loadTexture()
It copies the contents of the internal texture to both pixels arrays of the surface and the texture object.


updatePixels

public void updatePixels()
It copies the contents of surface's pixels to the internal texture.



processing library GLGraphics by Andres Colubri. (c) 2008-2011