opengl

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNSUPPORTED_GLYPH_ID = 0xffffffffffffffff // "Unsupported"
	UNDERCURL_GLYPH_ID   = 0xfffffffffffffffe // "Undercurl"
)

Variables

View Source
var (
	//go:embed shaders/grid.vert
	ShaderSourceGridVert string
	//go:embed shaders/grid.geom
	ShaderSourceGridGeom string
	//go:embed shaders/grid.frag
	ShaderSourceGridFrag string
)

Embedded shader sources

Functions

This section is empty.

Types

type Atlas

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

func (*Atlas) BindTexture

func (atlas *Atlas) BindTexture()

func (*Atlas) Destroy

func (atlas *Atlas) Destroy()

func (*Atlas) FontKit

func (atlas *Atlas) FontKit() *fontkit.FontKit

func (*Atlas) FontSize

func (atlas *Atlas) FontSize() float64

func (*Atlas) GetCharPos

func (atlas *Atlas) GetCharPos(char rune, bold, italic, underline, strikethrough bool, imgSize common.Vector2[int]) common.Rectangle[int]

func (*Atlas) ImageSize

func (atlas *Atlas) ImageSize() common.Vector2[int]

func (*Atlas) Normalize

func (atlas *Atlas) Normalize(pos common.Rectangle[int]) common.Rectangle[float32]

Normalization required when updating texture position to the gpu

func (*Atlas) Reset

func (atlas *Atlas) Reset()

func (*Atlas) SetBoxDrawing

func (atlas *Atlas) SetBoxDrawing(useBoxDrawing, useBlockDrawing bool)

func (*Atlas) SetFontKit

func (atlas *Atlas) SetFontKit(kit *fontkit.FontKit)

func (*Atlas) SetFontSize

func (atlas *Atlas) SetFontSize(fontSize, dpi float64)

func (*Atlas) String

func (atlas *Atlas) String() string

func (*Atlas) Undercurl

func (atlas *Atlas) Undercurl(imgSize common.Vector2[int]) (common.Rectangle[int], bool)

For the first time draws and caches undercurl image, returns image pos and true representing first time After that uses cached image and returns false

type Context

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

func New

func New(getProcAddress func(name string) unsafe.Pointer) (*Context, error)

Call per window

func (*Context) ClearScreen

func (context *Context) ClearScreen(c common.Color)

func (*Context) CreateTexture

func (context *Context) CreateTexture(width, height int) Texture

func (*Context) CreateVertexBuffer

func (context *Context) CreateVertexBuffer(size int) *VertexBuffer

func (*Context) Destroy

func (context *Context) Destroy()

func (*Context) Flush

func (context *Context) Flush()

func (*Context) Info

func (context *Context) Info() ContextInfo

func (*Context) NewAtlas

func (context *Context) NewAtlas(kit *fontkit.FontKit, size, dpi float64, useBoxDrawing, useBlockDrawing bool) *Atlas

func (*Context) SetViewport

func (context *Context) SetViewport(rect common.Rectangle[int])

type ContextInfo

type ContextInfo struct {
	Version                string
	Vendor                 string
	Renderer               string
	ShadingLanguageVersion string
	MaxTextureSize         int32
}

type Shader added in v0.2.5

type Shader struct {
	ID   uint32
	Type ShaderType
}

func NewShaderFromSource added in v0.2.5

func NewShaderFromSource(shader_type ShaderType, source string) *Shader

func (*Shader) Delete added in v0.2.5

func (shader *Shader) Delete()

type ShaderProgram

type ShaderProgram struct {
	ID uint32
	// contains filtered or unexported fields
}

func NewShaderProgram added in v0.2.5

func NewShaderProgram(vert *Shader, geom *Shader, frag *Shader) *ShaderProgram

All shaders can be safely destroyed after program creation

func (ShaderProgram) Destroy

func (program ShaderProgram) Destroy()

func (ShaderProgram) UniformLocation

func (program ShaderProgram) UniformLocation(name string) int32

