engine: github.com/g3n/engine/renderer Index | Files | Directories

package renderer

import "github.com/g3n/engine/renderer"

Package renderer implements the scene renderer.

Index

Package Files

doc.go logger.go renderer.go shaman.go

Constants

const GLSL_VERSION = "330 core"

type ProgSpecs Uses

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

ProgSpecs represents a compiled shader program along with its specs

type Renderer Uses

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

Renderer renders a 3D scene and/or a 2D GUI on the current window.

func NewRenderer Uses

func NewRenderer(gs *gls.GLS) *Renderer

NewRenderer creates and returns a pointer to a new Renderer.

func (*Renderer) AddChunk Uses

func (r *Renderer) AddChunk(name, source string)

AddChunk adds a shader chunk with the specified name and source code.

func (*Renderer) AddDefaultShaders Uses

func (r *Renderer) AddDefaultShaders() error

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

func (*Renderer) AddProgram Uses

func (r *Renderer) AddProgram(name, vertex, frag string, others ...string)

AddProgram adds the program with the specified name, with associated vertex and fragment shaders (previously registered).

func (*Renderer) AddShader Uses

func (r *Renderer) AddShader(name, source string)

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

func (*Renderer) ObjectSorting Uses

func (r *Renderer) ObjectSorting() bool

ObjectSorting returns whether objects will be sorted before rendering.

func (*Renderer) Panel3D Uses

func (r *Renderer) Panel3D() gui.IPanel

Panel3D returns the current gui panel over the 3D scene.

func (*Renderer) Render Uses

func (r *Renderer) Render(icam camera.ICamera) (bool, error)

Render renders the previously set Scene and Gui using the specified camera. Returns an indication if anything was rendered and an error.

func (*Renderer) SetGui Uses

func (r *Renderer) SetGui(gui gui.IPanel)

SetGui sets the gui panel which contains the Gui to render. If set to nil, no Gui will be rendered.

func (*Renderer) SetGuiPanel3D Uses

func (r *Renderer) SetGuiPanel3D(panel3D gui.IPanel)

SetGuiPanel3D sets the gui panel inside which the 3D scene is shown. This informs the renderer that the Gui elements over this panel must be redrawn even if they didn't change. This panel panel must not be renderable, otherwise it will cover the 3D scene.

func (*Renderer) SetObjectSorting Uses

func (r *Renderer) SetObjectSorting(sort bool)

SetObjectSorting sets whether objects will be sorted before rendering.

func (*Renderer) SetScene Uses

func (r *Renderer) SetScene(scene core.INode)

SetScene sets the 3D scene to be rendered. If set to nil, no 3D scene will be rendered.

func (*Renderer) Stats Uses

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 Uses

type ShaderSpecs struct {
    Name             string             // Shader name
    Version          string             // GLSL version
    ShaderUnique     bool               // indicates if shader is independent of lights and textures
    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
    Defines          gls.ShaderDefines  // Additional shader defines
}

ShaderSpecs describes the specification of a compiled shader program

type Shaman Uses

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

Shaman is the shader manager

func NewShaman Uses

func NewShaman(gs *gls.GLS) *Shaman

NewShaman creates and returns a pointer to a new shader manager

func (*Shaman) AddChunk Uses

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

AddChunk adds a shader chunk with the specified name and source code

func (*Shaman) AddDefaultShaders Uses

func (sm *Shaman) AddDefaultShaders() error

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

func (*Shaman) AddProgram Uses

func (sm *Shaman) AddProgram(name, vertexName, fragName string, others ...string)

AddProgram adds a program with the specified name and associated vertex and fragment shaders names (previously registered)

func (*Shaman) AddShader Uses

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

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

func (*Shaman) GenProgram Uses

func (sm *Shaman) GenProgram(specs *ShaderSpecs) (*gls.Program, error)

GenProgram generates shader program from the specified specs

func (*Shaman) Init Uses

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

Init initializes the shader manager

func (*Shaman) SetProgram Uses

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

SetProgram sets the shader program to satisfy the specified specs. Returns an indication if the current shader has changed and a possible error when creating a new shader program. Receives a copy of the specs because it changes the fields which specify the number of lights depending on the UseLights flags.

type Stats Uses

type Stats struct {
    Graphics int // Number of graphic objects 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 object types were rendered. It is cleared at the start of each render.

Directories

PathSynopsis
shadersPackage shaders contains the several shaders used by the engine

Package renderer imports 15 packages (graph) and is imported by 4 packages. Updated 2018-08-17. Refresh now. Tools for package owners.