nux-1.16.0
nux::TemplateQuadBuffer Class Reference

List of all members.

Public Member Functions

 TemplateQuadBuffer (GpuDevice *, ShaderType Type=SHADER_TYPE_GLSL, int NumQuads=256)
void BindAttribute (INT AttributeLocation, UINT AttributeIndex)
 Bind GLSL parameter.
void UnBindAttribute (INT AttributeLocation)
 Bind NVidia CG parameter.
void UnBind ()
void Render (INT NumPrimitives)
void SetPerQuadAttribute (UINT AttributeIndex, INT Num, Vector4 *)
 Set the Vertices's attribute on a per quad basis.
void SetPerVertexAttribute (UINT AttributeIndex, INT Num, Vector4 *pVector)
 Set the Vertices's attribute on a per vertex basis.
void UnSetQuadAttribute (UINT AttributeIndex)
void SetNumQuads (int NumQuads)
int GetNumQuads () const

Protected Member Functions

void FormatQuads ()

Protected Attributes

ObjectPtr< IOpenGLIndexBufferm_IB

Detailed Description

Definition at line 41 of file GLTemplatePrimitiveBuffer.h.


Member Function Documentation

void nux::TemplateQuadBuffer::SetPerQuadAttribute ( UINT  AttributeIndex,
INT  Num,
Vector4 pVector 
)

Set the Vertices's attribute on a per quad basis.

Set the Vertices's attribute on a per quad basis. All vertex of the quad will have the same value for the attribute index.

Definition at line 305 of file GLTemplatePrimitiveBuffer.cpp.

  {
    nuxAssert (AttributeIndex > 0); // Index 0 is the vertex position attribute. This on is set in the constructor.
    nuxAssert (AttributeIndex < 16);

    // Destroy the vertex buffer by setting it to NULL;
    VertexAttributeBuffer[AttributeIndex] = ObjectPtr<IOpenGLVertexBuffer> (0);;

    VertexAttributeBuffer[AttributeIndex] = m_pDeviceFactory->CreateVertexBuffer (m_NumQuad * 4 * sizeof (Vector4), VBO_USAGE_DYNAMIC);

    FLOAT *data;
    VertexAttributeBuffer[AttributeIndex]->Lock (0, m_NumQuad * 4 * sizeof (Vector4), (void **) &data);

    INT i;

    for (i = 0; (i < m_NumQuad) && (i <  Num); i++)
    {
      for (INT j = 0; j < 4; j++)
      {
        data[16*i + 4*j + 0] = pVector[i].x;
        data[16*i + 4*j + 1] = pVector[i].y;
        data[16*i + 4*j + 2] = pVector[i].z;
        data[16*i + 4*j + 3] = pVector[i].w;
      }
    }

    while (i < m_NumQuad)
    {
      // this happens if Num < m_NumQuad.
      // Fill the rest with the last element of the parameter array passed as argument of the function.
      for (INT j = 0; j < 4; j++)
      {
        data[16*i + 4*j + 0] = pVector[Num-1].x;
        data[16*i + 4*j + 1] = pVector[Num-1].y;
        data[16*i + 4*j + 2] = pVector[Num-1].z;
        data[16*i + 4*j + 3] = pVector[Num-1].w;
      }

      i++;
    }

    VertexAttributeBuffer[AttributeIndex]->Unlock();
  }
void nux::TemplateQuadBuffer::SetPerVertexAttribute ( UINT  AttributeIndex,
INT  Num,
Vector4 pVector 
)

Set the Vertices's attribute on a per vertex basis.

Set the vertex attribute on a per vertex basis.

Definition at line 349 of file GLTemplatePrimitiveBuffer.cpp.

  {
    nuxAssert (AttributeIndex > 0); // Index 0 is the vertex position attribute. This on is set in the constructor.
    nuxAssert (AttributeIndex < 16);

    // Destroy the vertex buffer by setting it to NULL;
    VertexAttributeBuffer[AttributeIndex] = ObjectPtr<IOpenGLVertexBuffer> (0);;

    VertexAttributeBuffer[AttributeIndex] = m_pDeviceFactory->CreateVertexBuffer (m_NumQuad * 4 * sizeof (Vector4), VBO_USAGE_DYNAMIC);

    FLOAT *data;
    VertexAttributeBuffer[AttributeIndex]->Lock (0, m_NumQuad * 4 * sizeof (Vector4), (void **) &data);

    INT i;

    for (i = 0; (i < m_NumQuad * 4) && (i <  Num); i++)
    {
      data[4*i+0] = pVector[i].x;
      data[4*i+1] = pVector[i].y;
      data[4*i+2] = pVector[i].z;
      data[4*i+3] = pVector[i].w;
    }

    while (i < m_NumQuad * 4)
    {
      // this happens if Num < m_NumQuad.
      // Fill the rest with the last element of the parameter array passed as argument of the function.
      data[4*i+0] = pVector[Num-1].x;
      data[4*i+1] = pVector[Num-1].y;
      data[4*i+2] = pVector[Num-1].z;
      data[4*i+3] = pVector[Num-1].w;
      i++;
    }

    VertexAttributeBuffer[AttributeIndex]->Unlock();
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends