engine

package
v0.0.0-...-296174e Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FOV float64 = 90.0
)

Variables

This section is empty.

Functions

func Equal

func Equal(a, b float32) bool

func MergeChan

func MergeChan[T interface{}](left chan T, right chan T, c chan T, sort func(a, b T) bool)

func MergeSort

func MergeSort[T any](arr []T, ch chan T, sort func(a, b T) bool)

func ReadEvents

func ReadEvents(game *Game)

func ReadFile

func ReadFile(path string) primitives.Mesh

func Sort

func Sort[T interface{}](a []T, sort func(a, b T) bool) []T

func Swap

func Swap[T any](v1, v2 *T)

Types

type Camera

type Camera struct {
	object.UObject
}

func InitCamera

func InitCamera() *Camera

func (*Camera) GetDirection

func (c *Camera) GetDirection() *primitives.Vector3d

func (*Camera) GetView

func (camera *Camera) GetView() *primitives.Matrix4x4

type Event

type Event interface {
	Type() EventType
}

type EventType

type EventType string
const (
	Render     EventType = "Render"
	AddCommand EventType = "AddCommand"
	Quit       EventType = "Quit"
)

type Game

type Game struct {
	Width     int64
	Height    int64
	Renderer  *Renderer
	Camera    *Camera
	IsRunning bool

	DeltaTime time.Duration
	// contains filtered or unexported fields
}

func Init

func Init(width int64, height int64) (*Game, error)

func InitGame

func InitGame(width int64, height int64) (*Game, error)

func (*Game) FrameEnd

func (game *Game) FrameEnd()

func (*Game) FrameStart

func (game *Game) FrameStart()

func (*Game) HandleEvents

func (game *Game) HandleEvents()

func (*Game) Quit

func (game *Game) Quit()

func (*Game) Run

func (game *Game) Run(entities []*object.UObject)

func (*Game) RunCommands

func (game *Game) RunCommands()

type PipeLine

type PipeLine struct {
	Camera *Camera

	IsDebug bool
	// contains filtered or unexported fields
}

func NewPipeline

func NewPipeline(camera *Camera, renderer *Renderer, isDebug bool) *PipeLine

func (*PipeLine) ClipTriangles

func (pipe *PipeLine) ClipTriangles(tris []*primitives.Triangle) []*primitives.Triangle

func (PipeLine) Project

func (pipe PipeLine) Project(object object.Entity) []*primitives.Triangle

func (*PipeLine) RasterizeTriangles

func (pipe *PipeLine) RasterizeTriangles(tris []*primitives.Triangle, texture *primitives.Image)

func (PipeLine) Render

func (pipe PipeLine) Render(objects []*object.UObject)

type Queue

type Queue[T any] struct {
	Values chan T
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) Add

func (q *Queue[T]) Add()

func (*Queue[T]) Collect

func (q *Queue[T]) Collect() []T

func (*Queue[T]) Done

func (q *Queue[T]) Done()

func (*Queue[T]) ForEach

func (q *Queue[T]) ForEach(operand func(T))

func (*Queue[T]) Push

func (q *Queue[T]) Push(elem T)

type QuitEvent

type QuitEvent struct{}

func NewQuitEvent

func NewQuitEvent() *QuitEvent

func (QuitEvent) Type

func (c QuitEvent) Type() EventType

type Renderer

type Renderer struct {
	Window *sdl.Window

	ProjectionMatrix *primitives.Matrix4x4
	// contains filtered or unexported fields
}

func InitRenderer

func InitRenderer(width int64, height int64) (*Renderer, error)

func (*Renderer) Destroy

func (renderer *Renderer) Destroy()

func (*Renderer) DrawLine

func (renderer *Renderer) DrawLine(x1, y1, x2, y2 float64, color uint32)

func (*Renderer) DrawPixel

func (renderer *Renderer) DrawPixel(x, y, w float64, color uint32)

func (*Renderer) DrawTriangle

func (r *Renderer) DrawTriangle(tri *primitives.Triangle, texture *primitives.Image)

func (*Renderer) DrawTriangleWireframe

func (r *Renderer) DrawTriangleWireframe(t *primitives.Triangle, color color.Color)

func (*Renderer) Render

func (renderer *Renderer) Render()

func (*Renderer) SwapTextures

func (renderer *Renderer) SwapTextures()

type Signal

type Signal struct{}

type Texture

type Texture struct {
	Buffer      []uint32
	DepthBuffer [][]float64
	// contains filtered or unexported fields
}

func InitTexture

func InitTexture(renderer *sdl.Renderer, width, height int32) *Texture

func (*Texture) Clear

func (texture *Texture) Clear()

func (*Texture) ClearBuffer

func (texture *Texture) ClearBuffer()

func (*Texture) Destroy

func (texture *Texture) Destroy()

func (*Texture) DrawPixel

func (texture *Texture) DrawPixel(x, y int64, w float64, color uint32)

func (*Texture) Lock

func (texture *Texture) Lock()

func (*Texture) Unlock

func (texture *Texture) Unlock(renderer *sdl.Renderer)

Jump to

Keyboard shortcuts

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