Documentation ¶
Overview ¶
Package glman is manage complex 3D objects for render with opengl. for example font, text, shapes and particle system.
the standard coordinate system is left-handed, the floor plane is x-y, the above is negtive z.
|/ 0 ---------- x+ - 0 ------- x+ | /| | / | | / z+ | y+ y+
the standard culling settings is front=CW, back=CCW
1 -- 3 -- 5 -- | \ | \ | \ | \ | \ | \ 0 -- 2 -- 4 --
Index ¶
- Variables
- func DbgCheckError()
- func DynDrawImageRect(rect Rect, color Color)
- func DynDrawRect(rect Rect, color Color, lineWidth float32)
- func DynDrawRectEx(rect Rect, color Color, szLeft, szRight, szTop, szBottom float32)
- func DynDrawText(s string, rect Rect, font Font, color Color, options OptionDrawText)
- func DynFillRect(rect Rect, color Color)
- func OSVersion() (s string)
- func Routine()
- func SetViewport(rc Rect)
- type Clip2DStack
- type Color
- type Font
- type Image
- type MText
- type Mat4
- type Model
- type Mtl
- type MtlInfo
- type OptionDrawText
- type Program
- func (p *Program) IsCurrentProgram() bool
- func (p *Program) LoadClip2DStack()
- func (p *Program) LoadMStack()
- func (p *Program) LoadMVPStack()
- func (p *Program) LoadVPStack()
- func (p *Program) SetMVP(model, view, projection Mat4, transpose bool)
- func (p *Program) SetMVPfv(model, view, projection *float32, transpose bool)
- func (p *Program) UseProgram()
- type Provider
- type Rect
- type Res
- type Vec2
- type Vec3
- type Vec4
Constants ¶
This section is empty.
Variables ¶
var ( // StackMatP is matrix stack for projection StackMatP = geom.Mat4Stack{geom.Mat4Ident()} // StackMatV is matrix stack for view/camera StackMatV = geom.Mat4Stack{geom.Mat4Ident()} // StackMatM is matrix stack for model StackMatM = geom.Mat4Stack{geom.Mat4Ident()} // StackClip2D is stack for 2D clipping StackClip2D = Clip2DStack([]Rect{infClipRect}) )
var ( // MtlIndex is index of materials MtlIndex = make(map[string]*MtlInfo) )
Functions ¶
func DbgCheckError ¶
func DbgCheckError()
DbgCheckError invoke glGetError and verify the return code, panic if got a error
func DynDrawImageRect ¶
DynDrawImageRect fill rectangle
func DynDrawRect ¶
DynDrawRect draw rectangle
func DynDrawRectEx ¶
DynDrawRectEx draw rectangle
func DynDrawText ¶
func DynDrawText(s string, rect Rect, font Font, color Color, options OptionDrawText)
DynDrawText draw text
Types ¶
type Clip2DStack ¶
type Clip2DStack []Rect
Clip2DStack stack type for 2D clipping
func (*Clip2DStack) LoadInf ¶
func (s *Clip2DStack) LoadInf(rect Rect)
LoadInf load a very large rect, make it act as no clip at all. the components is large numbers, not realy INF.
type Color ¶
type Color [4]float32
Color is floating point color
func (Color) RGBA ¶
RGBA returns the alpha-premultiplied red, green, blue and alpha values for the color. Each value ranges within [0, 0xffff], but is represented by a uint32 so that multiplying by a blend factor up to 0xffff will not overflow.
An alpha-premultiplied color component c has been scaled by alpha (a), so has valid values 0 <= c <= a.
implement image/color.Color interface.
type Font ¶
type Font string
Font descriptor, i.e."Arial(Bold) 20", "Monospace 24". if the program don't know such font, it will fallback to default font. it's discourage make Font from a string by hand, use LoadFont instead.
type MText ¶
type MText interface { Render() Colors() []Color SetColors(c ...Color) DrawEdge() bool SetDrawEdge(b bool) Text() string }
MText is text model
type MtlInfo ¶
type MtlInfo struct { Diffuse [3]float32 Ambient [3]float32 Specular [3]float32 Emissive [3]float32 SpecularPower float32 Alpha float32 RenderMode uint32 MapDiffuse string MapSpecular string MapBump string MapAlpha string }
MtlInfo is surface material
type OptionDrawText ¶
type OptionDrawText int
OptionDrawText is options for draw text
const ( DtTop OptionDrawText = 0x00000000 DtLeft OptionDrawText = 0x00000000 DtCenter OptionDrawText = 0x00000001 DtRight OptionDrawText = 0x00000002 DtVCenter OptionDrawText = 0x00000004 DtBottom OptionDrawText = 0x00000008 DtSingleLine OptionDrawText = 0x00000010 )
options for draw text
type Program ¶
type Program struct { // ID of program ID uint32 // attribute location for vertesx shader AttPos int32 `attrib:"attPos"` AttTC int32 `attrib:"attTC"` AttNorm int32 `attrib:"attNorm"` AttColor int32 `attrib:"attColor"` // uniform location for vertesx shader UniMatP int32 `uniform:"uniMatP"` UniMatV int32 `uniform:"uniMatV"` UniMatM int32 `uniform:"uniMatM"` // sampler uniform for fragment shader UniTex0 int32 `uniform:"uniTex0"` UniTex1 int32 `uniform:"uniTex1"` UniColors int32 `uniform:"uniColors"` UniClip2D int32 `uniform:"uniClip2D"` UniTexSize int32 `uniform:"uniTexSize"` }
Program wrap shader program
func LoadProgram ¶
LoadProgram load and link shaders into program, cached in memory.
func MustLoadProgram ¶
MustLoadProgram load and link shaders into program, cached in memory. panics if failed.
func UseProgSimpleDraw ¶
func UseProgSimpleDraw() (p *Program)
UseProgSimpleDraw load and use the simple draw program
func UseProgTexFont ¶
UseProgTexFont load and use the tex font program
func (*Program) IsCurrentProgram ¶
IsCurrentProgram reports whether the program is in use
func (*Program) LoadClip2DStack ¶
func (p *Program) LoadClip2DStack()
LoadClip2DStack load clip rect from StackClip2D
func (*Program) LoadMVPStack ¶
func (p *Program) LoadMVPStack()
LoadMVPStack load model, view and projection matrix from stack
func (*Program) LoadVPStack ¶
func (p *Program) LoadVPStack()
LoadVPStack load view and projection matrix from stack
func (*Program) SetMVPfv ¶
SetMVPfv set model, view and projection matrix. i.e. SetMVP(matModel,nil,matProj, false)
func (*Program) UseProgram ¶
func (p *Program) UseProgram()
UseProgram use the program, same as gl.UseProgram(p.ID)
type Rect ¶
Rect type
func GetViewport ¶
func GetViewport() Rect
GetViewport is convenience wrapper for gl.Get(gl.VIEWPORT)
type Res ¶
type Res struct {
// contains filtered or unexported fields
}
Res is pointer to resource
func GenVertexArray ¶
GenVertexArray is wrapper for gl.GenVertexArrays
func LoadTexture ¶
LoadTexture load and cache texture by name, must set ProvideTexture before call this function.