engine: github.com/g3n/engine/texture Index | Files

package texture

import "github.com/g3n/engine/texture"

Package texture contains several types of textures which can be added to materials.

Index

Package Files

animator.go board.go doc.go logger.go texture2D.go

func DecodeImage Uses

func DecodeImage(imgfile string) (*image.RGBA, error)

DecodeImage reads and decodes the specified image file into RGBA8. The supported image files are PNG, JPEG and GIF.

type Animator Uses

type Animator struct {
    // contains filtered or unexported fields
}

Animator can generate a texture animation based on a texture sheet

func NewAnimator Uses

func NewAnimator(tex *Texture2D, htiles, vtiles int) *Animator

NewAnimator creates and returns a texture sheet animator for the specified texture.

func (*Animator) Cycles Uses

func (a *Animator) Cycles() int

Cycles returns the number of complete cycles displayed

func (*Animator) Restart Uses

func (a *Animator) Restart()

Restart restart the animator

func (*Animator) SetDispTime Uses

func (a *Animator) SetDispTime(dtime time.Duration)

SetDispTime sets the display time of each tile in milliseconds. The default value is: 1.0/30.0 = 16.6.ms

func (*Animator) SetMaxCycles Uses

func (a *Animator) SetMaxCycles(maxCycles int)

SetMaxCycles sets the number of complete cycles to display. The default value is: 0 (display continuously)

func (*Animator) Update Uses

func (a *Animator) Update(now time.Time)

Update prepares the next tile to be rendered. Must be called with the current time

type Texture2D Uses

type Texture2D struct {
    // contains filtered or unexported fields
}

Texture2D represents a texture

func NewBoard Uses

func NewBoard(width, height int, c1, c2, c3, c4 *math32.Color, alpha float32) *Texture2D

NewBoard creates and returns a pointer to a new checker board 2D texture. A checker board texture contains up to 4 different colors arranged in the following order:

+------+------+
|      |      |
|  c3  |  c4  |
|      |      |
+------+------+
|      |      |
|  c1  |  c2  | height (pixels)
|      |      |
+------+------+
  width
(pixels)

func NewTexture2DFromData Uses

func NewTexture2DFromData(width, height int, format int, formatType, iformat int, data interface{}) *Texture2D

NewTexture2DFromData creates a new texture from data

func NewTexture2DFromImage Uses

func NewTexture2DFromImage(imgfile string) (*Texture2D, error)

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.

func NewTexture2DFromRGBA Uses

func NewTexture2DFromRGBA(rgba *image.RGBA) *Texture2D

NewTexture2DFromRGBA creates a new texture from a pointer to an RGBA image object.

func (*Texture2D) Dispose Uses

func (t *Texture2D) Dispose()

Dispose decrements this texture reference count and if necessary releases OpenGL resources and C memory associated with this texture.

func (*Texture2D) GetUniformNames Uses

func (t *Texture2D) GetUniformNames() (sampler, info string)

GetUniformNames returns the names of the uniforms in the shader for sampler and texture info.

func (*Texture2D) Height Uses

func (t *Texture2D) Height() int

Height returns the texture height in pixels

func (*Texture2D) Incref Uses

func (t *Texture2D) Incref() *Texture2D

Incref increments the reference count for this texture and returns a pointer to the geometry. It should be used when this texture is shared by another material.

func (*Texture2D) Offset Uses

func (t *Texture2D) Offset() (float32, float32)

Offset returns the current X and Y offset factors

func (*Texture2D) RenderSetup Uses

func (t *Texture2D) RenderSetup(gs *gls.GLS, slotIdx, uniIdx int)

RenderSetup is called by the material render setup

func (*Texture2D) Repeat Uses

func (t *Texture2D) Repeat() (float32, float32)

Repeat returns the current X and Y repeat factors

func (*Texture2D) SetData Uses

func (t *Texture2D) SetData(width, height int, format int, formatType, iformat int, data interface{})

SetData sets the texture data

func (*Texture2D) SetFlipY Uses

func (t *Texture2D) SetFlipY(state bool)

SetFlipY set the state for flipping the Y coordinate

func (*Texture2D) SetFromRGBA Uses

func (t *Texture2D) SetFromRGBA(rgba *image.RGBA)

SetFromRGBA sets the texture data from the specified image.RGBA object

func (*Texture2D) SetImage Uses

func (t *Texture2D) SetImage(imgfile string) error

SetImage sets a new image for this texture

func (*Texture2D) SetMagFilter Uses

func (t *Texture2D) SetMagFilter(magFilter uint32)

SetMagFilter sets the filter to be applied when the texture element covers more than on pixel. The default value is gls.Linear.

func (*Texture2D) SetMinFilter Uses

func (t *Texture2D) SetMinFilter(minFilter uint32)

SetMinFilter sets the filter to be applied when the texture element covers less than on pixel. The default value is gls.Linear.

func (*Texture2D) SetOffset Uses

func (t *Texture2D) SetOffset(x, y float32)

SetOffset sets the offset factor

func (*Texture2D) SetRepeat Uses

func (t *Texture2D) SetRepeat(x, y float32)

SetRepeat set the repeat factor

func (*Texture2D) SetUniformNames Uses

func (t *Texture2D) SetUniformNames(sampler, info string)

SetUniformNames sets the names of the uniforms in the shader for sampler and texture info.

func (*Texture2D) SetVisible Uses

func (t *Texture2D) SetVisible(state bool)

SetVisible sets the visibility state of the texture

func (*Texture2D) SetWrapS Uses

func (t *Texture2D) SetWrapS(wrapS uint32)

SetWrapS set the wrapping mode for texture S coordinate The default value is GL_CLAMP_TO_EDGE;

func (*Texture2D) SetWrapT Uses

func (t *Texture2D) SetWrapT(wrapT uint32)

SetWrapT set the wrapping mode for texture T coordinate The default value is GL_CLAMP_TO_EDGE;

func (*Texture2D) Visible Uses

func (t *Texture2D) Visible() bool

Visible returns the current visibility state of the texture

func (*Texture2D) Width Uses

func (t *Texture2D) Width() int

Width returns the texture width in pixels

Package texture imports 12 packages (graph) and is imported by 16 packages. Updated 2018-06-06. Refresh now. Tools for package owners.