Documentation ¶
Index ¶
- Constants
- Variables
- type AsGPUDrawer
- type Drawer
- func (dw *Drawer) AsGPUDrawer() *Drawer
- func (dw *Drawer) ConfigPipeline(pl *gpu.GraphicsPipeline, blend bool)
- func (dw *Drawer) Copy(dp image.Point, src image.Image, sr image.Rectangle, op draw.Op, ...)
- func (dw *Drawer) CopyUsed(dp image.Point, sr image.Rectangle, op draw.Op, flipY bool)
- func (dw *Drawer) DestBounds() image.Rectangle
- func (dw *Drawer) DestSize() image.Point
- func (dw *Drawer) End()
- func (dw *Drawer) Fill(clr color.Color, dr image.Rectangle, op draw.Op)
- func (dw *Drawer) Release()
- func (dw *Drawer) Renderer() any
- func (dw *Drawer) Scale(dr image.Rectangle, src image.Image, sr image.Rectangle, rotateDeg float32, ...)
- func (dw *Drawer) ScaleUsed(dr image.Rectangle, sr image.Rectangle, rotateDeg float32, op draw.Op, ...)
- func (dw *Drawer) Start()
- func (dw *Drawer) Transform(xform math32.Matrix3, src image.Image, sr image.Rectangle, op draw.Op, ...)
- func (dw *Drawer) TransformUsed(xform math32.Matrix3, sr image.Rectangle, op draw.Op, flipY bool)
- func (dw *Drawer) UseGoImage(img image.Image, unchanged bool)
- func (dw *Drawer) UseTexture(tx *gpu.Texture)
Constants ¶
const ( // Unchanged should be used for the unchanged argument in drawer calls, // when the caller knows that the image is unchanged. Unchanged = true // Changed should be used for the unchanged argument to drawer calls, // when the image has changed since last time or its status is unknown Changed )
const ( // Over = alpha blend with existing content. Over = draw.Over // Src = copy source to destination with no blending ("blit"). Src = draw.Src )
These draw.Op constants are provided so that users of this package don't have to explicitly import "image/draw". We also add the fill operations.
Variables ¶
var AllocChunk = 16
AllocChunk is number of images / matrix elements to allocate at a time, to reduce number of reallocations. Should be set to the rough scale of number of items expected.
Functions ¶
This section is empty.
Types ¶
type AsGPUDrawer ¶
type AsGPUDrawer interface { // AsGPUDrawer returns the drawer as a [Drawer]. // It may return nil if it cannot be used as a [Drawer]. AsGPUDrawer() *Drawer }
AsGPUDrawer represents a type that can be used as a Drawer.
type Drawer ¶
type Drawer struct { // drawing system System *gpu.GraphicsSystem // use Lock, Unlock on Drawer for all impl routines sync.Mutex // contains filtered or unexported fields }
Drawer is the overall GPUDraw implementation, which draws Textures or Fills solid colors to a render target. A sequence of drawing operations is programmed for each render pass, between Start and End calls, which is then uploaded and performed in one GPU render pass, according to the recorded order of operations.
func (*Drawer) AsGPUDrawer ¶
AsGPUDrawer implements AsGPUDrawer.
func (*Drawer) ConfigPipeline ¶
func (dw *Drawer) ConfigPipeline(pl *gpu.GraphicsPipeline, blend bool)
ConfigPipeline configures graphics settings on the pipeline
func (*Drawer) Copy ¶
func (dw *Drawer) Copy(dp image.Point, src image.Image, sr image.Rectangle, op draw.Op, unchanged bool)
Copy copies the given Go source image to the render target, with the same semantics as golang.org/x/image/draw.Copy, with the destination implicit in the Drawer target.
- Must have called Start first!
- dp is the destination point.
- src is the source image. If an image.Uniform, fast Fill is done.
- sr is the source region, if zero full src is used; must have for Uniform.
- op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing.
- unchanged should be true if caller knows that this image is unchanged from the last time it was used -- saves re-uploading to gpu.
func (*Drawer) CopyUsed ¶
CopyUsed copies the current Use* texture to render target. Must have called Start and a Use* method first!
- dp is the destination point.
- src is the source image. If an image.Uniform, fast Fill is done.
- sr is the source region, if zero full src is used.
- op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing.
- flipY = flipY axis when drawing this image.
func (*Drawer) DestBounds ¶
DestBounds returns the bounds of the render destination
func (*Drawer) End ¶
func (dw *Drawer) End()
End ends image drawing rendering process on render target.
func (*Drawer) Fill ¶
Fill fills given color to render target, to given destination region dr.
- op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing
func (*Drawer) Scale ¶
func (dw *Drawer) Scale(dr image.Rectangle, src image.Image, sr image.Rectangle, rotateDeg float32, op draw.Op, unchanged bool)
Scale copies the given Go source image to the render target, scaling the region defined by src and sr to the destination such that sr in src-space is mapped to dr in dst-space, and applying an optional rotation of the source image. Has the same general semantics as golang.org/x/image/draw.Scale, with the destination implicit in the Drawer target. If src image is an
- Must have called Start first!
- dr is the destination rectangle; if zero uses full dest image.
- src is the source image. Uniform does not work (or make sense) here.
- sr is the source region, if zero full src is used; must have for Uniform.
- rotateDeg = rotation degrees to apply in the mapping: 90 = left, -90 = right, 180 = invert.
- op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing.
- unchanged should be true if caller knows that this image is unchanged from the last time it was used -- saves re-uploading to gpu.
func (*Drawer) ScaleUsed ¶
func (dw *Drawer) ScaleUsed(dr image.Rectangle, sr image.Rectangle, rotateDeg float32, op draw.Op, flipY bool)
ScaleUsed copies the current Use* texture to render target, scaling the region defined by src and sr to the destination such that sr in src-space is mapped to dr in dst-space. Must have called Start and a Use* method first!
- dr is the destination rectangle; if zero uses full dest image.
- sr is the source region; if zero uses full src image.
- rotateDeg = rotation degrees to apply in the mapping: 90 = left, -90 = right, 180 = invert.
- op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing.
- flipY = flipY axis when drawing this image.
func (*Drawer) Start ¶
func (dw *Drawer) Start()
Start starts recording a sequence of draw / fill actions, which will be performed on the GPU at End(). This must be called prior to any Drawer operations.
func (*Drawer) Transform ¶
func (dw *Drawer) Transform(xform math32.Matrix3, src image.Image, sr image.Rectangle, op draw.Op, unchanged bool)
Transform copies the given Go source image to the render target, with the same semantics as golang.org/x/image/draw.Transform, with the destination implicit in the Drawer target.
- xform is the transform mapping source to destination coordinates.
- src is the source image. Uniform does not work (or make sense) here.
- sr is the source region, if zero full src is used; must have for Uniform.
- op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing.
- unchanged should be true if caller knows that this image is unchanged from the last time it was used -- saves re-uploading to gpu.
func (*Drawer) TransformUsed ¶
TransformUsed draws the current Use* texture to render target Must have called Start and a Use* method first!
- xform is the transform mapping source to destination coordinates.
- sr is the source region; if zero uses full src image.
- op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing.
func (*Drawer) UseGoImage ¶
UseGoImage uses the given Go image.Image as the source image for the next Draw operation. unchanged is a hint from the source about whether the image is unchanged from last use, in which case it does not need to be re-uploaded (if found).
func (*Drawer) UseTexture ¶
UseTexture uses the given GPU resident Texture as the source image for the next Draw operation.