polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

debug.c (725B)


      1 
      2 #include "debug.h"
      3 #include <stdlib.h>
      4 #include <stdio.h>
      5 
      6 void show_program_info_log(int program)
      7 {
      8 	GLint msgLen = 0;
      9 	glGetProgramiv(program, GL_INFO_LOG_LENGTH, &msgLen);
     10 
     11 	// The maxLength includes the NULL character
     12 	char *buffer = malloc(msgLen);
     13 	glGetProgramInfoLog(program, msgLen, &msgLen, buffer);
     14 
     15 	printf("program error: (%d) %.*s\n", msgLen, msgLen, buffer);
     16 
     17 	free(buffer);
     18 }
     19 
     20 void show_shader_info_log(GLuint shader) {
     21 	GLint msgLen = 0;
     22 	glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &msgLen);
     23 
     24 	// The maxLength includes the NULL character
     25 	char *buffer = malloc(msgLen);
     26 	glGetShaderInfoLog(shader, msgLen, &msgLen, buffer);
     27 
     28 	printf("shader error: (%d) %.*s\n", msgLen, msgLen, buffer);
     29 
     30 	free(buffer);
     31 }
     32 
     33