### codeanticode.glgraphics

# Class GLGraphics

- `PGraphicsOpenGL`
- - `codeanticode.glgraphics.GLGraphics`

Implemented Interfaces:
  GLConstants

`public class GLGraphics`
`extends PGraphicsOpenGL`
`implements GLConstants`

This class makes the OpenGL renderer compatible with the GLTexture object.

  ## Field Summary
  `static int` | `MAX_LIGHTS_GL` Maximum lights by default is 8, the minimum defined by OpenGL.
  `float` | `currentLightFalloffConstantGL` Current light falloff
  `float` | `currentLightFalloffLinearGL`
  `float` | `currentLightFalloffQuadraticGL`
  `float[]` | `currentLightSpecularGL` Current specular color for lighting
  `int` | `lightCountGL`
  `float[][]` | `lightDiffuseGL` Diffuse colors for lights.
  `float[]` | `lightFalloffConstantGL` Light falloff
  `float[]` | `lightFalloffLinearGL`
  `float[]` | `lightFalloffQuadraticGL`
  `float[][]` | `lightNormalGL` Light direction (normalized vector)
  `float[][]` | `lightPositionGL` Light positions
  `float[][]` | `lightSpecularGL` Specular colors for lights.
  `float[]` | `lightSpotAngleCosGL` Cosine of light spot angle
  `float[]` | `lightSpotAngleGL` Light spot angle
  `float[]` | `lightSpotConcentrationGL` Light spot concentration
  `int[]` | `lightTypeGL` Light types
  `int` | `saveLightCount`
  `float[]` | `zeroBufferGL`

  ## Constructor Summary
  `GLGraphics()` Default constructor.

  ## Method Summary
  `void` | `addWindow(GLWindow win)` Adds a GLWindow to be handled by this renderer.
  `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()`
  `GL` | `beginGL()`
  `void` | `camera()`
  `void` | `camera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)`
  `boolean` | `canDraw()` Adds the additional check for all the GL windows.
  `GLFont` | `createGLFont(String name, float size)`
  `GLFont` | `createGLFont(String name, float size, boolean smooth)`
  `GLFont` | `createGLFont(String name, float size, boolean smooth, charset[] )`
  `void` | `directionalLight(float r, float g, float b, float nx, float ny, float nz)`
  `void` | `endCamera()`
  `void` | `endDraw()`
  `void` | `endGL()`
  `void` | `frustum(float left, float right, float bottom, float top, float near, float far)`
  `GLCapabilities` | `getCapabilities()` Returns the OpenGL capabilities of the drawable associated to this renderer.
  `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` | `lights()`
  `GLFont` | `loadGLFont(String filename)`
  `void` | `model(GLModel model)`
  `void` | `model(GLModel model, GLModelEffect effect)`
  `void` | `model(GLModel model, float x, float y, float z, int first, int last, GLModelEffect effect)`
  `void` | `model(GLModel model, int first, int last)`
  `void` | `model(GLModel model, int first, int last, GLModelEffect effect)`
  `float` | `modelX(float x, float y, float z)`
  `float` | `modelY(float x, float y, float z)`
  `float` | `modelZ(float x, float y, float z)`
  `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()`
  `void` | `pushMatrix()`
  `void` | `resetLights()`
  `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)`
  `float` | `screenX(float x, float y)`
  `float` | `screenX(float x, float y, float z)`
  `float` | `screenY(float x, float y)`
  `float` | `screenY(float x, float y, float z)`
  `float` | `screenZ(float x, float y, float z)`
  `void` | `setBlendMode(int MODE)`
  `void` | `setOffScreenRenderer(GLGraphicsOffScreen renderer)`
  `void` | `setSize(int iwidth, int iheight)`
  `void` | `shareContext(GLCanvas canvas)` Creates a new context for canvas that is shared with the context of GLGraphics.
  `void` | `shareContext(GLDrawable drawable)` Creates a new context for drawable that is shared with the context of GLGraphics.
  `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)`

## Field Details

### MAX_LIGHTS_GL

    public static final int MAX_LIGHTS_GL

> Maximum lights by default is 8, the minimum defined by OpenGL.
> Field Value:
>   8

### currentLightFalloffConstantGL

    public float currentLightFalloffConstantGL

> Current light falloff

### currentLightFalloffLinearGL

    public float currentLightFalloffLinearGL

### currentLightFalloffQuadraticGL

    public float currentLightFalloffQuadraticGL

### currentLightSpecularGL

    public float[] currentLightSpecularGL

> Current specular color for lighting

### lightCountGL

    public int lightCountGL

### lightDiffuseGL

    public float[][] lightDiffuseGL

> Diffuse colors for lights. For an ambient light, this will hold the ambient color. Internally these are stored as numbers between 0 and 1.

### lightFalloffConstantGL

    public float[] lightFalloffConstantGL

> Light falloff

### lightFalloffLinearGL

    public float[] lightFalloffLinearGL

### lightFalloffQuadraticGL

    public float[] lightFalloffQuadraticGL

### lightNormalGL

    public float[][] lightNormalGL

> Light direction (normalized vector)

### lightPositionGL

    public float[][] lightPositionGL

> Light positions

### lightSpecularGL

    public float[][] lightSpecularGL

> Specular colors for lights. Internally these are stored as numbers between 0 and 1.

### lightSpotAngleCosGL

    public float[] lightSpotAngleCosGL

> Cosine of light spot angle

### lightSpotAngleGL

    public float[] lightSpotAngleGL

> Light spot angle

### lightSpotConcentrationGL

    public float[] lightSpotConcentrationGL

> Light spot concentration

### lightTypeGL

    public int[] lightTypeGL

> Light types

### saveLightCount

    public int saveLightCount

### zeroBufferGL

    public float[] zeroBufferGL

## Constructor Details

### GLGraphics

    public GLGraphics()

> Default constructor.

## Method Details

### addWindow

    public void addWindow(GLWindow win)

> Adds a GLWindow to be handled by this renderer.
> Parameters:
>   `win` - GLWindow

### 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.

### beginDraw

    public void beginDraw()

### beginGL

    public GL beginGL()

### 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)

### canDraw

    public boolean canDraw()

> Adds the additional check for all the GL windows.

### createGLFont

    public GLFont createGLFont(String name,
                               float size)

### createGLFont

    public GLFont createGLFont(String name,
                               float size,
                               boolean smooth)

### createGLFont

    public GLFont createGLFont(String name,
                               float size,
                               boolean smooth,
                               charset[] )

### directionalLight

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

### endCamera

    public void endCamera()

### endDraw

    public void endDraw()

### endGL

    public void endGL()

### frustum

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

### getCapabilities

    public GLCapabilities getCapabilities()

> Returns the OpenGL capabilities of the drawable associated to this renderer.
> Returns:
>   GLCapabilities

### 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.

### lights

    public void lights()

### loadGLFont

    public GLFont loadGLFont(String filename)

### model

    public void model(GLModel model)

### model

    public void model(GLModel model,
                      GLModelEffect effect)

### model

    public void model(GLModel model,
                      float x,
                      float y,
                      float z,
                      int first,
                      int last,
                      GLModelEffect effect)

### model

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

### model

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

### modelX

    public float modelX(float x,
                        float y,
                        float z)

### modelY

    public float modelY(float x,
                        float y,
                        float z)

### modelZ

    public float modelZ(float x,
                        float y,
                        float z)

### noLights

    public void noLights()

### 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)

### pointLight

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

### popMatrix

    public void popMatrix()

### pushMatrix

    public void pushMatrix()

### resetLights

    public void resetLights()

### restoreLights

    public void restoreLights()

### rotate

    public void rotate(float angle)

### rotate

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

### rotateX

    public void rotateX(float angle)

### rotateY

    public void rotateY(float angle)

### rotateZ

    public void rotateZ(float angle)

### saveLights

    public void saveLights()

### scale

    public void scale(float s)

### scale

    public void scale(float sx,
                      float sy)

### scale

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

### screenX

    public float screenX(float x,
                         float y)

### screenX

    public float screenX(float x,
                         float y,
                         float z)

### screenY

    public float screenY(float x,
                         float y)

### screenY

    public float screenY(float x,
                         float y,
                         float z)

### screenZ

    public float screenZ(float x,
                         float y,
                         float z)

### setBlendMode

    public void setBlendMode(int MODE)

### setOffScreenRenderer

    public void setOffScreenRenderer(GLGraphicsOffScreen renderer)

### setSize

    public void setSize(int iwidth,
                        int iheight)

### shareContext

    public void shareContext(GLCanvas canvas)

> Creates a new context for canvas that is shared with the context of GLGraphics.
> Parameters:

### shareContext

    public void shareContext(GLDrawable drawable)

> Creates a new context for drawable that is shared with the context of GLGraphics.
> Parameters:

### 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)

### translate

    public void translate(float tx,
                          float ty)

### translate

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

processing library glgraphics by Andres Colubri. (c) 2008