Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / gpu / command_buffer / tests / gl_test_utils.h
blob802d54d18ec715b1f48171231da8f931d47614aa
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Helper functions for GL.
7 #ifndef GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_
8 #define GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_
10 #include <GLES2/gl2.h>
11 #include "base/basictypes.h"
13 class GLTestHelper {
14 public:
15 static const uint8 kCheckClearValue = 123u;
17 static bool HasExtension(const char* extension);
18 static bool CheckGLError(const char* msg, int line);
20 // Compiles a shader.
21 // Does not check for errors, always returns shader.
22 static GLuint CompileShader(GLenum type, const char* shaderSrc);
24 // Compiles a shader and checks for compilation errors.
25 // Returns shader, 0 on failure.
26 static GLuint LoadShader(GLenum type, const char* shaderSrc);
28 // Attaches 2 shaders and links them to a program.
29 // Does not check for errors, always returns program.
30 static GLuint LinkProgram(GLuint vertex_shader, GLuint fragment_shader);
32 // Attaches 2 shaders, links them to a program, and checks for errors.
33 // Returns program, 0 on failure.
34 static GLuint SetupProgram(GLuint vertex_shader, GLuint fragment_shader);
36 // Compiles 2 shaders, attaches and links them to a program
37 // Returns program, 0 on failure.
38 static GLuint LoadProgram(
39 const char* vertex_shader_source,
40 const char* fragment_shader_source);
42 // Make a unit quad with position only.
43 // Returns the created buffer.
44 static GLuint SetupUnitQuad(GLint position_location);
46 // Make a 6 vertex colors.
47 // Returns the created buffer.
48 static GLuint SetupColorsForUnitQuad(
49 GLint location, const GLfloat color[4], GLenum usage);
51 // Checks an area of pixels for a color.
52 static bool CheckPixels(
53 GLint x, GLint y, GLsizei width, GLsizei height, GLint tolerance,
54 const uint8* color);
56 // Uses ReadPixels to save an area of the current FBO/Backbuffer.
57 static bool SaveBackbufferAsBMP(const char* filename, int width, int height);
60 #endif // GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_