Documentation ¶
Overview ¶
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Package engine provides an abstraction layer on top of OpenGL. It contains entities relevant for rendering.
Index ¶
- Variables
- func CheckGLError()
- type Camera
- type CameraFPS
- func (camera *CameraFPS) GetOrtho() mgl32.Mat4
- func (camera *CameraFPS) GetPerspective() mgl32.Mat4
- func (camera *CameraFPS) GetView() mgl32.Mat4
- func (camera *CameraFPS) GetViewPerspective() mgl32.Mat4
- func (camera *CameraFPS) OnCursorPosMove(x, y, dx, dy float64) bool
- func (camera *CameraFPS) OnKeyPress(key, action, mods int) bool
- func (camera *CameraFPS) OnMouseButtonPress(leftPressed, rightPressed bool) bool
- func (camera *CameraFPS) OnMouseScroll(x, y float64) bool
- func (camera *CameraFPS) Rotate(theta, phi float32)
- func (camera *CameraFPS) SetPos(pos mgl32.Vec3)
- func (camera *CameraFPS) Update()
- func (camera *CameraFPS) Zoom(distance float32)
- type CameraTrackball
- func MakeCameraTrackball(width, height int, radius float32, target mgl32.Vec3, fov, near, far float32) CameraTrackball
- func MakeDefaultCameraTrackball(width, height int, radius float32) CameraTrackball
- func NewCameraTrackball(width, height int, radius float32, target mgl32.Vec3, fov, near, far float32) *CameraTrackball
- func NewDefaultCameraTrackball(width, height int, radius float32) *CameraTrackball
- func (camera *CameraTrackball) GetOrtho() mgl32.Mat4
- func (camera *CameraTrackball) GetPerspective() mgl32.Mat4
- func (camera *CameraTrackball) GetView() mgl32.Mat4
- func (camera *CameraTrackball) GetViewPerspective() mgl32.Mat4
- func (camera *CameraTrackball) OnCursorPosMove(x, y, dx, dy float64) bool
- func (camera *CameraTrackball) OnKeyPress(key, action, mods int) bool
- func (camera *CameraTrackball) OnMouseButtonPress(leftPressed, rightPressed bool) bool
- func (camera *CameraTrackball) OnMouseScroll(x, y float64) bool
- func (camera *CameraTrackball) Rotate(theta, phi float32)
- func (camera *CameraTrackball) SetPos(pos mgl32.Vec3)
- func (camera *CameraTrackball) Update()
- func (camera *CameraTrackball) Zoom(distance float32)
- type Cube
- type CursorPosHandler
- type FBO
- func (fbo *FBO) AttachColorTexture(texture Texture, index uint32)
- func (fbo *FBO) AttachDepthTexture(texture Texture)
- func (fbo *FBO) Bind()
- func (fbo *FBO) Clear()
- func (fbo *FBO) CopyAttachmentColorToFBO(other *FBO, index1, index2 uint32, x, y, width, height int32)
- func (fbo *FBO) CopyAttachmentColorToFBORegionSmooth(other *FBO, index1, index2 uint32, x1, y1, w1, h1, x2, y2, w2, h2 int32)
- func (fbo *FBO) CopyAttachmentColorToFBOSmooth(other *FBO, index1, index2 uint32, x, y, width, height int32)
- func (fbo *FBO) CopyColorAttachmentToFBORegion(other *FBO, index1, index2 uint32, x1, y1, w1, h1, x2, y2, w2, h2 int32)
- func (fbo *FBO) CopyColorToFBO(other *FBO, x, y, width, height int32)
- func (fbo *FBO) CopyColorToFBORegion(other *FBO, x1, y1, w1, h1, x2, y2, w2, h2 int32)
- func (fbo *FBO) CopyColorToFBORegionSmooth(other *FBO, x1, y1, w1, h1, x2, y2, w2, h2 int32)
- func (fbo *FBO) CopyColorToFBOSmooth(other *FBO, x, y, width, height int32)
- func (fbo *FBO) CopyDepthToFBO(other *FBO, x, y, width, height int32)
- func (fbo *FBO) CopyDepthToFBORegion(other *FBO, x1, y1, w1, h1, x2, y2, w2, h2 int32)
- func (fbo *FBO) CopyToFBO(other *FBO, x, y, width, height int32)
- func (fbo *FBO) CopyToFBORegion(other *FBO, x1, y1, w1, h1, x2, y2, w2, h2 int32)
- func (fbo *FBO) CopyToScreen(index uint32, x, y, width, height int32)
- func (fbo *FBO) CopyToScreenRegion(index uint32, x1, y1, w1, h1, x2, y2, w2, h2 int32)
- func (fbo *FBO) Delete()
- func (fbo *FBO) IsComplete() bool
- func (fbo *FBO) Unbind()
- type Face
- type IBO
- type Image
- type Interactable
- type KeyPressHandler
- type Mesh
- type MouseButtonHandler
- type MouseScrollHandler
- type Obj
- type RawImageData
- func (data *RawImageData) GetA(x, y int32) uint8
- func (data *RawImageData) GetB(x, y int32) uint8
- func (data *RawImageData) GetG(x, y int32) uint8
- func (data *RawImageData) GetHeight() int32
- func (data *RawImageData) GetR(x, y int32) uint8
- func (data *RawImageData) GetRGB(x, y int32) (uint8, uint8, uint8)
- func (data *RawImageData) GetRGBA(x, y int32) (uint8, uint8, uint8, uint8)
- func (data *RawImageData) GetWidth() int32
- func (data *RawImageData) SetA(x, y int32, a uint8)
- func (data *RawImageData) SetB(x, y int32, b uint8)
- func (data *RawImageData) SetG(x, y int32, g uint8)
- func (data *RawImageData) SetR(x, y int32, r uint8)
- func (data *RawImageData) SetRGB(x, y int32, r, g, b uint8)
- func (data *RawImageData) SetRGBA(x, y int32, r, g, b, a uint8)
- type Renderable
- type SSBO
- func (ssbo *SSBO) Bind(pos int32)
- func (ssbo *SSBO) Delete()
- func (ssbo *SSBO) Download() []float32
- func (ssbo *SSBO) GetHandle() uint32
- func (ssbo *SSBO) Len() int
- func (ssbo *SSBO) Resize(len int)
- func (ssbo *SSBO) Unbind()
- func (ssbo *SSBO) UploadArray(values []float32)
- func (ssbo *SSBO) UploadArrayInRange(values []float32, start, len int)
- func (ssbo *SSBO) UploadValue(value []float32)
- func (ssbo *SSBO) UploadValueInRange(value []float32, start, len int)
- type ShaderProgram
- func (shaderProgram *ShaderProgram) AddRenderable(renderable Renderable)
- func (ShaderProgram *ShaderProgram) Compute(numgroupsx, numgroupsy, numgroupsz uint32)
- func (shaderProgram *ShaderProgram) Delete()
- func (shaderProgram *ShaderProgram) GetHandle() uint32
- func (ShaderProgram *ShaderProgram) RemoveAllRenderables()
- func (shaderProgram *ShaderProgram) Render()
- func (shaderProgram *ShaderProgram) RenderInstanced(instancecount int32)
- func (shaderProgram *ShaderProgram) UpdateFloat32(uniformName string, f32 float32)
- func (shaderProgram *ShaderProgram) UpdateInt32(uniformName string, i32 int32)
- func (shaderProgram *ShaderProgram) UpdateMat4(uniformName string, mat mgl32.Mat4)
- func (shaderProgram *ShaderProgram) UpdateVec2(uniformName string, vec2 mgl32.Vec2)
- func (shaderProgram *ShaderProgram) UpdateVec3(uniformName string, vec3 mgl32.Vec3)
- func (shaderProgram *ShaderProgram) Use()
- type Skybox
- type Texture
- func MakeColorMultisampleTexture(width, height, samples int32) Texture
- func MakeColorTexture(width, height int32) Texture
- func MakeCubeMapTexture(right, left, top, bottom, front, back string) (Texture, error)
- func MakeDepthMultisampleTexture(width, height, samples int32) Texture
- func MakeDepthTexture(width, height int32) Texture
- func MakeEmptyTexture() Texture
- func MakeMultisampleTexture(width, height, samples int32, format uint32, min, mag, s, t int32) Texture
- func MakeTexture(width, height, internalformat int32, format, pixelType uint32, ...) Texture
- func MakeTextureFromPath(path string) (Texture, error)
- type VAO
- func (vao *VAO) AddIndexBuffer(ibo *IBO)
- func (vao *VAO) AddVertexBuffer(vbo *VBO)
- func (vao *VAO) BuildBuffers(shaderProgramHandle uint32)
- func (vao *VAO) Delete()
- func (vao *VAO) GetIndexBuffer() *IBO
- func (vao *VAO) GetVertexBuffer(idx int) *VBO
- func (vao *VAO) Render()
- func (vao *VAO) RenderInstanced(instancecount int32)
- type VBO
- type VertexAttribute
- type WindowManager
- func (windowManager *WindowManager) AddCursorPosHandler(handler CursorPosHandler)
- func (windowManager *WindowManager) AddInteractable(interactable Interactable)
- func (windowManager *WindowManager) AddKeyPressHandler(handler KeyPressHandler)
- func (windowManager *WindowManager) AddMouseButtonHandler(handler MouseButtonHandler)
- func (windowManager *WindowManager) AddMouseScrollHandler(handler MouseScrollHandler)
- func (windowManager *WindowManager) Close()
- func (windowManager *WindowManager) EnableCursorLoop()
- func (windowManager *WindowManager) GetFPS() float64
- func (windowManager *WindowManager) LockFPS(fps float64)
- func (windowManager *WindowManager) RunMainLoop(render func())
- func (windowManager *WindowManager) SetClearColor(r, g, b float32)
- func (windowManager *WindowManager) SetTitle(title string)
Constants ¶
This section is empty.
Variables ¶
var MAX_THETA = math.Pi - MIN_THETA
var MIN_THETA = 0.000001
Functions ¶
func CheckGLError ¶
func CheckGLError()
CheckGLError can be used after any interaction with OpenGL to grab the last error from the GPU.
Types ¶
type Camera ¶
type Camera interface { Update() Rotate(theta, phi float32) Zoom(distance float32) GetView() mgl32.Mat4 GetPerspective() mgl32.Mat4 GetViewPerspective() mgl32.Mat4 }
Camera abstracts a camera model with either perspective or orthographic projection.
type CameraFPS ¶
type CameraFPS struct { Pos mgl32.Vec3 Target mgl32.Vec3 Up mgl32.Vec3 Right mgl32.Vec3 Fov float32 Near float32 Far float32 // contains filtered or unexported fields }
CameraFPS moves in the view direction while the viewing direction can be changed.
func MakeCameraFPS ¶
MakeDefaultCameraFPS creates a CameraFPS with the viewport of width and height and a radius from the origin. It assumes a field of view of 45 degrees and a near and far plane at 0.1 and 100.0 respectively.
func (*CameraFPS) GetPerspective ¶
GetPerspective returns the perspective projection of the camera.
func (*CameraFPS) GetViewPerspective ¶
GetViewPerspective returns P*V.
func (*CameraFPS) OnCursorPosMove ¶
OnCursorPosMove is a callback handler that is called every time the cursor moves.
func (*CameraFPS) OnKeyPress ¶
OnKeyPress is a callback handler that is called every time a keyboard key is pressed.
func (*CameraFPS) OnMouseButtonPress ¶
OnMouseButtonPress is a callback handler that is called every time a mouse button is pressed or released.
func (*CameraFPS) OnMouseScroll ¶
OnMouseScroll is a callback handler that is called every time the mouse wheel moves.
func (*CameraFPS) Rotate ¶
Rotate adds delta angles in degrees to the theta and phi angles. Where theta is the vertical angle and phi the horizontal angle.
func (*CameraFPS) SetPos ¶
SetPos updates the target point of the camera. It requires to call Update to take effect.
type CameraTrackball ¶
type CameraTrackball struct { Pos mgl32.Vec3 Target mgl32.Vec3 Up mgl32.Vec3 Fov float32 Near float32 Far float32 // contains filtered or unexported fields }
CameraTrackball moves on a sphere around a target point with a specified radius.
func MakeCameraTrackball ¶
func MakeCameraTrackball(width, height int, radius float32, target mgl32.Vec3, fov, near, far float32) CameraTrackball
MakeCameraTrackball creates a CameraTrackball with the viewport of width and height, the radius from the target, the target position the camera is orbiting around, the field of view and the distance of the near and far plane.
func MakeDefaultCameraTrackball ¶
func MakeDefaultCameraTrackball(width, height int, radius float32) CameraTrackball
MakeDefaultCameraTrackbal creates a CameraTrackball with the viewport of width and height and a radius from the origin. It assumes a field of view of 45 degrees and a near and far plane at 0.1 and 100.0 respectively.
func NewCameraTrackball ¶
func NewCameraTrackball(width, height int, radius float32, target mgl32.Vec3, fov, near, far float32) *CameraTrackball
MakeCameraTrackball creates a reference to a CameraTrackball with the viewport of width and height, the radius from the target, the target position the camera is orbiting around, the field of view and the distance of the near and far plane.
func NewDefaultCameraTrackball ¶
func NewDefaultCameraTrackball(width, height int, radius float32) *CameraTrackball
NewDefaultCameraTrackball creates a reference to a CameraTrackball with the viewport of width and height and a radius from the origin. It assumes a field of view of 45 degrees and a near and far plane at 0.1 and 100.0 respectively.
func (*CameraTrackball) GetOrtho ¶
func (camera *CameraTrackball) GetOrtho() mgl32.Mat4
GetOrtho returns the orthographic projection of the camera.
func (*CameraTrackball) GetPerspective ¶
func (camera *CameraTrackball) GetPerspective() mgl32.Mat4
GetPerspective returns the perspective projection of the camera.
func (*CameraTrackball) GetView ¶
func (camera *CameraTrackball) GetView() mgl32.Mat4
GetView returns the view matrix of the camera.
func (*CameraTrackball) GetViewPerspective ¶
func (camera *CameraTrackball) GetViewPerspective() mgl32.Mat4
GetViewPerspective returns P*V.
func (*CameraTrackball) OnCursorPosMove ¶
func (camera *CameraTrackball) OnCursorPosMove(x, y, dx, dy float64) bool
OnCursorPosMove is a callback handler that is called every time the cursor moves.
func (*CameraTrackball) OnKeyPress ¶
func (camera *CameraTrackball) OnKeyPress(key, action, mods int) bool
OnKeyPress is a callback handler that is called every time a keyboard key is pressed.
func (*CameraTrackball) OnMouseButtonPress ¶
func (camera *CameraTrackball) OnMouseButtonPress(leftPressed, rightPressed bool) bool
OnMouseButtonPress is a callback handler that is called every time a mouse button is pressed or released.
func (*CameraTrackball) OnMouseScroll ¶
func (camera *CameraTrackball) OnMouseScroll(x, y float64) bool
OnMouseScroll is a callback handler that is called every time the mouse wheel moves.
func (*CameraTrackball) Rotate ¶
func (camera *CameraTrackball) Rotate(theta, phi float32)
Rotate adds delta angles in degrees to the theta and phi angles. Where theta is the vertical angle and phi the horizontal angle.
func (*CameraTrackball) SetPos ¶
func (camera *CameraTrackball) SetPos(pos mgl32.Vec3)
SetPos updates the target point of the camera. It requires to call Update to take effect.
func (*CameraTrackball) Update ¶
func (camera *CameraTrackball) Update()
Update recalculates the position of the camera. Call it every time after calling Rotate or Zoom.
func (*CameraTrackball) Zoom ¶
func (camera *CameraTrackball) Zoom(distance float32)
Zoom changes the radius of the camera to the target point.
type Cube ¶
type Cube struct {
// contains filtered or unexported fields
}
Cube is a Renderable that can be specified with different dimensions..
func (Cube) Build ¶
Build prepares the vertex buffers for rendering. It is called by the RenderProgram after adding it using AddRenderable thus it is usually not advised to call it on your own.
func (Cube) Render ¶
func (cube Cube) Render()
Render draws the geometry of this Renderable using the currently bound shader.
func (Cube) RenderInstanced ¶
RenderInstanced draws the geometry of this Renderable multiple times according to the instancecount.
type CursorPosHandler ¶
CursorPosHandler is called every time the cursor position changes.
type FBO ¶
type FBO struct { ColorTextures []*Texture DepthTexture *Texture // contains filtered or unexported fields }
FBO can hold multiple color textues and up to one depth texture. It can be bound as alternative render target contrary to the default frame buffer.
func MakeEmptyFBO ¶
func MakeEmptyFBO() FBO
MakeEmpty FBO creates an empty FBO that works as the default frame buffer.
func MakeFBO ¶
MakeFBO creates an FBO with one color and depth texture of the specified width and height.
func MakeMultisampleFBO ¶
func MakeMultisampleFBO() FBO
MakeMultisampleFBO make an empty multisampled frame buffer.
func (*FBO) AttachColorTexture ¶
AttachColorTexture adds a color texture at the position specified by index.
func (*FBO) AttachDepthTexture ¶
AttachDepthTexture adds a depth texture to the FBO.
func (*FBO) Clear ¶
func (fbo *FBO) Clear()
Clear clears the color and depth buffer if this FBO has been bound before.
func (*FBO) CopyAttachmentColorToFBO ¶
func (fbo *FBO) CopyAttachmentColorToFBO(other *FBO, index1, index2 uint32, x, y, width, height int32)
CopyAttachmentColorToFBO copies a color texture specified by index1 to the color texture of another FBO at index2.
func (*FBO) CopyAttachmentColorToFBORegionSmooth ¶
func (fbo *FBO) CopyAttachmentColorToFBORegionSmooth(other *FBO, index1, index2 uint32, x1, y1, w1, h1, x2, y2, w2, h2 int32)
CopyAttachmentColorToFBORegionSmooth copies a texture specfied by index2 within a region specified by the position (x1,y1) and width w1 and height h1 to the color texture of another FBO at index2 in the region (x2,y2) and the width w2 and height h2 using linear interpolation using linear interpolation.
func (*FBO) CopyAttachmentColorToFBOSmooth ¶
func (fbo *FBO) CopyAttachmentColorToFBOSmooth(other *FBO, index1, index2 uint32, x, y, width, height int32)
CopyAttachmentColorToFBOSmooth copies a color texture specified by index1 to the color texture of another FBO at index2 using linear interpolation.
func (*FBO) CopyColorAttachmentToFBORegion ¶
func (fbo *FBO) CopyColorAttachmentToFBORegion(other *FBO, index1, index2 uint32, x1, y1, w1, h1, x2, y2, w2, h2 int32)
CopyColorAttachmentToFBORegion copies a texture specfied by index2 within a region specified by the position (x1,y1) and width w1 and height h1 to the color texture of another FBO at index2 in the region (x2,y2) and the width w2 and height h2 using linear interpolation.
func (*FBO) CopyColorToFBO ¶
CopyColorToFBO copies all color textures to another FBO.
func (*FBO) CopyColorToFBORegion ¶
CopyColorToFBORegion copies all color textures within a region specified by the position (x1,y1) and width w1 and height h1 to another FBO in the region (x2,y2) and the width w2 and height h2.
func (*FBO) CopyColorToFBORegionSmooth ¶
CopyColorToFBORegionSmooth copies all color textures within a region specified by the position (x1,y1) and width w1 and height h1 to another FBO in the region (x2,y2) and the width w2 and height h2 using linear interpolation.
func (*FBO) CopyColorToFBOSmooth ¶
CopyColorToFBOSmooth copies all color textures to another FBO using linear interpolation.
func (*FBO) CopyDepthToFBO ¶
CopyDepthToFBO copies the depth texture to another FBO.
func (*FBO) CopyDepthToFBORegion ¶
CopyDepthToFBORegion copies the depth texture within a region specified by the position (x1,y1) and width w1 and height h1 to another FBO in the region (x2,y2) and the width w2 and height h2.
func (*FBO) CopyToFBORegion ¶
CopyToFBORegion copies all color and depth textures within a region specified by the position (x1,y1) and width w1 and height h1 to another FBO in the region (x2,y2) and the width w2 and height h2.
func (*FBO) CopyToScreen ¶
CopyToScreen copies all color and depth textures to the default frame buffer.
func (*FBO) CopyToScreenRegion ¶
CopyToScreenRegion copies all color and depth textures within a region specified by the position (x1,y1) and width w1 and height h1 to the default frame buffer in the region (x2,y2) and the width w2 and height h2.
type Face ¶
Face specifies three or more vertices with vertex position, normal and texture coordinate.
type IBO ¶
type IBO struct {
// contains filtered or unexported fields
}
IBO contains indices to vertex attributes. It has to be used together with a VAO.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image holds image information of the data, dimensions and formats.
type Interactable ¶
type Interactable interface { OnCursorPosMove(x, y, dx, dy float64) bool OnMouseButtonPress(leftPressed, rightPressed bool) bool OnMouseScroll(x, y float64) bool OnKeyPress(key, action, mods int) bool }
Interactable is an entity that listens to different events and reacts to them.
type KeyPressHandler ¶
KeyPressHandler is called every time a keyboard key is pressed of released.
type Mesh ¶
type Mesh struct {
// contains filtered or unexported fields
}
Mesh holds the geometry of the object.
func MakeEmptyMesh ¶
MakeEmptyMesh constructs a Mesh without any geometry specified.
func MakeMeshFromArrays ¶
func MakeMeshFromArrays(positions, normals, texcoords []float32, pname, nname, tname string, pcount, ncount, tcount uint32, mode uint32) (Mesh, error)
MakeMeshFromArrays constructs a Mesh with vertex positions, normals and texture coordinates. Normals and texture coordinates can be set to Nil if they are not required.
func MakeSimpleMesh ¶
MakeSimpleMesh constructs a Mesh that only has vertex positions.
func (Mesh) Render ¶
func (mesh Mesh) Render()
Render draws the Mesh using the currently bound Shader.
func (Mesh) RenderInstanced ¶
RenderInstanced draws the Mesh multiple times specified by instancecount using the currently bound Shader.
type MouseButtonHandler ¶
MouseButtonHandler is called every time the left or right mouse button is pressed or released.
type MouseScrollHandler ¶
MouseScrollHandler is called every time the mouse scroll is used.
type RawImageData ¶
type RawImageData struct {
// contains filtered or unexported fields
}
RawImageData stores the image data on the CPU.
func MakeRawImageData ¶
func MakeRawImageData(path string) (RawImageData, error)
MakeRawImageData loads the raw image data from the specified path.
func (*RawImageData) GetA ¶
func (data *RawImageData) GetA(x, y int32) uint8
GetA returns the alpha value of the pixel at (x,y).
func (*RawImageData) GetB ¶
func (data *RawImageData) GetB(x, y int32) uint8
GetB returns the blue value of the pixel at (x,y).
func (*RawImageData) GetG ¶
func (data *RawImageData) GetG(x, y int32) uint8
GetG returns the green value of the pixel at (x,y).
func (*RawImageData) GetHeight ¶
func (data *RawImageData) GetHeight() int32
GetHeight returns the height of the image.
func (*RawImageData) GetR ¶
func (data *RawImageData) GetR(x, y int32) uint8
GetR returns the red value of the pixel at (x,y).
func (*RawImageData) GetRGB ¶
func (data *RawImageData) GetRGB(x, y int32) (uint8, uint8, uint8)
GetRGB returns the RGB values of the pixel at (x,y).
func (*RawImageData) GetWidth ¶
func (data *RawImageData) GetWidth() int32
GetWidth returns the width of the image.
func (*RawImageData) SetA ¶
func (data *RawImageData) SetA(x, y int32, a uint8)
SetA sets the alpha value of the pixel at (x,y).
func (*RawImageData) SetB ¶
func (data *RawImageData) SetB(x, y int32, b uint8)
SetB sets the blue value of the pixel at (x,y).
func (*RawImageData) SetG ¶
func (data *RawImageData) SetG(x, y int32, g uint8)
SetG sets the green value of the pixel at (x,y).
func (*RawImageData) SetR ¶
func (data *RawImageData) SetR(x, y int32, r uint8)
SetR sets the red value of the pixel at (x,y).
func (*RawImageData) SetRGB ¶
func (data *RawImageData) SetRGB(x, y int32, r, g, b uint8)
SetRGB sets the RGB values of the pixel at (x,y).
func (*RawImageData) SetRGBA ¶
func (data *RawImageData) SetRGBA(x, y int32, r, g, b, a uint8)
SetRGBA sets the RGBA values of the pixel at (x,y).
type Renderable ¶
type Renderable interface { Build(shaderProgramHandle uint32) Render() RenderInstanced(instancecount int32) }
Renderable is an object that can be drawn by a renderer.
type SSBO ¶
type SSBO struct {
// contains filtered or unexported fields
}
SSBO is a buffer that can hold different kinds of data. The typesize specifies the byte size of one element and len specifes the number of elements.
func MakeEmptySSBO ¶
MakeEmptySSBO constructs a SSBO with the byte size of one element and a length of zero.
func MakeSSBO ¶
MakeSSBO constructs a SSBO with the byte size of one element and the number of elements.
func (*SSBO) Bind ¶
Bind makes this buffer available at the specified position. The pos attribute has to coincide with the order of buffer within the shader.
func (*SSBO) Delete ¶
func (ssbo *SSBO) Delete()
Delete destroys the SSBO and deletes the buffer data on the GPU.
func (*SSBO) Unbind ¶
func (ssbo *SSBO) Unbind()
Unbind makes this buffer unavailable for reading and writing.
func (*SSBO) UploadArray ¶
UploadArray replaces the data on the GPU with the data in values. Make sure that the size of values matches the bytesize*len of the SSBO.
func (*SSBO) UploadArrayInRange ¶
UploadArray replaces the data on the GPU with the data in values in the range from start to start+len. Make sure that the size of values matches the bytesize*len specified in the arguments.
func (*SSBO) UploadValue ¶
UploadValue fills the buffer with one element N times where N is the length of the buffer. Thus the length of value has to match the bytesize specified on construction of the SSBO.
func (*SSBO) UploadValueInRange ¶
UploadValueInRange value fills the buffer with one element starting at start len times into this SSBO. Thus the length of value has to match the bytesize specified on construction of the SSBO.
type ShaderProgram ¶
type ShaderProgram struct {
// contains filtered or unexported fields
}
ShaderProgram represents a shader program object and contains all Renderables that share the same shader.
func MakeComputeProgram ¶
func MakeComputeProgram(computeShaderPath string) (ShaderProgram, error)
MakeComputeProgram contrusts a ShaderProgram that consists of a compute shader.
func MakeGeomProgram ¶
func MakeGeomProgram(vertexShaderPath, geometryShaderPath, fragmentShaderPath string) (ShaderProgram, error)
MakeGeomProgram contrusts a ShaderProgram that consists of a vertex, geometry and fragment shader.
func MakeProgram ¶
func MakeProgram(vertexShaderPath, fragmentShaderPath string) (ShaderProgram, error)
MakeProgram contrusts a ShaderProgram that consists of a vertex and fragment shader.
func (*ShaderProgram) AddRenderable ¶
func (shaderProgram *ShaderProgram) AddRenderable(renderable Renderable)
AddRenderable adds a Rendereable to the slices of Renderables that should be rendered.
func (*ShaderProgram) Compute ¶
func (ShaderProgram *ShaderProgram) Compute(numgroupsx, numgroupsy, numgroupsz uint32)
Compute needs to be called when the shader is a compute shader. The group sizes of the compute shader have to specified in the x,y and z dimension. The dimensions need to be > 1.
func (*ShaderProgram) Delete ¶
func (shaderProgram *ShaderProgram) Delete()
Delete deletes the OpenGL ShaderProgram handle.
func (*ShaderProgram) GetHandle ¶
func (shaderProgram *ShaderProgram) GetHandle() uint32
Returns a handle to the ShaderProgram.
func (*ShaderProgram) RemoveAllRenderables ¶
func (ShaderProgram *ShaderProgram) RemoveAllRenderables()
RemoveAllRenderables removes all Renderables.
func (*ShaderProgram) Render ¶
func (shaderProgram *ShaderProgram) Render()
Render draws all Renderables that had been added to this ShaderProgram.
func (*ShaderProgram) RenderInstanced ¶
func (shaderProgram *ShaderProgram) RenderInstanced(instancecount int32)
RenderInstances draws all Renderables each multiple times defined by instancecount.
func (*ShaderProgram) UpdateFloat32 ¶
func (shaderProgram *ShaderProgram) UpdateFloat32(uniformName string, f32 float32)
UpdateInt32 updates the value of an 32bit float in the shader.
func (*ShaderProgram) UpdateInt32 ¶
func (shaderProgram *ShaderProgram) UpdateInt32(uniformName string, i32 int32)
UpdateInt32 updates the value of an 32bit int in the shader.
func (*ShaderProgram) UpdateMat4 ¶
func (shaderProgram *ShaderProgram) UpdateMat4(uniformName string, mat mgl32.Mat4)
UpdateInt32 updates the value of an mat4 in the shader.
func (*ShaderProgram) UpdateVec2 ¶
func (shaderProgram *ShaderProgram) UpdateVec2(uniformName string, vec2 mgl32.Vec2)
UpdateInt32 updates the value of an vec2 in the shader.
func (*ShaderProgram) UpdateVec3 ¶
func (shaderProgram *ShaderProgram) UpdateVec3(uniformName string, vec3 mgl32.Vec3)
UpdateInt32 updates the value of an vec3 in the shader.
func (*ShaderProgram) Use ¶
func (shaderProgram *ShaderProgram) Use()
Use binds the shader for rendering. Call it before calling Render.
type Skybox ¶
type Skybox struct {
// contains filtered or unexported fields
}
Skybox is a cube of size 2 ranging from -1 to 1 in all three dimensions. It requires a cubemap as texture for its six sides.
func MakeSkybox ¶
MakeSkybox constructs a Skybox object with the given cubemapTexture.
func (Skybox) Build ¶
Build prepares the vertex buffers for rendering. It is called by the RenderProgram after adding it using AddRenderable thus it is usually not advised to call it on your own.
func (*Skybox) Delete ¶
func (skybox *Skybox) Delete()
Delete destroys this Renderable as well as the cubemapTexture.
func (Skybox) Render ¶
func (skybox Skybox) Render()
Render draws the geometry of this Renderable using the currently bound shader.
func (Skybox) RenderInstanced ¶
RenderInstanced draws the geometry of this Renderable multiple times according to the instancecount.
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture holds no to several images.
func MakeColorMultisampleTexture ¶
MakeColorMultisampleTexture creates a multisample color texture of the given width and height and the number of samples that should be used.
func MakeColorTexture ¶
MakeColorTexture creates a color texture of the specified size.
func MakeCubeMapTexture ¶
MakeCupeMapTexture creates a cube map with the images specfied from the path.
func MakeDepthMultisampleTexture ¶
MakeDepthMultisampleTexture creates a multisample depth texture of the given width and height and the number of samples that should be used.
func MakeDepthTexture ¶
MakeDepthTexture creates a depth texture of the specfied size.
func MakeEmptyTexture ¶
func MakeEmptyTexture() Texture
MakeEmptyTexture creates a Texture with no image data.
func MakeMultisampleTexture ¶
func MakeMultisampleTexture(width, height, samples int32, format uint32, min, mag, s, t int32) Texture
MakeMultisampleTexture creates a multisample texture of the given width and height and the number of samples that should be used. Internalformat, format and pixelType specifed the layout of the data. Data is pointing to the data that is going to be uploaded. Min and mag specify the behaviour when down and upscaling the texture. S and t specify the behaviour at the borders of the image.
func MakeTexture ¶
func MakeTexture(width, height, internalformat int32, format, pixelType uint32, data unsafe.Pointer, min, mag, s, t int32) Texture
MakeTexture creates a texture the given width and height. Internalformat, format and pixelType specifed the layout of the data. Data is pointing to the data that is going to be uploaded. Min and mag specify the behaviour when down and upscaling the texture. S and t specify the behaviour at the borders of the image.
func MakeTextureFromPath ¶
MakeTextureFromPath creates a texture with the image data specifed in path.
func (*Texture) GenMipmap ¶
func (tex *Texture) GenMipmap()
GenMipmap generates mipmap levels. Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the GL_LINEAR criterion to produce a texture value.
func (*Texture) GenMipmapNearest ¶
func (tex *Texture) GenMipmapNearest()
GenMipmap generates mipmap levels. Chooses the mipmap that most closely matches the size of the pixel being textured and uses the GL_LINEAR criterion to produce a texture value.
type VAO ¶
type VAO struct {
// contains filtered or unexported fields
}
VAO is a buffer that holds multiple vertex buffers and zero to one index buffer.
func MakeVAO ¶
Creates a new VAO. 'mode' specified the drawing mode used. Some modes would be TRIANGLE, TRIANGLE_STRIP, TRIANGLE_FAN
func (*VAO) AddIndexBuffer ¶
AddIndexBuffer sets the index buffer.
func (*VAO) AddVertexBuffer ¶
AddVertexBuffer adds a vertex buffer at the end.
func (*VAO) BuildBuffers ¶
BuildBuffers gets called by the Shader to setup all added buffers.
func (*VAO) Delete ¶
func (vao *VAO) Delete()
Delete destroys this and all vertex and index buffers associated with this VAO.
func (*VAO) GetIndexBuffer ¶
GetIndexBuffer returns the only index buffer.
func (*VAO) GetVertexBuffer ¶
GetVertexBuffer returns the vertex buffer at the specifed index.
func (*VAO) Render ¶
func (vao *VAO) Render()
Render draws the geometry. It uses indexed rendering if a index buffer is present.
func (*VAO) RenderInstanced ¶
RenderInstanced draws the geomtry multiple times defined by the instancecount. It uses indexed rendering if a index buffer is present.
type VBO ¶
type VBO struct {
// contains filtered or unexported fields
}
VBO is a buffer that stores vertex attributes.
func MakeVBO ¶
MakeVBO construct a VBO width the specified data and the size of one element. The usage gives the GPU a hint how to treat the data usage. Usage patterns are GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY
func (*VBO) AddVertexAttribute ¶
AddVertexAttribute adds a new vertex layout for the given name the number of elements and the data type of the elements.
func (*VBO) BuildVertexAttributes ¶
BuildVertexAttributes is called by the shader and binds the vertex data to the variable specified by name.
func (*VBO) UpdateData ¶
UpdateData replaces the previous data with this data. Make sure that the data follows the same layout as specified by the vertex attributes.
type VertexAttribute ¶
type VertexAttribute struct {
// contains filtered or unexported fields
}
VertexAttribute specifies the layout of the vertex buffer.
type WindowManager ¶
type WindowManager struct { Window *glfw.Window Width int Height int // contains filtered or unexported fields }
WindowManager takes care of window creation and interaction.
func NewWindowManager ¶
func NewWindowManager(title string, width, height int) (*WindowManager, error)
NewWindowManager returns a pointer to a WindowManager with the specified window title and window width and height.
func (*WindowManager) AddCursorPosHandler ¶
func (windowManager *WindowManager) AddCursorPosHandler(handler CursorPosHandler)
AddCursorPosHandler registers a CursorPosHandler in the WindowManager.
func (*WindowManager) AddInteractable ¶
func (windowManager *WindowManager) AddInteractable(interactable Interactable)
AddInteractable registers all handlers of the interactable in the Windowmanager.
func (*WindowManager) AddKeyPressHandler ¶
func (windowManager *WindowManager) AddKeyPressHandler(handler KeyPressHandler)
AddKeyPressHandler registers a KeyPressHandler in the WindowManager.
func (*WindowManager) AddMouseButtonHandler ¶
func (windowManager *WindowManager) AddMouseButtonHandler(handler MouseButtonHandler)
AddMouseButtonHandler registers a MouseButtonHandler in the WindowManager.
func (*WindowManager) AddMouseScrollHandler ¶
func (windowManager *WindowManager) AddMouseScrollHandler(handler MouseScrollHandler)
AddMouseScrollHandler registers a MouseScrollHandler in the WindowManager.
func (*WindowManager) Close ¶
func (windowManager *WindowManager) Close()
Close cleans up the WindowManager.
func (*WindowManager) EnableCursorLoop ¶
func (windowManager *WindowManager) EnableCursorLoop()
EnableCursorLoop hides the cursor and loops it inside the window in x and y direction.
func (*WindowManager) GetFPS ¶
func (windowManager *WindowManager) GetFPS() float64
GetFPS returns the fps of the previous frame.
func (*WindowManager) LockFPS ¶
func (windowManager *WindowManager) LockFPS(fps float64)
LockFPS provides an upper bound for the FPS. The fps has to be greater than zero.
func (*WindowManager) RunMainLoop ¶
func (windowManager *WindowManager) RunMainLoop(render func())
RunMainLoop calls the specified render function each frame until the window is being closed.
func (*WindowManager) SetClearColor ¶
func (windowManager *WindowManager) SetClearColor(r, g, b float32)
SetClearColor updates the color used for a new frame and when clearing a FBO.
func (*WindowManager) SetTitle ¶
func (windowManager *WindowManager) SetTitle(title string)
SetTitle updates the window title.