graphics

package
v0.0.0-...-d51a67d Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MillisPerSecond = 1000
	SleepDuration   = time.Millisecond * 5
)

Variables

This section is empty.

Functions

func InitOpenGL

func InitOpenGL()

InitOpenGL initializes OpenGL and returns an initialized program.

func MakeLightVao

func MakeLightVao(vertices []float32, program uint32, vbo uint32) uint32

func MakeObjectVao

func MakeObjectVao(vertices []float32, program uint32) (uint32, uint32)

func MakeTexture

func MakeTexture(path string) uint32

func Show

func Show(keepOpen *bool)

Show demonstrates most ImGui features that were ported to Go. This function tries to recreate the original demo window as closely as possible.

In theory, if both windows would provide the identical functionality, then the wrapper would be complete.

Types

type Camera

type Camera struct {
	CameraPos   mgl.Vec3
	CameraFront mgl.Vec3
	CameraUp    mgl.Vec3

	Yaw         float64
	Pitch       float64
	LastX       float64
	LastY       float64
	Fov         float64
	Sensitivity float64

	FirstMouse bool
}

func GetCamera

func GetCamera() Camera

func (*Camera) MouseCallback

func (c *Camera) MouseCallback(w *glfw.Window, xpos float64, ypos float64)

func (*Camera) ScrollCallback

func (c *Camera) ScrollCallback(w *glfw.Window, xoff float64, yoff float64)

type Clipboard

type Clipboard struct {
	Platform Platform
}

func (Clipboard) SetText

func (board Clipboard) SetText(text string)

func (Clipboard) Text

func (board Clipboard) Text() (string, error)

type GLFW

type GLFW struct {
	ImguiIO imgui.IO

	Window *glfw.Window
	// contains filtered or unexported fields
}

GLFW implements a platform based on github.com/go-gl/glfw (v3.2).

func InitGlfw

func InitGlfw(io imgui.IO, cnf *config.Config) (*GLFW, error)

initGlfw initializes glfw and returns a Window to use.

func (*GLFW) ClipboardText

func (platform *GLFW) ClipboardText() (string, error)

ClipboardText returns the current Clipboard text, if available.

func (*GLFW) DisplaySize

func (platform *GLFW) DisplaySize() [2]float32

DisplaySize returns the dimension of the display.

func (*GLFW) Dispose

func (platform *GLFW) Dispose()

Dispose cleans up the resources.

func (*GLFW) FramebufferSize

func (platform *GLFW) FramebufferSize() [2]float32

FramebufferSize returns the dimension of the framebuffer.

func (*GLFW) NewFrame

func (platform *GLFW) NewFrame()

NewFrame marks the begin of a render pass. It forwards all current state to imgui IO.

func (*GLFW) PostRender

func (platform *GLFW) PostRender()

PostRender performs a buffer swap.

func (*GLFW) ProcessEvents

func (platform *GLFW) ProcessEvents()

ProcessEvents handles all pending Window events.

func (*GLFW) SetClipboardText

func (platform *GLFW) SetClipboardText(text string)

SetClipboardText sets the text as the current Clipboard text.

func (*GLFW) ShouldStop

func (platform *GLFW) ShouldStop() bool

ShouldStop returns true if the Window is to be closed.

type GLFWClientAPI

type GLFWClientAPI string

GLFWClientAPI identifies the render system that shall be initialized.

type OpenGL3

type OpenGL3 struct {
	// contains filtered or unexported fields
}

OpenGL3 implements a renderer based on github.com/go-gl/gl (v3.2-core).

func NewOpenGL3

func NewOpenGL3(io imgui.IO) (*OpenGL3, error)

NewOpenGL3 attempts to initialize a renderer. An OpenGL context has to be established before calling this function.

func (*OpenGL3) Dispose

func (renderer *OpenGL3) Dispose()

Dispose cleans up the resources.

func (*OpenGL3) PreRender

func (renderer *OpenGL3) PreRender(clearColor [3]float32)

PreRender clears the framebuffer.

func (*OpenGL3) Render

func (renderer *OpenGL3) Render(displaySize [2]float32, framebufferSize [2]float32, drawData imgui.DrawData)

Render translates the ImGui draw data to OpenGL3 commands.

type Platform

type Platform interface {
	// ShouldStop is regularly called as the abort condition for the program loop.
	ShouldStop() bool
	// ProcessEvents is called once per render loop to dispatch any pending events.
	ProcessEvents()
	// DisplaySize returns the dimension of the display.
	DisplaySize() [2]float32
	// FramebufferSize returns the dimension of the framebuffer.
	FramebufferSize() [2]float32
	// NewFrame marks the begin of a render pass. It must update the imgui IO state according to user input (mouse, keyboard, ...)
	NewFrame()
	// PostRender marks the completion of one render pass. Typically this causes the display buffer to be swapped.
	PostRender()
	// ClipboardText returns the current text of the Clipboard, if available.
	ClipboardText() (string, error)
	// SetClipboardText sets the text as the current text of the Clipboard.
	SetClipboardText(text string)
}

Platform covers mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.

type Renderer

type Renderer interface {
	// PreRender causes the display buffer to be prepared for new output.
	PreRender(clearColor [3]float32)
	// Render draws the provided imgui draw data.
	Render(displaySize [2]float32, framebufferSize [2]float32, drawData imgui.DrawData)
}

Renderer covers rendering imgui draw data.

type Shader

type Shader struct {
	Id uint32
}

func ShaderFactory

func ShaderFactory(vertexShaderSource string, fragmentShaderSource string) Shader

func (*Shader) SetFloat

func (s *Shader) SetFloat(name string, value float32)

func (*Shader) SetInt

func (s *Shader) SetInt(name string, value int32)

Wrapping the ugly gl function calls

func (*Shader) SetMat2

func (s *Shader) SetMat2(name string, value mgl.Mat2)

func (*Shader) SetMat3

func (s *Shader) SetMat3(name string, value mgl.Mat3)

func (*Shader) SetMat4

func (s *Shader) SetMat4(name string, value mgl.Mat4)

func (*Shader) SetVec2

func (s *Shader) SetVec2(name string, value mgl.Vec2)

func (*Shader) SetVec3

func (s *Shader) SetVec3(name string, value mgl.Vec3)

func (*Shader) SetVec4

func (s *Shader) SetVec4(name string, value mgl.Vec4)

func (*Shader) Use

func (s *Shader) Use()

type StringError

type StringError string

StringError describes a basic error with static information.

func (StringError) Error

func (err StringError) Error() string

Error returns the string itself.

Jump to

Keyboard shortcuts

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