render

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 39 Imported by: 0

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

View Source
const (
	CursorModeNormal = 0
	CursorModeHidden = 1
)
View Source
const BackendName = "gogpu-wgpu"

Variables

This section is empty.

Functions

func BitmapTextSize

func BitmapTextSize(text string) (int, int)

func BitmapTextTopForCenter

func BitmapTextTopForCenter(containerH int) int

func DrawActorUILabels

func DrawActorUILabels(dst *Frame, labels []string, emblem *Image, centerX, y float64, foreground, outline color.RGBA)

func DrawBitmapTextAt

func DrawBitmapTextAt(dst *Frame, text string, x, y int)

func DrawBitmapTextAtColor

func DrawBitmapTextAtColor(dst *Frame, text string, x, y int, c color.RGBA)

func DrawCenteredUIOutlinedTextAt

func DrawCenteredUIOutlinedTextAt(dst *Frame, text string, centerX, y float64, foreground, outline color.RGBA)

func DrawCenteredUITextAt

func DrawCenteredUITextAt(dst *Frame, text string, centerX, y float64, foreground color.RGBA)

func DrawCenteredUITextAtSize added in v0.8.0

func DrawCenteredUITextAtSize(dst *Frame, text string, centerX, y float64, foreground color.RGBA, size float32, bold bool)

func DrawImageBitmapTextAtColor

func DrawImageBitmapTextAtColor(dst *Image, text string, x, y int, c color.RGBA)

func DrawImageRect

func DrawImageRect(dst *Image, x, y, w, h float64, c color.Color)

func DrawLine

func DrawLine(dst *Frame, x0, y0, x1, y1 float64, c color.Color)

func DrawOutlinedTextAt

func DrawOutlinedTextAt(dst *Frame, text string, x, y int, foreground, outline color.RGBA)

func DrawRect

func DrawRect(dst *Frame, x, y, w, h float64, c color.Color)

func DrawUIOutlinedTextAt

func DrawUIOutlinedTextAt(dst *Frame, text string, x, y float64, foreground, outline color.RGBA)

func DrawUIRect

func DrawUIRect(dst *Frame, x, y, w, h float64, c color.RGBA)

func DrawUISpeechBubble

func DrawUISpeechBubble(dst *Frame, text string, centerX, bottomY, maxWidth float64)

func DrawUITextAt

func DrawUITextAt(dst *Frame, text string, x, y float64, foreground color.RGBA)

func DrawUITooltip

func DrawUITooltip(dst *Frame, text string, centerX, belowY, aboveY float64)

func DrawUITooltipBox

func DrawUITooltipBox(dst *Frame, text string, centerX, belowY, aboveY, maxWidth float64, maxLines int)

func Run

func Run(game Game, cfg config.WindowConfig, renderCfg config.RenderConfig) error

func SetCursorMode

func SetCursorMode(mode int)

func SetUIFont

func SetUIFont(regular, bold []byte) error

SetUIFont installs the client UI font used for ordinary window text and, when provided, the bold face used by outlined actor names. It is intended for RO clients that ship System/Font/SCDream4.otf and SCDream6.otf.

func SnapScreenPoint

func SnapScreenPoint(dst *Frame, x, y float64) (float64, float64)

Types

type Address

type Address int
const (
	AddressUnsafe Address = iota
	AddressClampToZero
	AddressClampToEdge
	AddressRepeat
)

type Blend

type Blend int
const (
	BlendSourceOver Blend = iota
	BlendLighter
	BlendSrcAlphaDstAlpha
)

type Camera3D

type Camera3D struct {
	Enabled        bool
	ViewProjection [16]float32
	Fog            Fog3D
}

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 DrawTrianglesOptions struct {
	Filter     Filter
	Address    Address
	Blend      Blend
	DepthTest  bool
	DepthWrite bool
	DepthBias  float32
	DisableFog bool
}

type Filter

type Filter int
const (
	FilterNearest Filter = iota
	FilterLinear
)

type Fog3D

type Fog3D struct {
	Enabled  bool
	Near     float32
	Far      float32
	Strength float32
	ColorR   float32
	ColorG   float32
	ColorB   float32
}

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 NewFrame

func NewFrame(width, height int) *Frame

func (*Frame) BeginFrame

func (f *Frame) BeginFrame()

func (*Frame) Bounds

func (f *Frame) Bounds() image.Rectangle

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 (f *Frame) DrawWorldMesh(mesh *WorldMesh)

func (*Frame) Fill

func (f *Frame) Fill(c color.Color)

func (*Frame) SetCamera3D

func (f *Frame) SetCamera3D(camera Camera3D)

func (*Frame) SetScreenScale

func (f *Frame) SetScreenScale(x, y float32)

type Game

type Game interface {
	Update() error
	Draw(*Frame)
	Resize(width, height int)
	InputState() *input.State
}

type GeoM

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

func (*GeoM) Rotate

func (g *GeoM) Rotate(theta float64)

func (*GeoM) Scale

func (g *GeoM) Scale(sx, sy float64)

func (*GeoM) Translate

func (g *GeoM) Translate(tx, ty float64)

type Image

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

func NewImage

func NewImage(width, height int) *Image

func NewImageFromImage

func NewImageFromImage(src image.Image) *Image

func NewImageFromStraightAlpha

func NewImageFromStraightAlpha(src image.Image) *Image

func OutlinedTextImage

func OutlinedTextImage(text string, foreground, outline color.RGBA) *Image

func WhiteImage

func WhiteImage() *Image

func (*Image) Bounds

func (i *Image) Bounds() image.Rectangle

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)

func (*Image) Fill

func (i *Image) Fill(c color.Color)

func (*Image) RGBA

func (i *Image) RGBA() *image.RGBA

type UIActorLabelCommand

type UIActorLabelCommand struct {
	Labels     []string
	Emblem     *Image
	CenterX    float64
	Y          float64
	Foreground color.RGBA
	Outline    color.RGBA
	Size       float32
}

type UIRectCommand

type UIRectCommand struct {
	X, Y, W, H float64
	Color      color.RGBA
}

type UITextBoxAnchor

type UITextBoxAnchor int
const (
	UITextBoxAnchorTopLeft UITextBoxAnchor = iota
	UITextBoxAnchorBottomCenter
	UITextBoxAnchorTooltipCenter
)

type UITextBoxCommand

type UITextBoxCommand struct {
	Text     string
	X        float64
	Y        float64
	AltY     float64
	Anchor   UITextBoxAnchor
	MaxWidth float64
	MaxLines int
}

type UITextLabelCommand

type UITextLabelCommand struct {
	Text       string
	X          float64
	Y          float64
	Foreground color.RGBA
	Outline    color.RGBA
	Centered   bool
	Bold       bool
	Size       float32
}

type Vertex

type Vertex struct {
	DstX, DstY     float32
	SrcX, SrcY     float32
	ColorR, ColorG float32
	ColorB, ColorA float32
}

type Vertex3D

type Vertex3D struct {
	X, Y, Z                float32
	SrcX, SrcY             float32
	ColorR, ColorG         float32
	ColorB, ColorA         float32
	DepthX, DepthY, DepthZ float32
	LightSrcX, LightSrcY   float32
}

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 (m *WorldMesh) IndexCount() int

func (*WorldMesh) VertexCount

func (m *WorldMesh) VertexCount() int

type WorldMeshCommand

type WorldMeshCommand struct {
	Mesh *WorldMesh
}

Jump to

Keyboard shortcuts

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