MCPcopy
hub / github.com/g3n/engine / NewTexture2DFromImage

Function NewTexture2DFromImage

texture/texture2D.go:84–95  ·  view source on GitHub ↗

NewTexture2DFromImage creates and returns a pointer to a new Texture2D using the specified image file as data. Supported image formats are: PNG, JPEG and GIF.

(imgfile string)

Source from the content-addressed store, hash-verified

82// using the specified image file as data.
83// Supported image formats are: PNG, JPEG and GIF.
84func NewTexture2DFromImage(imgfile string) (*Texture2D, error) {
85
86 // Decodes image file into RGBA8
87 rgba, err := DecodeImage(imgfile)
88 if err != nil {
89 return nil, err
90 }
91
92 t := newTexture2D()
93 t.SetFromRGBA(rgba)
94 return t, nil
95}
96
97// NewTexture2DFromRGBA creates a new texture from a pointer to an RGBA image object.
98func NewTexture2DFromRGBA(rgba *image.RGBA) *Texture2D {

Callers 7

NewSkyboxFunction · 0.92
NewImageButtonFunction · 0.92
SetImageMethod · 0.92
NewImageFunction · 0.92
SetImageMethod · 0.92
NewTexture2DMethod · 0.92
loadTexMethod · 0.92

Calls 3

DecodeImageFunction · 0.85
newTexture2DFunction · 0.85
SetFromRGBAMethod · 0.80

Tested by

no test coverage detected