You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
1 year ago
|
#pragma once
|
||
|
#include <GL/glew.h>
|
||
|
#include <cstdlib>
|
||
|
#include <iostream>
|
||
|
|
||
|
namespace ErrorCheck{
|
||
|
inline void printShaderLog(GLuint shader) {
|
||
|
int len = 0;
|
||
|
int chWrittn = 0;
|
||
|
char *log;
|
||
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
|
||
|
if (len > 0) {
|
||
|
log = (char *)malloc(len);
|
||
|
glGetShaderInfoLog(shader, len, &chWrittn, log);
|
||
|
std::cout << "Shader Info Log: " << log << std::endl;
|
||
|
free(log);
|
||
|
} }
|
||
|
inline void printProgramLog(int prog) {
|
||
|
int len = 0;
|
||
|
int chWrittn = 0;
|
||
|
char *log;
|
||
|
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len);
|
||
|
if (len > 0) {
|
||
|
log = (char *)malloc(len);
|
||
|
glGetProgramInfoLog(prog, len, &chWrittn, log);
|
||
|
std::cout << "Program Info Log: " << log << std::endl;
|
||
|
free(log);
|
||
|
} }
|
||
|
inline bool checkOpenGLError() {
|
||
|
bool foundError = false;
|
||
|
int glErr = glGetError();
|
||
|
while (glErr != GL_NO_ERROR) {
|
||
|
std::cout << "glError: " << glErr << std::endl;
|
||
|
foundError = true;
|
||
|
glErr = glGetError();
|
||
|
}
|
||
|
return foundError;
|
||
|
}
|
||
|
}
|