Documentation ¶
Index ¶
- Constants
- type Bitmap
- type BitmapRetriever
- type BitmapTexture
- type BitmapTextureRenderer
- type BufferedTextureStore
- type Color
- type ColorProvider
- type Context
- type PaletteTexture
- type Rectangle
- type RectangleRenderer
- type RenderContext
- type StandardBitmapper
- type TextBitmap
- type TextPainter
- type Texture
- type TextureKey
- type TextureQuery
- type TextureRenderer
Constants ¶
const BytesPerRgba = 4
BytesPerRgba defines the byte count for an RGBA color value.
const ColorsPerPalette = 256
ColorsPerPalette defines how many colors are per palette. This value is 256 to cover byte-based bitmaps.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bitmap ¶ added in v0.3.0
Bitmap is a simple palette based image.
func BitmapFromRaw ¶ added in v0.3.0
func BitmapFromRaw(raw model.RawBitmap) Bitmap
BitmapFromRaw returns a bitmap instance with decoded pixel data.
type BitmapRetriever ¶ added in v0.3.0
type BitmapRetriever func() *BitmapTexture
BitmapRetriever is a thunk that retrieves a cached bitmap.
type BitmapTexture ¶
type BitmapTexture struct {
// contains filtered or unexported fields
}
BitmapTexture contains a bitmap stored as OpenGL texture.
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 implements the GraphicsTexture interface.
func (*BitmapTexture) Handle ¶
func (tex *BitmapTexture) Handle() uint32
Handle returns the texture handle.
func (*BitmapTexture) Size ¶ added in v0.3.0
func (tex *BitmapTexture) Size() (width, height float32)
Size returns the dimensions of the bitmap, in pixels.
func (*BitmapTexture) UV ¶ added in v0.3.0
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 BitmapTextureRenderer ¶ added in v0.4.0
type BitmapTextureRenderer struct {
// contains filtered or unexported fields
}
BitmapTextureRenderer renders bitmapped textures based on a palette.
func NewBitmapTextureRenderer ¶ added in v0.4.0
func NewBitmapTextureRenderer(renderContext *RenderContext, paletteTexture Texture) *BitmapTextureRenderer
NewBitmapTextureRenderer returns a new instance of a texture renderer for bitmaps.
func (*BitmapTextureRenderer) Dispose ¶ added in v0.4.0
func (renderer *BitmapTextureRenderer) Dispose()
Dispose clears any resources.
type BufferedTextureStore ¶ added in v0.4.0
type BufferedTextureStore struct {
// contains filtered or unexported fields
}
BufferedTextureStore keeps textures in a buffer.
func NewBufferedTextureStore ¶ added in v0.4.0
func NewBufferedTextureStore(query TextureQuery) *BufferedTextureStore
NewBufferedTextureStore returns a new instance of a store.
func (*BufferedTextureStore) Reset ¶ added in v0.4.0
func (store *BufferedTextureStore) Reset()
Reset clears the store. It disposes any registered texture.
func (*BufferedTextureStore) SetTexture ¶ added in v0.4.0
func (store *BufferedTextureStore) SetTexture(id TextureKey, texture *BitmapTexture)
SetTexture registers a (new) texture under given ID. It disposes any previously registered texture.
func (*BufferedTextureStore) Texture ¶ added in v0.4.0
func (store *BufferedTextureStore) Texture(id TextureKey) *BitmapTexture
Texture returns the texture associated with the given ID. May be nil if not yet known/available.
type Color ¶ added in v0.4.0
type Color interface { // AsVector returns the color as a 4-dimensional vector. AsVector() *[4]float32 }
Color represents a 4-element color, ordered R, G, B, A; Range: [0..1]
type ColorProvider ¶
ColorProvider is a function to return the RGBA values for a certain palette index.
type Context ¶ added in v0.4.0
type Context interface { RectangleRenderer() *RectangleRenderer TextPainter() TextPainter Texturize(bmp *Bitmap) *BitmapTexture UITextRenderer() *BitmapTextureRenderer NewPaletteTexture(colorProvider ColorProvider) *PaletteTexture BitmapsStore() *BufferedTextureStore WorldTextureStore(size model.TextureSize) *BufferedTextureStore GameObjectBitmapsStore() *BufferedTextureStore GameObjectIconsStore() *BufferedTextureStore }
Context is a provider of graphic utilities.
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, colorProvider ColorProvider) *PaletteTexture
NewPaletteTexture creates a new PaletteTexture instance.
func (*PaletteTexture) Dispose ¶
func (tex *PaletteTexture) Dispose()
Dispose implements the GraphicsTexture interface.
func (*PaletteTexture) Handle ¶
func (tex *PaletteTexture) Handle() uint32
Handle returns the texture handle.
type Rectangle ¶ added in v0.4.0
type Rectangle interface { // Left returns the left edge of the rectangle. Left() float32 // Top returns the top edge of the rectangle. Top() float32 // Right returns the coordinate beyond the right edge of the rectangle. Right() float32 // Bottom returns the coordinate beyond the bottom edge of the rectangle. Bottom() float32 }
Rectangle describes a rectangular area with four points.
func RectByCoord ¶ added in v0.4.0
RectByCoord returns a rectangle instance by coordinates.
type RectangleRenderer ¶ added in v0.4.0
type RectangleRenderer struct {
// contains filtered or unexported fields
}
RectangleRenderer renders rectangular shapes.
func NewRectangleRenderer ¶ added in v0.4.0
func NewRectangleRenderer(gl opengl.OpenGl, projectionMatrix *mgl.Mat4) *RectangleRenderer
NewRectangleRenderer returns a new instance of an RectangleRenderer type.
func (*RectangleRenderer) Dispose ¶ added in v0.4.0
func (renderer *RectangleRenderer) Dispose()
Dispose clears any open resources.
func (*RectangleRenderer) Fill ¶ added in v0.4.0
func (renderer *RectangleRenderer) Fill(left, top, right, bottom float32, fillColor Color)
Fill renders a rectangle filled with a solid color.
type RenderContext ¶ added in v0.4.0
type RenderContext struct {
// contains filtered or unexported fields
}
RenderContext provides current render properties.
func NewBasicRenderContext ¶ added in v0.4.0
func NewBasicRenderContext(gl opengl.OpenGl, projectionMatrix *mgl.Mat4, viewMatrix *mgl.Mat4) *RenderContext
NewBasicRenderContext returns a render context for the provided parameters.
func (*RenderContext) OpenGl ¶ added in v0.4.0
func (context *RenderContext) OpenGl() opengl.OpenGl
OpenGl returns the GL interface.
func (*RenderContext) ProjectionMatrix ¶ added in v0.4.0
func (context *RenderContext) ProjectionMatrix() *mgl.Mat4
ProjectionMatrix returns the current projection matrix.
func (*RenderContext) ViewMatrix ¶ added in v0.4.0
func (context *RenderContext) ViewMatrix() *mgl.Mat4
ViewMatrix returns the current view matrix.
type StandardBitmapper ¶ added in v0.8.0
type StandardBitmapper struct {
// contains filtered or unexported fields
}
StandardBitmapper creates bitmap images from generic images.
func NewStandardBitmapper ¶ added in v0.8.0
func NewStandardBitmapper(palette []color.Color) *StandardBitmapper
NewStandardBitmapper returns a new bitmapper instance.
type TextBitmap ¶ added in v0.4.0
type TextBitmap struct { Bitmap // contains filtered or unexported fields }
TextBitmap is a bitmap with text coordinates.
func (TextBitmap) CharOffset ¶ added in v0.4.0
func (bmp TextBitmap) CharOffset(line, char int) int
CharOffset returns the horizontal offset of given char in given line, in pixel. An unknown line results in an offset of zero, a char beyond the end results in the line's end.
func (TextBitmap) LineCount ¶ added in v0.4.0
func (bmp TextBitmap) LineCount() int
LineCount returns the number of lines in this bitmap.
func (TextBitmap) LineHeight ¶ added in v0.4.0
func (bmp TextBitmap) LineHeight() int
LineHeight returns the height of one line, in pixel.
func (TextBitmap) LineLength ¶ added in v0.4.0
func (bmp TextBitmap) LineLength(line int) int
LineLength returns the width of the given line, in pixel.
type TextPainter ¶ added in v0.4.0
type TextPainter interface { // Paint creates a new bitmap based on given text. Paint(text string, widthLimit int) TextBitmap }
TextPainter creates bitmaps for texts.
func NewBitmapTextPainter ¶ added in v0.4.0
func NewBitmapTextPainter(font model.Font) TextPainter
NewBitmapTextPainter returns a new text painter for the given bitmap font.
type Texture ¶
type Texture interface { // Dispose releases any internal resources. Dispose() // Handle returns the texture handle. Handle() uint32 }
Texture describes a texture in graphics memory.
type TextureKey ¶ added in v0.4.0
type TextureKey int
TextureKey is a reference identifier for textures.
func TextureKeyFromInt ¶ added in v0.4.0
func TextureKeyFromInt(value int) TextureKey
TextureKeyFromInt wraps an integer as TextureKey.
func (TextureKey) ToInt ¶ added in v0.4.0
func (key TextureKey) ToInt() int
ToInt returns the integer representation of the key.
type TextureQuery ¶ added in v0.4.0
type TextureQuery func(id TextureKey)
TextureQuery is a callback function to request the data for a specific texture.
type TextureRenderer ¶ added in v0.4.0
type TextureRenderer interface { // Render takes the portion defined by textureRect out of texture to // render it within the given display rectangle. // textureRect coordinates are given in fractions of the texture. Render(modelMatrix *mgl.Mat4, texture Texture, textureRect Rectangle) }
TextureRenderer renders textures.