gl

package
v0.0.0-...-9d492ec Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	CreateBuffer() any
	CreateFramebuffer() any
	CreateProgram() any
	CreateRenderbuffer() any
	CreateShader(xtype uint32) any
	CreateTexture() any
	CreateVertexArray() any

	DeleteBuffer(buffer any)
	DeleteFramebuffer(framebuffer any)
	DeleteProgram(progarm any)
	DeleteRenderbuffer(renderbuffer any)
	DeleteShader(shader any)
	DeleteTexture(texture any)
	DeleteVertexArray(vertexArray any)

	BindBuffer(target uint32, buffer any)
	BindFramebuffer(target uint32, framebuffer any)
	BindRenderbuffer(target uint32, renderbuffer any)
	BindTexture(target uint32, texture any)
	BindVertexArray(array any)

	AttachShader(program any, shader any)
	// WARNING: might override bound TEXTURE_2D in webgl
	BlitFramebuffer(srcX0 int32, srcY0 int32, srcX1 int32, srcY1 int32, dstX0 int32, dstY0 int32, dstX1 int32, dstY1 int32, mask uint32, filter uint32)
	BufferData(target uint32, data any, usage uint32)
	Clear(mask uint32)
	ClearColor(r, g, b, a float32)
	CompileShader(shader any)
	DrawElementsInstanced(mode uint32, count int32, xtype uint32, indexOffset uintptr, instancecount int32)
	EnableVertexAttribArray(index uint32)
	FramebufferRenderbuffer(target uint32, attachment uint32, renderbuffertarget uint32, renderbuffer any)
	FramebufferTexture2D(target uint32, attachment uint32, textarget uint32, texture any, level int32)
	GetProgramInfoLog(program any) string
	GetProgramParameter(program any, pname uint32) int32
	GetShaderInfoLog(shader any) string
	GetShaderParameter(shader any, pname uint32) int32
	GetUniformLocation(program any, name string) any
	LinkProgram(program any)
	RenderbufferStorageMultisample(target uint32, samples int32, internalformat uint32, width int32, height int32)
	ShaderSource(shader any, source string)
	TexImage2D(target uint32, level int32, internalformat int32, width int32, height int32, border int32, format uint32, xtype uint32, pixels any)
	UseProgram(program any)
	VertexAttribDivisor(index uint32, divisor uint32)
	VertexAttribIPointer(index uint32, size int32, xtype uint32, stride int32, offset uintptr)
	VertexAttribPointer(index uint32, size int32, xtype uint32, normalized bool, stride int32, offset uintptr)
	Viewport(x int32, y int32, width int32, height int32)

	Uniform1i(location any, v0 int32)
	Uniform2i(location any, v0, v1 int32)
	Uniform3i(location any, v0, v1, v2 int32)
	Uniform4i(location any, v0, v1, v2, v3 int32)
	Uniform1ui(location any, v0 uint32)
	Uniform2ui(location any, v0, v1 uint32)
	Uniform3ui(location any, v0, v1, v2 uint32)
	Uniform4ui(location any, v0, v1, v2, v3 uint32)
	Uniform1f(location any, v0 float32)
	Uniform2f(location any, v0, v1 float32)
	Uniform3f(location any, v0, v1, v2 float32)
	Uniform4f(location any, v0, v1, v2, v3 float32)
}

type DataBuffer

type DataBuffer struct {

	// buffer for data
	Buffer any
	// true if usgae is STATIC_DRAW
	Usage uint32
	// layout is part of VAO in opengl, so the glCalls should happen in the operation
	// Buffer layout of interleaved
	Layout []render.InputType
	// Size in bytes of a section of the buffer
	LayoutSize uint16
	// contains filtered or unexported fields
}

func (*DataBuffer) Free

func (d *DataBuffer) Free()

func (*DataBuffer) SetData16

func (d *DataBuffer) SetData16(data []uint16)

func (*DataBuffer) SetData32

func (d *DataBuffer) SetData32(data []uint32)

func (*DataBuffer) SetData64

func (d *DataBuffer) SetData64(data []uint64)

func (*DataBuffer) SetData8

func (d *DataBuffer) SetData8(data []uint8)

if only generic methods were a thing... code repitition will work for now

func (*DataBuffer) SetLayout

func (d *DataBuffer) SetLayout(layout ...render.InputType)

type Operation

