add guGetShaderLog() and guGetProgramLog()
This commit is contained in:
parent
cf31a302f2
commit
01f9c2e467
@ -1,8 +1,29 @@
|
|||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "glslUtil.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)
|
void guMatrixLoadIdentity(guMatrix4x4 *m)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -168,3 +189,29 @@ void guOrtho(guMatrix4x4 *m,
|
|||||||
mult[2][3] = - (far + near) / fn;
|
mult[2][3] = - (far + near) / fn;
|
||||||
mult[3][3] = 1.0;
|
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;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,8 @@ void guOrtho(guMatrix4x4 *m,
|
|||||||
GLfloat left, GLfloat right,
|
GLfloat left, GLfloat right,
|
||||||
GLfloat bottom, GLfloat top,
|
GLfloat bottom, GLfloat top,
|
||||||
GLfloat near, GLfloat far);
|
GLfloat near, GLfloat far);
|
||||||
|
char *guGetShaderLog(GLuint id);
|
||||||
|
char *guGetProgramLog(GLuint id);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user