Documentation
¶
Overview ¶
Package render wraps the gogpu backend and provides drawing primitives used by game.
Image is CPU texture data. Frame is a per-frame command buffer consumed by the gogpu renderer. The package should draw submitted data without owning Ragnarok map, actor, input, or UI behavior.
Index ¶
- Constants
- func BitmapTextSize(text string) (int, int)
- func DrawActorUILabels(dst *Frame, labels []string, emblem *Image, centerX, y float64, ...)
- func DrawBitmapTextAtColor(dst *Frame, text string, x, y int, c color.RGBA)
- func DrawCenteredUIOutlinedTextAt(dst *Frame, text string, centerX, y float64, foreground, outline color.RGBA)
- func DrawCenteredUITextAt(dst *Frame, text string, centerX, y float64, foreground color.RGBA)
- func DrawCenteredUITextAtSize(dst *Frame, text string, centerX, y float64, foreground color.RGBA, ...)
- func DrawImageBitmapTextAtColor(dst *Image, text string, x, y int, c color.RGBA)
- func DrawOutlinedTextAt(dst *Frame, text string, x, y int, foreground, outline color.RGBA)
- func DrawRect(dst *Frame, x, y, w, h float64, c color.Color)
- func DrawUISpeechBubble(dst *Frame, text string, centerX, bottomY, maxWidth float64)
- func DrawUITextAt(dst *Frame, text string, x, y float64, foreground color.RGBA)
- func DrawUITextBanner(dst *Frame, text string, centerX, y, maxWidth float64, foreground color.RGBA, ...)
- func DrawUITooltipBox(dst *Frame, text string, centerX, belowY, aboveY, maxWidth float64, ...)
- func Run(game Game, cfg config.WindowConfig, renderCfg config.RenderConfig) error
- func RunHeadless(ctx context.Context, game Game, cfg config.WindowConfig) error
- func SetCursorMode(mode int)
- func SetUIFont(regular, bold []byte) error
- func SnapScreenPoint(dst *Frame, x, y float64) (float64, float64)
- type Address
- type Blend
- type Camera3D
- type ColorScale
- type DrawCommand
- type DrawImageOptions
- type DrawTrianglesOptions
- type Filter
- type Fog3D
- type Frame
- func (f *Frame) BeginFrame()
- func (f *Frame) Bounds() image.Rectangle
- func (f *Frame) DrawImage(src *Image, opts *DrawImageOptions)
- func (f *Frame) DrawTriangles(vertices []Vertex, indices []uint16, texture *Image, ...)
- func (f *Frame) DrawTriangles3D(vertices []Vertex3D, indices []uint16, texture *Image, ...)
- func (f *Frame) DrawTriangles3DOwned(vertices []Vertex3D, indices []uint16, texture *Image, ...)
- func (f *Frame) DrawTrianglesOwned(vertices []Vertex, indices []uint16, texture *Image, ...)
- func (f *Frame) DrawWorldBillboard(cmd WorldBillboardCommand)
- func (f *Frame) DrawWorldMesh(mesh *WorldMesh)
- func (f *Frame) Fill(c color.Color)
- func (f *Frame) PrepareImage(img *Image)
- func (f *Frame) SetCamera3D(camera Camera3D)
- func (f *Frame) SetScreenScale(x, y float32)
- type Game
- type GeoM
- type Image
- func (i *Image) Bounds() image.Rectangle
- func (i *Image) ByteSize() int
- func (i *Image) DrawImage(src *Image, opts *DrawImageOptions)
- func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, texture *Image, ...)
- func (i *Image) DrawTriangles3D(vertices []Vertex3D, indices []uint16, texture *Image, ...)
- func (i *Image) DrawTriangles3DOwned(vertices []Vertex3D, indices []uint16, texture *Image, ...)
- func (i *Image) DrawTrianglesOwned(vertices []Vertex, indices []uint16, texture *Image, ...)
- func (i *Image) Fill(c color.Color)
- func (i *Image) RGBA() *image.RGBA
- type ImageGroup
- type UIActorLabelCommand
- type UITextBoxAnchor
- type UITextBoxCommand
- type UITextLabelCommand
- type Vertex
- type Vertex3D
- type WorldBillboardCommand
- type WorldCommand
- type WorldMesh
- type WorldMeshCommand
Constants ¶
const ( CursorModeNormal = 0 CursorModeHidden = 1 )
const BackendName = "gogpu-wgpu"
Variables ¶
This section is empty.
Functions ¶
func BitmapTextSize ¶
func DrawActorUILabels ¶
func DrawBitmapTextAtColor ¶
func DrawCenteredUITextAt ¶
func DrawCenteredUITextAtSize ¶ added in v0.8.0
func DrawOutlinedTextAt ¶
func DrawUISpeechBubble ¶
func DrawUITextBanner ¶ added in v0.13.0
func DrawUITextBanner(dst *Frame, text string, centerX, y, maxWidth float64, foreground color.RGBA, size float32, bold bool)
DrawUITextBanner wraps and draws text together with its translucent background using the same font metrics, cached at the display's resolution.
func DrawUITooltipBox ¶
func Run ¶
func Run(game Game, cfg config.WindowConfig, renderCfg config.RenderConfig) error
func RunHeadless ¶ added in v0.13.0
RunHeadless runs the normal frame lifecycle without a window or GPU. Frame records CPU-side commands; the headless renderer discards them.
func SetCursorMode ¶
func SetCursorMode(mode int)
Types ¶
type ColorScale ¶
type ColorScale struct {
// contains filtered or unexported fields
}
func (*ColorScale) Scale ¶
func (c *ColorScale) Scale(r, g, b, a float32)
func (*ColorScale) ScaleAlpha ¶
func (c *ColorScale) ScaleAlpha(a float32)
type DrawCommand ¶
type DrawCommand struct {
Vertices []Vertex
Indices []uint16
Texture *Image
Options DrawTrianglesOptions
}
type DrawImageOptions ¶
type DrawImageOptions struct {
GeoM GeoM
ColorScale ColorScale
Filter Filter
Blend Blend
}
type DrawTrianglesOptions ¶
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame is the per-frame screen target. It owns draw command buffers and frame-only state; Image is only CPU texture data.
func (*Frame) BeginFrame ¶
func (f *Frame) BeginFrame()
func (*Frame) DrawImage ¶
func (f *Frame) DrawImage(src *Image, opts *DrawImageOptions)
func (*Frame) DrawTriangles ¶
func (f *Frame) DrawTriangles(vertices []Vertex, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
func (*Frame) DrawTriangles3D ¶
func (f *Frame) DrawTriangles3D(vertices []Vertex3D, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
func (*Frame) DrawTriangles3DOwned ¶
func (f *Frame) DrawTriangles3DOwned(vertices []Vertex3D, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
func (*Frame) DrawTrianglesOwned ¶
func (f *Frame) DrawTrianglesOwned(vertices []Vertex, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
func (*Frame) DrawWorldBillboard ¶
func (f *Frame) DrawWorldBillboard(cmd WorldBillboardCommand)
func (*Frame) DrawWorldMesh ¶
func (*Frame) PrepareImage ¶ added in v0.15.0
PrepareImage uploads a texture with this frame without drawing it. Callers wait for FrameSubmitted before considering the upload complete.
func (*Frame) SetCamera3D ¶
func (*Frame) SetScreenScale ¶
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
func NewImageFromImage ¶
func NewImageWithMipmaps ¶ added in v0.19.0
NewImageWithMipmaps prepares a static texture for minification. Call it while loading assets, before uploading to the GPU. Drawing into it drops the mipmaps.
func WhiteImage ¶
func WhiteImage() *Image
func (*Image) ByteSize ¶ added in v0.19.0
ByteSize includes all pixels that must be uploaded, including mip levels.
func (*Image) DrawImage ¶
func (i *Image) DrawImage(src *Image, opts *DrawImageOptions)
func (*Image) DrawTriangles ¶
func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
func (*Image) DrawTriangles3D ¶
func (i *Image) DrawTriangles3D(vertices []Vertex3D, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
func (*Image) DrawTriangles3DOwned ¶
func (i *Image) DrawTriangles3DOwned(vertices []Vertex3D, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
func (*Image) DrawTrianglesOwned ¶
func (i *Image) DrawTrianglesOwned(vertices []Vertex, indices []uint16, texture *Image, opts *DrawTrianglesOptions)
type ImageGroup ¶ added in v0.15.0
type ImageGroup struct {
// contains filtered or unexported fields
}
ImageGroup owns images with a common lifetime, such as a map's textures. Like Image and Frame, it is used on the game/render thread.
func (*ImageGroup) Add ¶ added in v0.15.0
func (g *ImageGroup) Add(img *Image) *Image
Add takes ownership of a newly created image. An image belongs to at most one group and must not be used after that group is released.
func (*ImageGroup) Release ¶ added in v0.15.0
func (g *ImageGroup) Release()
Release drops CPU pixels immediately. The renderer destroys uploaded textures and their bind groups before its next frame, on the GPU thread.
type UIActorLabelCommand ¶
type UITextBoxAnchor ¶
type UITextBoxAnchor int
const ( UITextBoxAnchorTopLeft UITextBoxAnchor = iota UITextBoxAnchorBottomCenter UITextBoxAnchorTooltipCenter UITextBoxAnchorTopCenter )
type UITextBoxCommand ¶
type UITextLabelCommand ¶
type WorldBillboardCommand ¶
type WorldBillboardCommand struct {
Texture *Image
Options DrawTrianglesOptions
Center [3]float32
RightAxis [3]float32
UpAxis [3]float32
DepthUpAxis [3]float32
Width float32
Height float32
AnchorX float32
AnchorY float32
ColorR float32
ColorG float32
ColorB float32
ColorA float32
DepthBias float32
}
type WorldCommand ¶
type WorldCommand struct {
Vertices []Vertex3D
Indices []uint16
Texture *Image
LightTexture *Image
Options DrawTrianglesOptions
}
type WorldMesh ¶
type WorldMesh struct {
// contains filtered or unexported fields
}
func NewWorldMesh ¶
func NewWorldMesh(vertices []Vertex3D, indices []uint16, texture *Image, opts *DrawTrianglesOptions) *WorldMesh
func NewWorldMeshWithLightmap ¶
func NewWorldMeshWithLightmap(vertices []Vertex3D, indices []uint16, texture, lightTexture *Image, opts *DrawTrianglesOptions) *WorldMesh
func (*WorldMesh) IndexCount ¶
func (*WorldMesh) VertexCount ¶
type WorldMeshCommand ¶
type WorldMeshCommand struct {
Mesh *WorldMesh
}
Source Files
¶
- backend.go
- cpu_raster.go
- cursor.go
- doc.go
- frame.go
- frame_commands.go
- gamepad.go
- gpu_bloom.go
- gpu_frame.go
- gpu_renderer.go
- gpu_shaders.go
- gpu_ssao.go
- gpu_targets.go
- gpu_world_mesh_batch.go
- gpu_world_mesh_buffer.go
- gpu_world_pass.go
- headless.go
- image.go
- image_draw.go
- image_group.go
- image_mipmap.go
- primitives.go
- types.go
- ui_async.go
- ui_image_canvas.go
- window_provider.go
- world_mesh.go