Index

zydeco / master

Experiment in graphics programming, C++, OpenGL, simulation techniques.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
703 Sep 2023 16:015f524c5OpenGL render abstractionsJosh Stockin1300G

Blob @ zydeco / src / render / gl / GLShader.cpp

text/plain676 bytesdownload raw
1#include <GL/gl3w.h>
2
3#include "GLShader.hpp"
4
5
6GLShader::GLShader(uint64_t shader_type, const char *shader_source)
7{
8 m_glShaderId = glCreateShader(shader_type);
9 glShaderSource(m_glShaderId, 1, &shader_source, nullptr);
10 glCompileShader(m_glShaderId);
11
12 int success;
13 char infoLog[512];
14 glGetShaderiv(m_glShaderId, GL_COMPILE_STATUS, &success);
15 if (!success)
16 {
17 glGetShaderInfoLog(m_glShaderId, 512, nullptr, infoLog);
18 ZydecoFault("Shader compilation failed (type {}):\n{}", shader_type, infoLog);
19 }
20}
21
22GLShader::~GLShader()
23{
24 glDeleteShader(m_glShaderId);
25}
26
27uint64_t GLShader::GetGLShaderID()
28{
29 return m_glShaderId;
30}
31