1
0
Fork 0
Univerxel/src/client/render/gl/buffer/LodShortIndexed.cpp

33 lines
1.1 KiB
C++

#include "LodShortIndexed.hpp"
using namespace buffer;
LodShortIndexed::LodShortIndexed(GLenum shape, const ShortIndexed::Data &data, const std::vector<size_t> &offsets): ShortIndexed(shape, data), offsets(offsets) { }
LodShortIndexed::LodShortIndexed(GLenum shape, const LodShortIndexed::LodData &data): ShortIndexed(shape, data.first), offsets(data.second) { }
LodShortIndexed::~LodShortIndexed() { }
#include <iostream>
uint LodShortIndexed::draw(buffer::params params) {
if(params.vertexOnly) {
enableVertexAttrib();
} else {
enableAllAttribs();
}
enableIndex();
const auto start = getOffset(level);
const auto end = getOffset(level+1);
const auto count = end - start;
if (params.instances == 1) {
glDrawElements(Shape, count, GL_UNSIGNED_SHORT, (void *)(start*sizeof(GLushort)));
} else {
glDrawElementsInstanced(Shape, count, GL_UNSIGNED_SHORT, (void *)(start*sizeof(GLushort)), params.instances);
}
if(params.vertexOnly) {
disableVertexAttrib();
} else {
disableAllAttribs();
}
return count * params.instances;
}