blob: 0ad1069ad4d6e48d432217f138e965d735cd08c9 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Buffer.h: Defines the Buffer class, representing storage of vertex and/or
16// index data. Implements GL buffer objects and related functionality.
17// [OpenGL ES 2.0.24] section 2.9 page 21.
18
19#ifndef LIBGLES_CM_BUFFER_H_
20#define LIBGLES_CM_BUFFER_H_
21
22#include "common/Object.hpp"
23#include "Common/Resource.hpp"
24
25#include <GLES/gl.h>
26
27#include <cstddef>
28#include <vector>
29
30namespace es1
31{
32class Buffer : public gl::NamedObject
33{
34public:
35 explicit Buffer(GLuint name);
36
37 virtual ~Buffer();
38
39 void bufferData(const void *data, GLsizeiptr size, GLenum usage);
40 void bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
41
42 const void *data() { return mContents ? mContents->data() : 0; }
43 size_t size() const { return mSize; }
44 GLenum usage() const { return mUsage; }
45
46 sw::Resource *getResource();
47
48private:
49 sw::Resource *mContents;
50 size_t mSize;
51 GLenum mUsage;
52};
53
54}
55
56#endif // LIBGLES_CM_BUFFER_H_