RenderBuffer.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #if ( defined DC_BACKENDS_SHADERGL_X11 || defined DC_BACKENDS_SHADERGL_WIN32 )
34 #ifndef H_DC_BACKENDS_GL_RENDERBUFFER_INCLUDED
35 #define H_DC_BACKENDS_GL_RENDERBUFFER_INCLUDED
36 
37 #include <Dynacoe/Backends/Renderer/ShaderGL_Multi.h>
38 
39 namespace Dynacoe {
40 class RenderBuffer {
41  public:
42 
43  virtual ~RenderBuffer(){}
44 
45  // returns the size in bytes of the data store
46  virtual int Size() = 0;
47 
48  // Redefines the data store with the specified buffer
49  virtual void Define(const float * dataSrc, int numElts) = 0;
50 
51  // Updates the data of the data store
52  virtual void UpdateData(const float * dataSrc, int offset, int numElts) = 0;
53 
54  // Retrieves the data of the data store.
55  virtual void GetData(float * outputData, int offset, int numElts) = 0;
56 
57  // Retrieves a pointer to the data store. This pointer is owned by
58  // the render buffer and should not be freed. The pointer is valid until
59  // the next function call for this RenderBuffer.
60  virtual float * GetData() = 0;
61 
62  // Sets the type of the render buffer. Can either be GL_ARRAY_BUFFER or GL_UNIFORM_BUFFER
63  virtual void SetType(GLenum e) = 0;
64 
65  // Generates an openGL buffer object name
66  // that reflects the state of the RenderBuffer at the time that
67  // this function is called. The buffer is valid until
68  // ReclaimIDs() is valled
69  virtual GLuint GenerateBufferID() = 0;
70 
71  // Invalidates all IDs given from GenerateBufferID() calls.
72  // this is not guaranteed to free any client/server memory
73  // but most of the time will.
74  virtual void ReclaimIDs() = 0;
75 
76 };
77 
78 // Returns a new render buffer
79 RenderBuffer * CreateRenderBuffer(bool forceTextureVariant = false);
80 
81 }
82 
83 #endif
84 #endif
Definition: AssetID.h:37