func (ShaderProgram) Use

func (program ShaderProgram) Use()

type ShaderType added in v0.2.5

type ShaderType uint32
const (
	VERTEX_SHADER   ShaderType = gl.VERTEX_SHADER
	GEOMETRY_SHADER ShaderType = gl.GEOMETRY_SHADER
	FRAGMENT_SHADER ShaderType = gl.FRAGMENT_SHADER
)

func (ShaderType) String added in v0.2.5

func (st ShaderType) String() string

type Texture

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

func (*Texture) Bind

func (texture *Texture) Bind()

func (*Texture) Clear

func (texture *Texture) Clear()

func (*Texture) Delete

func (texture *Texture) Delete()

func (*Texture) Draw

func (texture *Texture) Draw(image *image.RGBA, dest common.Rectangle[int])

Texture must bound before drawing

func (*Texture) Normalize

func (texture *Texture) Normalize(pos common.Rectangle[int]) common.Rectangle[float32]

Converts coordinates to opengl understandable coordinates, 0 to 1

func (*Texture) Resize

func (texture *Texture) Resize(width, height int)

Texture must bound before resizing

func (*Texture) Size

func (texture *Texture) Size() common.Vector2[int]

func (Texture) String

func (texture Texture) String() string

type Vertex

type Vertex struct {
	// position of this vertex
	Pos common.Rectangle[float32] // layout 0
	// texture position
	Tex1 common.Rectangle[float32] // layout 1
	// second texture position used for multiwidth characters
	Tex2 common.Rectangle[float32] // layout 2
	// foreground color
	Fg common.Color // layout 3
	// background color
	Bg common.Color // layout 4
	// special color
	Sp common.Color // layout 5
}

func (Vertex) String

func (vertex Vertex) String() string

type VertexBuffer

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

func (*VertexBuffer) Bind

func (buffer *VertexBuffer) Bind()

func (*VertexBuffer) CopyButPos

func (buffer *VertexBuffer) CopyButPos(dst, src int)

func (*VertexBuffer) Destroy

func (buffer *VertexBuffer) Destroy()

func (*VertexBuffer) Render

func (buffer *VertexBuffer) Render()

Caller responsible to bind buffer Caller responsible to Flush

func (*VertexBuffer) Resize

func (buffer *VertexBuffer) Resize(size int)

Resize should clear the buffer

func (*VertexBuffer) SetIndexBg

func (buffer *VertexBuffer) SetIndexBg(index int, bg common.Color)

func (*VertexBuffer) SetIndexFg

func (buffer *VertexBuffer) SetIndexFg(index int, fg common.Color)

func (*VertexBuffer) SetIndexPos

func (buffer *VertexBuffer) SetIndexPos(index int, pos common.Rectangle[float32])

func (*VertexBuffer) SetIndexSp

func (buffer *VertexBuffer) SetIndexSp(index int, sp common.Color)

func (*VertexBuffer) SetIndexTex1

func (buffer *VertexBuffer) SetIndexTex1(index int, tex1 common.Rectangle[float32])

func (*VertexBuffer) SetIndexTex2

func (buffer *VertexBuffer) SetIndexTex2(index int, tex2 common.Rectangle[float32])

func (*VertexBuffer) SetProjection

func (buffer *VertexBuffer) SetProjection(rect common.Rectangle[float32])

func (*VertexBuffer) SetUndercurlRect

func (buffer *VertexBuffer) SetUndercurlRect(rect common.Rectangle[float32])

func (*VertexBuffer) String

func (buffer *VertexBuffer) String() string

func (*VertexBuffer) Update

func (buffer *VertexBuffer) Update()

Updates current buffer to GPU Caller responsible to bind buffer

func (*VertexBuffer) VertexAt

func (buffer *VertexBuffer) VertexAt(index int) Vertex

Directories

Path Synopsis
Package gl implements Go bindings to OpenGL.
Package gl implements Go bindings to OpenGL.

Jump to

Keyboard shortcuts

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