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

Function compileGLSLprogram

cpp/5_Domain_Specific/postProcessGL/main.cpp:824–896  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

822//!
823////////////////////////////////////////////////////////////////////////////////
824GLuint compileGLSLprogram(const char *vertex_shader_src, const char *fragment_shader_src)
825{
826 GLuint v, f, p = 0;
827
828 p = glCreateProgram();
829
830 if (vertex_shader_src) {
831 v = glCreateShader(GL_VERTEX_SHADER);
832 glShaderSource(v, 1, &vertex_shader_src, NULL);
833 glCompileShader(v);
834
835 // check if shader compiled
836 GLint compiled = 0;
837 glGetShaderiv(v, GL_COMPILE_STATUS, &compiled);
838
839 if (!compiled) {
840 // #ifdef NV_REPORT_COMPILE_ERRORS
841 char temp[256] = "";
842 glGetShaderInfoLog(v, 256, NULL, temp);
843 printf("Vtx Compile failed:\n%s\n", temp);
844 // #endif
845 glDeleteShader(v);
846 return 0;
847 }
848 else {
849 glAttachShader(p, v);
850 }
851 }
852
853 if (fragment_shader_src) {
854 f = glCreateShader(GL_FRAGMENT_SHADER);
855 glShaderSource(f, 1, &fragment_shader_src, NULL);
856 glCompileShader(f);
857
858 // check if shader compiled
859 GLint compiled = 0;
860 glGetShaderiv(f, GL_COMPILE_STATUS, &compiled);
861
862 if (!compiled) {
863 // #ifdef NV_REPORT_COMPILE_ERRORS
864 char temp[256] = "";
865 glGetShaderInfoLog(f, 256, NULL, temp);
866 printf("frag Compile failed:\n%s\n", temp);
867 // #endif
868 glDeleteShader(f);
869 return 0;
870 }
871 else {
872 glAttachShader(p, f);
873 }
874 }
875
876 glLinkProgram(p);
877
878 int infologLength = 0;
879 int charsWritten = 0;
880
881 GLint linked = 0;

Callers 1

initGLBuffersFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected