texture

package
v0.0.0-...-682a2af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2024 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeEmbedImage

func DecodeEmbedImage(imgfile string, fs embed.FS) (*image.RGBA, error)

DecodeEmbedImage reads and decodes the specified image file from an embed.FS filesystem into RGBA8. The supported image files are PNG, JPEG and GIF.

func DecodeImage

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.

Types

type Animator

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

Animator can generate a texture animation based on a texture sheet

func NewAnimator

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

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

func (*Animator) Cycles

func (a *Animator) Cycles() int

Cycles returns the number of complete cycles displayed

func (*Animator) Restart

func (a *Animator) Restart()

Restart restart the animator

func (*Animator) SetDispTime

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

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

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

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

type Texture2D

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

Texture2D represents a texture

func NewBoard

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 NewTexture2DFromCompressedData

func NewTexture2DFromCompressedData(width, height int, iformat int32, size int32, data interface{}) *Texture2D

NewTexture2DFromCompressedData creates a new compressed texture from data

func NewTexture2DFromData

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

NewTexture2DFromData creates a new texture from data

func NewTexture2DFromEmbedImage

func NewTexture2DFromEmbedImage(imgfile string, fs embed.FS) (*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 NewTexture2DFromImage

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

func NewTexture2DFromRGBA(rgba *image.RGBA) *Texture2D

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

func (*Texture2D) Compressed

func (t *Texture2D) Compressed() bool

Compressed returns whether this texture is compressed

func (*Texture2D) Dispose

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

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

func (t *Texture2D) Height() int

Height returns the texture height in pixels

func (*Texture2D) Incref

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

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

Offset returns the current X and Y offset factors

func (*Texture2D) RenderSetup

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

RenderSetup is called by the material render setup

func (*Texture2D) Repeat

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

Repeat returns the current X and Y repeat factors

func (*Texture2D) SetCompressedData

func (t *Texture2D) SetCompressedData(width, height int, iformat int32, size int32, data interface{})

SetCompressedData sets the compressed texture data

func (*Texture2D) SetData

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

SetData sets the texture data

func (*Texture2D) SetEmbedImage

func (t *Texture2D) SetEmbedImage(imgfile string, fs embed.FS) error

SetEmbedImage sets a new image for this texture

func (*Texture2D) SetFlipY

func (t *Texture2D) SetFlipY(state bool)

SetFlipY set the state for flipping the Y coordinate

func (*Texture2D) SetFromRGBA

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

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

func (*Texture2D) SetImage

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

SetImage sets a new image for this texture

func (*Texture2D) SetMagFilter

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

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

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

SetOffset sets the offset factor

func (*Texture2D) SetRepeat

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

SetRepeat set the repeat factor

func (*Texture2D) SetUniformNames

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

func (t *Texture2D) SetVisible(state bool)

SetVisible sets the visibility state of the texture

func (*Texture2D) SetWrapS

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

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) TexName

func (t *Texture2D) TexName() uint32

TexName returns the texture handle for the texture

func (*Texture2D) Visible

func (t *Texture2D) Visible() bool

Visible returns the current visibility state of the texture

func (*Texture2D) Width

func (t *Texture2D) Width() int

Width returns the texture width in pixels

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL