<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <gl/glew.h>
#include <gl/GL.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <AntTweakBar.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4996) //4996 for _CRT_SECURE_NO_WARNINGS
#endif
#include <gli/gli.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "../common/shader.hpp"
#include "../common/utils.h"

static GLfloat const skybox_v[] = {
	-1.0f, 1.0f, -1.0f,
	-1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,
	1.0f, 1.0f, -1.0f,
	-1.0f, 1.0f, -1.0f,

	-1.0f, -1.0f, 1.0f,
	-1.0f, -1.0f, -1.0f,
	-1.0f, 1.0f, -1.0f,
	-1.0f, 1.0f, -1.0f,
	-1.0f, 1.0f, 1.0f,
	-1.0f, -1.0f, 1.0f,

	1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,

	-1.0f, -1.0f, 1.0f,
	-1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, -1.0f, 1.0f,
	-1.0f, -1.0f, 1.0f,

	-1.0f, 1.0f, -1.0f,
	1.0f, 1.0f, -1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	-1.0f, 1.0f, 1.0f,
	-1.0f, 1.0f, -1.0f,

	-1.0f, -1.0f, -1.0f,
	-1.0f, -1.0f, 1.0f,
	1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,
	-1.0f, -1.0f, 1.0f,
	1.0f, -1.0f, 1.0f
};

using namespace glm;

void load_texture(GLint idx, gli::texture const &texture)
{
	glTexImage2D(idx, 0, GL_RGB,
		texture.dimensions().x,
		texture.dimensions().y,
		0, GL_RGB, GL_UNSIGNED_BYTE, texture.data(0, 0, 0));
}

GLuint load_cubemap(std::string const &name_prefix)
{
	GLuint texture_id;
	glGenTextures(1, &texture_id);
	glActiveTexture(GL_TEXTURE0);

	int width, height;
	unsigned char* image;

	glBindTexture(GL_TEXTURE_CUBE_MAP, texture_id);
	gli::texture texture_p_x = gli::load(name_prefix + "+x.dds");
	assert(!texture_p_x.empty());
	gli::texture texture_p_y = gli::load(name_prefix + "+y.dds");
	assert(!texture_p_y.empty());
	gli::texture texture_p_z = gli::load(name_prefix + "+z.dds");
	assert(!texture_p_z.empty());
	gli::texture texture_m_x = gli::load(name_prefix + "-x.dds");
	assert(!texture_m_x.empty());
	gli::texture texture_m_y = gli::load(name_prefix + "-y.dds");
	assert(!texture_m_y.empty());
	gli::texture texture_m_z = gli::load(name_prefix + "-z.dds");
	assert(!texture_m_z.empty());
	load_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_X, texture_p_x);
	load_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, texture_p_y);
	load_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texture_p_z);
	load_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, texture_m_x);
	load_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, texture_m_y);
	load_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, texture_m_z);

	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
	glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

	return texture_id;
}


int main() 
{
	GLFWwindow *window = init();
	if (!window)
	{
		return -1;
	}

	GLuint skybox_shader = LoadShaders("task2_skybox.vertexshader", "task2_skybox.fragmentshader");
	GLuint scene_shader = LoadShaders("task2_scene.vertexshader", "task2_scene.fragmentshader");

	GLuint skybox_vao, skybox_vbo;
	glGenVertexArrays(1, &skybox_vao);
	glGenBuffers(1, &skybox_vbo);
	glBindVertexArray(skybox_vao);
	glBindBuffer(GL_ARRAY_BUFFER, skybox_vbo);
	glBufferData(GL_ARRAY_BUFFER, sizeof(skybox_v), &skybox_v, GL_STATIC_DRAW);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr);
	glBindVertexArray(0);

	GLuint skybox_texture = load_cubemap("SantaMariaDeiMiracoli");
	if (!skybox_texture)
	{
		return -5;
	}

	std::pair<std::vector<GLfloat>, std::vector<GLfloat>> vert_and_normals = 
			load_scene("spider.obj");

	std::vector<GLfloat> &vertexes = vert_and_normals.first;
	std::vector<GLfloat> &normals = vert_and_normals.second;
	GLuint vertex_buffer, vertex_array_o;
	glGenVertexArrays(1, &vertex_array_o);
	glGenBuffers(1, &vertex_buffer);
	glBindVertexArray(vertex_array_o);
	glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
	glBufferData(GL_ARRAY_BUFFER, vertexes.size() * sizeof(GLfloat), vertexes.data(), GL_STATIC_DRAW);
	glEnableVertexAttribArray(0);
	glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr);
	GLuint norm_buffer;
	glGenBuffers(1, &norm_buffer);
	glBindBuffer(GL_ARRAY_BUFFER, norm_buffer);
	glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(GLfloat), normals.data(), GL_STATIC_DRAW);
	glEnableVertexAttribArray(1);
	glBindBuffer(GL_ARRAY_BUFFER, norm_buffer);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr);
	glBindVertexArray(0);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	float t = 0;
	while (!glfwWindowShouldClose(window))
	{
		t += 3e-3;
		//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		glfwPollEvents();<commit_msg>Minor fixes<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <gl/glew.h>
#include <gl/GL.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <AntTweakBar.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4996) //4996 for _CRT_SECURE_NO_WARNINGS
#endif
#include <gli/gli.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "../common/shader.hpp"
#include "../common/utils.h"

static GLfloat const skybox_v[] = {
	-1.0f, 1.0f, -1.0f,
	-1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,
	1.0f, 1.0f, -1.0f,
	-1.0f, 1.0f, -1.0f,

	-1.0f, -1.0f, 1.0f,
	-1.0f, -1.0f, -1.0f,
	-1.0f, 1.0f, -1.0f,
	-1.0f, 1.0f, -1.0f,
	-1.0f, 1.0f, 1.0f,
	-1.0f, -1.0f, 1.0f,

	1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,

	-1.0f, -1.0f, 1.0f,
	-1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, -1.0f, 1.0f,
	-1.0f, -1.0f, 1.0f,

	-1.0f, 1.0f, -1.0f,
	1.0f, 1.0f, -1.0f,
	1.0f, 1.0f, 1.0f,
	1.0f, 1.0f, 1.0f,
	-1.0f, 1.0f, 1.0f,
	-1.0f, 1.0f, -1.0f,

	-1.0f, -1.0f, -1.0f,
	-1.0f, -1.0f, 1.0f,
	1.0f, -1.0f, -1.0f,
	1.0f, -1.0f, -1.0f,
	-1.0f, -1.0f, 1.0f,
	1.0f, -1.0f, 1.0f
};

using namespace glm;

void load_texture(GLint idx, gli::texture const &texture)
{
	glTexImage2D(idx, 0, GL_RGB,
		texture.dimensions().x,
		texture.dimensions().y,
		0, GL_RGB, GL_UNSIGNED_BYTE, texture.data(0, 0, 0));
}

GLuint load_cubemap(std::string const &name_prefix)
{
	GLuint texture_id;
	glGenTextures(1, &texture_id);
	glActiveTexture(GL_TEXTURE0);

	glBindTexture(GL_TEXTURE_CUBE_MAP, texture_id);
	gli::texture texture_p_x = gli::load(name_prefix + "+x.dds");
	assert(!texture_p_x.empty());
	gli::texture texture_p_y = gli::load(name_prefix + "+y.dds");
	assert(!texture_p_y.empty());
	gli::texture texture_p_z = gli::load(name_prefix + "+z.dds");
	assert(!texture_p_z.empty());
	gli::texture texture_m_x = gli::load(name_prefix + "-x.dds");
	assert(!texture_m_x.empty());
	gli::texture texture_m_y = gli::load(name_prefix + "-y.dds");
	assert(!texture_m_y.empty());
	gli::texture texture_m_z = gli::load(name_prefix + "-z.dds");
	assert(!texture_m_z.empty());
	load_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_X, texture_p_x);
	load_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, texture_p_y);
	load_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texture_p_z);
	load_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, texture_m_x);
	load_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, texture_m_y);
	load_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, texture_m_z);

	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
	glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

	return texture_id;
}


int main() 
{
	GLFWwindow *window = init();
	if (!window)
	{
		return -1;
	}

	GLuint skybox_shader = LoadShaders("task2_skybox.vertexshader", "task2_skybox.fragmentshader");
	GLuint scene_shader = LoadShaders("task2_scene.vertexshader", "task2_scene.fragmentshader");

	GLuint skybox_vao, skybox_vbo;
	glGenVertexArrays(1, &skybox_vao);
	glGenBuffers(1, &skybox_vbo);
	glBindVertexArray(skybox_vao);
	glBindBuffer(GL_ARRAY_BUFFER, skybox_vbo);
	glBufferData(GL_ARRAY_BUFFER, sizeof(skybox_v), &skybox_v, GL_STATIC_DRAW);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr);
	glBindVertexArray(0);

	GLuint skybox_texture = load_cubemap("SantaMariaDeiMiracoli");
	if (!skybox_texture)
	{
		return -5;
	}

	std::pair<std::vector<GLfloat>, std::vector<GLfloat>> vert_and_normals = 
			load_scene("spider.obj");

	std::vector<GLfloat> &vertexes = vert_and_normals.first;
	std::vector<GLfloat> &normals = vert_and_normals.second;
	GLuint vertex_buffer, vertex_array_o;
	glGenVertexArrays(1, &vertex_array_o);
	glGenBuffers(1, &vertex_buffer);
	glBindVertexArray(vertex_array_o);
	glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
	glBufferData(GL_ARRAY_BUFFER, vertexes.size() * sizeof(GLfloat), vertexes.data(), GL_STATIC_DRAW);
	glEnableVertexAttribArray(0);
	glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr);
	GLuint norm_buffer;
	glGenBuffers(1, &norm_buffer);
	glBindBuffer(GL_ARRAY_BUFFER, norm_buffer);
	glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(GLfloat), normals.data(), GL_STATIC_DRAW);
	glEnableVertexAttribArray(1);
	glBindBuffer(GL_ARRAY_BUFFER, norm_buffer);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr);
	glBindVertexArray(0);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	float t = 0;
	while (!glfwWindowShouldClose(window))
	{
		t += 3e-3f;
		//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		glfwPollEvents();
{'fraction_non_alphanumeric': 0.16655236602331733, 'fraction_numerical': 0.051337317527187225, 'mean_word_length': 5.489510489510489, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '722883', 'n_tokens_mistral': 5066, 'n_tokens_neox': 4851, 'n_words': 732}