|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object processing.core.PImage processing.core.PGraphics processing.core.PGraphics3D processing.opengl.PGraphicsOpenGL
public class PGraphicsOpenGL
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.PGraphics |
---|
ambientB, ambientG, ambientR, backgroundColor, bezierDetail, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, curveTightness, edge, ellipseMode, emissiveB, emissiveG, emissiveR, fill, fillColor, image, imageMode, normalX, normalY, normalZ, pixelCount, rectMode, shapeMode, shininess, smooth, specularB, specularG, specularR, sphereDetailU, sphereDetailV, stroke, strokeCap, strokeColor, strokeJoin, strokeWeight, textAlign, textAlignY, textFont, textLeading, textMode, textSize, textureImage, textureMode, textureU, textureV, tint, tintColor |
Fields inherited from class processing.core.PImage |
---|
format, height, parent, pixels, width |
Constructor Summary | |
---|---|
PGraphicsOpenGL()
|
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 PGraphics for drawing. |
javax.media.opengl.GL |
beginGL()
|
boolean |
canDraw()
OpenGL cannot draw until a proper native peer is available, so this returns the value of PApplet.isDisplayable() (inherited from Component). |
void |
directionalLight(float r,
float g,
float b,
float nx,
float ny,
float nz)
|
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. |
javax.media.opengl.GLContext |
getContext()
Get the current context, for use by libraries that need to talk to it. |
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 |
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 |
mask(int[] alpha)
Set alpha channel for an image. |
void |
mask(PImage alpha)
Set alpha channel for an image using another image as the source. |
void |
noSmooth()
Disable smoothing. |
void |
pointLight(float r,
float g,
float b,
float x,
float y,
float z)
|
void |
report(java.lang.String where)
Report on anything from glError(). |
void |
resize(int wide,
int high)
Resize this image to a new width and height. |
void |
set(int x,
int y,
int argb)
Set a single pixel to the specified color. |
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 |
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)
|
void |
strokeWeight(float weight)
|
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 |
textFont(PFont which)
Sets the current font. |
void |
updatePixels()
Call this when finished messing with the pixels[] array. |
Methods inherited from class processing.core.PGraphics3D |
---|
applyMatrix, applyMatrix, applyMatrix, applyMatrix, beginCamera, beginShape, box, camera, camera, endCamera, endShape, flush, frustum, getMatrix, getMatrix, is2D, is3D, lights, modelX, modelY, modelZ, noLights, ortho, ortho, perspective, perspective, popMatrix, printCamera, printMatrix, printProjection, pushMatrix, resetMatrix, rotate, rotate, rotateX, rotateY, rotateZ, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, setMatrix, setMatrix, setSize, sphere, texture, translate, translate, vertex, vertex |
Methods inherited from class processing.core.PImage |
---|
blend, blend, blendColor, clone, copy, copy, get, getCache, getImage, init, isModified, removeCache, save, setCache, setModified, setModified, updatePixels |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public javax.media.opengl.GL gl
public javax.media.opengl.glu.GLU glu
public static boolean BIG_ENDIAN
Constructor Detail |
---|
public PGraphicsOpenGL()
Method Detail |
---|
public javax.media.opengl.GLContext getContext()
public boolean canDraw()
canDraw
in class PGraphics
public void beginDraw()
PGraphics
beginDraw
in class PGraphics3D
public void endDraw()
PGraphics3D
endDraw
in class PGraphics3D
public javax.media.opengl.GL beginGL()
public void endGL()
public void hint(int which)
PGraphics
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:
hint
in class PGraphics3D
public void smooth()
PGraphics
smooth
in class PGraphics3D
public void noSmooth()
PGraphics
noSmooth
in class PGraphics3D
public float textAscent()
PGraphics
textAscent
in class PGraphics
public float textDescent()
PGraphics
textDescent
in class PGraphics
public void textFont(PFont which)
PGraphics
textFont
in class PGraphics
public void strokeWeight(float weight)
strokeWeight
in class PGraphics
public void strokeJoin(int join)
strokeJoin
in class PGraphics3D
public void strokeCap(int cap)
strokeCap
in class PGraphics3D
public void shininess(float shine)
shininess
in class PGraphics
public void ambientLight(float r, float g, float b)
PGraphics3D
ambientLight
in class PGraphics3D
public void ambientLight(float r, float g, float b, float x, float y, float z)
PGraphics3D
ambientLight
in class PGraphics3D
public void directionalLight(float r, float g, float b, float nx, float ny, float nz)
directionalLight
in class PGraphics3D
public void pointLight(float r, float g, float b, float x, float y, float z)
pointLight
in class PGraphics3D
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)
spotLight
in class PGraphics3D
public void lightFalloff(float constant, float linear, float quadratic)
PGraphics3D
lightFalloff
in class PGraphics3D
public void lightSpecular(float x, float y, float z)
PGraphics3D
lightSpecular
in class PGraphics3D
public void report(java.lang.String where)
public void loadPixels()
PImage
loadPixels
in class PImage
public void updatePixels()
PImage
updatePixels
in class PImage
public void resize(int wide, int high)
PImage
resize
in class PImage
public int get(int x, int y)
PImage
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.
get
in class PImage
public PImage get()
PImage
get
in class PImage
public void set(int x, int y, int argb)
PImage
set
in class PImage
public void set(int x, int y, PImage source)
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.
set
in class PImage
public void mask(int[] alpha)
PImage
Strictly speaking the "blue" value from the source image is used as the alpha color. For a fully grayscale image, this is correct, but for a color image it's not 100% accurate. For a more accurate conversion, first use filter(GRAY) which will make the image into a "correct" grayscake by performing a proper luminance-based conversion.
mask
in class PImage
public void mask(PImage alpha)
PImage
mask
in class PImage
public void filter(int kind)
filter
in class PImage
public void filter(int kind, float param)
filter
in class PImage
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |