Documentation ¶
Overview ¶
package render implements OpenGL rendering logic and wrappers.
Index ¶
- Variables
- func Color(s string) (c color.RGBA)
- func F[X int | int32 | int64 | uint | uint32 | uint64 | float32](i X) float64
- func Time() float64
- func Version() string
- type Camera
- type Scene
- type Shader
- func (s *Shader) FragmentShader(src string) *Shader
- func (s *Shader) Link() error
- func (s *Shader) UniformFloats(name string, v ...float32) error
- func (s *Shader) UniformInts(name string, v ...int32) error
- func (s *Shader) UniformTransformation(name string, model glm.Mat4) error
- func (s *Shader) Use()
- func (s *Shader) VertexShader(src string) *Shader
- type Texture
- type Window
Constants ¶
This section is empty.
Variables ¶
var ( // ErrShaderNotLinked is returned when the program attempts to use a shader // program that was not properly compiled and linked. ErrShaderNotLinked = errors.New("shader: invalid state: uniform called before Link()") // ErrNotImplemented indicates that the rendering layer in use has // functionality that is not yet implemented. ErrNotImplemented = errors.New("not implemented") )
var ( // BgColor is the default rendering background color used by OpenGL. BgColor = Color("#87CEEB") )
Functions ¶
func Color ¶
Color parses the provided web color string and returns a color.RGBA value. It panics if the provided string is not in the format #RRGGBB or #RGB.
Types ¶
type Scene ¶
type Scene struct {
// contains filtered or unexported fields
}
Scene represents a graph of elements to be drawn on screen by the OpenGL driver.
func NewScene ¶
func NewScene() *Scene
NewScene initializes an empty scene with the proper memory allocations.
func (*Scene) AddTexture ¶
func (*Scene) AddTriangles ¶
AddTriangles adds the provided vertices and indices to the current scene.
func (*Scene) AddVertices ¶
type Shader ¶
type Shader struct {
// contains filtered or unexported fields
}
Shader abstracts raw GLSL shader compilation, linking and usage.
func (*Shader) FragmentShader ¶
FragmentShader appends the provided shader file to the pipeline. This method returns the Shader reference to allow for chaining.
func (*Shader) Link ¶
Link creates an OpenGL shader program linking all previously compiled shaders. It reports an error if no shaders where compiled, or if there were an error linking them.
func (*Shader) UniformFloats ¶
UniformFloat adds the provided float value as a GLSL uniform with the given name. Returns an error if the program was not linked.
func (*Shader) UniformInts ¶
UniformInt adds the provided int value as a GLSL uniform with the given name. Returns an error if the shader was not linked.
func (*Shader) UniformTransformation ¶
func (*Shader) Use ¶
func (s *Shader) Use()
Use attempt to use the linked program by calling gl.UseProgram. It will panic if no shaders were compiled and linked previously.
func (*Shader) VertexShader ¶
VertexShader appends the provider shader file to the pipeline. This method returns the Shader reference to allow for chaining.
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
func NewTexture ¶
func NewTextureFromBytes ¶
type Window ¶
Window handles the basic GUI and Input event handling.
Window must be created using NewWindow, which will load all the required components of OpenGL and GLFW, as well as initializing a Scene object that can be used to draw elements on. To add elements call the Scene() method.
During the app main event loop, callers must make sure to call the PollEvents() method to receive any window/input changes from the Operating System.
func (*Window) Close ¶
func (w *Window) Close()
Close frees any used resources and close the underlying GLFW window.
func (*Window) PollEvents ¶
func (w *Window) PollEvents()
PoolEvents listen to any window/input events to be passed to the input callbacks.
func (*Window) ShouldClose ¶
ShouldClose returns true when the window must be closed. Before it should be closed, it is safe to call any drawing operations. Once the window should be closed is flipped to true, then callers must call Close() method to ensure resources are properly freed.
func (*Window) SwapBuffers ¶
func (w *Window) SwapBuffers()
SwapBuffers will flip the drawing buffer to the visible buffer on the display.