Documentation ¶
Index ¶
- Constants
- 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) ConfigImageName(name string, fmt *vgpu.ImageFormat)
- func (dw *Drawer) ConfigMtxs(src2dst mat32.Mat3, 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) DestSize() image.Point
- func (dw *Drawer) Destroy()
- func (dw *Drawer) Draw(idx, layer int, src2dst mat32.Mat3, sr image.Rectangle, op draw.Op, flipY bool) error
- func (dw *Drawer) EndDraw()
- func (dw *Drawer) EndFill()
- func (dw *Drawer) Fill(clr color.Color, src2dst mat32.Mat3, reg image.Rectangle, op draw.Op) error
- func (dw *Drawer) FillRect(clr color.Color, reg image.Rectangle, op draw.Op) error
- func (dw *Drawer) GetImageVal(idx int) *vgpu.Val
- func (dw *Drawer) ImageIdxByName(name string) 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, fb *vgpu.Framebuffer)
- 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(descIdx int)
- func (dw *Drawer) StartFill()
- func (dw *Drawer) SyncImages()
- func (dw *Drawer) UseTextureSet(descIdx 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 ¶
This section is empty.
Types ¶
type Drawer ¶
type Drawer struct { // drawing system Sys vgpu.System `desc:"drawing system"` // surface if render target Surf *vgpu.Surface `desc:"surface if render target"` // render frame if render target Frame *vgpu.RenderFrame `desc:"render frame if render target"` // 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 `` /* 265-byte string literal not displayed */ // implementation state -- ignore Impl DrawerImpl `desc:"implementation state -- ignore"` // [view: -] mutex on updating UpdtMu sync.Mutex `view:"-" copy:"-" json:"-" xml:"-" desc:"mutex on updating"` }
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) 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 mat32.Mat3, 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) Draw ¶
func (dw *Drawer) Draw(idx, layer int, src2dst mat32.Mat3, 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 ¶
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) GetImageVal ¶ added in v1.0.4
GetImageVal returns vgpu Val value of Image for given index
func (*Drawer) ImageIdxByName ¶
ImageIdxByName returns index of image val by name. Logs error if not found, and returns 0.
func (*Drawer) Scale ¶
func (dw *Drawer) Scale(idx, layer int, dr image.Rectangle, sr image.Rectangle, op draw.Op, flipY bool) 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.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) SelectPipeline ¶ added in v1.0.0
SelectPipeline selects the pipeline based on draw op only changes if not last one used. Default is Src
func (*Drawer) SetFrameImage ¶
func (dw *Drawer) SetFrameImage(idx int, fb *vgpu.Framebuffer)
SetFrameImage sets given 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. descIdx is the descriptor set to use -- choose this based on the bank of 16 texture values if number of textures > MaxTexturesPerSet.
func (*Drawer) StartFill ¶
func (dw *Drawer) StartFill()
StartFill starts color fill drawing rendering process on render target
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 SurfIdx uint32 `desc:"surface index for current render process"` // maximum number of images per pass -- set by user at config MaxTextures int `desc:"maximum number of images per pass -- set by user at config"` // whether to render image with flipped Y FlipY bool `desc:"whether to render image with flipped Y"` // last draw operation used -- used for switching pipeline LastOp draw.Op `desc:"last draw operation used -- used for switching pipeline"` }
DrawerImpl contains implementation state -- ignore..