surface

package
v0.0.0-...-4142f2f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

The surface package provides a virtual screen to render things to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RenderQueue

type RenderQueue struct {
	*wgpu.Device
	*wgpu.SwapChainDescriptor
	Textures map[textureHandle]*Texture
	// contains filtered or unexported fields
}

func NewRenderQueue

func NewRenderQueue(surface *Surface, d *wgpu.Device, scd *wgpu.SwapChainDescriptor) *RenderQueue

func (*RenderQueue) AddCircle

func (rq *RenderQueue) AddCircle(cx, cy int, radius float32, c color.Color, segments int) graphics.Shape

AddCircle creates a new Circle renderable and adds it to the RenderQueue. It returns a reference to the created Circle.

func (*RenderQueue) AddLine

func (rq *RenderQueue) AddLine(x1, y1, x2, y2 int, width float32, c color.Color) graphics.Shape

AddLine creates a new Line renderable and adds it to the RenderQueue. It returns a reference to the created Line.

func (*RenderQueue) AddPolygon

func (rq *RenderQueue) AddPolygon(cx, cy int, width float32, c color.Color, sides int) graphics.Shape

AddPolygon creates a new Polygon renderable and adds it to the RenderQueue. It returns a reference to the created Polygon.

func (*RenderQueue) AddRectangle

func (rq *RenderQueue) AddRectangle(x, y, width, height int, c color.Color) graphics.Shape

AddRectangle creates a new Rectangle renderable and adds it to the RenderQueue. It returns a reference to the created Rectangle.

func (*RenderQueue) AddToRenderQueue

func (rq *RenderQueue) AddToRenderQueue(r graphics.Renderable)

func (*RenderQueue) AddTriangle

func (rq *RenderQueue) AddTriangle(x1, y1, x2, y2, x3, y3 int, c color.Color) graphics.Shape

AddTriangle creates a new Triangle renderable and adds it to the RenderQueue. It returns a reference to the created Triangle.

func (*RenderQueue) CreateTextureFromImage

func (rq *RenderQueue) CreateTextureFromImage(img image.Image) (graphics.Texture, error)

func (*RenderQueue) DisposeTexture

func (rq *RenderQueue) DisposeTexture(h uintptr)

func (*RenderQueue) Pop

func (rq *RenderQueue) Pop() (graphics.Renderable, bool)

func (*RenderQueue) PrepareFrame

func (rq *RenderQueue) PrepareFrame()

func (*RenderQueue) RenderClear

func (rq *RenderQueue) RenderClear()

func (*RenderQueue) RenderFrame

func (rq *RenderQueue) RenderFrame(pass *wgpu.RenderPassEncoder)

func (*RenderQueue) UpdateTextureFromImage

func (rq *RenderQueue) UpdateTextureFromImage(texture graphics.Texture, img image.Image)

type Surface

type Surface struct {
	*gpu.Renderer
	*RenderQueue

	Width  int
	Height int
}

func New

func New(w, h int, win *window.Window) *Surface

func (*Surface) Destroy

func (s *Surface) Destroy()

func (*Surface) GetScreenSize

func (s *Surface) GetScreenSize() (int, int)

func (*Surface) GetSurfaceSize

func (s *Surface) GetSurfaceSize() (int, int)

func (*Surface) Resize

func (s *Surface) Resize(width, height uint32)

func (*Surface) SetScreenSize

func (s *Surface) SetScreenSize(w, h int)

func (*Surface) SetSurfaceSize

func (s *Surface) SetSurfaceSize(w, h int)

type Texture

type Texture struct {
	// contains filtered or unexported fields
}

func NewTexture

func NewTexture(surface *Surface, d *wgpu.Device, scd *wgpu.SwapChainDescriptor, img image.Image, renderQueue *RenderQueue) *Texture

func (*Texture) Clip

func (t *Texture) Clip(minX, minY, maxX, maxY float32)

func (*Texture) Dispose

func (t *Texture) Dispose()

func (*Texture) FlipHorizontal

func (t *Texture) FlipHorizontal()

func (*Texture) FlipVertical

func (t *Texture) FlipVertical()

func (*Texture) Handle

func (t *Texture) Handle() uintptr

func (*Texture) Hide

func (t *Texture) Hide()

func (*Texture) IsDisposed

func (t *Texture) IsDisposed() bool

func (*Texture) Move

func (t *Texture) Move(x, y float32)

func (*Texture) Render

func (t *Texture) Render()

func (*Texture) RenderPass

func (t *Texture) RenderPass(pass *wgpu.RenderPassEncoder)

func (*Texture) Resize

func (t *Texture) Resize(width, height float32)

func (*Texture) Rotate

func (t *Texture) Rotate(a, pivotX, pivotY float32)

func (*Texture) Scale

func (t *Texture) Scale(x, y float32)

func (*Texture) SetHandle

func (t *Texture) SetHandle(h textureHandle)

func (*Texture) SetShouldBeRendered

func (t *Texture) SetShouldBeRendered(shouldRender bool)

func (*Texture) UpdateImage

func (t *Texture) UpdateImage(img image.Image) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL