VR-Forces 4.1 Class Documentation
DtFormatRenderer.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
12 #include <GL/glew.h>
13 
14 namespace makVrv
15 {
19  {
20  public:
21 
28  static unsigned int theVertexCountToModeMap[5];
29  };
30 
33  template <typename VertexFormat>
35  {
36  public:
37 
38 
39  //Draw arrays using client memory.
40  void drawArrays(unsigned int vertexCount, const VertexFormat* vertexArray, unsigned int index, unsigned int count)
41  {
42  bindVertexArrays(vertexArray);
43  glDrawArrays(DtRenderModes::theVertexCountToModeMap[vertexCount],index,count);
45  }
46 
47  //Draw arrays using server memory.
48  void drawArrays(unsigned int vertexCount, unsigned int vbo, unsigned int index, unsigned int count)
49  {
50  glBindBuffer(GL_ARRAY_BUFFER,vbo);
51 
53  glDrawArrays(DtRenderModes::theVertexCountToModeMap[vertexCount],index,count);
55 
56  glBindBuffer(GL_ARRAY_BUFFER,0);
57  }
58 
59  //Draw elements using client memory.
60  void drawElements(unsigned int vertexCount, const VertexFormat* vertexArray, const unsigned int* indicies, unsigned int count )
61  {
62  bindVertexArrays(vertexArray);
63  glDrawElements(DtRenderModes::theVertexCountToModeMap[vertexCount], count, GL_UNSIGNED_INT, indicies);
65  }
66 
67  //Draw elements using server memory.
68  void drawElements(unsigned int vertexCount, unsigned int vbo, unsigned int ibo, unsigned int count )
69  {
70  glBindBuffer(GL_ARRAY_BUFFER,vbo);
71  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ibo);
72 
73  bindVertexArrays(0);
74  glDrawElements(DtRenderModes::theVertexCountToModeMap[vertexCount], count, GL_UNSIGNED_INT, 0);
76 
77  glBindBuffer(GL_ARRAY_BUFFER,0);
78  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
79  }
80 
81  protected:
82  virtual void bindVertexArrays(const VertexFormat* vertexArray) = 0;
83  virtual void unbindVertexArrays() = 0;
84  };
85 
86 }
87 

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)