processing.opengl
Class PGraphicsOpenGL

java.lang.Object
  extended by processing.core.PImage
      extended by processing.core.PGraphics
          extended by processing.core.PGraphics3D
              extended by processing.opengl.PGraphicsOpenGL
All Implemented Interfaces:
java.lang.Cloneable, PConstants

public class PGraphicsOpenGL
extends PGraphics3D

Implementation of the PGraphics API that employs OpenGL rendering via JOGL.

JOGL requires Java 1.4 or higher, so there are no restrictions on this code to be compatible with Java 1.1 or Java 1.3.

This code relies on PGraphics3D for all lighting and transformations. Meaning that translate(), rotate(), and any lighting will be done in PGraphics3D, and OpenGL is only used to blit lines and triangles as fast as it possibly can.

For this reason, OpenGL may not be accelerated as far as it could be, but I don't have the time to maintain two separate versions of the renderer. My development time must always be focused on implementation and covering features first, and optimizing later.

Further, the difference may be negligible, as the primary slowdown in Java is moving pixels (i.e. a large frame buffer is nearly impossible because Java just can't do a MemoryImageSource at screen resolution) and the overhead from JNI tends to be significant. In the latter case, we may even save time in some cases where a large number of calls to OpenGL would otherwise be used, but that's probably a stretch.

The code is also very messy, while features are being added and removed rapidly as we head towards 1.0. Things got particularly ugly as we approached beta while both Simon and I were working on it. Relax, we'll get it fixed up later.

When exporting applets, the JOGL Applet Launcher is used. More information about the launcher can be found at its documentation page.


Nested Class Summary
 class PGraphicsOpenGL.TessCallback
          There must be a better way to do this, but I'm having a brain fart with all the inner class crap.
 
Field Summary
static boolean BIG_ENDIAN
          Set to true if the host system is big endian (PowerPC, MIPS, SPARC), false if little endian (x86 Intel for Mac or PC).
 javax.media.opengl.GL gl
           
 javax.media.opengl.glu.GLU glu
           
 
Fields inherited from class processing.core.PGraphics3D
line, shape_index, TRI_COLOR_COUNT, TRI_DIFFUSE_A, TRI_DIFFUSE_B, TRI_DIFFUSE_G, TRI_DIFFUSE_R, TRI_SPECULAR_B, TRI_SPECULAR_G, TRI_SPECULAR_R, triangle
 
Fields inherited from class processing.core.PGraphics
A, AB, AG, ambientB, ambientG, ambientR, AR, B, backgroundColor, BEEN_LIT, bezierDetail, camera, cameraAspect, cameraFar, cameraFOV, cameraInv, cameraNear, cameraX, cameraY, cameraZ, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, currentLightFalloffConstant, currentLightFalloffLinear, currentLightFalloffQuadratic, currentLightSpecular, curveTightness, DA, DB, DG, DR, EB, EDGE, EG, ellipseMode, emissiveB, emissiveG, emissiveR, ER, fill, fillColor, G, height1, image, lightCount, lightDiffuse, lightFalloffConstant, lightFalloffLinear, lightFalloffQuadratic, lightNormal, lightPosition, lightSpecular, lightSpotAngle, lightSpotAngleCos, lightSpotConcentration, lightType, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33, MAX_LIGHTS, modelview, modelviewInv, normalX, normalY, normalZ, NX, NY, NZ, pixelCount, projection, R, rectMode, SA, SB, settingsInited, SG, SHINE, shininess, SPB, specularB, specularG, specularR, SPG, sphereDetailU, sphereDetailV, SPR, SR, stencil, stroke, strokeCap, strokeColor, strokeJoin, strokeWeight, SW, textAlign, textAlignY, textFont, textFontNative, textFontNativeMetrics, textLeading, textMode, textSize, textureImage, textureMode, textureU, textureV, textX, textY, textZ, tint, tintColor, TX, TY, TZ, U, V, VW, VX, VY, VZ, width1, X, Y, Z, zbuffer
 
Fields inherited from class processing.core.PImage
cache, format, height, imageMode, modified, mx1, mx2, my1, my2, parent, pixels, smooth, width
 
Fields inherited from interface processing.core.PConstants
ADD, ALPHA, ALPHA_MASK, ALT, AMBIENT, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BURN, CENTER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DXF, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ERODE, ESC, EXCLUSION, GIF, GRAY, GREEN_MASK, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMALIZED, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PDF, PERSPECTIVE, PI, PIXEL_CENTER, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, WAIT, WHITESPACE, WINDOWS
 
Constructor Summary
PGraphicsOpenGL()
           
 
Method Summary
 void ambient(float gray)
           
 void ambient(float x, float y, float z)
           
 void ambient(int rgb)
           
 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 background(PImage bgimage)
          Takes an RGB or RGBA image and sets it as the background.
 void beginDraw()
          Prepares the PGraphics for drawing.
 javax.media.opengl.GL beginGL()
           
 void bindTexture(PImage texture)
           
 void blend(int sx, int sy, int dx, int dy, int mode)
           
 void blend(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          TODO - extremely slow and not optimized.
 void blend(PImage src, int sx, int sy, int dx, int dy, int mode)
           
 void blend(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          TODO - extremely slow and not optimized.
 boolean canDraw()
          OpenGL cannot draw until a proper native peer is available, so this returns the value of PApplet.isDisplayable() (inherited from Component).
 void clear()
          Clear pixel buffer.
 void copy(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2)
          Extremely slow and not optimized, should use glCopyPixels instead.
 void copy(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2)
          TODO - extremely slow and not optimized.
 void directionalLight(float r, float g, float b, float nx, float ny, float nz)
           
 void emissive(float gray)
           
 void emissive(float x, float y, float z)
           
 void emissive(int rgb)
           
 void endDraw()
          See notes in PGraphics.
 void endGL()
           
 void filter(int kind)
          This is really inefficient and not a good idea in OpenGL.
 void filter(int kind, float param)
          This is really inefficient and not a good idea in OpenGL.
 PImage get()
          Returns a copy of this PImage.
 int get(int x, int y)
          Returns an ARGB "color" type (a packed 32 bit int with the color.
 PImage get(int x, int y, int w, int h)
          Grab a subsection of a PImage, and copy it into a fresh PImage.
 javax.media.opengl.GLContext getContext()
          Get the current context, for use by libraries that need to talk to it.
 void glLightSpotAngle(int num)
           
 void glLightSpotConcentration(int num)
           
 void hint(int which)
          Enable a hint option.
 void lightFalloff(float constant, float linear, float quadratic)
          Set the light falloff rates for the last light that was created.
 void lights()
          Sets up an ambient and directional light.
 void lightSpecular(float x, float y, float z)
          Set the specular color of the last light created.
 void loadPixels()
          Call this when you want to mess with the pixels[] array.
 void noSmooth()
          Disable smoothing.
 void pointLight(float r, float g, float b, float x, float y, float z)
           
 void renderLines()
           
 void report(java.lang.String where)
          Report on anything from glError().
 void save(java.lang.String filename)
          Save this image to disk.
 void set(int x, int y, int argb)
          Silently ignores if the coordinate is outside the image.
 void set(int x, int y, PImage source)
          Set an image directly to the screen.
 void shininess(float shine)
           
 void smooth()
          If true in PImage, use bilinear interpolation for copy() operations.
 void specular(float gray)
           
 void specular(float x, float y, float z)
           
 void specular(int rgb)
           
 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 strokeCap(int cap)
           
 void strokeJoin(int join)
           
 float textAscent()
          Returns the ascent of the current font at the current size.
 float textDescent()
          Returns the descent of the current font at the current size.
 void textMode(int mode)
          Sets the text rendering/placement to be either SCREEN (direct to the screen, exact coordinates, only use the font's original size) or MODEL (the default, where text is manipulated by translate() and can have a textSize).
 void textSize(float size)
          Same as parent, but override for native version of the font.
 void updatePixels()
          Call this when finished messing with the pixels[] array.
 float uscale(PImage texture)
           
 float vscale(PImage texture)
           
 
Methods inherited from class processing.core.PGraphics3D
applyMatrix, applyMatrix, beginCamera, beginShape, bezierVertex, bezierVertex, box, box, camera, camera, defaultSettings, endCamera, endShape, frustum, loadMatrix, modelX, modelY, modelZ, noLights, normal, ortho, ortho, perspective, perspective, point, point, popMatrix, printCamera, printMatrix, printProjection, pushMatrix, quad, resetMatrix, rotate, rotate, rotateX, rotateY, rotateZ, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, setSize, sphere, sphereDetail, sphereDetail, texture, translate, translate, triangle, vertex, vertex, vertex, vertex
 
Methods inherited from class processing.core.PGraphics
alpha, arc, background, background, background, background, background, background, beginRaw, beginShape, bezier, bezier, bezierDetail, bezierPoint, bezierTangent, blue, breakShape, brightness, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, curve, curve, curveDetail, curvePoint, curveTangent, curveTightness, curveVertex, curveVertex, displayable, dispose, ellipse, ellipseMode, endRaw, endShape, fill, fill, fill, fill, fill, fill, green, hue, image, image, image, lerpColor, lerpColor, line, line, mask, mask, noFill, noStroke, noTint, rect, rectMode, red, saturation, setParent, setPath, setPrimary, stroke, stroke, stroke, stroke, stroke, stroke, strokeWeight, text, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textFont, textFont, textLeading, textureMode, textWidth, textWidth, tint, tint, tint, tint, tint, tint
 
Methods inherited from class processing.core.PImage
blendColor, clone, getImage, imageMode, init, resize, updatePixels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gl

public javax.media.opengl.GL gl

glu

public javax.media.opengl.glu.GLU glu

BIG_ENDIAN

public static boolean BIG_ENDIAN
Set to true if the host system is big endian (PowerPC, MIPS, SPARC), false if little endian (x86 Intel for Mac or PC).

Constructor Detail

PGraphicsOpenGL

public PGraphicsOpenGL()
Method Detail

hint

public void hint(int which)
Description copied from class: PGraphics
Enable a hint option.

For the most part, hints are temporary api quirks, for which a proper api hasn't been properly worked out. for instance SMOOTH_IMAGES existed because smooth() wasn't yet implemented, but it will soon go away.

They also exist for obscure features in the graphics engine, like enabling/disabling single pixel lines that ignore the zbuffer, the way they do in alphabot.

Current hint options:

Overrides:
hint in class PGraphics3D

getContext

public javax.media.opengl.GLContext getContext()
Get the current context, for use by libraries that need to talk to it.


canDraw

public boolean canDraw()
OpenGL cannot draw until a proper native peer is available, so this returns the value of PApplet.isDisplayable() (inherited from Component).

Overrides:
canDraw in class PGraphics

beginDraw

public void beginDraw()
Description copied from class: PGraphics
Prepares the PGraphics for drawing.

When creating your own PGraphics, you should call this before drawing anything.

Overrides:
beginDraw in class PGraphics3D

endDraw

public void endDraw()
Description copied from class: PGraphics3D
See notes in PGraphics. If z-sorting has been turned on, then the triangles will all be quicksorted here (to make alpha work more properly) and then blit to the screen.

Overrides:
endDraw in class PGraphics3D

beginGL

public javax.media.opengl.GL beginGL()

endGL

public void endGL()

uscale

public float uscale(PImage texture)

vscale

public float vscale(PImage texture)

bindTexture

public void bindTexture(PImage texture)

renderLines

public void renderLines()

textAscent

public float textAscent()
Description copied from class: PGraphics
Returns the ascent of the current font at the current size. This is a method, rather than a variable inside the PGraphics object because it requires calculation.

Overrides:
textAscent in class PGraphics

textDescent

public float textDescent()
Description copied from class: PGraphics
Returns the descent of the current font at the current size. This is a method, rather than a variable inside the PGraphics object because it requires calculation.

Overrides:
textDescent in class PGraphics

textSize

public void textSize(float size)
Same as parent, but override for native version of the font.

Also gets called by textFont, so the metrics will get recorded properly.

Overrides:
textSize in class PGraphics

textMode

public void textMode(int mode)
Description copied from class: PGraphics
Sets the text rendering/placement to be either SCREEN (direct to the screen, exact coordinates, only use the font's original size) or MODEL (the default, where text is manipulated by translate() and can have a textSize). The text size cannot be set when using textMode(SCREEN), because it uses the pixels directly from the font.

Overrides:
textMode in class PGraphics

lights

public void lights()
Description copied from class: PGraphics3D
Sets up an ambient and directional light.
 The Lighting Skinny:

 The way lighting works is complicated enough that it's worth
 producing a document to describe it. Lighting calculations proceed
 pretty much exactly as described in the OpenGL red book.

 Light-affecting material properties:

   AMBIENT COLOR
   - multiplies by light's ambient component
   - for believability this should match diffuse color

   DIFFUSE COLOR
   - multiplies by light's diffuse component

   SPECULAR COLOR
   - multiplies by light's specular component
   - usually less colored than diffuse/ambient

   SHININESS
   - the concentration of specular effect
   - this should be set pretty high (20-50) to see really
     noticeable specularity

   EMISSIVE COLOR
   - constant additive color effect

 Light types:

   AMBIENT
   - one color
   - no specular color
   - no direction
   - may have falloff (constant, linear, and quadratic)
   - may have position (which matters in non-constant falloff case)
   - multiplies by a material's ambient reflection

   DIRECTIONAL
   - has diffuse color
   - has specular color
   - has direction
   - no position
   - no falloff
   - multiplies by a material's diffuse and specular reflections

   POINT
   - has diffuse color
   - has specular color
   - has position
   - no direction
   - may have falloff (constant, linear, and quadratic)
   - multiplies by a material's diffuse and specular reflections

   SPOT
   - has diffuse color
   - has specular color
   - has position
   - has direction
   - has cone angle (set to half the total cone angle)
   - has concentration value
   - may have falloff (constant, linear, and quadratic)
   - multiplies by a material's diffuse and specular reflections

 Normal modes:

 All of the primitives (rect, box, sphere, etc.) have their normals
 set nicely. During beginShape/endShape normals can be set by the user.

   AUTO-NORMAL
   - if no normal is set during the shape, we are in auto-normal mode
   - auto-normal calculates one normal per triangle (face-normal mode)

   SHAPE-NORMAL
   - if one normal is set during the shape, it will be used for
     all vertices

   VERTEX-NORMAL
   - if multiple normals are set, each normal applies to
     subsequent vertices
   - (except for the first one, which applies to previous
     and subsequent vertices)

 Efficiency consequences:

   There is a major efficiency consequence of position-dependent
   lighting calculations per vertex. (See below for determining
   whether lighting is vertex position-dependent.) If there is no
   position dependency then the only factors that affect the lighting
   contribution per vertex are its colors and its normal.
   There is a major efficiency win if

   1) lighting is not position dependent
   2) we are in AUTO-NORMAL or SHAPE-NORMAL mode

   because then we can calculate one lighting contribution per shape
   (SHAPE-NORMAL) or per triangle (AUTO-NORMAL) and simply multiply it
   into the vertex colors. The converse is our worst-case performance when

   1) lighting is position dependent
   2) we are in AUTO-NORMAL mode

   because then we must calculate lighting per-face * per-vertex.
   Each vertex has a different lighting contribution per face in
   which it appears. Yuck.

 Determining vertex position dependency:

   If any of the following factors are TRUE then lighting is
   vertex position dependent:

   1) Any lights uses non-constant falloff
   2) There are any point or spot lights
   3) There is a light with specular color AND there is a
      material with specular color

 So worth noting is that default lighting (a no-falloff ambient
 and a directional without specularity) is not position-dependent.
 We should capitalize.

 Simon Greenwold, April 2005
 

