Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435//// Created by kam on 6.10.2026.//
#pragma once
#include "types.h"
namespace Snail { class Buffer { u32 id;
public: explicit Buffer() = default; explicit Buffer(u32 id); ~Buffer();
isize get_size();
template<typename T> void update(std::vector<T> data, s32 start = 0, s32 count = -1) { s32 dataSize = data.size() * sizeof(T);
glBindBuffer(GL_ARRAY_BUFFER, id); if (get_size() == dataSize) { count = count < 0 ? dataSize : count * sizeof(T); glBufferSubData(GL_ARRAY_BUFFER, start, count, data.data()); } else { glBufferData(GL_ARRAY_BUFFER, dataSize, data.data(), GL_STATIC_DRAW); } glBindBuffer(GL_ARRAY_BUFFER, 0); } };}