MCPcopy Create free account
hub / github.com/arrayfire/forge / loadShaders

Function loadShaders

src/backend/opengl/common.cpp:106–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106Shaders loadShaders(const char* pVertexShaderSrc,
107 const char* pFragmentShaderSrc,
108 const char* pGeometryShaderSrc)
109{
110 GLuint f, v;
111
112 v = glCreateShader(GL_VERTEX_SHADER);
113 f = glCreateShader(GL_FRAGMENT_SHADER);
114
115 // load shaders & get length of each
116 glShaderSource(v, 1, &pVertexShaderSrc, NULL);
117 glShaderSource(f, 1, &pFragmentShaderSrc, NULL);
118
119 GLint compiled;
120
121 glCompileShader(v);
122 glGetShaderiv(v, GL_COMPILE_STATUS, &compiled);
123 if (!compiled) {
124 std::cerr << "Vertex shader not compiled." << std::endl;
125 FG_COMPILE_LINK_ERROR(v, Shader);
126 }
127
128 glCompileShader(f);
129 glGetShaderiv(f, GL_COMPILE_STATUS, &compiled);
130 if (!compiled) {
131 std::cerr << "Fragment shader not compiled." << std::endl;
132 FG_COMPILE_LINK_ERROR(f, Shader);
133 }
134
135 GLuint g = 0;
136 /* compile geometry shader if source provided */
137 if (pGeometryShaderSrc) {
138 g = glCreateShader(GL_GEOMETRY_SHADER);
139 glShaderSource(g, 1, &pGeometryShaderSrc, NULL);
140 glCompileShader(g);
141 glGetShaderiv(g, GL_COMPILE_STATUS, &compiled);
142 if (!compiled) {
143 std::cerr << "Geometry shader not compiled." << std::endl;
144 FG_COMPILE_LINK_ERROR(g, Shader);
145 }
146 }
147
148 Shaders out; out.vertex = v; out.fragment = f; out.geometry = g;
149
150 return out;
151}
152
153namespace forge
154{

Callers 1

ShaderProgramMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected