Enviado em 21/09/2021 - 13:19h
Boa tarde senhores(as),#include <fstream>
#include <string>
#include <GL/gl.h>
std::string ReadFile(const char* path)
{
std::ifstream fs{path, std::ios::in};
std::string ret, line;
while (!fs.eof()) {
std::getline(fs, line);
ret.append(line + "\n");
}
return ret;
}
GLuint CreateVertexShader(const char* filePath)
{
auto code{ReadFile(filePath)};
const GLchar* constCodePtr = code.c_str();
GLuint vShader{glCreateShader(GL_VERTEX_SHADER)};
glShaderSource(vShader, 1, &constCodePtr, NULL);
glCompileShader(vShader);
return vShader;
}
GLuint CreateFragmentShader(const char* filePath)
{
auto code{ReadFile(filePath)};
const GLchar* constCodePtr = code.c_str();
GLuint fShader{glCreateShader(GL_FRAGMENT_SHADER)};
glShaderSource(fShader, 1, &constCodePtr, NULL);
glCompileShader(fShader);
return fShader;
}
GLuint ConstructShaderProgram(const char* vertexShaderPath, const char* fragmentShaderPath)
{
GLuint program{glCreateProgram()};
glAttachShader(program, CreateVertexShader(vertexShaderPath));
glAttachShader(program, CreateFragmentShader(fragmentShaderPath));
glLinkProgram(program);
return program;
}
Atenção a quem posta conteúdo de dicas, scripts e tal (1)
Manutenção de sistemas Linux Debian e derivados com apt-get, apt, aptitude e dpkg
Melhorando o tempo de boot do Fedora e outras distribuições
Como instalar as extensões Dash To Dock e Hide Top Bar no Gnome 45/46
Como Atualizar Fedora 39 para 40
Instalar Google Chrome no Debian e derivados
Consertando o erro do Sushi e Wayland no Opensuse Leap 15
Instalar a última versão do PostgreSQL no Lunix mantendo atualizado
Flathub na sua distribuição Linux e comandos básicos de gerenciamento
Erro ao converter string para inteiro (6)
Diferença entre formas de instalar o Samba [RESOLVIDO] (4)
Dongle Bluetooth 5.0 não funciona no Pop Os 22.04 (0)
Como adicionar módulo de saúde da bateria dos notebooks Acer ao kernel... (24)
[Shell Script] Script para desinstalar pacotes desnecessários no OpenSuse
[Shell Script] Script para criar certificados de forma automatizada no OpenVpn
[Shell Script] Conversor de vídeo com opção de legenda
[C/C++] BRT - Bulk Renaming Tool
[Shell Script] Criação de Usuarios , Grupo e instalação do servidor de arquivos samba