注释很详细,有错误的地方希望大佬能指正
#define GLEW_STATIC//GLEW静态库编译预处理
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
//编译着色器对象
static unsigned int CompileShader(unsigned int type, const std::string& source)
{
unsigned int id = glCreateShader(type);//创建着色器对象
const char* src = source.c_str();
glShaderSource(id, 1, &src, nullptr);//替换着色器对象中的源代码
glCompileShader(id);//编译着色器对象
int result;
glGetShaderiv(id, GL_COMPILE_STATUS, &result);//从着色器对象返回编译是否成功
if (result == GL_FALSE)
{
int length;
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &length);//从着色器对象返回着色器的信息日志的长度
char* message = (char*)alloca(length * sizeof(char));
glGetShaderInfoLog(id, length, &length, message);//返回着色器对象的信息日志
std::cout << "Failed to compile" << (type == GL_

本文详细指导如何在Windows Visual Studio中配置OpenGL环境,包括编译着色器、创建着色程序和解决常见错误,适合OpenGL初学者或开发者参考。
最低0.47元/天 解锁文章
&spm=1001.2101.3001.5002&articleId=127399573&d=1&t=3&u=7801994c931a4ee88036429316089b5e)
499

被折叠的 条评论
为什么被折叠?



