Documentation ¶
Overview ¶
Package render mostly agnostic gl renderer with a couple of exceptions due to some limitations
It will listen for ECS events
Index ¶
- func BlendEnum(n gorge.BlendEnum) gl.Enum
- func BlendEq(n gorge.BlendEq) gl.Enum
- func CullMask(n gorge.CullMaskFlags) gorge.CullMaskFlags
- func DrawMode(d gorge.DrawMode) gl.Enum
- func StencilFunc(n gorge.StencilFunc) gl.Enum
- func StencilOp(n gorge.StencilOp) gl.Enum
- func System(g *gorge.Context)
- func TextureFormat(n gorge.TextureFormat) (int, gl.Enum, gl.Enum)
- func TextureWrap(n gorge.TextureWrap) int
- type Bufferer
- type Camera
- type Component
- type Context
- type EventStat
- type Light
- type Queue
- type Render
- func (r *Render) AddCamera(camera Camera)
- func (r *Render) AddLight(light Light)
- func (r *Render) AddRenderable(re Renderable)
- func (r *Render) Draw(mode gl.Enum, v *VBO, count uint32)
- func (r *Render) GetVBO(mesh *gorge.Mesh) *VBO
- func (r *Render) Gorge() *gorge.Context
- func (r *Render) Init()
- func (r *Render) NewBuffer(target, usage gl.Enum) Bufferer
- func (r *Render) NewShader(gs *gorge.ShaderData) *Shader
- func (r *Render) PassShadow(ri *Step, s *Shader)
- func (r *Render) RemoveCamera(camera Camera)
- func (r *Render) RemoveLight(light Light)
- func (r *Render) RemoveRenderable(re Renderable)
- func (r *Render) Render()
- func (r *Render) SetInitStage(s StepFunc)
- func (r *Render) SetRenderStage(s StepFunc)
- func (r *Render) SetupShader(ri *Step, re Renderable)
- type Renderable
- type RenderableGroup
- func (rg *RenderableGroup) Add(r Renderable)
- func (rg *RenderableGroup) Destroy()
- func (rg *RenderableGroup) Front() Renderable
- func (rg *RenderableGroup) Remove(r Renderable)
- func (rg *RenderableGroup) Renderable() *gorge.RenderableComponent
- func (rg *RenderableGroup) Update(s *Step)
- func (rg *RenderableGroup) VAO(shader *Shader) gl.VertexArray
- func (rg *RenderableGroup) VBO() *VBO
- type Shader
- type Step
- type StepFunc
- type Texture
- type VBO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CullMask ¶
func CullMask(n gorge.CullMaskFlags) gorge.CullMaskFlags
CullMask returns a bit CullMask if it's 0 it will return the default mask 0xFF
func DrawMode ¶
DrawMode converts gorge DrawMode into gl POINTS = 0x0000 LINES = 0x0001 LINE_LOOP = 0x0002 LINE_STRIP = 0x0003 TRIANGLES = 0x0004 TRIANGLE_STRIP = 0x0005 TRIANGLE_FAN = 0x0006
func StencilFunc ¶
func StencilFunc(n gorge.StencilFunc) gl.Enum
StencilFunc converts gorge stencil to opengl enum.
func TextureFormat ¶
TextureFormat returns the internal format and format enum for gl.TexImage2D
func TextureWrap ¶
func TextureWrap(n gorge.TextureWrap) int
TextureWrap converts gorge textureWrap to gl.
Types ¶
type Bufferer ¶
type Bufferer interface { ID() gl.Buffer Init(sz int) Destroy() Bind() WriteAt(data []byte, offs int) Flush() Size() int }
Bufferer interface to handle renderer buffer
type Camera ¶
type Camera interface { Mat4() gm.Mat4 Camera() *gorge.CameraComponent }
Camera interface for accepting camera structs
type Component ¶
type Component struct {
Draw func()
}
Component component to be injected in entities for manual rendering. TODO: {lpf} useless for now.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context rendering context to be used on gorge systems.
func FromContext ¶
FromContext returns a Context from gorge Context triggers an error and returns nil if doesn't exists.
type EventStat ¶
type EventStat struct { VAOs int VBOs int Textures int Shaders int Instances int Buffers int RenderDuration time.Duration DrawCalls int }
EventStat track gpu resources for debugging
type Light ¶
type Light interface { Mat4() gm.Mat4 Light() *gorge.LightComponent }
Light interface for light composition
type Render ¶
type Render struct { Cameras setlist.SetList[Camera] Lights setlist.SetList[Light] Renderables []*RenderableGroup DrawCalls int DisableRender bool // Or Renderer Render InitStage StepFunc RenderStage StepFunc // contains filtered or unexported fields }
Render thing
func (*Render) AddRenderable ¶
func (r *Render) AddRenderable(re Renderable)
AddRenderable adds a renderable instance
func (*Render) Init ¶
func (r *Render) Init()
Init initializes the renderer by calling the proper stages and etc...
func (*Render) NewShader ¶
func (r *Render) NewShader(gs *gorge.ShaderData) *Shader
NewShader returns a shader based on ShaderData
func (*Render) PassShadow ¶
PassShadow passes geometry with a specific shader TODO: we are checking DisableShadow here
func (*Render) RemoveCamera ¶
RemoveCamera removes a specific camera if exists.
func (*Render) RemoveRenderable ¶
func (r *Render) RemoveRenderable(re Renderable)
RemoveRenderable remove to renderable renderable
func (*Render) SetInitStage ¶
SetInitStage sets Init stage for renderer, used to prepare stuff.
func (*Render) SetRenderStage ¶
SetRenderStage sets the renderer stage.
func (*Render) SetupShader ¶
func (r *Render) SetupShader( ri *Step, re Renderable, )
SetupShader sets the current material uniforms
TODO: {lpf} Maybe set on renderable only since we could use it in render pipeline to draw the sky box
type Renderable ¶
type Renderable interface { Mat4() gm.Mat4 Renderable() *gorge.RenderableComponent }
Renderable the renderer renderable component interface.
type RenderableGroup ¶
type RenderableGroup struct { // Instances Instances setlist.SetList[Renderable] // Count is the number of ACTIVE renderable in this group Count uint32 // contains filtered or unexported fields }
RenderableGroup represents instance set of renderables
func (*RenderableGroup) Add ¶
func (rg *RenderableGroup) Add(r Renderable)
Add adds a new instance to this set.
func (*RenderableGroup) Destroy ¶
func (rg *RenderableGroup) Destroy()
Destroy unreferences all resources on this group.
func (*RenderableGroup) Front ¶
func (rg *RenderableGroup) Front() Renderable
Front returns the first Renderable on this group.
func (*RenderableGroup) Remove ¶
func (rg *RenderableGroup) Remove(r Renderable)
Remove removes an instance from this set.
func (*RenderableGroup) Renderable ¶
func (rg *RenderableGroup) Renderable() *gorge.RenderableComponent
Renderable returns the renderable component for this instance.
func (*RenderableGroup) Update ¶
func (rg *RenderableGroup) Update(s *Step)
Update updates any related gpu buffer on the group based on pass we update the group with the pass render number which might be updated
func (*RenderableGroup) VAO ¶
func (rg *RenderableGroup) VAO(shader *Shader) gl.VertexArray
VAO returns an existing VAO for shader hash, if vao doesn't exists it will create one and bind attributes there might be different VAO's per shader as some shaders might not care for normals vertexbuffers etc.
type Shader ¶
type Shader struct { Name string // debug purposes // contains filtered or unexported fields }
Shader handle gl program, it holds a local State
type Step ¶
type Step struct { RenderNumber int Viewport gm.Vec4 CameraUBO *bufutil.NamedOffset // Current rendering camera. Camera Camera Lights []Light QueuesIndex []int Queues map[int]*Queue StencilDirty bool // Global specified uniforms, could be fetch from camera // or directly on props Projection gm.Mat4 View gm.Mat4 CamPos gm.Vec3 Ambient gm.Vec3 // Global props that will be set in every material // As in, defaults Ubos map[string]gl.Buffer Props map[string]any Samplers map[string]*Texture }
Step holds information about a render Step.
type Texture ¶
type Texture struct { ID gl.Texture Type gl.Enum // gl.TEXTURE_2D, gl.TEXTURE_CUBE etc.. defaults to 2D // contains filtered or unexported fields }
Texture is a opengl texture controller
type VBO ¶
type VBO struct { Format gorge.VertexFormat FrontFacing gorge.FrontFacing ElementsLen uint32 ElementsType gl.Enum VertexLen uint32 // contains filtered or unexported fields }
VBO vertexBufferObject.
func (*VBO) BindAttribs ¶
BindAttribs Back named attribs please
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package bufutil provides means to cache and write into underlying gpu buffers
|
Package bufutil provides means to cache and write into underlying gpu buffers |
nolint: revive
|
nolint: revive |
Package renderpl contains default rendering pipeline for gorge
|
Package renderpl contains default rendering pipeline for gorge |