add guGetShaderLog() and guGetProgramLog()

This commit is contained in:
Josh Holtrop 2011-05-09 17:22:41 -04:00
parent cf31a302f2
commit 01f9c2e467
2 changed files with 49 additions and 0 deletions

View File

@ -1,8 +1,29 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
#include <string.h>
#include "glslUtil.h"
/**************************************************************************
* Helper Functions *
*************************************************************************/
static char *loadFile(const char *fname)
{
struct stat st;
if (stat(fname, &st) != 0)
return NULL;
if (st.st_size <= 0)
return NULL;
char * buff = malloc(st.st_size + 1);
int fd = open(fname, O_RDONLY);
read(fd, buff, st.st_size);
close(fd);
buff[st.st_size] = '\0';
return buff;
}
void guMatrixLoadIdentity(guMatrix4x4 *m)
{
int i, j;
@ -168,3 +189,29 @@ void guOrtho(guMatrix4x4 *m,
mult[2][3] = - (far + near) / fn;
mult[3][3] = 1.0;
}
char *guGetShaderLog(GLuint id)
{
GLint log_length;
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &log_length);
if (log_length > 0)
{
char *log = malloc(sizeof(char) * log_length);
glGetShaderInfoLog(id, log_length, &log_length, log);
return log;
}
return NULL;
}
char *guGetProgramLog(GLuint id)
{
GLint log_length;
glGetProgramiv(id, GL_INFO_LOG_LENGTH, &log_length);
if (log_length > 0)
{
char *log = malloc(sizeof(char) * log_length);
glGetProgramInfoLog(id, log_length, &log_length, log);
return log;
}
return NULL;
}

View File

@ -30,6 +30,8 @@ void guOrtho(guMatrix4x4 *m,
GLfloat left, GLfloat right,
GLfloat bottom, GLfloat top,
GLfloat near, GLfloat far);
char *guGetShaderLog(GLuint id);
char *guGetProgramLog(GLuint id);
#ifdef __cplusplus
}