gl_helper.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2015 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.
  4. #ifndef UI_GL_GL_HELPER_H_
  5. #define UI_GL_GL_HELPER_H_
  6. #include "ui/gl/gl_bindings.h"
  7. #include "ui/gl/gl_export.h"
  8. namespace gl {
  9. class GL_EXPORT GLHelper {
  10. public:
  11. // Compiles a shader.
  12. // Does not check for errors, always returns shader.
  13. static GLuint CompileShader(GLenum type, const char* src);
  14. // Compiles a shader and checks for compilation errors.
  15. // Returns shader, 0 on failure.
  16. static GLuint LoadShader(GLenum type, const char* src);
  17. // Attaches 2 shaders and links them to a program.
  18. // Does not check for errors, always returns program.
  19. static GLuint LinkProgram(GLuint vertex_shader, GLuint fragment_shader);
  20. // Attaches 2 shaders, links them to a program, and checks for errors.
  21. // Returns program, 0 on failure.
  22. static GLuint SetupProgram(GLuint vertex_shader, GLuint fragment_shader);
  23. // Sets up a vertex buffer containing 4 vertices that can be used to draw
  24. // a quad as a tri-strip.
  25. static GLuint SetupQuadVertexBuffer();
  26. // Draws a quad to the currently bound frame buffer.
  27. static void DrawQuad(GLuint vertex_buffer);
  28. // When using the desktop core profile we have to bind a VAO before
  29. // calling glVertexAttribPointer.
  30. static bool ShouldTestsUseVAOs();
  31. };
  32. } // namespace gl
  33. #endif // UI_GL_GL_HELPER_H_