1 // 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 18 #ifndef LIBGL_BUFFER_H_ 19 #define LIBGL_BUFFER_H_ 20 21 #include "common/Object.hpp" 22 #include "Common/Resource.hpp" 23 24 #define _GDI32_ 25 #include <windows.h> 26 #include <GL/GL.h> 27 #include <GL/glext.h> 28 29 #include <cstddef> 30 #include <vector> 31 32 namespace gl 33 { 34 class Buffer : public NamedObject 35 { 36 public: 37 explicit Buffer(GLuint name); 38 39 virtual ~Buffer(); 40 41 void bufferData(const void *data, GLsizeiptr size, GLenum usage); 42 void bufferSubData(const void *data, GLsizeiptr size, GLintptr offset); 43 data()44 const void *data() { return mContents ? mContents->data() : 0; } size()45 size_t size() const { return mSize; } usage()46 GLenum usage() const { return mUsage; } 47 48 sw::Resource *getResource(); 49 50 private: 51 sw::Resource *mContents; 52 size_t mSize; 53 GLenum mUsage; 54 }; 55 56 } 57 58 #endif // LIBGL_BUFFER_H_ 59