de.grogra.imp3d.gl20
Class GL20GfxServer

java.lang.Object
  extended by de.grogra.imp3d.gl20.GL20GfxServer

public class GL20GfxServer
extends java.lang.Object


Field Summary
static int ELEMENTS_BYTE
          elements are stored as byte indicator
static int ELEMENTS_INT
          elements are stored as int
static int ELEMENTS_MASK
          elements storage mask
static int ELEMENTS_SHORT
          elements are stored as short
static int HAS_NO_NORMALS
          no normals are stored
static int HAS_NO_TEXTURE_UV
          no texture coordinates are stored
static int HAS_NORMALS_BYTE
          normals are stored in byte indicator
static int HAS_NORMALS_FLOAT
          normals are stored in float indicator
static int HAS_TEXTURE_UV_FLOAT
          texture coordinates are stored in float indicator
static int HAS_TEXTURE_UV_SHORT
          texture coordinates are stored in short indicator
static int HAS_VERTEX_3_FLOAT
          vertex with 3 elements are stored in float indicator
static int HAS_VERTEX_3_SHORT
          vertex with 3 elements are stored in short indicator
static int HAS_VERTEX_4_FLOAT
          vetrex with 4 elements are stored in float indicator
static int HAS_VERTEX_4_SHORT
          vertex with 4 elements are stored in short indicator
static int LINES
          line indicator
static int NORMAL_MASK
          normal mask
static int ORDER_MASK
          order mask
static int ORDER_N_UV_V
          normal - uv - vertex order indicator
static int ORDER_N_V_UV
          normal - vertex - uv order indicator
static int ORDER_UV_N_V
          uv - normal - vertex order indicator
static int ORDER_UV_V_N
          uv - vertex - normal order indicator
static int ORDER_V_N_UV
          vertex - normal - uv order indicator
static int ORDER_V_UV_N
          vertex - uv - normal order indicator
static int PRIMITIVE_MASK
          primitive mask
static int QUADS
          quadrilaterals indicator
static int TEXTURE_MASK
          texture mask
static int TRIANGLES
          triangle indicator
static int VERTEX_MASK
          vertex mask
 
Method Summary
 void addNodeToScene(GL20Node node)
          add a GL20Node to the current scene.
 void addNodeToTool(GL20Node node)
          add a GL20Node to the current tool nodes
 boolean beginScene(javax.media.opengl.GL currentGL)
          begin a new scene
 boolean bindTextureIndex(int dimensions, int textureIndex, int textureStage)
          bind a texture given by its textureIndex to a texture stage given by its textureStage.
 void checkExtensions()
           
 void closeArrayBuffer(int arrayBufferIndex)
          close an array buffer, that was opened before with openArrayBuffer()
 void closeElementArrayBuffer(int elementArrayBufferIndex)
          close an element array buffer that was opened before with openElementArrayBuffer()
 int createArrayBuffer()
          create a new array buffer that can contain vertex data
 int createElementArrayBuffer()
          create a new element array buffer that can contain indices to vertices in a array buffer
 int createShader(de.grogra.imp3d.gl20.GL20GLSLCode code)
           
 int createTextureIndex(int dimensions)
          create a new texture index
 void deleteArrayBuffer(int arrayBufferIndex)
          delete an array buffer given by its index
 void deleteElementArrayBuffer(int elementArrayBufferIndex)
          delete an element array buffer given by its index
 void deleteTextureIndex(int dimensions, int textureIndex)
          delete a texture index that was created via createTextureIndex()
 boolean drawElementArrayBuffer(int elementArrayBufferIndex, int arrayBufferIndex, int firstElementIndex, int elementUsedCount, int flags)
          draw an array buffer while using an element array buffer for the element indices.
 void drawLine(Tuple3f start, Tuple3f end)
          draw a single line should only called for very few reasons, e.g. like lines for tools
 void endScene()
          end the current scene
 int getContextID()
          get the current OpenGL context ID. every context change the context ID will be incremented.
 Vector4f getCurrentColor()
          get the current color
 int getFrameID()
          get the current frame ID. every frame the frame ID will be incremented.
