Заголовок:
Код: Выделить всё
#pragma once
#include
#include
#include
#include
class Shader
{
public:
unsigned int ID;
Shader(const char* vertexPath, const char* fragmentPath);
void use();
void setInt(std::string& name, int value) const;
void setFloat(std::string& name, float value) const;
void setBool(std::string& name, bool value) const;
};
Код: Выделить всё
#include "Shader.h"
Shader::Shader(const char* vertexPath, const char* fragmentPath):ID(0) {
//will hold the code as a string
std::string vertexCode;
std::string fragmentCode;
//file readers
std::ifstream vertexFile;
std::ifstream fragmentFile;
//set the exceptions that will cause failure when filereading
vertexFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fragmentFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
//open the files
vertexFile.open(vertexPath);
fragmentFile.open(fragmentPath);
//stringStreams to hold the file's contents
std::stringstream vertexStringStream, fragmentStringStream;
//read each file buffer into the stringStream
vertexStringStream
Подробнее здесь: [url]https://stackoverflow.com/questions/79856017/linking-errors-when-creating-a-shader-class[/url]