Code 1

#ifndef SHADER_H
#define SHADER_H
#pragma once
#include <glad/glad.h>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
class Shader
{
public:
	unsigned int id;
	Shader(const char* vertex_code, const char* fragment_code)
	{
		unsigned int vertex_shader = glCreateShader(GL_VERTEX_SHADER), fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
		int success;
		char infoLog[512];
		id = glCreateProgram();
		glShaderSource(vertex_shader, 1, &vertex_code, NULL);
		glCompileShader(vertex_shader);
		glShaderSource(fragment_shader, 1, &fragment_code, NULL);
		glCompileShader(fragment_shader);
		glAttachShader(id, vertex_shader);
		glAttachShader(id, fragment_shader);
		glLinkProgram(id);
		glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &success);
		if (!success)
		{
			glGetShaderInfoLog(vertex_shader, 512, NULL, infoLog);
			std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
		}
		glGetShaderiv(fragment_shader, GL_COMPILE_STATUS, &success);
		if (!success)
		{
			glGetShaderInfoLog(vertex_shader, 512, NULL, infoLog);
			std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
		}
		glGetProgramiv(id, GL_LINK_STATUS, &success);
		if (!success)
		{
			glGetProgramInfoLog(id, 512, NULL, infoLog);
			std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
		}
		glDeleteShader(vertex_shader);
		glDeleteShader(fragment_shader);
	}
	void Use()
	{
		glUseProgram(id);
	}
	void Set3f(const std::string& name, float x, float y, float z)
	{
		glUniform3f(glGetUniformLocation(id, name.c_str()), x, y, z);
	}
	void SetVec3(const std::string& name, glm::vec3 val)
	{
		glUniform3f(glGetUniformLocation(id, name.c_str()), val.x, val.y, val.z);
	}
	void SetVec4(const std::string& name, glm::vec4 val)
	{
		glUniform4f(glGetUniformLocation(id, name.c_str()), val.x, val.y, val.z, val.w);
	}
	void SetInt(const std::string& name, int val)
	{
		glUniform1i(glGetUniformLocation(id, name.c_str()), val);
	}void Setf(const std::string& name, float val)
	{
		glUniform1f(glGetUniformLocation(id, name.c_str()), val);
	}
	void SetMat4(const std::string& name, glm::mat4 val)
	{
		glUniformMatrix4fv(glGetUniformLocation(id, name.c_str()), 1, GL_FALSE, &val[0][0]);
	}
private:
};
#endif