graphics

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitmapTexture

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

BitmapTexture wraps an OpenGL handle for a downloaded image.

func NewBitmapTexture

func NewBitmapTexture(gl opengl.OpenGL, width, height int, pixelData []byte) *BitmapTexture

NewBitmapTexture downloads the provided raw data to OpenGL and returns a BitmapTexture instance.

func (*BitmapTexture) Dispose

func (tex *BitmapTexture) Dispose()

Dispose releases the OpenGL texture.

func (*BitmapTexture) Handle

func (tex *BitmapTexture) Handle() uint32

Handle returns the texture handle.

func (*BitmapTexture) PixelData added in v0.6.0

func (tex *BitmapTexture) PixelData() []byte

PixelData returns the original paletted pixel data.

func (*BitmapTexture) Size

func (tex *BitmapTexture) Size() (width, height float32)

Size returns the dimensions of the bitmap, in pixels.

func (*BitmapTexture) UV

func (tex *BitmapTexture) UV() (u, v float32)

UV returns the maximum U and V values for the bitmap. The bitmap will be stored in a power-of-two texture, which may be larger than the bitmap.

type FrameCache added in v1.4.0

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

FrameCache loads bitmaps with their palettes and provides OpenGL textures.

func NewFrameCache added in v1.4.0

func NewFrameCache(gl opengl.OpenGL) *FrameCache

NewFrameCache returns a new instance.

func (*FrameCache) AllocateKey added in v1.4.0

func (cache *FrameCache) AllocateKey() FrameCacheKey

AllocateKey returns a new key to be used with uploading a new frame.

func (*FrameCache) DropTextureForKey added in v1.4.0

func (cache *FrameCache) DropTextureForKey(key FrameCacheKey)

DropTextureForKey removes the currently cached frame.

func (FrameCache) HandlesForKey added in v1.4.0

func (cache FrameCache) HandlesForKey(key FrameCacheKey) (palette uint32, texture uint32)

HandlesForKey returns the OpenGL handles for both palette and texture for given key.

func (*FrameCache) SetTexture added in v1.4.0

func (cache *FrameCache) SetTexture(key FrameCacheKey, width, height uint16, pixels []byte, palette *bitmap.Palette)

SetTexture registers a texture based on given bitmap under given key. The bitmap should contain a palette, otherwise it will most likely not be displayed.

func (*FrameCache) Texture added in v1.4.0

func (cache *FrameCache) Texture(key FrameCacheKey) *BitmapTexture

Texture returns the buffered texture for given key.

type FrameCacheKey added in v1.4.0

type FrameCacheKey uint16

FrameCacheKey is used to identify a cached frame.

type PaletteCache

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

PaletteCache loads palettes and provides OpenGL textures.

func NewPaletteCache

func NewPaletteCache(gl opengl.OpenGL, localizer resource.Localizer) *PaletteCache

NewPaletteCache returns a new instance.

func (*PaletteCache) InvalidateResources

func (cache *PaletteCache) InvalidateResources(ids []resource.ID)

InvalidateResources lets the cache remove any palette from resources that are specified in the given slice.

func (*PaletteCache) Palette

func (cache *PaletteCache) Palette(index int) (*PaletteTexture, error)

Palette returns the palette with given index - if available.

type PaletteTexture

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

PaletteTexture contains a palette stored as OpenGL texture.

func NewPaletteTexture

func NewPaletteTexture(gl opengl.OpenGL, palette *bitmap.Palette) *PaletteTexture

NewPaletteTexture creates a new PaletteTexture instance.

func (*PaletteTexture) Dispose

func (tex *PaletteTexture) Dispose()

Dispose releases the OpenGL texture.

func (*PaletteTexture) Handle

func (tex *PaletteTexture) Handle() uint32

Handle returns the texture handle.

func (*PaletteTexture) Palette

func (tex *PaletteTexture) Palette() bitmap.Palette

Palette returns the original palette.

func (*PaletteTexture) Update

func (tex *PaletteTexture) Update(palette *bitmap.Palette)

Update reloads the palette.

type TextureCache

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

TextureCache loads bitmaps and provides OpenGL textures.

func NewTextureCache

func NewTextureCache(gl opengl.OpenGL, localizer resource.Localizer) *TextureCache

NewTextureCache returns a new instance.

func (*TextureCache) InvalidateResources

func (cache *TextureCache) InvalidateResources(ids []resource.ID)

InvalidateResources lets the cache remove any textures from resources that are specified in the given slice.

func (*TextureCache) Texture

func (cache *TextureCache) Texture(key resource.Key) (*BitmapTexture, error)

Texture returns the texture with given key - if available.

func (*TextureCache) TextureReferenced added in v1.2.0

func (cache *TextureCache) TextureReferenced(key resource.Key, reference *resource.Key) (*BitmapTexture, error)

TextureReferenced returns the texture with given key - if available. Should the underlying bitmap have to be loaded, then the given reference is taken as a basis for compressed bitmaps. If reference is nil, then no reference is used.

Jump to

Keyboard shortcuts

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