Skip to content

package assets

import "kaijuengine.com/engine/assets"

Constants

TextureSquare

"square.png"

TextureCube

"cube.png"

TextureBlankSquare

"blank_square.png"

MaterialDefinitionGrid

"grid.material"

MaterialDefinitionUnlit

"unlit.material"

MaterialDefinitionUnlitTransparent

"unlit_transparent.material"

MaterialDefinitionBasic

"basic.material"

MaterialDefinitionBasicTransparent

"basic_transparent.material"

MaterialDefinitionPBR

"pbr.material"

MaterialDefinitionTerrain

"terrain.material"

MaterialDefinitionBasicSkinned

"basic_skinned.material"

MaterialDefinitionText3D

"text3d.material"

MaterialDefinitionText3DTransparent

"text3d_transparent.material"

MaterialDefinitionText

"text.material"

MaterialDefinitionTextTransparent

"text_transparent.material"

MaterialDefinitionCombine

"combine.material"

MaterialDefinitionComposite

"composite.material"

MaterialDefinitionUI

"ui.material"

MaterialDefinitionUITransparent

"ui_transparent.material"

MaterialDefinitionSprite

"sprite.material"

MaterialDefinitionSpriteTransparent

"sprite_transparent.material"

MaterialDefinitionLightDepth

"light_depth.material"

MaterialDefinitionLightDepthCSM1

"light_depth_csm1.material"

MaterialDefinitionLightDepthCSM2

"light_depth_csm2.material"

MaterialDefinitionLightCubeDepth

"light_cube_depth.material"

MaterialDefinitionParticle

"particle.material"

MaterialDefinitionParticleTransparent

"particle_transparent.material"

MaterialDefinitionEdTransformWire

"ed_transform_wire.material"

MaterialDefinitionEdFrustumWire

"ed_frustum_wire.material"

MaterialDefinitionEdGizmo

"ed_gizmo.material"

ShaderTextVert

"text.vert.spv"

ShaderTextFrag

"text.frag.spv"

ShaderText3DVert

"text3d.vert.spv"

ShaderText3DFrag

ShaderTextFrag

ShaderCompositeVert

"composite.vert.spv"

ShaderCompositeFrag

"composite.frag.spv"

ShaderHdrVert

"hdr.vert.spv"

ShaderHdrFrag

"hdr.frag.spv"

ShaderUIVert

"ui.vert.spv"

ShaderUIFrag

"ui.frag.spv"

ShadersUINineFrag

"ui_nine.frag.spv"

Types

ArchiveDatabase

struct

type ArchiveDatabase struct {
    // Has unexported fields.
}

ArchiveDatabase.Cache

func (a *ArchiveDatabase) Cache(key string, data []byte)

ArchiveDatabase.CacheClear

func (a *ArchiveDatabase) CacheClear()

ArchiveDatabase.CacheRemove

func (a *ArchiveDatabase) CacheRemove(key string)

ArchiveDatabase.Close

func (a *ArchiveDatabase) Close()

ArchiveDatabase.Exists

func (a *ArchiveDatabase) Exists(key string) bool

ArchiveDatabase.PostWindowCreate

func (a *ArchiveDatabase) PostWindowCreate(windowHandle PostWindowCreateHandle) error

ArchiveDatabase.Read

func (a *ArchiveDatabase) Read(key string) ([]byte, error)

ArchiveDatabase.ReadText

func (a *ArchiveDatabase) ReadText(key string) (string, error)

Database

interface

