diff --git a/pixelgl/texture.go b/pixelgl/texture.go index 708bc4eb5f239262f161c8c9657520e4824881d8..ad9a9190ec0ebc4575f52700b4ecd60d74e069e0 100644 --- a/pixelgl/texture.go +++ b/pixelgl/texture.go @@ -4,15 +4,20 @@ import "github.com/go-gl/gl/v3.3-core/gl" // Texture is an OpenGL texture. type Texture struct { - enabled bool - parent Doer - tex uint32 + enabled bool + parent Doer + tex uint32 + width, height int } // NewTexture creates a new texture with the specified width and height. // The pixels must be a sequence of RGBA values. func NewTexture(parent Doer, width, height int, pixels []uint8) (*Texture, error) { - texture := &Texture{parent: parent} + texture := &Texture{ + parent: parent, + width: width, + height: height, + } parent.Do(func(ctx Context) { Do(func() { @@ -54,6 +59,16 @@ func (t *Texture) ID() uint32 { return t.tex } +// Width returns the width of a texture in pixels. +func (t *Texture) Width() int { + return t.width +} + +// Height returns the height of a texture in pixels. +func (t *Texture) Height() int { + return t.height +} + // Do bind a texture, executes sub, and unbinds the texture. func (t *Texture) Do(sub func(Context)) { t.parent.Do(func(ctx Context) {