Documentation
¶
Index ¶
- Variables
- func ByteToNormalizedColour(b uint8) float32
- func GetCurrentBackgroundColor() color.NRGBA
- func GetCurrentForegroundColour() color.NRGBA
- func IsOnRenderThread() bool
- func LogAndClearGlErrors(logger glog.Logger)
- func LogAndClearGlErrorsWithAttribution(logger glog.Logger, fn any)
- func MatrixIsEqual(lhs, rhs Matrix) bool
- func MustBeOnRenderThread()
- func MustNotBeOnRenderThread()
- func NormalizedColourToByte(f float32) uint8
- func WithBlankScreen(r, g, b, a gl.GLclampf, fn func())
- func WithColour(r, g, b, a float32, fn func())
- func WithFreshMatrices(fn func())
- func WithMatrixInMode(mat *Matrix, mode MatrixMode, fn func())
- func WithMatrixMode(mode MatrixMode, fn func())
- func WithMultMatrixInMode(mat *Matrix, mode MatrixMode, fn func())
- func WithTexture2DSetting(enableT2D bool, fn func())
- func WithTexturing(fn func())
- func WithoutTexturing(fn func())
- type JobTimingInfo
- type JobTimingListener
- type Matrix
- type MatrixMode
- type RenderJob
- type RenderQueueInterface
- func MakeQueue(initialization RenderJob) RenderQueueInterface
- func MakeQueueWithLogger(initialization RenderJob, logger glog.Logger) RenderQueueInterface
- func MakeQueueWithTiming(initialization RenderJob, listener *JobTimingListener) RenderQueueInterface
- func MakeQueueWithTimingAndLogger(initialization RenderJob, listener *JobTimingListener, logger glog.Logger) RenderQueueInterface
- type RenderQueueState
- type RenderQueueWithLoggerInterface
- type ShaderBank
- func (bank *ShaderBank) EnableShader(name string) error
- func (bank *ShaderBank) HasShader(shaderName string) bool
- func (bank *ShaderBank) RegisterShader(name string, vertex, fragment string) error
- func (bank *ShaderBank) SetUniformF(shader, variable string, f float32) error
- func (bank *ShaderBank) SetUniformI(shader, variable string, n int) error
- type Showmat
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrShaderAlreadyRegistered shaderError = "shader name already in use"
View Source
var (
QueueShutdownError = &queueShutdownError{}
)
Functions ¶
func ByteToNormalizedColour ¶
func IsOnRenderThread ¶
func IsOnRenderThread() bool
func LogAndClearGlErrors ¶
func MatrixIsEqual ¶
func MustBeOnRenderThread ¶
func MustBeOnRenderThread()
func MustNotBeOnRenderThread ¶
func MustNotBeOnRenderThread()
func NormalizedColourToByte ¶
func WithBlankScreen ¶
func WithColour ¶
func WithColour(r, g, b, a float32, fn func())
func WithFreshMatrices ¶
func WithFreshMatrices(fn func())
func WithMatrixInMode ¶
func WithMatrixInMode(mat *Matrix, mode MatrixMode, fn func())
func WithMatrixMode ¶
func WithMatrixMode(mode MatrixMode, fn func())
func WithMultMatrixInMode ¶
func WithMultMatrixInMode(mat *Matrix, mode MatrixMode, fn func())
func WithTexture2DSetting ¶
func WithTexture2DSetting(enableT2D bool, fn func())
func WithTexturing ¶
func WithTexturing(fn func())
func WithoutTexturing ¶
func WithoutTexturing(fn func())
Types ¶
type JobTimingInfo ¶
type JobTimingListener ¶
type JobTimingListener struct {
// NOTE: this notification runs on the render thread that ran the slow job.
// Care should be taken not to make a bad situation worse!
//
// Called after a render job took longer than Threshold. The actual time
// taken and the job's source attribution is also given.
OnNotify func(*JobTimingInfo, string)
// Only jobs that took Threshold or longer will trigger a call to OnNotify.
// A job's total time is its RunTime plus its QueueTime.
Threshold time.Duration
}
Instances of JobTimingListener can be registered only at Queue construction.
type Matrix ¶
func GetCurrentMatrix ¶
func GetCurrentMatrix(mode MatrixMode) Matrix
type MatrixMode ¶
type MatrixMode int32
const ( MatrixModeModelView MatrixMode = gl.MODELVIEW MatrixModeProjection MatrixMode = gl.PROJECTION MatrixModeTexture MatrixMode = gl.TEXTURE MatrixModeColour MatrixMode = gl.COLOR )
func GetCurrentMatrixMode ¶
func GetCurrentMatrixMode() MatrixMode
type RenderQueueInterface ¶
type RenderQueueInterface interface {
// The given callback will be invoked when queued jobs panic over an error
// value. Note that such panics do _not_ cause the Queue to enter a 'defunct'
// state; other jobs can still be queued and run.
AddErrorCallback(func(RenderQueueInterface, error))
// Eventually runs the given closure on a thread dedicated to OpenGL
// operations. Jobs are run sequentially in the order queued. Each job is
// passed a reference to data that must only be used on this
// RenderQueueInterface's render thread. Callers may assume that the
// RenderQueueState instance passed to each RenderJob is the same object
// per-queue. Caveat: if the queue is in a 'defunct' state, calls to Queue()
// will succeed but the jobs may not run.
Queue(f RenderJob)
// Blocks until all Queue'd jobs have completed. Note that, if other
// goroutines are queueing jobs, this will block waiting for them as well!
// If the queue enters a 'defunct' state (by calling StopProcessing or if the
// underlying goroutine exits), current and subsequent calls to Purge() will
// panic with a 'render.QueueShutdownError'.
Purge()
// StartProcessing() needs to be called exactly once per queue in order to
// start running jobs. Queue()ing is allowed before processing has started.
// Purge()ing is allowed before processing has started with the caveat that
// even an empty queue will block Purge()ers from continuing until
// StartProcessing() _is_ called.
StartProcessing()
// StopProcessing() can be called to stop processing jobs on the render
// queue. It can be called before or after StartProcessing(). It will not
// interrupt a running job but will pre-empt any other scheduled work. Any
// subsequent or currently blocked calls to Purge() will panic with a
// 'render.QueueShutdownError'. Calling StopProcessing() on a defunct queue
// is a no-op.
StopProcessing()
// Returns true iff the queue is in a 'defunct' state.
IsDefunct() bool
// For debugability, polls the queue's current Purging/NotPurging status.
IsPurging() bool
}
Accepts jobs for running on a dedicated, internal thread of control. Helpful for ensuring certain preconditions needed for calling into OpenGL.
func MakeQueue ¶
func MakeQueue(initialization RenderJob) RenderQueueInterface
func MakeQueueWithLogger ¶
func MakeQueueWithLogger(initialization RenderJob, logger glog.Logger) RenderQueueInterface
func MakeQueueWithTiming ¶
func MakeQueueWithTiming(initialization RenderJob, listener *JobTimingListener) RenderQueueInterface
func MakeQueueWithTimingAndLogger ¶
func MakeQueueWithTimingAndLogger(initialization RenderJob, listener *JobTimingListener, logger glog.Logger) RenderQueueInterface
type RenderQueueState ¶
type RenderQueueState interface {
Context() context.Context
Shaders() *ShaderBank
}
TODO(tmckee): clean: is there a better name for this? RenderContext?
type RenderQueueWithLoggerInterface ¶
type RenderQueueWithLoggerInterface interface {
RenderQueueInterface
SetLogger(glog.Logger)
}
type ShaderBank ¶
func MakeShaderBank ¶
func MakeShaderBank() *ShaderBank
func (*ShaderBank) EnableShader ¶
func (bank *ShaderBank) EnableShader(name string) error
TODO(tmckee): refactor: There should be a 'DisableShader' to 'UseProgram(0)'
func (*ShaderBank) HasShader ¶
func (bank *ShaderBank) HasShader(shaderName string) bool
func (*ShaderBank) RegisterShader ¶
func (bank *ShaderBank) RegisterShader(name string, vertex, fragment string) error
func (*ShaderBank) SetUniformF ¶
func (bank *ShaderBank) SetUniformF(shader, variable string, f float32) error
func (*ShaderBank) SetUniformI ¶
func (bank *ShaderBank) SetUniformI(shader, variable string, n int) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
package rendertest implements testing helpers that are useful for projects that are using the 'render' package.
|
package rendertest implements testing helpers that are useful for projects that are using the 'render' package. |
|
package tls uses native code to expose Thread Local Storage primitives.
|
package tls uses native code to expose Thread Local Storage primitives. |
Click to show internal directories.
Click to hide internal directories.