static GL20GfxServer getInstance()
          get the server instance of this GL20GfxServer
 Matrix4d getViewToClipMatrix()
          get the view to clip matrix
 Matrix4d getWorldToClipMatrix()
          get the world to clip matrix.
 Matrix4d getWorldToViewMatrix()
          get the world to view matrix
 boolean inScene()
          check if this GL20GfxServer is between beginScene() and endScene()
 boolean openArrayBuffer(int arrayBufferIndex, int size)
          open an array buffer for writing
 boolean openElementArrayBuffer(int elementArrayBufferIndex, int size)
          open an element array buffer for writing
 void setCurrentColor(Vector4f color)
          set the current color
 int setTextureImage(int textureIndex, int width, int height, int depth, int[] pixelData)
           
 boolean setViewToClipMatrix(Matrix4d viewToClipMatrix)
          set the view to clip matrix. can only be setted before beginScene()
 boolean setWorldToViewMatrix(Matrix4d worldToViewMatrix)
          set the world to view matrix. can only be setted before beginScene()
 void setWorldTransformationMatrix(Matrix4d worldMatrix)
          set the world transformation matrix
 void unbindTexture(int dimensions, int textureStage)
          unbind a texture from a given textureStage
 int writeArrayBuffer2b(byte a, byte b)
           
 int writeArrayBuffer2f(float x, float y)
           
 int writeArrayBuffer2i(int a, int b)
           
 int writeArrayBuffer3b(byte a, byte b, byte c)
           
 int writeArrayBuffer3f(float x, float y, float z)
           
 int writeArrayBuffer3i(int a, int b, int c)
           
 int writeArrayBuffer4b(byte a, byte b, byte c, byte d)
           
 int writeArrayBuffer4f(float x, float y, float z, float w)
           
 int writeArrayBuffer4i(int a, int b, int c, int d)
           
 int writeArrayBufferbv(byte[] v, int count)
           
 int writeArrayBufferfv(float[] v, int count)
           
 int writeArrayBufferiv(int[] v, int count)
           
 int writeElementArrayBuffer2b(byte a, byte b)
           
 int writeElementArrayBuffer2f(float x, float y)
           
 int writeElementArrayBuffer2i(int a, int b)
           
 int writeElementArrayBuffer3b(byte a, byte b, byte c)
           
 int writeElementArrayBuffer3f(float x, float y, float z)
           
 int writeElementArrayBuffer3i(int a, int b, int c)
           
 int writeElementArrayBuffer4b(byte a, byte b, byte c, byte d)
           
 int writeElementArrayBuffer4f(float x, float y, float z, float w)
           
 int writeElementArrayBuffer4i(int a, int b, int c, int d)
           
 int writeElementArrayBufferbv(byte[] v, int count)
           
 int writeElementArrayBufferfv(float[] v, int count)
           
 int writeElementArrayBufferiv(int[] v, int count)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENTS_BYTE

public static final int ELEMENTS_BYTE
elements are stored as byte indicator

See Also:
Constant Field Values

ELEMENTS_INT

public static final int ELEMENTS_INT
elements are stored as int

See Also:
Constant Field Values

ELEMENTS_MASK

public static final int ELEMENTS_MASK
elements storage mask

See Also:
Constant Field Values

ELEMENTS_SHORT

public static final int ELEMENTS_SHORT
elements are stored as short

See Also:
Constant Field Values

HAS_NO_NORMALS

public static final int HAS_NO_NORMALS
no normals are stored

See Also:
Constant Field Values

HAS_NO_TEXTURE_UV

public static final int HAS_NO_TEXTURE_UV
no texture coordinates are stored

See Also:
Constant Field Values

HAS_NORMALS_BYTE

public static final int HAS_NORMALS_BYTE
normals are stored in byte indicator

See Also:
Constant Field Values

HAS_NORMALS_FLOAT

public static final int HAS_NORMALS_FLOAT
normals are stored in float indicator

See Also:
Constant Field Values

HAS_TEXTURE_UV_FLOAT

public static final int HAS_TEXTURE_UV_FLOAT
texture coordinates are stored in float indicator

