MCPcopy Index your code
hub / github.com/EngoEngine/engo / LoadShader

Function LoadShader

common/render_shaders.go:134–159  ·  view source on GitHub ↗

LoadShader takes a Vertex-shader and Fragment-shader, compiles them and attaches them to a newly created glProgram. It will log possible compilation errors

(vertSrc, fragSrc string)

Source from the content-addressed store, hash-verified

132// LoadShader takes a Vertex-shader and Fragment-shader, compiles them and attaches them to a newly created glProgram.
133// It will log possible compilation errors
134func LoadShader(vertSrc, fragSrc string) (*gl.Program, error) {
135 vertShader := engo.Gl.CreateShader(engo.Gl.VERTEX_SHADER)
136 engo.Gl.ShaderSource(vertShader, vertSrc)
137 engo.Gl.CompileShader(vertShader)
138 if !engo.Gl.GetShaderiv(vertShader, engo.Gl.COMPILE_STATUS) {
139 errorLog := engo.Gl.GetShaderInfoLog(vertShader)
140 return nil, VertexShaderCompilationError{errorLog}
141 }
142 defer engo.Gl.DeleteShader(vertShader)
143
144 fragShader := engo.Gl.CreateShader(engo.Gl.FRAGMENT_SHADER)
145 engo.Gl.ShaderSource(fragShader, fragSrc)
146 engo.Gl.CompileShader(fragShader)
147 if !engo.Gl.GetShaderiv(fragShader, engo.Gl.COMPILE_STATUS) {
148 errorLog := engo.Gl.GetShaderInfoLog(fragShader)
149 return nil, FragmentShaderCompilationError{errorLog}
150 }
151 defer engo.Gl.DeleteShader(fragShader)
152
153 program := engo.Gl.CreateProgram()
154 engo.Gl.AttachShader(program, vertShader)
155 engo.Gl.AttachShader(program, fragShader)
156 engo.Gl.LinkProgram(program)
157
158 return program, nil
159}
160
161func newCamera(w *ecs.World) {
162 shaderInitMutex.Lock()

Callers 5

SetupMethod · 0.85
TestShaderCompilationFunction · 0.85
SetupMethod · 0.85
SetupMethod · 0.85
SetupMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestShaderCompilationFunction · 0.68