MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / CreateFromNamedSource

Method CreateFromNamedSource

GTE/Graphics/GL46/GLSLProgramFactory.cpp:109–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109std::shared_ptr<ComputeProgram> GLSLProgramFactory::CreateFromNamedSource(
110 std::string const&, std::string const& csSource)
111{
112 if (csSource == "")
113 {
114 LogError("A program must have a compute shader.");
115 }
116
117 GLuint csHandle = Compile(GL_COMPUTE_SHADER, csSource);
118 if (csHandle == 0)
119 {
120 return nullptr;
121 }
122
123 GLuint programHandle = glCreateProgram();
124 if (programHandle == 0)
125 {
126 LogError("Program creation failed.");
127 }
128
129 glAttachShader(programHandle, csHandle);
130
131 if (!Link(programHandle))
132 {
133 glDetachShader(programHandle, csHandle);
134 glDeleteShader(csHandle);
135 glDeleteProgram(programHandle);
136 return nullptr;
137 }
138
139 auto program = std::make_shared<GLSLComputeProgram>(programHandle, csHandle);
140 GLSLReflection const& reflector = program->GetReflector();
141 auto cshader = std::make_shared<GLSLShader>(reflector, GT_COMPUTE_SHADER, GLSLReflection::ReferenceType::COMPUTE);
142 program->SetComputeShader(cshader);
143 return program;
144}
145
146GLuint GLSLProgramFactory::Compile(GLenum shaderType, std::string const& source)
147{

Callers

nothing calls this directly

Calls 6

glCreateProgramFunction · 0.85
glAttachShaderFunction · 0.85
glDetachShaderFunction · 0.85
glDeleteShaderFunction · 0.85
glDeleteProgramFunction · 0.85
SetComputeShaderMethod · 0.80

Tested by

no test coverage detected