126 lines
1.6 KiB
C
126 lines
1.6 KiB
C
/*
|
|
* This file is automaticaly generated, Please dont edit this file!
|
|
*/
|
|
#include <engine/shader.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void shader_constructor( shader * this, GLuint shaderType ) {
|
|
|
|
this->glShader = glCreateShader( shaderType );
|
|
|
|
}
|
|
|
|
void shader_loadFromFile( shader * this, char * shaderPath ) {
|
|
|
|
text * shaderSource = fileSystem_readFile( filesystem, shaderPath, "utf8" );
|
|
|
|
glShaderSource( this->glShader, 1, &shaderSource->value, NULL );
|
|
|
|
glCompileShader( this->glShader );
|
|
|
|
shader_checkShaderForErrors( this, this->glShader );
|
|
|
|
}
|
|
|
|
void shader_checkShaderForErrors( shader * this, GLuint shader ) {
|
|
|
|
GLint isCompiled = 0;
|
|
|
|
glGetShaderiv( shader, GL_COMPILE_STATUS, &isCompiled );
|
|
|
|
if( isCompiled == GL_FALSE )
|
|
{
|
|
GLint maxLength = 0;
|
|
|
|
glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &maxLength );
|
|
|
|
GLchar errorMessage[ maxLength ];
|
|
|
|
glGetShaderInfoLog( shader, maxLength, &maxLength, errorMessage );
|
|
|
|
printf("\n\n\n\n Error: %s\n\n\n\n\n\n", errorMessage);
|
|
|
|
|
|
glDeleteShader( shader );
|
|
|
|
exit( 0 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shader shader_new(GLuint shaderType) {
|
|
|
|
shader instance;
|
|
|
|
shader_constructor( &instance, shaderType);
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
shader * shader_newPointer(GLuint shaderType) {
|
|
|
|
struct shader * pointer = malloc( sizeof ( struct shader ) );
|
|
|
|
shader_constructor( pointer , shaderType);
|
|
|
|
return pointer;
|
|
|
|
}
|
|
|
|
attribute attribute_new() {
|
|
|
|
attribute instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
attribute * attribute_newPointer() {
|
|
|
|
struct attribute * pointer = malloc( sizeof ( struct attribute ) );
|
|
|
|
return pointer;
|
|
|
|
}
|
|
|