Package com.jogamp.opengl.util
Class ImmModeSink
- java.lang.Object
-
- com.jogamp.opengl.util.ImmModeSink
-
public class ImmModeSink extends Object
Immediate mode sink, implementing OpenGL fixed function subset of immediate mode operations, i.e.
glBegin(); glVertex3f(1f, 1f, 1f); glColor4f(1f, 1f, 1f, 1f); ... glEnd();Implementation buffers all vertex, colors, normal and texture-coord elements in their respective buffers to be either rendered directly viaglEnd(GL)or to be added to an internal display list viaglEnd(gl, false)for deferred rendering viadraw(GL, boolean).Buffer storage and it's creation via
createFixed(..)andcreateGLSL(..)If unsure whether colors, normals and textures will be used, simply add them with an expected component count. This implementation will only render buffers which are being filled.
The buffer growing implementation will only grow the exceeded buffers, unused buffers are not resized.Note: Optional types, i.e. color, must be either not used or used w/ the same element count as vertex, etc. This is a semantic constraint, same as in the original OpenGL spec.
-
-
Field Summary
Fields Modifier and Type Field Description static intGL_POLYGONstatic intGL_QUAD_STRIPstatic intGL_QUADS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmModeSinkcreateFixed(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, int nComps, int nDataType, int tComps, int tDataType, int glBufferUsage)Uses a GL2ES1, or ES2 fixed function emulation immediate mode sinkstatic ImmModeSinkcreateGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, int nComps, int nDataType, int tComps, int tDataType, int glBufferUsage, int shaderProgram)Uses a GL2ES2 GLSL shader immediate mode sink, utilizing the given shader-program.static ImmModeSinkcreateGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, int nComps, int nDataType, int tComps, int tDataType, int glBufferUsage, ShaderState st)Uses a GL2ES2 GLSL shader immediate mode sink, utilizing the given ShaderState.voiddestroy(GL gl)voiddraw(GL gl, boolean disableBufferAfterDraw)voiddraw(GL gl, Buffer indices, boolean disableBufferAfterDraw)intgetResizeElementCount()Returns the additional element count if buffer resize is required.booleangetUseVBO()voidglBegin(int mode)voidglColor3b(byte x, byte y, byte z)voidglColor3f(float x, float y, float z)voidglColor3s(short x, short y, short z)voidglColor3ub(byte x, byte y, byte z)voidglColor4b(byte x, byte y, byte z, byte a)voidglColor4f(float x, float y, float z, float a)voidglColor4s(short x, short y, short z, short a)voidglColor4ub(byte x, byte y, byte z, byte a)voidglColorv(Buffer v)voidglEnd(GL gl)voidglEnd(GL gl, boolean immediateDraw)voidglEnd(GL gl, Buffer indices)voidglNormal3b(byte x, byte y, byte z)voidglNormal3f(float x, float y, float z)voidglNormal3s(short x, short y, short z)voidglNormalv(Buffer v)voidglTexCoord2b(byte x, byte y)voidglTexCoord2f(float x, float y)voidglTexCoord2s(short x, short y)voidglTexCoord3b(byte x, byte y, byte z)voidglTexCoord3f(float x, float y, float z)voidglTexCoord3s(short x, short y, short z)voidglTexCoordv(Buffer v)voidglVertex2b(byte x, byte y)voidglVertex2f(float x, float y)voidglVertex2s(short x, short y)voidglVertex3b(byte x, byte y, byte z)voidglVertex3f(float x, float y, float z)voidglVertex3s(short x, short y, short z)voidglVertexv(Buffer v)voidreset()voidreset(GL gl)voidsetResizeElementCount(int v)Sets the additional element count if buffer resize is required, defaults toinitialElementCountof factory method.StringtoString()
-
-
-
Field Detail
-
GL_QUADS
public static final int GL_QUADS
- See Also:
- Constant Field Values
-
GL_QUAD_STRIP
public static final int GL_QUAD_STRIP
- See Also:
- Constant Field Values
-
GL_POLYGON
public static final int GL_POLYGON
- See Also:
- Constant Field Values
-
-
Method Detail
-
createFixed
public static ImmModeSink createFixed(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, int nComps, int nDataType, int tComps, int tDataType, int glBufferUsage)
Uses a GL2ES1, or ES2 fixed function emulation immediate mode sink- Parameters:
initialElementCount- initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size.vComps- mandatory vertex component count, should be 2, 3 or 4.vDataType- mandatory vertex data type, e.g.GL.GL_FLOATcComps- optional color component count, may be 0, 3 or 4cDataType- optional color data type, e.g.GL.GL_FLOATnComps- optional normal component count, may be 0, 3 or 4nDataType- optional normal data type, e.g.GL.GL_FLOATtComps- optional texture-coordinate component count, may be 0, 2 or 3tDataType- optional texture-coordinate data type, e.g.GL.GL_FLOATglBufferUsage- VBOusageparameter forGL.glBufferData(int, long, Buffer, int), e.g.GL.GL_STATIC_DRAW, set to0for no VBO usage
-
createGLSL
public static ImmModeSink createGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, int nComps, int nDataType, int tComps, int tDataType, int glBufferUsage, ShaderState st)
Uses a GL2ES2 GLSL shader immediate mode sink, utilizing the given ShaderState.- Parameters:
initialElementCount- initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size.vComps- mandatory vertex component count, should be 2, 3 or 4.vDataType- mandatory vertex data type, e.g.GL.GL_FLOATcComps- optional color component count, may be 0, 3 or 4cDataType- optional color data type, e.g.GL.GL_FLOATnComps- optional normal component count, may be 0, 3 or 4nDataType- optional normal data type, e.g.GL.GL_FLOATtComps- optional texture-coordinate component count, may be 0, 2 or 3tDataType- optional texture-coordinate data type, e.g.GL.GL_FLOATglBufferUsage- VBOusageparameter forGL.glBufferData(int, long, Buffer, int), e.g.GL.GL_STATIC_DRAW, set to0for no VBO usagest- ShaderState to locate the vertex attributes- See Also:
draw(GL, boolean),ShaderState.useProgram(GL2ES2, boolean),com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState()
-
createGLSL
public static ImmModeSink createGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, int nComps, int nDataType, int tComps, int tDataType, int glBufferUsage, int shaderProgram)
Uses a GL2ES2 GLSL shader immediate mode sink, utilizing the given shader-program.- Parameters:
initialElementCount- initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size.vComps- mandatory vertex component count, should be 2, 3 or 4.vDataType- mandatory vertex data type, e.g.GL.GL_FLOATcComps- optional color component count, may be 0, 3 or 4cDataType- optional color data type, e.g.GL.GL_FLOATnComps- optional normal component count, may be 0, 3 or 4nDataType- optional normal data type, e.g.GL.GL_FLOATtComps- optional texture-coordinate component count, may be 0, 2 or 3tDataType- optional texture-coordinate data type, e.g.GL.GL_FLOATglBufferUsage- VBOusageparameter forGL.glBufferData(int, long, Buffer, int), e.g.GL.GL_STATIC_DRAW, set to0for no VBO usageshaderProgram- shader-program name to locate the vertex attributes- See Also:
draw(GL, boolean),ShaderState.useProgram(GL2ES2, boolean),com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState()
-
destroy
public void destroy(GL gl)
-
reset
public void reset()
-
reset
public void reset(GL gl)
-
draw
public void draw(GL gl, boolean disableBufferAfterDraw)
-
glBegin
public void glBegin(int mode)
-
glEnd
public final void glEnd(GL gl)
-
glEnd
public void glEnd(GL gl, boolean immediateDraw)
-
glVertexv
public void glVertexv(Buffer v)
-
glNormalv
public void glNormalv(Buffer v)
-
glColorv
public void glColorv(Buffer v)
-
glTexCoordv
public void glTexCoordv(Buffer v)
-
glVertex2f
public final void glVertex2f(float x, float y)
-
glVertex3f
public final void glVertex3f(float x, float y, float z)
-
glNormal3f
public final void glNormal3f(float x, float y, float z)
-
glColor3f
public final void glColor3f(float x, float y, float z)
-
glColor4f
public final void glColor4f(float x, float y, float z, float a)
-
glTexCoord2f
public final void glTexCoord2f(float x, float y)
-
glTexCoord3f
public final void glTexCoord3f(float x, float y, float z)
-
glVertex2s
public final void glVertex2s(short x, short y)
-
glVertex3s
public final void glVertex3s(short x, short y, short z)
-
glNormal3s
public final void glNormal3s(short x, short y, short z)
-
glColor3s
public final void glColor3s(short x, short y, short z)
-
glColor4s
public final void glColor4s(short x, short y, short z, short a)
-
glTexCoord2s
public final void glTexCoord2s(short x, short y)
-
glTexCoord3s
public final void glTexCoord3s(short x, short y, short z)
-
glVertex2b
public final void glVertex2b(byte x, byte y)
-
glVertex3b
public final void glVertex3b(byte x, byte y, byte z)
-
glNormal3b
public final void glNormal3b(byte x, byte y, byte z)
-
glColor3b
public final void glColor3b(byte x, byte y, byte z)
-
glColor3ub
public final void glColor3ub(byte x, byte y, byte z)
-
glColor4b
public final void glColor4b(byte x, byte y, byte z, byte a)
-
glColor4ub
public final void glColor4ub(byte x, byte y, byte z, byte a)
-
glTexCoord2b
public final void glTexCoord2b(byte x, byte y)
-
glTexCoord3b
public final void glTexCoord3b(byte x, byte y, byte z)
-
getUseVBO
public boolean getUseVBO()
-
getResizeElementCount
public int getResizeElementCount()
Returns the additional element count if buffer resize is required.- See Also:
setResizeElementCount(int)
-
setResizeElementCount
public void setResizeElementCount(int v)
Sets the additional element count if buffer resize is required, defaults toinitialElementCountof factory method.
-
-