hmi.graphics.opengl
Class GLVertexAttribute

java.lang.Object
  extended by hmi.graphics.opengl.GLVertexAttribute

public class GLVertexAttribute
extends Object

The OpenGL counterpart of the VertexAttribute class for GMesh It stores attribute data in FloatBuffer format, ready for rendering operations.


Field Summary
private  int attribSize
           
private  int attributeIndex
           
private  String attributeName
           
private  boolean bufferModified
           
private  int bufferOffset
           
private  int byteBufferSize
           
private  int floatBufferSize
           
private  int nrOfVertices
           
private  int texUnit
           
private  FloatBuffer vertexDataBuffer
           
 
Constructor Summary
GLVertexAttribute(String attrName, float[] vertexData, int attribSize, int nrOfVertices, int texUnit)
          Create a new GLVertexAttribute
GLVertexAttribute(VertexAttribute va)
          Create a new GLVertexAttribute from a generic VertexAttribute
 
Method Summary
 StringBuffer appendTo(StringBuffer buf)
           
 String getAttributeName()
           
 int getByteBufferSize()
          Returns the buffer size, in number of bytes
 String getName()
          Returns the GLAttribute name.
 int getNrOfVertices()
          Returns the number of vertices
 int getTexUnit()
           
 float[] getVertexData(float[] vertexData)
          Fills and returns the vertexData float array with the current contents of the vertex data buffer.
 void glInit(GLBinding gl)
           
 void glRender(GLBinding gl)
          GL render for this attribute.
 void setArrayBufferOffset(int offset)
          Sets the GL_ARRAY_BUFFER buffer offset
 int setAttributeIndex(GLBinding gl, int prog)
          Sets the GLSL attribute index for the specified shader program, by queriying for the attribute location.
 void setTexUnit(int texUnit)
          Sets the texture unit to be used for this (texture) attribute
 void setVertexData(float[] vertexData)
          Sets vertex data, by copying from the specified array.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributeName

private String attributeName

attributeIndex

private int attributeIndex

texUnit

private int texUnit

vertexDataBuffer

private FloatBuffer vertexDataBuffer

floatBufferSize

private int floatBufferSize

byteBufferSize

private int byteBufferSize

attribSize

private int attribSize

bufferModified

private boolean bufferModified

bufferOffset

private int bufferOffset

nrOfVertices

private int nrOfVertices
Constructor Detail

GLVertexAttribute

public GLVertexAttribute(String attrName,
                         float[] vertexData,
                         int attribSize,
                         int nrOfVertices,
                         int texUnit)
Create a new GLVertexAttribute


GLVertexAttribute

public GLVertexAttribute(VertexAttribute va)
Create a new GLVertexAttribute from a generic VertexAttribute

Method Detail

getAttributeName

public String getAttributeName()

toString

public String toString()
Overrides:
toString in class Object

appendTo

public StringBuffer appendTo(StringBuffer buf)

setTexUnit

public void setTexUnit(int texUnit)
Sets the texture unit to be used for this (texture) attribute


getTexUnit

public int getTexUnit()

getName

public String getName()
Returns the GLAttribute name.


getNrOfVertices

public int getNrOfVertices()
Returns the number of vertices


getByteBufferSize

public int getByteBufferSize()
Returns the buffer size, in number of bytes


setArrayBufferOffset

public void setArrayBufferOffset(int offset)
Sets the GL_ARRAY_BUFFER buffer offset


setVertexData

public void setVertexData(float[] vertexData)
Sets vertex data, by copying from the specified array.


getVertexData

public float[] getVertexData(float[] vertexData)
Fills and returns the vertexData float array with the current contents of the vertex data buffer. The passed in vertexData array can be null, in which case a new float array is allocated.


setAttributeIndex

public int setAttributeIndex(GLBinding gl,
                             int prog)
Sets the GLSL attribute index for the specified shader program, by queriying for the attribute location. If the attribute name is not an active variable for this shader, the index is set to -1, which effectively disables this attribute for rendering. Returns the assigned attribute index.


glInit

public void glInit(GLBinding gl)

glRender

public void glRender(GLBinding gl)
GL render for this attribute. Basically, copies vertex data to the GL_ARRAY_BUFFER buffer, if data has been modified, and sets the gl vertex data pointer to the buffer data.