type Operation struct {

	// Vao Object
	Vao any
	// Amount of instances to draw
	InstanceAmt uint32
	// Procedure to use for drawing
	Proc *Procedure
	// Parameters for uniforms
	UniformParams map[string]any
	// Start index of sprite in
	SpriteIdxStart int32
	// Amount of indices in sprite
	SpriteIdxAmt int32
	// contains filtered or unexported fields
}

func GLOperation

func GLOperation(o render.Operation) (*Operation, bool)

func (*Operation) DrawTo

func (o *Operation) DrawTo(target render.RenderTarget)

func (*Operation) Free

func (o *Operation) Free()

func (*Operation) SetAmount

func (o *Operation) SetAmount(amount uint32)

func (*Operation) SetChannelValue

func (o *Operation) SetChannelValue(channel render.Channel, data any)

func (*Operation) SetInstanceAttribute

func (o *Operation) SetInstanceAttribute(channel render.Channel, buffer render.DataBuffer, offset uint32, index uint16)

func (*Operation) SetSprite

func (o *Operation) SetSprite(buffer render.SpriteBuffer, id uint32)

type Procedure

type Procedure struct {
	render.ProcedureIdentifier

	// Shader program object
	Prog any
	// Uniform location of screen size
	ScreenSizeLocation any
	// Attribute channels
	AttribChannels map[render.Channel]shader.AttribChannelInfo
	// Uniform locations
	UniformLocations map[string]any
	// contains filtered or unexported fields
}

func (*Procedure) Free

func (p *Procedure) Free()

type RenderTarget

type RenderTarget struct {

	// Framebuffer object
	Framebuffer any
	// DrawBuffer object, this is either a texture or a renderbuffer (if multisampled)
	DrawBuffer any
	// DepthBuffer object, again eithr a texture or a renderbuffer (if multisampled)
	DepthBuffer any
	Multisample bool
	// contains filtered or unexported fields
}

func GLRenderTarget

func GLRenderTarget(target render.RenderTarget) (*RenderTarget, bool)

func (*RenderTarget) BlitTo

func (t *RenderTarget) BlitTo(target render.RenderTarget, x, y int32)

func (*RenderTarget) Clear

func (t *RenderTarget) Clear(r uint8, g uint8, b uint8)

func (*RenderTarget) Free

func (t *RenderTarget) Free()

func (*RenderTarget) Height

func (t *RenderTarget) Height() uint16

func (*RenderTarget) Resize

func (t *RenderTarget) Resize(width, height uint16)

func (*RenderTarget) Width

func (t *RenderTarget) Width() uint16

type Renderer

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

func GLRenderer

func GLRenderer(r render.Renderer) (*Renderer, bool)

doing it like this since some types might be extended (like primaryRenderTarget)

func NewRenderer

func NewRenderer(winWdith, winHeight func() uint16, cxt Context, version string, overrideTarget bool) *Renderer

should be called after gl and GLFW is initialized assumes primary rendertarget is set up properly

func (*Renderer) Context

func (r *Renderer) Context() Context

renderer types do not have this method, since you can just get the context here and save it

func (*Renderer) GLSLVersion

func (r *Renderer) GLSLVersion() string

func (*Renderer) MakeDataBuffer

func (r *Renderer) MakeDataBuffer(static bool) render.DataBuffer

func (*Renderer) MakeOperation

func (r *Renderer) MakeOperation(proc render.Procedure) render.Operation

func (*Renderer) MakeProcedureBuilder

func (r *Renderer) MakeProcedureBuilder() render.ProcedureBuilder

func (*Renderer) MakeRenderTarget

func (r *Renderer) MakeRenderTarget(width, height uint16, multisample bool) render.RenderTarget

func (*Renderer) MakeSpriteBufferBuilder

func (r *Renderer) MakeSpriteBufferBuilder() render.SpriteBufferBuilder

func (*Renderer) PrimaryRenderTarget

func (r *Renderer) PrimaryRenderTarget() render.RenderTarget

func (*Renderer) RealPrimaryRenderTarget

func (r *Renderer) RealPrimaryRenderTarget() render.RenderTarget

type SpriteBuffer

type SpriteBuffer struct {
	render.SpriteBufferIdentifier

	// Buffer of verts
	Verts any
	// Buffer of inds
	Inds any
	// Start indices for every sprite, first is 0, last is len(Inds)
	IdxPositions []uint32
	// The usage passed to BufferData
	Usage uint32
	// contains filtered or unexported fields
}

func GLSpriteBuffer

func GLSpriteBuffer(s render.SpriteBuffer) (*SpriteBuffer, bool)

func (*SpriteBuffer) Free

func (s *SpriteBuffer) Free()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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