Skip to content

Commit

Permalink
Merge pull request fyne-io#3305 from Jacalz/shadersource
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Oct 4, 2022
2 parents d695fd7 + a358f1d commit 94713bb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions internal/painter/gl/painter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import (
"fyne.io/fyne/v2/theme"
)

var shaderSources = map[string][2][]byte{
"line": {shaderLineVert.StaticContent, shaderLineFrag.StaticContent},
"line_es": {shaderLineesVert.StaticContent, shaderLineesFrag.StaticContent},
"simple": {shaderSimpleVert.StaticContent, shaderSimpleFrag.StaticContent},
"simple_es": {shaderSimpleesVert.StaticContent, shaderSimpleesFrag.StaticContent},
func shaderSourceNamed(name string) ([]byte, []byte) {
switch name {
case "line":
return shaderLineVert.StaticContent, shaderLineFrag.StaticContent
case "line_es":
return shaderLineesVert.StaticContent, shaderLineesFrag.StaticContent
case "simple":
return shaderSimpleVert.StaticContent, shaderSimpleFrag.StaticContent
case "simple_es":
return shaderSimpleesVert.StaticContent, shaderSimpleesFrag.StaticContent
}

return nil, nil
}

// Painter defines the functionality of our OpenGL based renderer
Expand Down Expand Up @@ -128,8 +136,7 @@ func (p *painter) createProgram(shaderFilename string) Program {
// Why a switch over a filename?
// Because this allows for a minimal change, once we reach Go 1.16 and use go:embed instead of
// fyne bundle.
sources := shaderSources[shaderFilename]
vertexSrc, fragmentSrc := sources[0], sources[1]
vertexSrc, fragmentSrc := shaderSourceNamed(shaderFilename)
if vertexSrc == nil {
panic("shader not found: " + shaderFilename)
}
Expand Down

0 comments on commit 94713bb

Please sign in to comment.