Documentation ¶
Index ¶
- Variables
- func LoadImageToTexture(filePath string) (glTex uint32, e error)
- func LoadShaderProgram(vertShader, fragShader string) (uint32, error)
- func SetGlQuat(dst *mgl.Quat, src *m.Quat)
- func SetGlVector3(dst *mgl.Vec3, src *m.Vector3)
- type Entity
- type ExampleApp
- type RenderLoopCallback
- type Renderable
Constants ¶
This section is empty.
Variables ¶
var ( // UnlitColorVertShader is a basic color vertex shader UnlitColorVertShader = `` /* 232-byte string literal not displayed */ // UnlitColorFragShader is a basic color fragment shader UnlitColorFragShader = `#version 330 in vec4 vs_diffuse; out vec4 colourOut; void main() { colourOut = vs_diffuse; }` DiffuseColorVertShader = `` /* 362-byte string literal not displayed */ DiffuseColorFragShader = `` /* 527-byte string literal not displayed */ DiffuseTextureVertShader = `` /* 428-byte string literal not displayed */ DiffuseTextureFragShader = `` /* 615-byte string literal not displayed */ )
Functions ¶
func LoadImageToTexture ¶
func LoadShaderProgram ¶
LoadShaderProgram loads shader objects and then attaches them to a program
Types ¶
type Entity ¶
type Entity struct { Node *Renderable Collider cubez.Collider }
type ExampleApp ¶
type ExampleApp struct { // MainWindow is the main OpenGL window for the application MainWindow *glfw.Window // Width is how wide the app window is Width int // Height is how tall the app window is Height int // CameraPos is the position of the camera in world space CameraPos mgl.Vec3 // CameraRotation is a quaternion representing the direction // the camera is looking. CameraRotation mgl.Quat // OnUpdate is called just prior to OnRender and can be used to update // the application data. OnUpdate RenderLoopCallback // OnRender is called at the end of the render loop and is meant to be // the spot where the application renders the objects to OpenGL. OnRender RenderLoopCallback }
ExampleApp is a type representing the example application and holds on to related data like OpenGL windows.
func NewApp ¶
func NewApp() *ExampleApp
NewApp returns a new ExampleApp object to control the display of the example app.
func (*ExampleApp) InitGraphics ¶
func (app *ExampleApp) InitGraphics(title string, w int, h int)
InitGraphics creates an OpenGL window and initializes the required graphics libraries. It will either succeed or panic.
func (*ExampleApp) RenderLoop ¶
func (app *ExampleApp) RenderLoop()
RenderLoop is the main render loop for the application
func (*ExampleApp) SetKeyCallback ¶
func (app *ExampleApp) SetKeyCallback(cb glfw.KeyCallback)
SetKeyCallback sets a key handler for the main window.
func (*ExampleApp) Terminate ¶
func (app *ExampleApp) Terminate()
Terminate closes the OpenGL window and unloads the graphics libraries.
type RenderLoopCallback ¶
type RenderLoopCallback func(delta float64)
type Renderable ¶
type Renderable struct { // Shader is the shader program to use to draw the renderable Shader uint32 // Tex0 is the first texture to be bound to the shader Tex0 uint32 // Color is a material color for the object passed to the shader when drawn. Color mgl.Vec4 // Vao is the VAO object used to draw the object Vao uint32 // VertVBO is the VBO that holds the vertex data VertVBO uint32 // UvVBO is the VBO that holds the UV data UvVBO uint32 // NormsVBO is the VBO that hold the normal data NormsVBO uint32 // ElementsVBO is the VBO ElementsVBO uint32 // FaceCount is the number of faces to draw for the object FaceCount int // Scale represents how to scale the object when drawing Scale mgl.Vec3 // Location positions the object in world space Location mgl.Vec3 // Rotation is the rotation of the object in world space Rotation mgl.Quat // LocalRotation is rotation applied to the object in local space LocalRotation mgl.Quat }
Renderable is an object that can be drawn in the render loop
func CreateCube ¶
func CreateCube(xmin, ymin, zmin, xmax, ymax, zmax float32) *Renderable
CreateCube makes a new Renderable object with the specified dimensions for the cube.
func CreatePlaneXZ ¶
func CreatePlaneXZ(x0, z0, x1, z1 float32, scaleUVs float32) *Renderable
CreatePlaneXZ makes a 2d Renderable object on the XZ plane for the given size, where (x0,z0) is the lower left and (x1, z1) is the upper right coordinate.
func CreateSphere ¶
func CreateSphere(radius float32, rings int, sectors int) *Renderable
CreateSphere generates a 3d uv-sphere with the given radius and returns a Renderable.
func NewRenderable ¶
func NewRenderable() *Renderable
NewRenderable creates a new Renderable object.
func (*Renderable) GetTransformMat4 ¶
func (r *Renderable) GetTransformMat4() mgl.Mat4
GetTransformMat4 creates a transform matrix: scale * transform