blob: b580ea8f8d24d54ca9de2a2f55b7d54cfbd65b1d [file] [log] [blame]
Geoff Langf9a6f082015-01-22 13:32:49 -05001//
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 Langcd69f1c2015-03-18 14:33:23 -040012#include "libANGLE/angletypes.h"
13#include "libANGLE/renderer/gl/FunctionsGL.h"
14#include "libANGLE/renderer/gl/StateManagerGL.h"
Geoff Langf9a6f082015-01-22 13:32:49 -050015
16namespace rx
17{
18
Geoff Langcd69f1c2015-03-18 14:33:23 -040019RenderbufferGL::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 Langf9a6f082015-01-22 13:32:49 -050027
28RenderbufferGL::~RenderbufferGL()
Geoff Langcd69f1c2015-03-18 14:33:23 -040029{
30 if (mRenderbufferID != 0)
31 {
32 mFunctions->deleteRenderbuffers(1, &mRenderbufferID);
33 mRenderbufferID = 0;
34 }
35}
Geoff Langf9a6f082015-01-22 13:32:49 -050036
Geoff Langa08e1bd2015-03-24 10:17:18 -040037gl::Error RenderbufferGL::setStorage(GLenum internalformat, size_t width, size_t height)
38{
Geoff Langcd69f1c2015-03-18 14:33:23 -040039 mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID);
40 mFunctions->renderbufferStorage(GL_RENDERBUFFER, internalformat, width, height);
41 return gl::Error(GL_NO_ERROR);
Geoff Langa08e1bd2015-03-24 10:17:18 -040042}
43
44gl::Error RenderbufferGL::setStorageMultisample(size_t samples, GLenum internalformat, size_t width, size_t height)
Geoff Langf9a6f082015-01-22 13:32:49 -050045{
Geoff Langcd69f1c2015-03-18 14:33:23 -040046 mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID);
47 mFunctions->renderbufferStorageMultisample(GL_RENDERBUFFER, samples, internalformat, width, height);
48 return gl::Error(GL_NO_ERROR);
49}
50
51GLuint RenderbufferGL::getRenderbufferID() const
52{
53 return mRenderbufferID;
Geoff Langf9a6f082015-01-22 13:32:49 -050054}
55
56}