renderer

package
v0.0.0-...-5f0f668 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWindowClosed = errors.New("window closed")

Functions

func GLDebugOutput

func GLDebugOutput() <-chan GLDebugMessage

func Includes

func Includes(filenames ...string) ([]string, error)

Includes recursively resolves dependencies in the specified file.

The argument file is returned included in the returned list of files.

func ListUniforms

func ListUniforms(program uint32) map[string]Uniform

Types

type CompileError

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

func (CompileError) Error

func (err CompileError) Error() string

func (CompileError) PrettyPrint

func (err CompileError) PrettyPrint(out io.Writer)

type Environment

type Environment interface {
	// Sources should return the shader sources mapped by their pipeline stage.
	// Multiple shader sources are combined per stage.
	Sources() (map[Stage][]Source, error)

	// Setup may be used to initialize any OpenGL state before the first frame
	// is rendered.
	Setup(state RenderState) error

	// SubEnvironments returns a set of environments which render output is
	// required in this environment.
	//
	// The implementing environment is not required to retain any state of the
	// environments returned.
	SubEnvironments() (map[string]SubEnvironment, error)

	// PreRender updates the program's uniform values for each next frame.
	//
	// sinceStart is the animation time elapsed since the first frame was
	// rendered.
	PreRender(state RenderState)

	// Close should shut down the environment by freeing all associated
	// (OpenGL) resources.
	Close() error
}

type GLDebugMessage

type GLDebugMessage struct {
	ID       uint32
	Source   uint32
	Type     uint32
	Severity uint32
	Message  string
	Stack    string
}

func (GLDebugMessage) SeverityString

func (dm GLDebugMessage) SeverityString() string

func (GLDebugMessage) String

func (dm GLDebugMessage) String() string

type LinkError

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

func (LinkError) Error

func (err LinkError) Error() (str string)

type OnScreenEngine

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

OnScreenEngine is an animation engine for rendering to an OS window.

Internally, it renders to a framebuffer so we can obtain a texture containing a rendered frame that can be used as the previous frame in shaders. This texture is then immediately outputted to the window by drawing a fullscreen quad.

func NewOnScreenEngine

func NewOnScreenEngine(glVersion OpenGLVersion) (*OnScreenEngine, error)

func (*OnScreenEngine) Animate

func (eng *OnScreenEngine) Animate(ctx context.Context) error

func (*OnScreenEngine) Close

func (eng *OnScreenEngine) Close() error

func (*OnScreenEngine) SetEnvironment

func (eng *OnScreenEngine) SetEnvironment(env Environment)

type OpenGLVersion

type OpenGLVersion int
const (
	OpenGL20 OpenGLVersion = 20
	OpenGL21 OpenGLVersion = 21
	OpenGL30 OpenGLVersion = 30
	OpenGL31 OpenGLVersion = 31
	OpenGL32 OpenGLVersion = 32
	OpenGL33 OpenGLVersion = 33
)

func OpenGLVersionFromGLSLVersion

func OpenGLVersionFromGLSLVersion(s string) (OpenGLVersion, error)

func ParseOpenGLVersion

func ParseOpenGLVersion(s string) (OpenGLVersion, error)

func (OpenGLVersion) String

func (v OpenGLVersion) String() string

type RenderState

type RenderState struct {
	Time            time.Duration
	Interval        time.Duration
	FramesProcessed uint64

	CanvasWidth  uint
	CanvasHeight uint

	Uniforms           map[string]Uniform
	PreviousFrameTexID func() uint32

	// SubBuffers contains the render output for each environment returned by
	// SubEnvironments as a textureID.
	SubBuffers map[string]uint32
}

type Shader

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

func NewShader

func NewShader(width, height uint, glVersion OpenGLVersion) (*Shader, error)

func (*Shader) Animate

func (sh *Shader) Animate(ctx context.Context, interval time.Duration, stream chan<- image.Image)

func (*Shader) Close

func (sh *Shader) Close() error

func (*Shader) SetEnvironment

func (sh *Shader) SetEnvironment(env Environment)

type Source

type Source interface {
	// Contents reads the contents of the source file.
	Contents() ([]byte, error)
	// Dir returns the parent directory the file is located in.
	Dir() string
}

Source represents a single source file.

type SourceBuf

type SourceBuf string

SourceBuf is an implementation of the Source interface that keeps its contents in memory.

func (SourceBuf) Contents

func (s SourceBuf) Contents() ([]byte, error)

Contents implemetns the Source interface.

func (SourceBuf) Dir

func (s SourceBuf) Dir() string

Dir implemetns the Source interface.

A Sourcebuf has no parent directory, so the current working directory is returned instead.

type SourceFile

type SourceFile struct {
	Filename string
}

SourceFile is an implementation of the Source interface for real files.

func SourceFiles

func SourceFiles(filenames ...string) []SourceFile

func (SourceFile) Contents

func (s SourceFile) Contents() ([]byte, error)

Contents implemetns the Source interface.

func (SourceFile) Dir

func (s SourceFile) Dir() string

Dir implemetns the Source interface.

type Stage

type Stage string
const (
	StageVertex   Stage = "vert"
	StageFragment Stage = "frag"
)

type SubEnvironment

type SubEnvironment struct {
	Environment
	Width, Height uint
}

type Uniform

type Uniform struct {
	Name     string
	Type     uint32
	Location int32
}

func (Uniform) String

func (u Uniform) String() string

func (Uniform) TypeLiteral

func (u Uniform) TypeLiteral() string

Jump to

Keyboard shortcuts

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