• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #ifndef SAMPLE_UTIL_SHADER_UTILS_H
8 #define SAMPLE_UTIL_SHADER_UTILS_H
9 
10 #include <functional>
11 #include <string>
12 #include <vector>
13 
14 #include "util/util_export.h"
15 #include "util/util_gl.h"
16 
17 ANGLE_UTIL_EXPORT GLuint CheckLinkStatusAndReturnProgram(GLuint program, bool outputErrorMessages);
18 ANGLE_UTIL_EXPORT GLuint GetProgramShader(GLuint program, GLint requestedType);
19 ANGLE_UTIL_EXPORT GLuint CompileShader(GLenum type, const char *source);
20 ANGLE_UTIL_EXPORT GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath);
21 
22 ANGLE_UTIL_EXPORT GLuint
23 CompileProgramWithTransformFeedback(const char *vsSource,
24                                     const char *fsSource,
25                                     const std::vector<std::string> &transformFeedbackVaryings,
26                                     GLenum bufferMode);
27 
28 ANGLE_UTIL_EXPORT GLuint CompileProgram(const char *vsSource, const char *fsSource);
29 
30 ANGLE_UTIL_EXPORT GLuint CompileProgram(const char *vsSource,
31                                         const char *fsSource,
32                                         const std::function<void(GLuint)> &preLinkCallback);
33 
34 ANGLE_UTIL_EXPORT GLuint CompileProgramWithGS(const char *vsSource,
35                                               const char *gsSource,
36                                               const char *fsSource);
37 ANGLE_UTIL_EXPORT GLuint CompileProgramFromFiles(const std::string &vsPath,
38                                                  const std::string &fsPath);
39 ANGLE_UTIL_EXPORT GLuint CompileComputeProgram(const char *csSource,
40                                                bool outputErrorMessages = true);
41 ANGLE_UTIL_EXPORT bool LinkAttachedProgram(GLuint program);
42 
43 ANGLE_UTIL_EXPORT GLuint LoadBinaryProgramOES(const std::vector<uint8_t> &binary,
44                                               GLenum binaryFormat);
45 ANGLE_UTIL_EXPORT GLuint LoadBinaryProgramES3(const std::vector<uint8_t> &binary,
46                                               GLenum binaryFormat);
47 
48 namespace angle
49 {
50 
51 namespace essl1_shaders
52 {
53 
54 ANGLE_UTIL_EXPORT const char *PositionAttrib();
55 ANGLE_UTIL_EXPORT const char *ColorUniform();
56 ANGLE_UTIL_EXPORT const char *Texture2DUniform();
57 
58 namespace vs
59 {
60 
61 // A shader that sets gl_Position to zero.
62 ANGLE_UTIL_EXPORT const char *Zero();
63 
64 // A shader that sets gl_Position to attribute a_position.
65 ANGLE_UTIL_EXPORT const char *Simple();
66 
67 // A shader that passes through attribute a_position, setting it to gl_Position and varying
68 // v_position.
69 ANGLE_UTIL_EXPORT const char *Passthrough();
70 
71 // A shader that simply passes through attribute a_position, setting it to gl_Position and varying
72 // texcoord.
73 ANGLE_UTIL_EXPORT const char *Texture2D();
74 
75 }  // namespace vs
76 
77 namespace fs
78 {
79 
80 // A shader that renders a simple checker pattern of red and green. X axis and y axis separate the
81 // different colors. Needs varying v_position.
82 ANGLE_UTIL_EXPORT const char *Checkered();
83 
84 // A shader that fills with color taken from uniform named "color".
85 ANGLE_UTIL_EXPORT const char *UniformColor();
86 
87 // A shader that fills with 100% opaque red.
88 ANGLE_UTIL_EXPORT const char *Red();
89 
90 // A shader that fills with 100% opaque green.
91 ANGLE_UTIL_EXPORT const char *Green();
92 
93 // A shader that fills with 100% opaque blue.
94 ANGLE_UTIL_EXPORT const char *Blue();
95 
96 // A shader that samples the texture
97 ANGLE_UTIL_EXPORT const char *Texture2D();
98 
99 }  // namespace fs
100 }  // namespace essl1_shaders
101 
102 namespace essl3_shaders
103 {
104 
105 ANGLE_UTIL_EXPORT const char *PositionAttrib();
106 
107 namespace vs
108 {
109 
110 // A shader that sets gl_Position to zero.
111 ANGLE_UTIL_EXPORT const char *Zero();
112 
113 // A shader that sets gl_Position to attribute a_position.
114 ANGLE_UTIL_EXPORT const char *Simple();
115 
116 // A shader that simply passes through attribute a_position, setting it to gl_Position and varying
117 // v_position.
118 ANGLE_UTIL_EXPORT const char *Passthrough();
119 
120 }  // namespace vs
121 
122 namespace fs
123 {
124 
125 // A shader that fills with 100% opaque red.
126 ANGLE_UTIL_EXPORT const char *Red();
127 
128 // A shader that fills with 100% opaque green.
129 ANGLE_UTIL_EXPORT const char *Green();
130 
131 // A shader that fills with 100% opaque blue.
132 ANGLE_UTIL_EXPORT const char *Blue();
133 
134 }  // namespace fs
135 }  // namespace essl3_shaders
136 
137 namespace essl31_shaders
138 {
139 
140 ANGLE_UTIL_EXPORT const char *PositionAttrib();
141 
142 namespace vs
143 {
144 
145 // A shader that sets gl_Position to zero.
146 ANGLE_UTIL_EXPORT const char *Zero();
147 
148 // A shader that sets gl_Position to attribute a_position.
149 ANGLE_UTIL_EXPORT const char *Simple();
150 
151 // A shader that simply passes through attribute a_position, setting it to gl_Position and varying
152 // v_position.
153 ANGLE_UTIL_EXPORT const char *Passthrough();
154 
155 }  // namespace vs
156 
157 namespace fs
158 {
159 
160 // A shader that fills with 100% opaque red.
161 ANGLE_UTIL_EXPORT const char *Red();
162 
163 // A shader that fills with 100% opaque green.
164 ANGLE_UTIL_EXPORT const char *Green();
165 
166 }  // namespace fs
167 }  // namespace essl31_shaders
168 }  // namespace angle
169 
170 #endif  // SAMPLE_UTIL_SHADER_UTILS_H
171