Documentation
¶
Index ¶
- Constants
- Variables
- func Clear()
- func Init() error
- func Poll()
- func SetBGColor(col color.Color)
- func Terminate()
- type Mesh
- type Shader
- func (s *Shader) BindUniforms()
- func (s *Shader) Destroy()
- func (s *Shader) GetProgram() (uint32, error)
- func (s *Shader) GetUniform(str string) *Uniform
- func (s *Shader) MustGetProgram() uint32
- func (s *Shader) SetFragmentSource(src string) (err error)
- func (s *Shader) SetOutput(out string)
- func (s *Shader) SetVertexSource(src string) (err error)
- func (s *Shader) Use()
- type Text
- type Texture
- type TextureFilter
- type TextureOptions
- type Uniform
- type Window
- type WindowOptions
- type WindowResizeCallback
- type WrapType
Constants ¶
const DefaultFragmentShader = `
#version 330 core
in vec2 fragTexCoord;
out vec4 color;
void main() {
color = vec4(fragTexCoord.xy,1.0,1.0);
}
` + "\x00"
DefaultFragmentShader is the fragment portion of the default shader
const DefaultVertexShader = `
#version 330 core
uniform mat4 transform;
in vec3 vert;
in vec2 vertTexCoord;
out vec2 fragTexCoord;
void main() {
fragTexCoord = vertTexCoord;
gl_Position = transform * vec4(vert, 1);
}
` + "\x00"
DefaultVertexShader is the vertex portion of the default shader
const SYSDPI = 72 //TODO Support customizable DPI
SYSDPI is the default (and currently fixed) DPI setting
Variables ¶
var ( ErrMissingVertexShader = errors.New("vertex shader is missing") ErrMissingFragmentShader = errors.New("fragment shader is missing") ErrUniformInvalidType = errors.New("uniform set value is not of a valid/supported type") )
Shader errors
var (
ErrTextureNotBound = errors.New("texture not bound to any texture unit")
)
Texture errors
Functions ¶
Types ¶
type Mesh ¶
type Mesh struct { Shader *Shader // contains filtered or unexported fields }
Mesh is a mesh that can be drawn
type Shader ¶
type Shader struct {
// contains filtered or unexported fields
}
Shader is a OpenGL program with one vertex and one fragment shader
func DefaultShader ¶
func DefaultShader() *Shader
DefaultShader returns a plain, kinda useless, shader
func (*Shader) BindUniforms ¶
func (s *Shader) BindUniforms()
BindUniforms sets all the uniforms to their current set value
func (*Shader) Destroy ¶
func (s *Shader) Destroy()
Destroy frees up the resources used by the shader and makes it unusable
func (*Shader) GetProgram ¶
GetProgram compiles (if needed) and returns an OpenGL program with the specified shaders
func (*Shader) GetUniform ¶
GetUniform returns the uniform value for a given shader uniform variable
func (*Shader) MustGetProgram ¶
MustGetProgram calls GetProgram and panics if it gets an error
func (*Shader) SetFragmentSource ¶
SetFragmentSource sets (and updates) the fragment portion of the shader
func (*Shader) SetVertexSource ¶
SetVertexSource sets (and updates) the vertex portion of the shader
type Text ¶
func (*Text) SetContent ¶
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture is a single OpenGL texture
func MakeTexture ¶
func MakeTexture(img *image.RGBA, options TextureOptions) *Texture
MakeTexture creates an OpenGL texture and returns it, if possible
func (*Texture) SetUniform ¶
SetUniform sets the texture as uniform for a GL program
type TextureFilter ¶
type TextureFilter int32
TextureFilter sets what algorithm is used when a texture is scaled
const ( TextureFilterNearest TextureFilter = gl.NEAREST TextureFilterLinear TextureFilter = gl.LINEAR )
Texture filter types
type TextureOptions ¶
type TextureOptions struct { WrapS WrapType WrapR WrapType MinFilter TextureFilter MagFilter TextureFilter Mipmap bool }
TextureOptions contains extra options for setting up a texture
type Uniform ¶
type Uniform struct {
// contains filtered or unexported fields
}
Uniform is a modifiable input for shaders
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a system window with an OpenGL context inside it
func CreateWindow ¶
func CreateWindow(width, height int, title string, monitor *glfw.Monitor, parent *Window, options WindowOptions) (*Window, error)
CreateWindow creates a window with an opengl context and returns it
func (*Window) SetResizeCallback ¶
func (w *Window) SetResizeCallback(fn WindowResizeCallback)
SetResizeCallback sets a callback to be called when the window is resized
type WindowOptions ¶
WindowOptions are extra options that can affect how the window looks or behaves
type WindowResizeCallback ¶
type WindowResizeCallback func(width, height int)
WindowResizeCallback is a callback that can be called when the window is resized