Block selection Chunk de/compression now uses internal buffer directly (0-copy) Optimized Chunk vertices list order (faster vert access from GPU cache) F5 Debug info: added triangle count Implemented ladder climb Road + jump pad makes you jump farther Fixed bad fog color blending (alpha-channel) Changed LZFX and enet compilation to Release, -O3
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#ifndef VBO_HPP
|
|
#define VBO_HPP
|
|
#include <vector>
|
|
#include <GL/glew.h>
|
|
#include <typeinfo>
|
|
#include "Platform.hpp"
|
|
#include <cstring>
|
|
|
|
namespace Diggler {
|
|
|
|
class VBO {
|
|
private:
|
|
int *m_refcount;
|
|
|
|
public:
|
|
GLuint id;
|
|
|
|
// Ctor / dtor
|
|
VBO();
|
|
~VBO();
|
|
// Copy
|
|
VBO(const VBO&);
|
|
VBO& operator=(const VBO&);
|
|
// Move
|
|
VBO(VBO&&);
|
|
VBO& operator=(VBO&&);
|
|
|
|
operator GLuint() const { return id; }
|
|
template <typename T> void setData(const std::vector<T>& data, GLenum usage = GL_STATIC_DRAW) {
|
|
GLint currentBoundArray; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, ¤tBoundArray);
|
|
glBindBuffer(GL_ARRAY_BUFFER, id);
|
|
glBufferData(GL_ARRAY_BUFFER, data.size()*sizeof(T), data.data(), usage);
|
|
glBindBuffer(GL_ARRAY_BUFFER, currentBoundArray);
|
|
}
|
|
template <typename T> void setData(const T *data, uint count, GLenum usage = GL_STATIC_DRAW) {
|
|
GLint currentBoundArray; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, ¤tBoundArray);
|
|
glBindBuffer(GL_ARRAY_BUFFER, id);
|
|
glBufferData(GL_ARRAY_BUFFER, count*sizeof(*data), data, usage);
|
|
glBindBuffer(GL_ARRAY_BUFFER, currentBoundArray);
|
|
}
|
|
void bind() const;
|
|
int getSize() const;
|
|
};
|
|
|
|
}
|
|
|
|
#endif |