glr

package
v0.0.0-...-ddc071b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

View Source
const (
	CAMERA_SPEED = 0.05
)

Variables

This section is empty.

Functions

func InitGLFW

func InitGLFW(width int, height int, title string) (*glfw.Window, error)

func InitOpenGL

func InitOpenGL() error

func MatrixTRS

func MatrixTRS(t []float32, r []float32, s []float32) []float32

Constructs a Matrix from Translation scale rotation quat

func ProcessCursor

func ProcessCursor(w *glfw.Window, xPos float64, yPos float64)

ProcessCursor - GLFW Callback. While mouse is in state hold calculate a X,Y derivative

func ProcessInput

func ProcessInput(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey)

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

func SizeGL

func SizeGL(typeID string) uint32

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

func (renderer *GLRenderer) BufferArrayData(vboID int, width int, offset int, ref []byte) error

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

func (renderer *GLRenderer) BufferArrayFloat(vboID int, width int, offset int, ref []float32) error

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

func (renderer *GLRenderer) BufferIndexData(vboID int, width int, offset int, ref []byte) error

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

type KeyState

type KeyState struct {
	Pressed int
	Time    time.Time
	Vec     vector.Vec
	Scale   float32
	Select  int
}

KeyState holds Key pressed state for GLFW polling

type MouseState

type MouseState struct {
	Hold     bool
	Position [2]int
	PosX     float64
	PosY     float64
	XRot     float32
	YRot     float32
	Dx       float32
	Dy       float32
	Time     time.Time
}

MouseState holds mouse state for GLFW polling

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL