// Wild Magic Source Code
// David Eberly
// http://www.geometrictools.com
// Copyright (c) 1998-2007
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version.  The license is available for reading at
// either of the locations:
//     http://www.gnu.org/copyleft/lgpl.html
//     http://www.geometrictools.com/License/WildMagicLicense.pdf
//
// Version: 4.0.2 (2006/11/24)

#include "Wm4OpenGLRendererPCH.h"
#include "Wm4OpenGLRenderer.h"
using namespace Wm4;

GLenum OpenGLRenderer::ms_aeObjectType[Geometry::GT_MAX_QUANTITY] =
{
    GL_POINTS,          // GT_POLYPOINT
    GL_LINES,           // GT_POLYLINE_SEGMENTS
    GL_LINE_STRIP,      // GT_POLYLINE_OPEN
    GL_LINE_LOOP,       // GT_POLYLINE_CLOSED
    GL_TRIANGLES,       // GT_TRIMESH
    GL_TRIANGLE_STRIP,  // GT_TRISTRIP
    GL_TRIANGLE_FAN     // GT_TRIFAN
};

//----------------------------------------------------------------------------
void OpenGLRenderer::DrawElements ()
{
    IndexBuffer* pkIBuffer = m_pkGeometry->IBuffer;
    assert(pkIBuffer);
    GLenum eType = ms_aeObjectType[m_pkGeometry->Type];
    int iOffset = pkIBuffer->GetOffset();
    glDrawElements(eType,pkIBuffer->GetIndexQuantity(),GL_UNSIGNED_INT,
        (const GLvoid*)((int*)0 + iOffset));
}
//----------------------------------------------------------------------------
