<commit_before>#include "painter_opengl.h"
#include "halley/core/graphics/material/material_definition.h"

using namespace Halley;

PainterOpenGL::PainterOpenGL()
{}

PainterOpenGL::~PainterOpenGL()
{
	if (vbo != 0) {
		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glDeleteBuffers(1, &vbo);
	}
	if (vao != 0) {
		glBindVertexArray(0);
		glDeleteVertexArrays(1, &vao);
	}
	if (veo != 0) {
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
		glDeleteBuffers(1, &veo);
	}
}

void PainterOpenGL::doStartRender()
{
	glCheckError();

	if (!glUtils) {
		glUtils = std::make_unique<GLUtils>();
	}

	if (vbo == 0) {
		glGenBuffers(1, &vbo);
		glCheckError();
	}

	if (vao == 0) {
		glGenVertexArrays(1, &vao);
		glCheckError();
	}

	if (veo == 0) {
		glGenVertexArrays(1, &veo);
		glCheckError();
	}

	glBindBuffer(GL_ARRAY_BUFFER, vbo);
	glCheckError();
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, veo);
	glCheckError();
	glBindVertexArray(vao);
	glCheckError();
}

void PainterOpenGL::doEndRender()
{
	glCheckError();
}

void PainterOpenGL::clear(Colour colour)
{
	glCheckError();
	glClearColor(colour.r, colour.g, colour.b, colour.a);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glCheckError();
}

void PainterOpenGL::setBlend(BlendType blend)
{
	glUtils->setBlendType(blend);
}

void PainterOpenGL::setVertices(MaterialDefinition& material, size_t numVertices, void* vertexData)
{
	// Load vertices into VBO
	size_t bytesSize = numVertices * material.getVertexStride();
	glBufferData(GL_ARRAY_BUFFER, bytesSize, vertexData, GL_STREAM_DRAW);
	glCheckError();
<commit_msg>Hopefully fix array elements<commit_after>#include "painter_opengl.h"
#include "halley/core/graphics/material/material_definition.h"

using namespace Halley;

PainterOpenGL::PainterOpenGL()
{}

PainterOpenGL::~PainterOpenGL()
{
	if (vbo != 0) {
		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glDeleteBuffers(1, &vbo);
		vbo = 0;
	}
	if (veo != 0) {
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
		glDeleteBuffers(1, &veo);
		veo = 0;
	}
	if (vao != 0) {
		glBindVertexArray(0);
		glDeleteVertexArrays(1, &vao);
		vao = 0;
	}
}

void PainterOpenGL::doStartRender()
{
	glCheckError();

	if (!glUtils) {
		glUtils = std::make_unique<GLUtils>();
	}

	if (vbo == 0) {
		glGenBuffers(1, &vbo);
		glCheckError();
	}

	if (veo == 0) {
		glGenBuffers(1, &veo);
		glCheckError();
	}

	if (vao == 0) {
		glGenVertexArrays(1, &vao);
		glCheckError();
		glBindVertexArray(vao);
		glCheckError();
		glBindBuffer(GL_ARRAY_BUFFER, vbo);
		glCheckError();
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, veo);
		glCheckError();
	}

	glBindVertexArray(vao);
}

void PainterOpenGL::doEndRender()
{
	glBindVertexArray(0);
	glCheckError();
}

void PainterOpenGL::clear(Colour colour)
{
	glCheckError();
	glClearColor(colour.r, colour.g, colour.b, colour.a);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glCheckError();
}

void PainterOpenGL::setBlend(BlendType blend)
{
	glUtils->setBlendType(blend);
}

void PainterOpenGL::setVertices(MaterialDefinition& material, size_t numVertices, void* vertexData)
{
	// Load vertices into VBO
	size_t bytesSize = numVertices * material.getVertexStride();
	glBufferData(GL_ARRAY_BUFFER, bytesSize, vertexData, GL_STREAM_DRAW);
	glCheckError();

{'fraction_non_alphanumeric': 0.14655441222326163, 'fraction_numerical': 0.010601808543810414, 'mean_word_length': 5.81104033970276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '493861', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1287, 'n_words': 211}