opengl_learn

Step-by-step introduction to OpenGL
git clone https://0xdd.org/code/opengl_learn.git
Log | Files | Refs | README | LICENSE

ogl_program_uniform_get_ID.c (594B)


      1 /*
      2 2018 David DiPaola
      3 licensed under CC0 (public domain, see https://creativecommons.org/publicdomain/zero/1.0/)
      4 */
      5 
      6 #include <stdio.h>
      7 
      8 #include <GL/glew.h>
      9 
     10 int
     11 ogl_program_uniform_get_ID(
     12 	GLuint program_ID, const char * uniform_name,
     13 	GLint * out_uniform_ID
     14 ) {
     15 	GLint uniform_ID;
     16 
     17 	uniform_ID = glGetUniformLocation(program_ID, uniform_name);
     18 	if (uniform_ID < 0) {
     19 		fprintf(stderr, "GL glGetUniformLocation(%i, \"%s\"): ERROR" "\n", program_ID, uniform_name);
     20 		fprintf(stderr, "\t" "at %s : %d" "\n", __FILE__, __LINE__);
     21 		return -1;
     22 	}
     23 
     24 	(*out_uniform_ID) = uniform_ID;
     25 	return 0;
     26 }
     27