Documentation ¶
Index ¶
- Variables
- func POT(img image.Image) image.Image
- func PreDraw(dev gfx.Device, rect image.Rectangle, o *gfx.Object, c gfx.Camera) (draw bool, err error)
- func VerticalFlip(img *image.RGBA)
- type BaseCanvas
- type Swapper
- func (s *Swapper) Bounds() image.Rectangle
- func (s *Swapper) Clear(r image.Rectangle, bg gfx.Color)
- func (s *Swapper) ClearDepth(r image.Rectangle, depth float64)
- func (s *Swapper) ClearStencil(r image.Rectangle, stencil int)
- func (s *Swapper) Clock() *clock.Clock
- func (s *Swapper) Download(r image.Rectangle, complete chan image.Image)
- func (s *Swapper) Draw(r image.Rectangle, o *gfx.Object, c gfx.Camera)
- func (s *Swapper) Info() gfx.DeviceInfo
- func (s *Swapper) LoadMesh(m *gfx.Mesh, done chan *gfx.Mesh)
- func (s *Swapper) LoadShader(sh *gfx.Shader, done chan *gfx.Shader)
- func (s *Swapper) LoadTexture(t *gfx.Texture, done chan *gfx.Texture)
- func (s *Swapper) MSAA() (msaa bool)
- func (s *Swapper) Precision() gfx.Precision
- func (s *Swapper) QueryWait()
- func (s *Swapper) Render()
- func (s *Swapper) RenderToTexture(cfg gfx.RTTConfig) gfx.Canvas
- func (s *Swapper) SetMSAA(msaa bool)
- type Warner
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilState = errors.New("Draw: gfx.State is nil (ignoring object)") ErrNilShader = errors.New("Draw: gfx.Shader is nil (ignoring object)") ErrNilSource = errors.New("Draw: gfx.Texture has a nil Source image (ignoring object)") ErrNoVertices = errors.New("Draw: gfx.Mesh has no vertices (ignoring object)") ErrNoMeshes = errors.New("Draw: gfx.Object has no meshes (ignoring object)") ErrShaderError = errors.New("Draw: gfx.Shader has a compiler error (ignoring object)") )
Functions ¶
func POT ¶
POT resamples/resizes the given image to the nearest power-of-two size (if it is not a power-of-two size already).
func PreDraw ¶
func PreDraw(dev gfx.Device, rect image.Rectangle, o *gfx.Object, c gfx.Camera) (draw bool, err error)
PreDraw performs the commonplace tasks that occur before each object is drawn in a call to gfx.Canvas.Draw. It returns a draw boolean which signals whether or not the object should be drawn, and also may return a != nil error if the developer should be warned.
It will return draw=false, err == nil in the following cases:
rect.Empty() == true o.Shader != nil && len(o.Shader.Error) > 0
It may return the following errors:
ErrNilState ErrNilShader ErrNilSource ErrNoVertices ErrNoMeshes ErrShaderError
If draw == true && err == nil, then it will:
Make the implicit call to o.Bounds() required by gfx.Canvas such that the object has a chance to calculate a bounding box before it's data slices are set to nil.
Ask the given device to load each shader, mesh, and texture that the object has associated with it and waits for loading to complete before returning.
func VerticalFlip ¶
VerticalFlip flips the given image in-place, vertically.
Types ¶
type BaseCanvas ¶
type BaseCanvas struct { sync.RWMutex VMSAA bool // The MSAA state. VPrecision gfx.Precision // The precision of this canvas. VBounds image.Rectangle // The bounding rectangle of this canvas. }
BaseCanvas implements basic portions of a gfx.Canvas. Specifically the methods it implements are:
SetMSAA MSAA Precision Bounds
func (*BaseCanvas) Bounds ¶
func (c *BaseCanvas) Bounds() image.Rectangle
Implements the gfx.Canvas interface.
func (*BaseCanvas) Precision ¶
func (c *BaseCanvas) Precision() gfx.Precision
Implements gfx.Canvas interface.
func (*BaseCanvas) SetMSAA ¶
func (c *BaseCanvas) SetMSAA(msaa bool)
Implements gfx.Canvas interface.
func (*BaseCanvas) UpdateBounds ¶
func (c *BaseCanvas) UpdateBounds(bounds image.Rectangle)
UpdateBounds updates the bounds of this canvas, under c's write lock.
type Swapper ¶
type Swapper struct { Yield chan struct{} Swap chan gfx.Device // contains filtered or unexported fields }
Swapper is a swappable gfx.Device implementation.
func NewSwapper ¶
NewSwapper returns a new graphics device swapper, wrapping the given device.
func (*Swapper) ClearDepth ¶
ClearDepth submits a depth clear operation to the current graphics device.
func (*Swapper) ClearStencil ¶
ClearStencil submits a stencil clear operation to the current graphics device.
func (*Swapper) Info ¶
func (s *Swapper) Info() gfx.DeviceInfo
Bounds returns the info of the current graphics device.
func (*Swapper) LoadShader ¶
LoadShader loads a shader using the current graphics device.
func (*Swapper) LoadTexture ¶
LoadTexture loads a texture using the current graphics device.
func (*Swapper) QueryWait ¶
func (s *Swapper) QueryWait()
QueryWait waits for occlusion queries to wait on the current graphics device.
func (*Swapper) Render ¶
func (s *Swapper) Render()
Render renders a frame using the current graphics device. When it finishes the swapper considers yielding and swapping the underlying graphics device out with another.
func (*Swapper) RenderToTexture ¶
RenderToTexture returns a new RTT canvas using the current graphics device.
TODO(slimsag): Do we require a swappable canvas, here, too?
type Warner ¶
Warner can warn developers of a potential problem. It writes it's warnings to the underlying writer.
A map of previous warnings is used to identify previous warnings, and as such you should be concious of potential memory overhead (i.e. only use it for situations where warnings should not happen generally).
func (*Warner) Warn ¶
Warn writes a single warning message out to the underlying writer (w.W). It will only write the message once even if multiple calls are made, thus:
w.Warn("Something bad has happened!") w.Warn("Something bad has happened!") w.Warn("Something bad has happened (again)!")
Will produce just the following output:
Something bad has happened! Something bad has happened (again)!