• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2002-2010 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 // Buffer.h: Defines the gl::Buffer class, representing storage of vertex and/or
8 // index data. Implements GL buffer objects and related functionality.
9 // [OpenGL ES 2.0.24] section 2.9 page 21.
10 
11 #ifndef LIBGLESV2_BUFFER_H_
12 #define LIBGLESV2_BUFFER_H_
13 
14 #include <cstddef>
15 #include <vector>
16 
17 #define GL_APICALL
18 #include <GLES2/gl2.h>
19 
20 #include "common/angleutils.h"
21 #include "libGLESv2/RefCountObject.h"
22 
23 namespace gl
24 {
25 class StaticVertexBuffer;
26 class StaticIndexBuffer;
27 
28 class Buffer : public RefCountObject
29 {
30   public:
31     explicit Buffer(GLuint id);
32 
33     virtual ~Buffer();
34 
35     void bufferData(const void *data, GLsizeiptr size, GLenum usage);
36     void bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
37 
data()38     void *data() { return mContents; }
size()39     size_t size() const { return mSize; }
usage()40     GLenum usage() const { return mUsage; }
41 
42     StaticVertexBuffer *getVertexBuffer();
43     StaticIndexBuffer *getIndexBuffer();
44     void invalidateStaticData();
45 
46   private:
47     DISALLOW_COPY_AND_ASSIGN(Buffer);
48 
49     GLubyte *mContents;
50     size_t mSize;
51     GLenum mUsage;
52 
53     StaticVertexBuffer *mVertexBuffer;
54     StaticIndexBuffer *mIndexBuffer;
55 };
56 
57 }
58 
59 #endif   // LIBGLESV2_BUFFER_H_
60