See Also:
Constant Field Values

HAS_TEXTURE_UV_SHORT

public static final int HAS_TEXTURE_UV_SHORT
texture coordinates are stored in short indicator

See Also:
Constant Field Values

HAS_VERTEX_3_FLOAT

public static final int HAS_VERTEX_3_FLOAT
vertex with 3 elements are stored in float indicator

See Also:
Constant Field Values

HAS_VERTEX_3_SHORT

public static final int HAS_VERTEX_3_SHORT
vertex with 3 elements are stored in short indicator

See Also:
Constant Field Values

HAS_VERTEX_4_FLOAT

public static final int HAS_VERTEX_4_FLOAT
vetrex with 4 elements are stored in float indicator

See Also:
Constant Field Values

HAS_VERTEX_4_SHORT

public static final int HAS_VERTEX_4_SHORT
vertex with 4 elements are stored in short indicator

See Also:
Constant Field Values

LINES

public static final int LINES
line indicator

See Also:
Constant Field Values

NORMAL_MASK

public static final int NORMAL_MASK
normal mask

See Also:
Constant Field Values

ORDER_MASK

public static final int ORDER_MASK
order mask

See Also:
Constant Field Values

ORDER_N_UV_V

public static final int ORDER_N_UV_V
normal - uv - vertex order indicator

See Also:
Constant Field Values

ORDER_N_V_UV

public static final int ORDER_N_V_UV
normal - vertex - uv order indicator

See Also:
Constant Field Values

ORDER_UV_N_V

public static final int ORDER_UV_N_V
uv - normal - vertex order indicator

See Also:
Constant Field Values

ORDER_UV_V_N

public static final int ORDER_UV_V_N
uv - vertex - normal order indicator

See Also:
Constant Field Values

ORDER_V_N_UV

public static final int ORDER_V_N_UV
vertex - normal - uv order indicator

See Also:
Constant Field Values

ORDER_V_UV_N

public static final int ORDER_V_UV_N
vertex - uv - normal order indicator

See Also:
Constant Field Values

PRIMITIVE_MASK

public static final int PRIMITIVE_MASK
primitive mask

See Also:
Constant Field Values

QUADS

public static final int QUADS
quadrilaterals indicator

See Also:
Constant Field Values

TEXTURE_MASK

public static final int TEXTURE_MASK
texture mask

See Also:
Constant Field Values

TRIANGLES

public static final int TRIANGLES
triangle indicator

See Also:
Constant Field Values

VERTEX_MASK

public static final int VERTEX_MASK
vertex mask

See Also:
Constant Field Values
Method Detail

addNodeToScene

public final void addNodeToScene(GL20Node node)
add a GL20Node to the current scene.

Parameters:
node - the node that should be added

addNodeToTool

public final void addNodeToTool(GL20Node node)
add a GL20Node to the current tool nodes

Parameters:
node - the node that should be added

beginScene

public final boolean beginScene(javax.media.opengl.GL currentGL)
begin a new scene

Returns:
true - successful

bindTextureIndex

public final boolean bindTextureIndex(int dimensions,
                                      int textureIndex,
                                      int textureStage)
bind a texture given by its textureIndex to a texture stage given by its textureStage.

Parameters:
dimensions - number of dimensions of the texture with given textureIndex
textureIndex - a texture index that was return by createTextureIndex
textureStage - the stage to which the texture should be bound
Returns:
true successful bound to given texture stage false textureStage and/or textureIndex are invalid

checkExtensions

public final void checkExtensions()

closeArrayBuffer

public final void closeArrayBuffer(int arrayBufferIndex)
close an array buffer, that was opened before with openArrayBuffer()

Parameters:
arrayBufferIndex - the index of the array buffer that should closed

closeElementArrayBuffer

public final void closeElementArrayBuffer(int elementArrayBufferIndex)
close an element array buffer that was opened before with openElementArrayBuffer()

Parameters:
elementArrayBufferIndex - the index of the element array buffer that should closed

createArrayBuffer

public final int createArrayBuffer()
create a new array buffer that can contain vertex data

Returns:
the index of the created array buffer

createElementArrayBuffer

public final int createElementArrayBuffer()
create a new element array buffer that can contain indices to vertices in a array buffer

Returns:
the index of the created element array buffer
See Also:
createArrayBuffer

createShader

public final int createShader(de.grogra.imp3d.gl20.GL20GLSLCode code)

createTextureIndex

public final int createTextureIndex(int dimensions)
create a new texture index

Parameters:
dimensions - number of the dimensions that the texture should have
Returns:
the new texture index

deleteArrayBuffer

public final void deleteArrayBuffer(int arrayBufferIndex)
delete an array buffer given by its index

Parameters:
index - the array buffer index

deleteElementArrayBuffer

public final void deleteElementArrayBuffer(int elementArrayBufferIndex)
delete an element array buffer given by its index

Parameters:
index - the element array buffer index

deleteTextureIndex

public final void deleteTextureIndex(int dimensions,
                                     int textureIndex)
delete a texture index that was created via createTextureIndex()

Parameters:
dimensions - number of the dimensions that the texture with textureIndex have
textureIndex - the texture index that should be deleted

drawElementArrayBuffer

public final boolean drawElementArrayBuffer(int elementArrayBufferIndex,
                                            int arrayBufferIndex,
                                            int firstElementIndex,
                                            int elementUsedCount,
                                            int flags)
draw an array buffer while using an element array buffer for the element indices. with firstElementIndex and elementUsedCount you can control if the whole element array buffer or just a part of it should used for drawing

Parameters:
elementArrayBufferIndex - the index of the element array buffer
arrayBufferIndex - the index of the array buffer
firstElementIndex - the index of the first index in element array buffer
elementUsedCount - the number of elements that should used starting at firstElementIndex
flags - flags the inform the GL20GfxServer how the buffers are build up
Returns:
true - successful drawing

drawLine

public final void drawLine(Tuple3f start,
                           Tuple3f end)
draw a single line should only called for very few reasons, e.g. like lines for tools

Parameters:
start - the start coordinate of the line
end - the end coordinate of the line

endScene

public final void endScene()
end the current scene


getContextID

public final int getContextID()
get the current OpenGL context ID. every context change the context ID will be incremented.

Returns:
the current context ID

getCurrentColor

public final Vector4f getCurrentColor()
get the current color

Returns:
the current color

getFrameID

public final int getFrameID()
get the current frame ID. every frame the frame ID will be incremented.

Returns:
the current frame ID

getInstance

public static final GL20GfxServer getInstance()
get the server instance of this GL20GfxServer

Returns:
the server instance

getViewToClipMatrix

public final Matrix4d getViewToClipMatrix()
get the view to clip matrix

Returns:
the view to clip matrix

getWorldToClipMatrix

public final Matrix4d getWorldToClipMatrix()
get the world to clip matrix. only valid when inScene() or inRendering()

Returns:
null - not inScene() or inRendering() otherwise - the world to clip matrix

getWorldToViewMatrix

public final Matrix4d getWorldToViewMatrix()
get the world to view matrix

Returns:
the world to view matrix

inScene

public final boolean inScene()
check if this GL20GfxServer is between beginScene() and endScene()

Returns:
true - this GL20GfxServer is between beginScene() and endScene()

openArrayBuffer

public final boolean openArrayBuffer(int arrayBufferIndex,
                                     int size)
open an array buffer for writing

Parameters:
arrayBufferIndex - the index of the array buffer that should opened
size - the size in bytes that the buffer should contain
Returns:
true - buffer is opened for writing
See Also:
createArrayBuffer()

openElementArrayBuffer

public final boolean openElementArrayBuffer(int elementArrayBufferIndex,
                                            int size)
open an element array buffer for writing

Parameters:
elementArrayBufferIndex - the index of the element array buffer that should opened
size - the size in bytes that the buffer should contain
Returns:
true - buffer is opened for writing
See Also:
createElementArrayBuffer()

setCurrentColor

public final void setCurrentColor(Vector4f color)
set the current color

Parameters:
color - the color that should set

setTextureImage

public final int setTextureImage(int textureIndex,
                                 int width,
                                 int height,
                                 int depth,
                                 int[] pixelData)
Parameters:
textureIndex -
width - the width of the image in pixel. must be power of 2
height - the height of the image in pixel. must be power of 2
depth - the depth of the image in pixel. must be power of 2
pixelData -
Returns:
0 image wasn't set otherwise the dimension of the image that was set

setViewToClipMatrix

public final boolean setViewToClipMatrix(Matrix4d viewToClipMatrix)
set the view to clip matrix. can only be setted before beginScene()

Parameters:
viewToClipMatrix - the matrix that should set
Returns:
true - the view to clip matrix was set successful

setWorldToViewMatrix

public final boolean setWorldToViewMatrix(Matrix4d worldToViewMatrix)
set the world to view matrix. can only be setted before beginScene()

Parameters:
worldToViewMatrix - the world to view matrix
Returns:
true - the world to view matrix was set successful

setWorldTransformationMatrix

public final void setWorldTransformationMatrix(Matrix4d worldMatrix)
set the world transformation matrix

Parameters:
worldMatrix - the world transformation matrix

unbindTexture

public final void unbindTexture(int dimensions,
                                int textureStage)
unbind a texture from a given textureStage

Parameters:
dimensions - number of dimensions that the texture of given textureStage has
textureStage - the stage which should unbind

writeArrayBuffer2b

public final int writeArrayBuffer2b(byte a,
                                    byte b)

writeArrayBuffer2f

public final int writeArrayBuffer2f(float x,
                                    float y)

writeArrayBuffer2i

public final int writeArrayBuffer2i(int a,
                                    int b)

writeArrayBuffer3b

public final int writeArrayBuffer3b(byte a,
                                    byte b,
                                    byte c)

writeArrayBuffer3f

public final int writeArrayBuffer3f(float x,
                                    float y,
                                    float z)

writeArrayBuffer3i

public final int writeArrayBuffer3i(int a,
                                    int b,
                                    int c)

writeArrayBuffer4b

public final int writeArrayBuffer4b(byte a,
                                    byte b,
                                    byte c,
                                    byte d)

writeArrayBuffer4f

public final int writeArrayBuffer4f(float x,
                                    float y,
                                    float z,
                                    float w)

writeArrayBuffer4i

public final int writeArrayBuffer4i(int a,
                                    int b,
                                    int c,
                                    int d)

writeArrayBufferbv

public final int writeArrayBufferbv(byte[] v,
                                    int count)

writeArrayBufferfv

public final int writeArrayBufferfv(float[] v,
                                    int count)

writeArrayBufferiv

public final int writeArrayBufferiv(int[] v,
                                    int count)

writeElementArrayBuffer2b

public final int writeElementArrayBuffer2b(byte a,
                                           byte b)

writeElementArrayBuffer2f

public final int writeElementArrayBuffer2f(float x,
                                           float y)

writeElementArrayBuffer2i

public final int writeElementArrayBuffer2i(int a,
                                           int b)

writeElementArrayBuffer3b

public final int writeElementArrayBuffer3b(byte a,
                                           byte b,
                                           byte c)

writeElementArrayBuffer3f

public final int writeElementArrayBuffer3f(float x,
                                           float y,
                                           float z)

writeElementArrayBuffer3i

public final int writeElementArrayBuffer3i(int a,
                                           int b,
                                           int c)

writeElementArrayBuffer4b

public final int writeElementArrayBuffer4b(byte a,
                                           byte b,
                                           byte c,
                                           byte d)

writeElementArrayBuffer4f

public final int writeElementArrayBuffer4f(float x,
                                           float y,
                                           float z,
                                           float w)

writeElementArrayBuffer4i

public final int writeElementArrayBuffer4i(int a,
                                           int b,
                                           int c,
                                           int d)

writeElementArrayBufferbv

public final int writeElementArrayBufferbv(byte[] v,
                                           int count)

writeElementArrayBufferfv

public final int writeElementArrayBufferfv(float[] v,
                                           int count)

writeElementArrayBufferiv

public final int writeElementArrayBufferiv(int[] v,
                                           int count)