type Database interface {
    // PostWindowCreate is a hook that is called after a window has been
    // created. Implementations can use the provided handle to perform any
    // platform‑specific initialisation. Most implementations are no‑ops.
    PostWindowCreate(windowHandle PostWindowCreateHandle) error

    // Cache stores the raw byte slice `data` under `key` for fast subsequent
    // reads. Implementations may choose to ignore this (e.g. DebugContentDatabase)
    // or provide a real cache (e.g. FileDatabase).
    Cache(key string, data []byte)

    // CacheRemove removes a cached entry identified by `key`. If the
    // implementation does not maintain a cache this is a no‑op.
    CacheRemove(key string)

    // CacheClear clears all cached entries. Implementations without a cache
    // should simply return.
    CacheClear()

    // Read returns the raw bytes for the asset identified by `key`. An error is
    // returned if the asset cannot be found or read.
    Read(key string) ([]byte, error)

    // ReadText is a convenience wrapper around Read that returns the asset as a
    // string. It returns any error from Read.
    ReadText(key string) (string, error)

    // Exists reports whether an asset with the given `key` is available in the
    // underlying storage. Implementations should check both the cache and the
    // backing store.
    Exists(key string) bool

    // Close releases any resources held by the implementation. Implementations
    // that have no resources may implement this as a no‑op.
    Close()
}

Database defines the contract for asset storage back‑ends used by the engine. Implementations may store assets on disk, in memory, inside an archive, or provide a debug view of the file system. The interface abstracts common operations required by the engine and editor.

NewArchiveDatabase

func NewArchiveDatabase(archive string, key []byte) (Database, error)

NewFileDatabase

func NewFileDatabase(root string) (Database, error)

DebugContentDatabase

struct

type DebugContentDatabase struct{}

DebugContentDatabase.Cache

func (DebugContentDatabase) Cache(key string, data []byte)

DebugContentDatabase.CacheClear

func (DebugContentDatabase) CacheClear()

DebugContentDatabase.CacheRemove

func (DebugContentDatabase) CacheRemove(key string)

DebugContentDatabase.Close

func (DebugContentDatabase) Close()

DebugContentDatabase.Exists

func (e DebugContentDatabase) Exists(key string) bool

DebugContentDatabase.PostWindowCreate

func (DebugContentDatabase) PostWindowCreate(PostWindowCreateHandle) error

DebugContentDatabase.Read

func (e DebugContentDatabase) Read(key string) ([]byte, error)

DebugContentDatabase.ReadText

func (e DebugContentDatabase) ReadText(key string) (string, error)

FileDatabase

struct

type FileDatabase struct {
    // Has unexported fields.
}

FileDatabase.Cache

func (a *FileDatabase) Cache(key string, data []byte)

FileDatabase.CacheClear

func (a *FileDatabase) CacheClear()

FileDatabase.CacheRemove

func (a *FileDatabase) CacheRemove(key string)

FileDatabase.Close

func (a *FileDatabase) Close()

FileDatabase.Exists

func (a *FileDatabase) Exists(key string) bool

FileDatabase.PostWindowCreate

func (a *FileDatabase) PostWindowCreate(PostWindowCreateHandle) error

FileDatabase.Read

func (a *FileDatabase) Read(key string) ([]byte, error)

FileDatabase.ReadText

func (a *FileDatabase) ReadText(key string) (string, error)

MockDatabase

struct

type MockDatabase struct {
    // Has unexported fields.
}

MockDatabase implements the assets.Database interface for testing.

NewMockDB

func NewMockDB(files map[string][]byte) *MockDatabase

MockDatabase.AddFile

func (m *MockDatabase) AddFile(key string, data []byte)

MockDatabase.Cache

func (m *MockDatabase) Cache(key string, data []byte)

MockDatabase.CacheClear

func (m *MockDatabase) CacheClear()

MockDatabase.CacheRemove

func (m *MockDatabase) CacheRemove(key string)

MockDatabase.Close

func (m *MockDatabase) Close()

MockDatabase.Exists

func (m *MockDatabase) Exists(key string) bool

MockDatabase.PostWindowCreate

func (m *MockDatabase) PostWindowCreate(windowHandle PostWindowCreateHandle) error

MockDatabase.Read

func (m *MockDatabase) Read(key string) ([]byte, error)

MockDatabase.ReadText

func (m *MockDatabase) ReadText(key string) (string, error)

MockDatabase.RemoveFile

func (m *MockDatabase) RemoveFile(key string)

PostWindowCreateHandle

interface

type PostWindowCreateHandle interface {
    ReadApplicationAsset(path string) ([]byte, error)
}