summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-04-12 18:16:20 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-04-12 18:16:20 -0700
commit022c91aeb5dc00f8ee41c2c627d82af5f5a215d5 (patch)
treef4883a7756bde9deea60c5246580fc7713ea5f47
parentbe1d1798e01d08be07b9e223fff7db6f0765e9ee (diff)
util: Add new function to compile shaders
This one takes a pointer and a size. This enables compiling shaders that are embedded in files with other data.
-rw-r--r--tests/util/piglit-util.c41
-rw-r--r--tests/util/piglit-util.h2
2 files changed, 34 insertions, 9 deletions
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index ba4efa002..a56bbf589 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -424,17 +424,11 @@ piglit_compile_shader(GLenum target, char *filename)
return prog;
}
-/**
- * Convenience function to compile a GLSL shader.
- */
-GLuint
-piglit_compile_shader_text(GLenum target, const char *text)
+static GLuint
+compile_shader(GLuint prog, GLenum target)
{
- GLuint prog;
- GLint ok;
+ GLenum ok;
- prog = glCreateShader(target);
- glShaderSource(prog, 1, (const GLchar **) &text, NULL);
glCompileShader(prog);
glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
@@ -465,6 +459,35 @@ piglit_compile_shader_text(GLenum target, const char *text)
return prog;
}
+/**
+ * Convenience function to compile a GLSL shader.
+ */
+GLuint
+piglit_compile_shader_text_with_length(GLenum target, const char *text,
+ GLint length)
+{
+ GLuint prog;
+
+ prog = glCreateShader(target);
+ glShaderSource(prog, 1, (const GLchar **) &text, &length);
+
+ return compile_shader(prog, target);
+}
+
+/**
+ * Convenience function to compile a GLSL shader.
+ */
+GLuint
+piglit_compile_shader_text(GLenum target, const char *text)
+{
+ GLuint prog;
+
+ prog = glCreateShader(target);
+ glShaderSource(prog, 1, (const GLchar **) &text, NULL);
+
+ return compile_shader(prog, target);
+}
+
GLint piglit_link_simple_program(GLint vs, GLint fs)
{
GLint prog, ok;
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index c89fef006..082553796 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -90,6 +90,8 @@ void piglit_require_vertex_program(void);
GLuint piglit_compile_program(GLenum target, const char* text);
GLuint piglit_compile_shader(GLenum target, char *filename);
GLuint piglit_compile_shader_text(GLenum target, const char *text);
+GLuint piglit_compile_shader_text_with_length(GLenum target, const char *text,
+ GLint length);
GLint piglit_link_simple_program(GLint vs, GLint fs);
GLvoid piglit_draw_rect(float x, float y, float w, float h);
GLvoid piglit_draw_rect_tex(float x, float y, float w, float h,