MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / compileProgram

Method compileProgram

cpp/5_Domain_Specific/smokeParticles/GLSLProgram.cpp:186–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186GLuint GLSLProgram::compileProgram(const char *vsource,
187 const char *gsource,
188 const char *fsource,
189 GLenum gsInput,
190 GLenum gsOutput)
191{
192 GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
193 GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
194
195 GLint compiled = 0;
196
197 glShaderSource(vertexShader, 1, &vsource, 0);
198 glShaderSource(fragmentShader, 1, &fsource, 0);
199
200 glCompileShader(vertexShader);
201
202 if (checkCompileStatus(vertexShader, &compiled) == 0) {
203 printf("<compileProgram compilation error with vertexShader>:\n");
204 printf("%s\n", vsource);
205 return 0;
206 }
207
208 glCompileShader(fragmentShader);
209
210 if (checkCompileStatus(fragmentShader, &compiled) == 0) {
211 printf("<compileProgram compilation error with fragmentShader>:\n");
212 printf("%s\n", fsource);
213 return 0;
214 }
215
216 GLuint program = glCreateProgram();
217
218 glAttachShader(program, vertexShader);
219 glAttachShader(program, fragmentShader);
220
221 if (gsource) {
222 GLuint geomShader = glCreateShader(GL_GEOMETRY_SHADER_EXT);
223 glShaderSource(geomShader, 1, &gsource, 0);
224 glCompileShader(geomShader);
225 glGetShaderiv(geomShader, GL_COMPILE_STATUS, (GLint *)&compiled);
226
227 if (checkCompileStatus(geomShader, &compiled) == 0) {
228 printf("<compileProgram compilation error with geomShader>:\n");
229 printf("%s\n", gsource);
230 return 0;
231 }
232
233 glAttachShader(program, geomShader);
234
235 glProgramParameteriEXT(program, GL_GEOMETRY_INPUT_TYPE_EXT, gsInput);
236 glProgramParameteriEXT(program, GL_GEOMETRY_OUTPUT_TYPE_EXT, gsOutput);
237 glProgramParameteriEXT(program, GL_GEOMETRY_VERTICES_OUT_EXT, 4);
238 }
239
240 glLinkProgram(program);
241
242 // check if program linked
243 GLint success = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected