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

Function LoadedSprite

common/render_filetype.go:169–185  ·  view source on GitHub ↗

LoadedSprite loads the texture-reference from `engo.Files`, and wraps it in a `*Texture`. This method is intended for image-files which represent entire sprites.

(url string)

Source from the content-addressed store, hash-verified

167// LoadedSprite loads the texture-reference from `engo.Files`, and wraps it in a `*Texture`.
168// This method is intended for image-files which represent entire sprites.
169func LoadedSprite(url string) (*Texture, error) {
170 res, err := engo.Files.Resource(url)
171 if err != nil {
172 return nil, err
173 }
174
175 img, ok := res.(TextureResource)
176 if !ok {
177 return nil, fmt.Errorf("resource not of type `TextureResource`: %s", url)
178 }
179
180 viewport := engo.AABB{Max: engo.Point{X: 1.0, Y: 1.0}}
181 if img.Viewport != nil {
182 viewport = *img.Viewport
183 }
184 return &Texture{img.Texture, img.Width, img.Height, viewport}, nil
185}
186
187// Texture represents a texture loaded in the GPU RAM (by using OpenGL), which defined dimensions and viewport
188type Texture struct {

Callers 15

SetupMethod · 0.92
SetupMethod · 0.92
SetupMethod · 0.92
SetupMethod · 0.92
SetupMethod · 0.92
SetupMethod · 0.92
NewRockFunction · 0.92
SetupMethod · 0.92
SetupMethod · 0.92
SetupMethod · 0.92
SetupMethod · 0.92
SetupMethod · 0.92

Calls 1

ResourceMethod · 0.65

Tested by

no test coverage detected