diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index 66783ca6e..c5167bca6 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -42,8 +42,7 @@ type AttribLocation int32 type ProgramID uint32 -// TODO: This should be a method? -func GetProgramID(p Program) ProgramID { +func (p Program) ID() ProgramID { return ProgramID(p) } diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index 0283021bb..f0e04f4d1 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -58,7 +58,7 @@ type AttribLocation int type ProgramID int -func GetProgramID(p Program) ProgramID { +func (p Program) ID() ProgramID { return ProgramID(p.Get("__ebiten_programId").Int()) } diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index ebcd485bb..044e08566 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -43,7 +43,7 @@ type AttribLocation mgl.Attrib type ProgramID uint32 -func GetProgramID(p Program) ProgramID { +func (p Program) ID() ProgramID { return ProgramID(p.Value) } diff --git a/internal/graphics/opengl/locationcache.go b/internal/graphics/opengl/locationcache.go index 758203650..8213f06a3 100644 --- a/internal/graphics/opengl/locationcache.go +++ b/internal/graphics/opengl/locationcache.go @@ -26,7 +26,7 @@ type UniformLocationGetter interface { // TODO: Rename these functions not to be confusing func GetUniformLocation(g UniformLocationGetter, p Program, location string) UniformLocation { - id := GetProgramID(p) + id := p.ID() if _, ok := uniformLocationCache[id]; !ok { uniformLocationCache[id] = map[string]UniformLocation{} } @@ -43,7 +43,7 @@ type AttribLocationGetter interface { } func GetAttribLocation(g AttribLocationGetter, p Program, location string) AttribLocation { - id := GetProgramID(p) + id := p.ID() if _, ok := attribLocationCache[id]; !ok { attribLocationCache[id] = map[string]AttribLocation{} }