glx-oml-sync-control-timing: Fix error message if glXWaitForMscOML fails
[piglit.git] / tests / security / initialized-texmemory.c
blob7f2f9d9d8b9509f1618cdb326c99397987eb4bd6
1 /*
2 * Copyright © 2012 VMware, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * Test that texture memory is initialized to a constant color and not
26 * stale data that may show old contents of VRAM.
28 * To pass this test an OpenGL implementation should initialize the
29 * contents of the new buffer to some fixed value (like all zeros).
30 * But since that's not spec'd by OpenGL, we only return WARN instead of
31 * FAIL if that's not the case.
33 * Brian Paul
34 * June 2012
37 #include "piglit-util-gl.h"
39 PIGLIT_GL_TEST_CONFIG_BEGIN
41 config.supports_gl_compat_version = 10;
43 config.window_width = 512;
44 config.window_height = 512;
45 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
47 PIGLIT_GL_TEST_CONFIG_END
50 enum piglit_result
51 piglit_display(void)
53 GLfloat firstPixel[4];
54 bool pass = true;
56 /* init color buffer to red */
57 glClearColor(1, 0, 0, 1);
58 glClear(GL_COLOR_BUFFER_BIT);
60 glEnable(GL_TEXTURE_2D);
62 piglit_draw_rect_tex(0, 0, piglit_width, piglit_height,
63 0.0, 0.0, 1.0, 1.0);
65 /* The whole image should be same color */
66 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, firstPixel);
67 pass = piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height,
68 firstPixel);
70 piglit_present_results();
72 return pass ? PIGLIT_PASS : PIGLIT_WARN;
76 void
77 piglit_init(int argc, char **argv)
79 GLsizei width = 1024, height = 1024;
80 GLuint tex;
82 /* Create texture image with pixels=NULL (undefined) */
83 glGenTextures(1, &tex);
84 glBindTexture(GL_TEXTURE_2D, tex);
85 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
86 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
87 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
88 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
89 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
91 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);