Overrides:
lights in class PGraphics3D

ambientLight

public void ambientLight(float r,
                         float g,
                         float b)
Description copied from class: PGraphics3D
Add an ambient light based on the current color mode.

Overrides:
ambientLight in class PGraphics3D

ambientLight

public void ambientLight(float r,
                         float g,
                         float b,
                         float x,
                         float y,
                         float z)
Description copied from class: PGraphics3D
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.

Overrides:
ambientLight in class PGraphics3D

directionalLight

public void directionalLight(float r,
                             float g,
                             float b,
                             float nx,
                             float ny,
                             float nz)
Overrides:
directionalLight in class PGraphics3D

pointLight

public void pointLight(float r,
                       float g,
                       float b,
                       float x,
                       float y,
                       float z)
Overrides:
pointLight in class PGraphics3D

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)
Overrides:
spotLight in class PGraphics3D

lightFalloff

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

Overrides:
lightFalloff in class PGraphics3D

lightSpecular

public void lightSpecular(float x,
                          float y,
                          float z)
Description copied from class: PGraphics3D
Set the specular color of the last light created.

Overrides:
lightSpecular in class PGraphics3D

glLightSpotAngle

public void glLightSpotAngle(int num)

glLightSpotConcentration

public void glLightSpotConcentration(int num)

