行业知识
opengl 学习(三)-----着色器
2026-11-11 00:14:52
来源:互联网转载
着色器
- 分类
- demo
- 效果
- 解析
- index.php/tags-41973.html" >���程
分类
OPengl C++
demo
#include "glad/glad.h"#include "glfw3.h"#include #include #include #include #include #include using namespace std;/******************************************************/class Shader{public: unsigned int ID; // constructor generates the shader on the fly // ------------------------------------------------------------------------ Shader(const char* vertexPath, const char* fragmentPath) { // 1. retrieve the vertex/fragment source code from filePath std::string vertexCode; std::string fragmentCode; std::ifstream vShaderFile; std::ifstream fShaderFile; // ensure ifstream objects can throw exceptions: vShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit); fShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit); try { // open files vShaderFile.open(vertexPath); fShaderFile.open(fragmentPath); std::stringstream vShaderStream, fShaderStream; // read file's buffer contents into streams vShaderStream std::cout