ソースを参照

[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