Documentation
¶
Index ¶
- type Context
- func (c *Context) AddTextureObject(cfg *TextureConfig) (*TextureObject, error)
- func (c *Context) AddVertexArrayObject(cfg *VAOConfig) error
- func (c *Context) Draw()
- func (c *Context) EventLoop(render func(*Context))
- func (c *Context) GetAttributeLocation(name string) uint32
- func (c *Context) GetUniformLocation(uname string) int32
- func (c *Context) NewVertexArrayObject(cfg *VAOConfig) (*VertexArrayObject, error)
- func (c *Context) Terminate()
- type Program
- type Shader
- type ShaderConfig
- type ShaderType
- type TextureConfig
- type TextureObject
- type VAOConfig
- type VertexArrayObject
- type Window
- type WindowConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context is a context for doing opengl graphics
func NewContext ¶
func NewContext(done chan struct{}, windowConfig *WindowConfig, shaderConfigs []*ShaderConfig) (*Context, error)
NewContext creates a new opengl context
func (*Context) AddTextureObject ¶
func (c *Context) AddTextureObject(cfg *TextureConfig) (*TextureObject, error)
AddTextureObject creates a new TextureObject by first creating a PixelBufferObject that will be used to store the texture. The PBO can be updated by calling TextureObject.Update() which will read the current state of cfg.Image.
func (*Context) AddVertexArrayObject ¶
AddVertexArrayObject creates a VAO from a VertexBufferObject (todo implement that type)
func (*Context) Draw ¶
func (c *Context) Draw()
Draw draws every VAO that's attached to the context.
func (*Context) EventLoop ¶
EventLoop clears the current framebuffer and executes render in a loop until the underlying glfw window tells it to stop. Calls glfw.Terminate when finished.
func (*Context) GetAttributeLocation ¶
GetAttributeLocation returns the location of an attribute with context's program.
func (*Context) GetUniformLocation ¶
GetUniformLocation returns the location of a uniform within the context's program.
func (*Context) NewVertexArrayObject ¶
func (c *Context) NewVertexArrayObject(cfg *VAOConfig) (*VertexArrayObject, error)
NewVertexArrayObject creates a VertexArrayObject
type Program ¶
Program represents an OpenGL program.
func (*Program) AttachShader ¶
func (p *Program) AttachShader(cfg *ShaderConfig) error
AttachShader attaches a shader from source to a program, defering compilation so that calls can be chained together and finished with a call to Link()
type Shader ¶
type Shader struct { ShaderID uint32 UniformLocations map[string]int32 AttributeLocations map[string]int32 // contains filtered or unexported fields }
Shader represents a shader with attached attribute pointers.
func NewShader ¶
func NewShader(cfg *ShaderConfig) (*Shader, error)
NewShader loads and compiles a new shader, but does not attach it to a program.
type ShaderConfig ¶
type ShaderConfig struct { Source string Typ ShaderType AttributeNames []string UniformNames []string }
ShaderConfig is used to create new shaders
type ShaderType ¶
type ShaderType int
ShaderType tells NewShader what type of shader it's creating.
const ( VertexShaderType ShaderType = iota FragmentShaderType )
Types of shaders
type TextureConfig ¶
TextureConfig is a configuration for creating a new TextureObject
type TextureObject ¶
type TextureObject struct {
// contains filtered or unexported fields
}
TextureObject represents a texture that is
func (*TextureObject) Update ¶
func (t *TextureObject) Update(img *image.RGBA)
type VAOConfig ¶
type VAOConfig struct { Vertices []float32 VertAttr string TexAttr string Stride int32 Size int GLDrawType uint32 OnDraw func(ctx *Context) bool }
VAOConfig represents a configuration for creating a new VAO. OnDraw is a function that returns true if the VAO should be drawn, but can also be used to set uniforms.
type VertexArrayObject ¶
type VertexArrayObject struct {
// contains filtered or unexported fields
}
VertexArrayObject points to a vertex buffer that has already been loaded into grpahics memory.
func (*VertexArrayObject) Draw ¶
func (v *VertexArrayObject) Draw(ctx *Context)
Draw draws a VertexArrayObject to the current frame buffer
type Window ¶
type Window struct { Config *WindowConfig GlfwWindow *glfw.Window }
Window represents a wrapped glfw window object.
func NewWindow ¶
func NewWindow(cfg *WindowConfig) (*Window, error)
NewWindow initializes a new window object with glfw.
type WindowConfig ¶
WindowConfig contains a new window configuration