Преглед на файлове

[gl_util.h] Adding function to get uniforms

Vinicius Teshima преди 1 година
родител
ревизия
7a891484ec
променени са 1 файла, в които са добавени 22 реда и са изтрити 0 реда
  1. 22 0
      src/gl_util.h

+ 22 - 0
src/gl_util.h

@@ -0,0 +1,22 @@
+#ifndef GL_UTIL_H
+#define GL_UTIL_H
+
+int32_t get_uniform_or_exit(uint32_t prog, const char *name);
+
+#if defined(GL_UTIL_IMP) || defined(IMP)
+
+int32_t
+get_uniform_or_exit(uint32_t prog, const char *name)
+{
+	int32_t uni = glGetUniformLocation(prog, name);
+	if ( uni == -1 ) {
+		fprintf(stderr, "Failed getting %s uniform location\n", name);
+		exit(EXIT_FAILURE);
+	}
+	printf("Got %s -> %d\n", name, uni);
+	return uni;
+}
+
+#endif /* defined(GL_UTIL_IMP) || defined(IMP) */
+
+#endif