| 15 | } |
| 16 | |
| 17 | GL46Buffer::GL46Buffer(Buffer const* buffer, GLenum type) |
| 18 | : |
| 19 | GL46Resource(buffer), |
| 20 | mType(type) |
| 21 | { |
| 22 | glGenBuffers(1, &mGLHandle); |
| 23 | |
| 24 | uint32_t usage = buffer->GetUsage(); |
| 25 | if (usage == Resource::Usage::IMMUTABLE) |
| 26 | { |
| 27 | mUsage = GL_STATIC_DRAW; |
| 28 | } |
| 29 | else if (usage == Resource::Usage::DYNAMIC_UPDATE) |
| 30 | { |
| 31 | mUsage = GL_DYNAMIC_DRAW; |
| 32 | } |
| 33 | else // usage == Resource::Usage::SHADER_OUTPUT |
| 34 | { |
| 35 | // TODO: In GLSL, is it possible to write to a buffer other than a |
| 36 | // vertex buffer? |
| 37 | if (mType == GL_ARRAY_BUFFER) |
| 38 | { |
| 39 | mUsage = GL_STREAM_DRAW; |
| 40 | } |
| 41 | else if (mType == GL_SHADER_STORAGE_BUFFER) |
| 42 | { |
| 43 | mUsage = GL_DYNAMIC_DRAW; |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | // TODO: Can this buffer type be a shader output? |
| 48 | mUsage = GL_STATIC_DRAW; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | void GL46Buffer::Initialize() |
| 54 | { |
nothing calls this directly
no test coverage detected