[Piglit] [PATCH 11/23] util: Add simple 1D and 3D texture creation functions.
Fabian Bieler
fabianbieler at fastmail.fm
Thu Nov 23 20:46:03 UTC 2017
---
tests/util/piglit-util-gl.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
tests/util/piglit-util-gl.h | 2 ++
2 files changed, 48 insertions(+)
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 43b38e5..8fe5f98 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -2677,6 +2677,52 @@ piglit_rgbw_texture(GLenum internalFormat, int w, int h, GLboolean mip,
}
/**
+ * Generate a 4 texel RGBA 1D texture with texels red, green, blue, white,
+ * edge clamping and NEAREST filtering.
+ */
+GLuint
+piglit_rgbw_texture_1d(void)
+{
+ GLuint tex;
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_1D, tex);
+ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ static const float img[] = {1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1};
+ glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 4, 0, GL_RGBA, GL_FLOAT, img);
+
+ return tex;
+}
+
+/**
+ * Generate a 2 by 2 by 2 texel RGBA 3D texture with texels red, green, blue,
+ * white, yellow, magenta, cyan, black, edge clamping and NEAREST filtering.
+ */
+GLuint
+piglit_rgbw_texture_3d(void)
+{
+ GLuint tex;
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_3D, tex);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ static const float img[] = {1, 0, 0, 1, 0, 1, 0, 1,
+ 0, 0, 1, 1, 1, 1, 1, 1,
+ 1, 1, 0, 1, 1, 0, 1, 1,
+ 0, 1, 1, 1, 0, 0, 0, 1};
+ glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 2, 2, 2, 0, GL_RGBA, GL_FLOAT, img);
+
+ return tex;
+}
+
+/**
* Generates a texture with the given integer internal format.
* Pixel data will be filled as R = x, G = y, B = b, A = a.
*/
diff --git a/tests/util/piglit-util-gl.h b/tests/util/piglit-util-gl.h
index e8728d0..73a38f7 100644
--- a/tests/util/piglit-util-gl.h
+++ b/tests/util/piglit-util-gl.h
@@ -301,6 +301,8 @@ GLfloat *piglit_rgbw_image(GLenum internalFormat, int w, int h,
GLubyte *piglit_rgbw_image_ubyte(int w, int h, GLboolean alpha);
GLuint piglit_rgbw_texture(GLenum internalFormat, int w, int h, GLboolean mip,
GLboolean alpha, GLenum basetype);
+GLuint piglit_rgbw_texture_1d(void);
+GLuint piglit_rgbw_texture_3d(void);
GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, int a);
GLuint piglit_depth_texture(GLenum target, GLenum format, int w, int h, int d, GLboolean mip);
GLuint piglit_array_texture(GLenum target, GLenum format, int w, int h, int d, GLboolean mip);
--
2.7.4
More information about the Piglit
mailing list