Documentation ¶
Index ¶
- Constants
- func InitGLFW(width int, height int, title string) (*glfw.Window, error)
- func InitOpenGL() error
- func MatrixTRS(t []float32, r []float32, s []float32) []float32
- func ProcessCursor(w *glfw.Window, xPos float64, yPos float64)
- func ProcessInput(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, ...)
- func ProcessMouse(w *glfw.Window, button glfw.MouseButton, action glfw.Action, ...)
- func SizeGL(typeID string) uint32
- type GLRenderer
- func (renderer *GLRenderer) AddShader(path string, gl_shader_type uint32) (uint32, error)
- func (renderer *GLRenderer) BindArrayBuffer(vbo_index int)
- func (renderer *GLRenderer) BindVertexArray(vao_index int)
- func (renderer *GLRenderer) BufferArrayData(vboID int, width int, offset int, ref []byte) error
- func (renderer *GLRenderer) BufferArrayFloat(vboID int, width int, offset int, ref []float32) error
- func (renderer *GLRenderer) BufferArrayPointer(vboID int, width int, ref unsafe.Pointer) error
- func (renderer *GLRenderer) BufferIndexData(vboID int, width int, offset int, ref []byte) error
- func (renderer *GLRenderer) Draw(mesh_entities []*defs.MeshEntity, shaders *defs.ShadersMap, ...) error
- func (renderer *GLRenderer) GetUniformLocation(program uint32, name string) (int32, error)
- func (r *GLRenderer) GetVAO(index int) uint32
- func (r *GLRenderer) GetVBO(index int) uint32
- func (renderer *GLRenderer) InvalidateBuffer(vboID int, width int) error
- func (renderer *GLRenderer) Layout(num_vao int, num_vbo int, num_tex int) error
- func (renderer *GLRenderer) LinkShaders(vertexGLID uint32, fragmentGLID uint32) (uint32, error)
- func (r *GLRenderer) LoadEnvironment(path string, index int) (uint32, error)
- func (r *GLRenderer) LoadTexture(path string, index int) (uint32, error)
- func (r *GLRenderer) MoveCamera(dir vector.Vec, mag float32)
- func (r *GLRenderer) SetActiveTexture(glid uint32, index uint32)
- func (renderer *GLRenderer) Setup(width int, height int, title string) error
- func (renderer *GLRenderer) ShaderLog(programGLID uint32)
- func (renderer *GLRenderer) ShouldClose() bool
- func (renderer *GLRenderer) Status() error
- func (r *GLRenderer) SwapBuffers()
- func (r *GLRenderer) Update(dt float64) error
- func (renderer *GLRenderer) VertexArrayAttr(index int, components int, gltype uint32, offset int)
- type InputState
- type KeyState
- type MouseState
Constants ¶
const ( MIN_PARAM_SIZE = 10 COORDS_PER_VERTEX = 3 BYTES_PER_FLOAT = 4 BYTES_PER_SHORT = 2 VERT_POSITION_DATA = 0 VERT_ATTR_NORM_DATA = 3 VERT_ATTR_RGB_DATA = 6 VERT_ATTR_UV_DATA = 9 )
Implements RenderAPIContext & Renderer Interface in float32 Env
const ( VERT_NORM_HALF = 0 VERT_NORM_COLOR_HALF = 1 VERT_NORM_TEX_HALF = 2 VERT_NORM_TEX_COLOR_HALF = 3 VERT_NORM_TEX_BINORM_HALF = 4 VERT_HALF = 5 VERT_COLOR_HALF = 6 MAX_VAO_BINDING = 7 )
VAO Index Array Positions
const (
CAMERA_SPEED = 0.05
)
Variables ¶
This section is empty.
Functions ¶
func InitOpenGL ¶
func InitOpenGL() error
func ProcessCursor ¶
ProcessCursor - GLFW Callback. While mouse is in state hold calculate a X,Y derivative
func ProcessInput ¶
func ProcessMouse ¶
func ProcessMouse(w *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey)
ProcessMouse sets the mouse state structure during click events
Types ¶
type GLRenderer ¶
type GLRenderer struct { MVPMatrix []float32 MVPMat []float32 VAO []uint32 Tex []uint32 VBO []uint32 ElementVBO []uint32 Indices []uint16 Window *glfw.Window Camera *camera.Camera }
OGLRenderer interface type
func Renderer ¶
func Renderer() *GLRenderer
func (*GLRenderer) AddShader ¶
func (renderer *GLRenderer) AddShader(path string, gl_shader_type uint32) (uint32, error)
func (*GLRenderer) BindArrayBuffer ¶
func (renderer *GLRenderer) BindArrayBuffer(vbo_index int)
func (*GLRenderer) BindVertexArray ¶
func (renderer *GLRenderer) BindVertexArray(vao_index int)
func (*GLRenderer) BufferArrayData ¶
BufferArrayData(vboID, width, byteSize, ref) - binds a VBO and fills its byte data using the simplest terms possible. The rendersystem will need to pass in the unique buffer ID it wants to fill. This VBO ID is not the GL generated VBO id but the reference index. The ref array will need to have the precomputed offset already computed so that ref[0] is the valid buffer data position.
func (*GLRenderer) BufferArrayFloat ¶
BufferArrayFloat() - Allocates float buffer to gl vertex buffer object
func (*GLRenderer) BufferArrayPointer ¶
func (renderer *GLRenderer) BufferArrayPointer(vboID int, width int, ref unsafe.Pointer) error
func (*GLRenderer) BufferIndexData ¶
BufferIndexData(vboID, width, byteSize, ref) - binds a VBO and fills its byte data using the simplest terms possible. The rendersystem will need to pass in the unique buffer ID it wants to fill. This VBO ID is not the GL generated VBO id but the reference index. The ref array will need to have the precomputed offset already computed so that ref[0] is the valid buffer data position.
func (*GLRenderer) Draw ¶
func (renderer *GLRenderer) Draw(mesh_entities []*defs.MeshEntity, shaders *defs.ShadersMap, materials map[string]*defs.Material, mapID uint32) error
func (*GLRenderer) GetUniformLocation ¶
func (renderer *GLRenderer) GetUniformLocation(program uint32, name string) (int32, error)
func (*GLRenderer) GetVAO ¶
func (r *GLRenderer) GetVAO(index int) uint32
func (*GLRenderer) GetVBO ¶
func (r *GLRenderer) GetVBO(index int) uint32
func (*GLRenderer) InvalidateBuffer ¶
func (renderer *GLRenderer) InvalidateBuffer(vboID int, width int) error
func (*GLRenderer) Layout ¶
func (renderer *GLRenderer) Layout(num_vao int, num_vbo int, num_tex int) error
Layout(num_vbo, num_tex)( error) - initializes as many VBOs and Textures as
requested by the RenderSystem caller. The Raw OpenGL handles are then copied into corresponding VAO/VBO/Tex GLRenderer state objects. Initialize VAO State layouts for position, color, tex data descriptions.
func (*GLRenderer) LinkShaders ¶
func (renderer *GLRenderer) LinkShaders(vertexGLID uint32, fragmentGLID uint32) (uint32, error)
func (*GLRenderer) LoadEnvironment ¶
func (r *GLRenderer) LoadEnvironment(path string, index int) (uint32, error)
func (*GLRenderer) LoadTexture ¶
func (r *GLRenderer) LoadTexture(path string, index int) (uint32, error)
func (*GLRenderer) MoveCamera ¶
func (r *GLRenderer) MoveCamera(dir vector.Vec, mag float32)
func (*GLRenderer) SetActiveTexture ¶
func (r *GLRenderer) SetActiveTexture(glid uint32, index uint32)
func (*GLRenderer) Setup ¶
func (renderer *GLRenderer) Setup(width int, height int, title string) error
Setup() - Setup GL Renderer
func (*GLRenderer) ShaderLog ¶
func (renderer *GLRenderer) ShaderLog(programGLID uint32)
func (*GLRenderer) ShouldClose ¶
func (renderer *GLRenderer) ShouldClose() bool
func (*GLRenderer) Status ¶
func (renderer *GLRenderer) Status() error
func (*GLRenderer) SwapBuffers ¶
func (r *GLRenderer) SwapBuffers()
func (*GLRenderer) Update ¶
func (r *GLRenderer) Update(dt float64) error
func (*GLRenderer) VertexArrayAttr ¶
func (renderer *GLRenderer) VertexArrayAttr(index int, components int, gltype uint32, offset int)
type InputState ¶
type InputState struct { Keys KeyState Mouse MouseState Time time.Time DebugPass bool }
var Input *InputState = new(InputState)
Exposes static OpenGL Input as static global variable for GLFW threaded calls