renderer

package
v0.2.87 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package renderer implements the scene renderer.

Index

Constants

View Source
const GLSL_VERSION = "330 core"

Variables

This section is empty.

Functions

This section is empty.

Types

type Renderer

type Renderer struct {
	Shaman // Embedded shader manager
	// contains filtered or unexported fields
}

Renderer renders a scene containing 3D objects and/or 2D GUI elements.

func NewRenderer

func NewRenderer(gs *gls.GLS) *Renderer

NewRenderer creates and returns a pointer to a new Renderer.

func (*Renderer) ObjectSorting

func (r *Renderer) ObjectSorting() bool

ObjectSorting returns whether objects will be sorted before rendering.

func (*Renderer) Render

func (r *Renderer) Render(scene core.INode, cam camera.ICamera) error

Render renders the specified scene using the specified camera. Returns an error.

func (*Renderer) SetObjectSorting

func (r *Renderer) SetObjectSorting(sort bool)

SetObjectSorting sets whether objects will be sorted before rendering.

func (*Renderer) Stats

func (r *Renderer) Stats() Stats

Stats returns a copy of the statistics for the last frame. Should be called after the frame was rendered.

type ShaderSpecs

type ShaderSpecs struct {
	Name             string              // Shader name
	UseLights        material.UseLights  // Bitmask indicating which lights to consider
	AmbientLightsMax int                 // Current number of ambient lights
	DirLightsMax     int                 // Current Number of directional lights
	PointLightsMax   int                 // Current Number of point lights
	SpotLightsMax    int                 // Current Number of spot lights
	MatTexturesMax   int                 // Current Number of material textures
	MaterialDefines  gls.MaterialDefines // Additional shader defines
	GeometryDefines  gls.GeometryDefines // Additional shader defines
	GraphicDefines   gls.GraphicDefines  // Additional shader defines
}

ShaderSpecs describes the specification of a compiled shader program

type Shaman

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

Shaman is the shader manager

func (*Shaman) AddDefaultShaders

func (sm *Shaman) AddDefaultShaders() error

AddDefaultShaders adds to this shader manager all default include chunks, shaders and programs statically registered.

func (*Shaman) AddProgram

func (sm *Shaman) AddProgram(name, vertex, fragment, geometry string)

AddProgram adds a program with the specified name and associated vertex, fragment, and geometry shader names.

The geometry shader is optional. An empty string means no geometry shader should be used.

func (*Shaman) AddShader

func (sm *Shaman) AddShader(name, source string)

AddShader adds a shader program with the specified name and source code.

func (*Shaman) Init

func (sm *Shaman) Init(gs *gls.GLS)

Init initializes the shader manager

func (*Shaman) NewFrame added in v0.2.81

func (sm *Shaman) NewFrame()

func (*Shaman) SetProgram

func (sm *Shaman) SetProgram(specs ShaderSpecs) (bool, error)

SetProgram sets the shader program to satisfy the specs.

Returns whether this is the first time this program was activated this frame and an error if one occurred.

type Stats

type Stats struct {
	GraphicMats int // Number of graphic materials rendered
	Lights      int // Number of lights rendered
	Panels      int // Number of GUI panels rendered
	Others      int // Number of other objects rendered
}

Stats describes how many objects of each type are being rendered. It is cleared at the start of each render.

Directories

Path Synopsis
Package shaders contains the several shaders used by the engine
Package shaders contains the several shaders used by the engine

Jump to

Keyboard shortcuts

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