Documentation ¶
Index ¶
- Constants
- func TransformMatrix(dr image.Rectangle, sr image.Rectangle, rotDeg float32) math32.Matrix3
- type Drawer
- func (dw *Drawer) ConfigFrame(dev *vgpu.Device, size image.Point, maxTextures int)
- func (dw *Drawer) ConfigImage(idx int, fmt *vgpu.ImageFormat)
- func (dw *Drawer) ConfigImageDefaultFormat(idx int, width int, height int, layers int)
- func (dw *Drawer) ConfigImageName(name string, fmt *vgpu.ImageFormat)
- func (dw *Drawer) ConfigMtxs(src2dst math32.Matrix3, txsz image.Point, sr image.Rectangle, op draw.Op, ...) *Mtxs
- func (dw *Drawer) ConfigPipeline(pl *vgpu.Pipeline)
- func (dw *Drawer) ConfigSurface(sf *vgpu.Surface, maxTextures int)
- func (dw *Drawer) ConfigSys()
- func (dw *Drawer) Copy(idx, layer int, dp image.Point, sr image.Rectangle, op draw.Op, flipY bool) error
- func (dw *Drawer) DestBounds() image.Rectangle
- func (dw *Drawer) DestSize() image.Point
- func (dw *Drawer) Destroy()
- func (dw *Drawer) Draw(idx, layer int, src2dst math32.Matrix3, sr image.Rectangle, op draw.Op, ...) error
- func (dw *Drawer) EndDraw()
- func (dw *Drawer) EndFill()
- func (dw *Drawer) Fill(clr color.Color, src2dst math32.Matrix3, reg image.Rectangle, op draw.Op) error
- func (dw *Drawer) FillRect(clr color.Color, reg image.Rectangle, op draw.Op) error
- func (dw *Drawer) GetImageValue(idx int) *vgpu.Value
- func (dw *Drawer) ImageIndexByName(name string) int
- func (dw *Drawer) MaxTextures() int
- func (dw *Drawer) Scale(idx, layer int, dr image.Rectangle, sr image.Rectangle, op draw.Op, flipY bool, ...) error
- func (dw *Drawer) SelectPipeline(op draw.Op) *vgpu.Pipeline
- func (dw *Drawer) SetFrameImage(idx int, fbi any)
- func (dw *Drawer) SetFrameImageName(name string, fb *vgpu.Framebuffer)
- func (dw *Drawer) SetGoImage(idx, layer int, img image.Image, flipY bool)
- func (dw *Drawer) SetGoImageName(name string, layer int, img image.Image, flipY bool)
- func (dw *Drawer) SetImageName(idx int, name string) error
- func (dw *Drawer) SetMaxTextures(maxTextures int)
- func (dw *Drawer) StartDraw(descIndex int) bool
- func (dw *Drawer) StartFill() bool
- func (dw *Drawer) Surface() any
- func (dw *Drawer) SyncImages()
- func (dw *Drawer) UseTextureSet(descIndex int)
- type DrawerImpl
- type Mtxs
Constants ¶
const ( Over = draw.Over Src = draw.Src )
These draw.Op constants are provided so that users of this package don't have to explicitly import "image/draw".
Variables ¶
This section is empty.
Functions ¶
func TransformMatrix ¶ added in v0.0.9
TransformMatrix returns a transformation matrix for the generic Draw function that scales, translates, and rotates the source image by the given degrees. to make it fit within the destination rectangle dr, given its original size sr (unrotated). To avoid scaling, ensure that the dr and sr are the same dimensions (post rotation). rotDeg = rotation degrees to apply in the mapping: 90 = left, -90 = right, 180 = invert
Types ¶
type Drawer ¶
type Drawer struct { // drawing system Sys vgpu.System // surface if render target Surf *vgpu.Surface // render frame if render target Frame *vgpu.RenderFrame // render so the Y axis points down, with 0,0 at the upper left, which is the Vulkan standard. default is Y is up, with 0,0 at bottom left, which is OpenGL default. this must be set prior to configuring, the surface, as it determines the rendering parameters. YIsDown bool // implementation state -- ignore Impl DrawerImpl // mutex on updating UpdateMu sync.Mutex `view:"-" copier:"-" json:"-" xml:"-"` }
Drawer is the vDraw implementation, which draws Textures or Fills solid colors to a render target (Surface, RenderFrame). Image and color palette must be set prior to a given render pass. Multiple fill operations can be performed in one pass, but only one Image can be used at a time.
func (*Drawer) ConfigFrame ¶
ConfigFrame configures the Drawer to use a RenderFrame as a render target, of given size. Use dw.Frame.SetSize to resize later. Frame is owned and managed by the Drawer. Uses given Device -- if nil, one is made. If maxTextures > vgpu.MaxTexturesPerSet (16) then multiple descriptor sets are used to hold more textures.
func (*Drawer) ConfigImage ¶
func (dw *Drawer) ConfigImage(idx int, fmt *vgpu.ImageFormat)
ConfigImage configures the draw image at given index to fit the given image format and number of layers as a drawing source.
func (*Drawer) ConfigImageDefaultFormat ¶
ConfigImageDefaultFormat configures the draw image at the given index to fit the default image format specified by the given width, height, and number of layers.
func (*Drawer) ConfigImageName ¶
func (dw *Drawer) ConfigImageName(name string, fmt *vgpu.ImageFormat)
ConfigImageName configures the draw image at given name to fit the given image format as a drawing source.
func (*Drawer) ConfigMtxs ¶
func (dw *Drawer) ConfigMtxs(src2dst math32.Matrix3, txsz image.Point, sr image.Rectangle, op draw.Op, flipY bool) *Mtxs
ConfigMtxs configures the draw matrix for given draw parameters: src2dst is the transform mapping source to destination coordinates (translation, scaling), txsz is the size of the texture to draw, sr is the source region (set to tex.Format.Bounds() for all) op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing flipY inverts the Y axis of the source image.
func (*Drawer) ConfigPipeline ¶
ConfigPipeline configures graphics settings on the pipeline
func (*Drawer) ConfigSurface ¶
ConfigSurface configures the Drawer to use given surface as a render target. maxTextures is maximum number of images that can be used per pass. If maxTextures > vgpu.MaxTexturesPerSet (16) then multiple descriptor sets are used to hold more textures.
func (*Drawer) ConfigSys ¶
func (dw *Drawer) ConfigSys()
ConfigSys configures the vDraw System and pipelines.
func (*Drawer) Copy ¶
func (dw *Drawer) Copy(idx, layer int, dp image.Point, sr image.Rectangle, op draw.Op, flipY bool) error
Copy copies texture at given index and layer to render target. dp is the destination point, sr is the source region (set to image.ZR zero rect for all), 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) Draw ¶
func (dw *Drawer) Draw(idx, layer int, src2dst math32.Matrix3, sr image.Rectangle, op draw.Op, flipY bool) error
Draw draws texture at index and layer to render target. Must have called StartDraw first. src2dst is the transform mapping source to destination coordinates (translation, scaling), sr is the source region (set to image.ZR for all) op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing
func (*Drawer) EndDraw ¶
func (dw *Drawer) EndDraw()
EndDraw ends image drawing rendering process on render target
func (*Drawer) EndFill ¶
func (dw *Drawer) EndFill()
EndFill ends color filling rendering process on render target
func (*Drawer) Fill ¶
func (dw *Drawer) Fill(clr color.Color, src2dst math32.Matrix3, reg image.Rectangle, op draw.Op) error
Fill fills given color to to render target. src2dst is the transform mapping source to destination coordinates (translation, scaling), reg is the region to fill op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing
func (*Drawer) FillRect ¶
FillRect fills given color to render target, to given region. op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing
func (*Drawer) GetImageValue ¶ added in v0.0.10
GetImageValue returns vgpu Value value of Image for given index
func (*Drawer) ImageIndexByName ¶ added in v0.0.10
ImageIndexByName returns index of image val by name. Logs error if not found, and returns 0.
func (*Drawer) MaxTextures ¶
MaxTextures returns the max number of textures for drawing, which is [Drawer.Impl.MaxTextures].
func (*Drawer) Scale ¶
func (dw *Drawer) Scale(idx, layer int, dr image.Rectangle, sr image.Rectangle, op draw.Op, flipY bool, rotDeg float32) error
Scale copies texture at given index and layer 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. dr is the destination rectangle sr is the source region (set to image.Rectangle{} zero rect for all), op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing flipY = flipY axis when drawing this image rotDeg = rotation degrees to apply in the mapping: 90 = left, -90 = right, 180 = invert
func (*Drawer) SelectPipeline ¶
SelectPipeline selects the pipeline based on draw op only changes if not last one used. Default is Src
func (*Drawer) SetFrameImage ¶
SetFrameImage sets given vgpu.Framebuffer image as a drawing source at index, used in subsequent Draw methods. Must have already been configured to fit!
func (*Drawer) SetFrameImageName ¶
func (dw *Drawer) SetFrameImageName(name string, fb *vgpu.Framebuffer)
SetFrameImageName sets given Framebuffer image as a drawing source at name, used in subsequent Draw methods. Must have already been configured to fit!
func (*Drawer) SetGoImage ¶
SetGoImage sets given Go image as a drawing source to given image index, and layer, used in subsequent Draw methods. A standard Go image is rendered upright on a standard Vulkan surface. Set flipY to true to flip.
func (*Drawer) SetGoImageName ¶
SetGoImageName sets given Go image as a drawing source to given image name, and layer, used in subsequent Draw methods. (use SetImageName to set names) A standard Go image is rendered upright on a standard Vulkan surface. Set flipY to true to flip. This can be used directly without pre-configuring.
func (*Drawer) SetImageName ¶
SetImageName sets name of image at given index, to enable name-based access for subsequent calls. Returns error if name already exists.
func (*Drawer) SetMaxTextures ¶
SetMaxTextures updates the max number of textures for drawing Must call this prior to doing any allocation of images.
func (*Drawer) StartDraw ¶
StartDraw starts image drawing rendering process on render target No images can be added or set after this point. descIndex is the descriptor set to use -- choose this based on the bank of 16 texture values if number of textures > MaxTexturesPerSet. It returns false if rendering can not proceed.
func (*Drawer) StartFill ¶
StartFill starts color fill drawing rendering process on render target. It returns false if rendering can not proceed.
func (*Drawer) SyncImages ¶
func (dw *Drawer) SyncImages()
SyncImages must be called after images have been updated, to sync memory up to the GPU.
func (*Drawer) UseTextureSet ¶
UseTextureSet selects the descriptor set to use -- choose this based on the bank of 16 texture values if number of textures > MaxTexturesPerSet.
type DrawerImpl ¶
type DrawerImpl struct { // surface index for current render process SurfIndex uint32 // maximum number of images per pass -- set by user at config MaxTextures int // whether to render image with flipped Y FlipY bool // last draw operation used -- used for switching pipeline LastOp draw.Op }
DrawerImpl contains implementation state -- ignore..