Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // RenderbufferGL.cpp: Implements the class methods for RenderbufferGL. |
| 8 | |
| 9 | #include "libANGLE/renderer/gl/RenderbufferGL.h" |
| 10 | |
| 11 | #include "common/debug.h" |
Geoff Lang | cd69f1c | 2015-03-18 14:33:23 -0400 | [diff] [blame^] | 12 | #include "libANGLE/angletypes.h" |
| 13 | #include "libANGLE/renderer/gl/FunctionsGL.h" |
| 14 | #include "libANGLE/renderer/gl/StateManagerGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 15 | |
| 16 | namespace rx |
| 17 | { |
| 18 | |
Geoff Lang | cd69f1c | 2015-03-18 14:33:23 -0400 | [diff] [blame^] | 19 | RenderbufferGL::RenderbufferGL(const FunctionsGL *functions, StateManagerGL *stateManager) |
| 20 | : RenderbufferImpl(), |
| 21 | mFunctions(functions), |
| 22 | mStateManager(stateManager), |
| 23 | mRenderbufferID(0) |
| 24 | { |
| 25 | mFunctions->genRenderbuffers(1, &mRenderbufferID); |
| 26 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 27 | |
| 28 | RenderbufferGL::~RenderbufferGL() |
Geoff Lang | cd69f1c | 2015-03-18 14:33:23 -0400 | [diff] [blame^] | 29 | { |
| 30 | if (mRenderbufferID != 0) |
| 31 | { |
| 32 | mFunctions->deleteRenderbuffers(1, &mRenderbufferID); |
| 33 | mRenderbufferID = 0; |
| 34 | } |
| 35 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 36 | |
Geoff Lang | a08e1bd | 2015-03-24 10:17:18 -0400 | [diff] [blame] | 37 | gl::Error RenderbufferGL::setStorage(GLenum internalformat, size_t width, size_t height) |
| 38 | { |
Geoff Lang | cd69f1c | 2015-03-18 14:33:23 -0400 | [diff] [blame^] | 39 | mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID); |
| 40 | mFunctions->renderbufferStorage(GL_RENDERBUFFER, internalformat, width, height); |
| 41 | return gl::Error(GL_NO_ERROR); |
Geoff Lang | a08e1bd | 2015-03-24 10:17:18 -0400 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | gl::Error RenderbufferGL::setStorageMultisample(size_t samples, GLenum internalformat, size_t width, size_t height) |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 45 | { |
Geoff Lang | cd69f1c | 2015-03-18 14:33:23 -0400 | [diff] [blame^] | 46 | mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID); |
| 47 | mFunctions->renderbufferStorageMultisample(GL_RENDERBUFFER, samples, internalformat, width, height); |
| 48 | return gl::Error(GL_NO_ERROR); |
| 49 | } |
| 50 | |
| 51 | GLuint RenderbufferGL::getRenderbufferID() const |
| 52 | { |
| 53 | return mRenderbufferID; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | } |