<commit_before>#include "app.h"
#include "obj_import.h"
#include "camera.h"
#include "color_shader.h"
#include "texture_shader.h"

using namespace lantern;

enum class shader_option
{
	color,
	texture
};

/** Draws simple triangle with interpolated color attribute */
class rasterized_color_triangle_app : public app
{
public:
	rasterized_color_triangle_app(unsigned int const width, unsigned int const height);

protected:
	void frame(float const delta_since_last_frame) override;
	void on_key_down(SDL_Keysym const key) override;

private:
	/** Updates view-model-projection matrix and gives it to the shader */
	void update_shader_mvp();

	vector3 const m_triangle_position;
	vector3 const m_triangle_rotation;
	mesh m_triangle_mesh;

	camera m_camera;
	
	color_shader m_color_shader;
	texture_shader m_texture_shader;
	shader_option m_shader_option;

	texture m_texture;
};

rasterized_color_triangle_app::rasterized_color_triangle_app(unsigned int const width, unsigned int const height)
	: app(width, height),
	  m_triangle_position{0.0f, 0.0f, 1.5f},
	  m_triangle_rotation{vector3::ZERO},
	  m_triangle_mesh{load_mesh_from_obj("resources/triangle.obj", false, false)},
	  m_camera{
		  vector3::ZERO,
		  vector3::Z_UNIT,
		  vector3::Y_UNIT,
		  static_cast<float>(M_PI) / 2.0f,
		  static_cast<float>(height) / static_cast<float>(width),
		  0.01f,
		  20.0f},
	  m_shader_option{shader_option::color},
	  m_texture{texture::load_from_file("resources/chess.png")}
{
	// Update model-view-projection matrix for the first time
	update_shader_mvp();

	std::vector<unsigned int> const indices{0, 1, 2};

	// Add color attribute to triangle mesh
	//
	std::vector<color> const colors{color::GREEN, color::RED, color::BLUE};
	mesh_attribute_info<color> const color_info{VERTEX_COLOR_ATTR_ID, colors, indices, attribute_interpolation_option::linear};
	m_triangle_mesh.get_color_attributes().push_back(color_info);

	// Add uv attribute to triangle mesh
	//
	std::vector<vector2f> uvs{vector2f{0.5f, 0.0f}, vector2f{0.0f, 1.0f}, vector2f{1.0f, 1.0f}};
	mesh_attribute_info<vector2f> uv_info{TEXCOORD_ATTR_ID, uvs, indices, attribute_interpolation_option::perspective_correct};
	m_triangle_mesh.get_vector2f_attributes().push_back(uv_info);
<commit_msg>rasterized triangle app syntax errors fixed<commit_after>#include "app.h"
#include "obj_import.h"
#include "camera.h"
#include "color_shader.h"
#include "texture_shader.h"

using namespace lantern;

enum class shader_option
{
	color,
	texture
};

/** Draws simple triangle with interpolated color attribute */
class rasterized_color_triangle_app : public app
{
public:
	rasterized_color_triangle_app(unsigned int const width, unsigned int const height);

protected:
	void frame(float const delta_since_last_frame) override;
	void on_key_down(SDL_Keysym const key) override;

private:
	/** Updates view-model-projection matrix and gives it to the shader */
	void update_shader_mvp();

	vector3f const m_triangle_position;
	vector3f const m_triangle_rotation;
	mesh m_triangle_mesh;

	camera m_camera;
	
	color_shader m_color_shader;
	texture_shader m_texture_shader;
	shader_option m_shader_option;

	texture m_texture;
};

rasterized_color_triangle_app::rasterized_color_triangle_app(unsigned int const width, unsigned int const height)
	: app(width, height),
	  m_triangle_position{0.0f, 0.0f, 1.5f},
	  m_triangle_rotation{vector3f{0.0f, 0.0f, 0.0f}},
	  m_triangle_mesh{load_mesh_from_obj("resources/triangle.obj", false, false)},
	  m_camera{
		  vector3f{0.0f, 0.0f, 0.0f},
		  vector3f{0.0f, 0.0f, 1.0f},
		  vector3f{0.0f, 1.0f, 0.0f},
		  static_cast<float>(M_PI) / 2.0f,
		  static_cast<float>(height) / static_cast<float>(width),
		  0.01f,
		  20.0f},
	  m_shader_option{shader_option::color},
	  m_texture{texture::load_from_file("resources/chess.png")}
{
	// Update model-view-projection matrix for the first time
	update_shader_mvp();

	std::vector<unsigned int> const indices{0, 1, 2};

	// Add color attribute to triangle mesh
	//
	std::vector<color> const colors{color::GREEN, color::RED, color::BLUE};
	mesh_attribute_info<color> const color_info{VERTEX_COLOR_ATTR_ID, colors, indices, attribute_interpolation_option::linear};
	m_triangle_mesh.get_color_attributes().push_back(color_info);

	// Add uv attribute to triangle mesh
	//
	std::vector<vector2f> uvs{vector2f{0.5f, 0.0f}, vector2f{0.0f, 1.0f}, vector2f{1.0f, 1.0f}};
	mesh_attribute_info<vector2f> uv_info{TEXCOORD_ATTR_ID, uvs, indices, attribute_interpolation_option::perspective_correct};
	m_triangle_mesh.get_vector2f_attributes().push_back(uv_info);

{'fraction_non_alphanumeric': 0.11208024422154383, 'fraction_numerical': 0.02311382468382032, 'mean_word_length': 6.078703703703703, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '2388766', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1649, 'n_words': 331}