Buffer.h revision fa0cc04a0eac3f80f00592cc885f2950f696d473
1// SwiftShader Software Renderer
2//
3// Copyright(c) 2005-2012 TransGaming Inc.
4//
5// All rights reserved. No part of this software may be copied, distributed, transmitted,
6// transcribed, stored in a retrieval system, translated into any human or computer
7// language by any means, or disclosed to third parties without the explicit written
8// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
9// or implied, including but not limited to any patent rights, are granted to you.
10//
11
12// Buffer.h: Defines the Buffer class, representing storage of vertex and/or
13// index data. Implements GL buffer objects and related functionality.
14// [OpenGL ES 2.0.24] section 2.9 page 21.
15
16#ifndef LIBGLESV2_BUFFER_H_
17#define LIBGLESV2_BUFFER_H_
18
19#include "common/Object.hpp"
20#include "Common/Resource.hpp"
21
22#define GL_APICALL
23#include <GLES2/gl2.h>
24
25#include <cstddef>
26#include <vector>
27
28namespace es2
29{
30class Buffer : public gl::RefCountObject
31{
32  public:
33    explicit Buffer(GLuint id);
34
35    virtual ~Buffer();
36
37    void bufferData(const void *data, GLsizeiptr size, GLenum usage);
38    void bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
39
40	const void *data() { return mContents ? mContents->data() : 0; }
41    size_t size() const { return mSize; }
42    GLenum usage() const { return mUsage; }
43
44	sw::Resource *getResource();
45
46  private:
47    sw::Resource *mContents;
48    size_t mSize;
49    GLenum mUsage;
50};
51
52}
53
54#endif   // LIBGLESV2_BUFFER_H_
55