strokeJoin

public void strokeJoin(int join)
Overrides:
strokeJoin in class PGraphics3D

strokeCap

public void strokeCap(int cap)
Overrides:
strokeCap in class PGraphics3D

ambient

public void ambient(int rgb)
Overrides:
ambient in class PGraphics3D

ambient

public void ambient(float gray)
Overrides:
ambient in class PGraphics3D

ambient

public void ambient(float x,
                    float y,
                    float z)
Overrides:
ambient in class PGraphics3D

specular

public void specular(int rgb)
Overrides:
specular in class PGraphics3D

specular

public void specular(float gray)
Overrides:
specular in class PGraphics3D

specular

public void specular(float x,
                     float y,
                     float z)
Overrides:
specular in class PGraphics3D

emissive

public void emissive(int rgb)
Overrides:
emissive in class PGraphics3D

emissive

public void emissive(float gray)
Overrides:
emissive in class PGraphics3D

emissive

public void emissive(float x,
                     float y,
                     float z)
Overrides:
emissive in class PGraphics3D

shininess

public void shininess(float shine)
Overrides:
shininess in class PGraphics3D

background

public void background(PImage bgimage)
Description copied from class: PGraphics3D
Takes an RGB or RGBA image and sets it as the background.

Note that even if the image is set as RGB, the high 8 bits of each pixel must be set (0xFF000000), because the image data will be copied directly to the screen.

