graphics

package
v0.0.0-...-48f6ed3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2017 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NormalMatrixOrthoOrigo       = iota
	NormalMatrixOrthoScreenCords = iota
)

Normal matrix IDs

Variables

This section is empty.

Functions

func AddRenderGroup

func AddRenderGroup(g *RenderGroup) int

AddRenderGroup assigns an id to the manager and returns it. This is NOT threadsafe and should not be ran while the graphics loop is running for now

func DeinitMasterLoop

func DeinitMasterLoop()

DeinitMasterLoop deinits all rendergroups

func GenerateImageFromFont

func GenerateImageFromFont(text string, font *truetype.Font, fontSize float64) (*image.RGBA, error)

GenerateImageFromFont generates an image from string, font and size.

func GetNormalMatrix

func GetNormalMatrix(id int) mgl32.Mat4

GetNormalMatrix returns a precalculated normalMatrix

func GetTextureByID

func GetTextureByID(id string) (uint32, error)

GetTextureByID returns an opengl texture id identified by a string id.

func GetViewPortSize

func GetViewPortSize() mgl32.Vec2

GetViewPortSize returns the size of the rendering area

func InitMasterLoop

func InitMasterLoop()

InitMasterLoop must be called before starting the graphics system using Start().

func NewProgram

func NewProgram(vertexShaderSource, fragmentShaderSource string) (uint32, error)

NewProgram compiles a shader program som vertex and fragment sources Deprecated: will be removed at some points

func ReadFont

func ReadFont(fontFile string) (*truetype.Font, error)

ReadFont reads a file and returns a truetype Font object

func RegisterTextureFromFile

func RegisterTextureFromFile(id string, file string) (uint32, error)

RegisterTextureFromFile first checks the cache for the specified texture id, then it reads it from the file.

func RegisterTextureFromImage

func RegisterTextureFromImage(id string, img *image.RGBA) (uint32, error)

RegisterTextureFromImage first checks the cache for the specified texture id, then it creates one from the image.

func RemoveRenderGroup

func RemoveRenderGroup(id int)

RemoveRenderGroup removes the specified id. This is NOT threadsafe and should not be ran while the graphics loop is running for now

func Render

func Render()

Render the registered render groups

func SetClearColor

func SetClearColor(r, g, b, a float32)

SetClearColor sets the clear color.

func SetViewPortSize

func SetViewPortSize(x, y int)

SetViewPortSize sets the size of the rendering area.

Types

type RenderGroup

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

RenderGroup implements basic shading handling

func GetRenderGroup

func GetRenderGroup(id int) *RenderGroup

GetRenderGroup returns the specified manager

func NewRenderGroup

func NewRenderGroup(id string, impl RenderGroupImplementation) *RenderGroup

NewRenderGroup creates a RenderGroup.

func (*RenderGroup) Deinit

func (g *RenderGroup) Deinit()

Deinit calls the initer to deinitiate

func (*RenderGroup) GetShaderProgram

func (g *RenderGroup) GetShaderProgram() uint32

GetShaderProgram returns the shader pgm

func (*RenderGroup) Render

func (g *RenderGroup) Render()

Render activates the shader program and calls the renderer

func (*RenderGroup) SetBlendingMode

func (g *RenderGroup) SetBlendingMode(enabled bool, blendFunc1, blendFunc2 uint32)

SetBlendingMode sets the blending mode used when rendering this group

func (*RenderGroup) SetDepthTestMode

func (g *RenderGroup) SetDepthTestMode(enabled bool, depthFunc uint32)

SetDepthTestMode sets the depth test details used when rendering this group

func (*RenderGroup) SetShaderFile

func (g *RenderGroup) SetShaderFile(shaderFile string)

SetShaderFile sets the shader file according to file ending. possible endings: .frag or .vert The programs are not compiled until the first time they are run. The reason it does not compile the programs is to stay away from the graphics thread's business

type RenderGroupImplementation

type RenderGroupImplementation interface {

	// Deinit deallocates any resources
	Deinit()

	InitShader()

	Render()
}

RenderGroupImplementation is an actual implementation of a render group

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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