VR-Forces 4.0.4 Class Documentation
include/vrvGraphics/DtFormatRenderer.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2010 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 
00009 
00010 #pragma once
00011 #include <vrvGraphics/vrvGraphics.h>
00012 #include <GL/glew.h>
00013 
00014 namespace makVrv
00015 {
00018    class DT_DLL_VRVGRAPHICS DtRenderModes
00019    {
00020    public:
00021 
00028       static unsigned int theVertexCountToModeMap[5];
00029    };
00030 
00033    template <typename VertexFormat> 
00034    class DtFormatRenderer
00035    {
00036    public:
00037 
00038 
00039       //Draw arrays using client memory.
00040       void drawArrays(unsigned int vertexCount, const VertexFormat* vertexArray, unsigned int index, unsigned int count)
00041       {
00042          bindVertexArrays(vertexArray);
00043          glDrawArrays(DtRenderModes::theVertexCountToModeMap[vertexCount],index,count);
00044          unbindVertexArrays();
00045       }
00046 
00047       //Draw arrays using server memory.
00048       void drawArrays(unsigned int vertexCount, unsigned int vbo, unsigned int index, unsigned int count)
00049       {
00050          glBindBuffer(GL_ARRAY_BUFFER,vbo);
00051 
00052          bindVertexArrays(0);
00053          glDrawArrays(DtRenderModes::theVertexCountToModeMap[vertexCount],index,count);
00054          unbindVertexArrays();    
00055 
00056          glBindBuffer(GL_ARRAY_BUFFER,0);
00057       }
00058 
00059       //Draw elements using client memory.   
00060       void drawElements(unsigned int vertexCount, const VertexFormat* vertexArray, const unsigned int* indicies, unsigned int count )
00061       {
00062          bindVertexArrays(vertexArray);            
00063          glDrawElements(DtRenderModes::theVertexCountToModeMap[vertexCount], count, GL_UNSIGNED_INT, indicies);      
00064          unbindVertexArrays();  
00065       }
00066 
00067       //Draw elements using server memory.
00068       void drawElements(unsigned int vertexCount, unsigned int  vbo, unsigned int  ibo, unsigned int count )
00069       {
00070          glBindBuffer(GL_ARRAY_BUFFER,vbo);
00071          glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ibo);
00072 
00073          bindVertexArrays(0);            
00074          glDrawElements(DtRenderModes::theVertexCountToModeMap[vertexCount], count, GL_UNSIGNED_INT, 0);      
00075          unbindVertexArrays();  
00076 
00077          glBindBuffer(GL_ARRAY_BUFFER,0);
00078          glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
00079       }
00080 
00081    protected:  
00082       virtual void bindVertexArrays(const VertexFormat* vertexArray) = 0;
00083       virtual void unbindVertexArrays() = 0;   
00084    };
00085 
00086 }
00087 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)