Also clears out the zbuffer and stencil buffer if they exist.

Overrides:
background in class PGraphics3D

clear

public void clear()
Description copied from class: PGraphics3D
Clear pixel buffer. With P3D and OPENGL, this also clears the zbuffer. Stencil buffer should also be cleared, but for now is ignored in P3D.


smooth

public void smooth()
Description copied from class: PImage
If true in PImage, use bilinear interpolation for copy() operations. When inherited by PGraphics, also controls shapes.

Overrides:
smooth in class PGraphics3D

noSmooth

public void noSmooth()
Description copied from class: PImage
Disable smoothing. See smooth().

Overrides:
noSmooth in class PGraphics3D

loadPixels

public void loadPixels()
Description copied from class: PImage
Call this when you want to mess with the pixels[] array.

For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array

Overrides:
loadPixels in class PImage

updatePixels

public void updatePixels()
Description copied from class: PImage
Call this when finished messing with the pixels[] array.

Mark all pixels as needing update.

Overrides:
updatePixels in class PImage

get

public int get(int x,
               int y)
Description copied from class: PImage
Returns an ARGB "color" type (a packed 32 bit int with the color. If the coordinate is outside the image, zero is returned (black, but completely transparent).

If the image is in RGB format (i.e. on a PVideo object), the value will get its high bits set, just to avoid cases where they haven't been set already.

If the image is in ALPHA format, this returns a white with its alpha value set.

This function is included primarily for beginners. It is quite slow because it has to check to see if the x, y that was provided is inside the bounds, and then has to check to see what image type it is. If you want things to be more efficient, access the pixels[] array directly.

Overrides:
get in class PImage

get

public PImage get(int x,
                  int y,
                  int w,
                  int h)
Description copied from class: PImage
Grab a subsection of a PImage, and copy it into a fresh PImage. This honors imageMode() for the coordinates.

Overrides:
get in class PImage

get

public PImage get()
Description copied from class: PImage
Returns a copy of this PImage. Equivalent to get(0, 0, width, height).

Overrides:
get in class PImage

set

public void set(int x,
                int y,
                int argb)
Description copied from class: PImage
Silently ignores if the coordinate is outside the image.

Overrides:
set in class PImage

set

public void set(int x,
                int y,
                PImage source)
Set an image directly to the screen.

TODO not optimized properly, creates multiple temporary buffers the size of the image. Needs to instead use image cache, but that requires two types of image cache. One for power of 2 textures and another for glReadPixels/glDrawPixels data that's flipped vertically. Both have their components all swapped to native.

Overrides:
set in class PImage

filter

public void filter(int kind)
This is really inefficient and not a good idea in OpenGL. Use get() and set() with a smaller image area, or call the filter on an image instead, and then draw that.

Overrides:
filter in class PImage

filter

public void filter(int kind,
                   float param)
This is really inefficient and not a good idea in OpenGL. Use get() and set() with a smaller image area, or call the filter on an image instead, and then draw that.

Overrides:
filter in class PImage

copy

public void copy(int sx1,
                 int sy1,
                 int sx2,
                 int sy2,
                 int dx1,
                 int dy1,
                 int dx2,
                 int dy2)
Extremely slow and not optimized, should use glCopyPixels instead. Currently calls a beginPixels() on the whole canvas, then does the copy, then it calls endPixels().

Overrides:
copy in class PImage

copy

public void copy(PImage src,
                 int sx1,
                 int sy1,
                 int sx2,
                 int sy2,
                 int dx1,
                 int dy1,
                 int dx2,
                 int dy2)
TODO - extremely slow and not optimized. Currently calls a beginPixels() on the whole canvas, then does the copy, then it calls endPixels().

Overrides:
copy in class PImage

blend

public void blend(int sx,
                  int sy,
                  int dx,
                  int dy,
                  int mode)

blend

public void blend(PImage src,
                  int sx,
                  int sy,
                  int dx,
                  int dy,
                  int mode)

blend

public void blend(int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
TODO - extremely slow and not optimized. Currently calls a beginPixels() on the whole canvas, then does the blend, then it calls endPixels().

Overrides:
blend in class PImage
See Also:
PImage.blendColor(int,int,int)

blend

public void blend(PImage src,
                  int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
TODO - extremely slow and not optimized. Currently calls a beginPixels() on the whole canvas, then does the blend, then it calls endPixels().

Overrides:
blend in class PImage
See Also:
PImage.blendColor(int,int,int)

save

public void save(java.lang.String filename)
Description copied from class: PImage
Save this image to disk.

As of revision 0100, this function requires an absolute path, in order to avoid confusion. To save inside the sketch folder, use the function savePath() from PApplet, or use saveFrame() instead. As of revision 0116, savePath() is not needed if this object has been created (as recommended) via createImage() or createGraphics() or one of its neighbors.

As of revision 0115, when using Java 1.4 and later, you can write to several formats besides tga and tiff. If Java 1.4 is installed and the extension used is supported (usually png, jpg, jpeg, bmp, and tiff), then those methods will be used to write the image. To get a list of the supported formats for writing, use:
println(javax.imageio.ImageIO.getReaderFormatNames())

To use the original built-in image writers, use .tga or .tif as the extension, or don't include an extension. When no extension is used, the extension .tif will be added to the file name.

The ImageIO API claims to support wbmp files, however they probably require a black and white image. Basic testing produced a zero-length file with no error.

Overrides:
save in class PImage

report

public void report(java.lang.String where)
Report on anything from glError(). Don't use this inside glBegin/glEnd otherwise it'll throw an GL_INVALID_OPERATION error.