Files
sanspie dae4bc19e1 Stage 1: engine core, platform, gpu, vfs
Foundation for the aego engine.

core/    errs, log, handle arena, mathx, clock, stats
platform SDL3 backend plus a headless one, input state, events
gpu      device abstraction with gl33 and null backends
vfs      scheme-based virtual filesystem with overlay mounts
engine   builder, module registry, phase-ordered system loop, jobs
demos    basic, resize, input, headless; sandbox driver

OpenGL bindings are generated into gpu/gl33/gl by tools/gen-gl.sh,
so the module has no external dependencies.
2026-09-18 20:51:54 +03:00

91 lines
1.8 KiB
Go

package gl33
import (
"aego/gpu/gl33/gl"
"aego/gpu/gl33/internal/glstate"
)
type realAPI struct{}
func (realAPI) UseProgram(id uint32) {
gl.UseProgram(id)
}
func (realAPI) BindVertexArray(id uint32) {
gl.BindVertexArray(id)
}
func (realAPI) BindUniformBuffer(slot int, id uint32) {
gl.BindBufferBase(gl.UNIFORM_BUFFER, uint32(slot), id)
}
func (realAPI) BindTexture(unit int, id uint32) {
gl.ActiveTexture(gl.TEXTURE0 + uint32(unit))
gl.BindTexture(gl.TEXTURE_2D, id)
}
func (realAPI) BindSampler(unit int, id uint32) {
gl.BindSampler(uint32(unit), id)
}
func (realAPI) BindFramebuffer(id uint32) {
gl.BindFramebuffer(gl.FRAMEBUFFER, id)
}
func (realAPI) SetBlend(b glstate.Blend) {
if !b.Enabled {
gl.Disable(gl.BLEND)
return
}
gl.Enable(gl.BLEND)
gl.BlendFuncSeparate(b.SrcRGB, b.DstRGB, b.SrcA, b.DstA)
}
func (realAPI) SetDepth(d glstate.Depth) {
if d.Test {
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(d.Func)
} else {
gl.Disable(gl.DEPTH_TEST)
}
gl.DepthMask(d.Write)
}
func (realAPI) SetCull(c glstate.Cull) {
if !c.Enabled {
gl.Disable(gl.CULL_FACE)
return
}
gl.Enable(gl.CULL_FACE)
gl.CullFace(c.Face)
}
func (realAPI) Viewport(r glstate.Rect) {
gl.Viewport(r.X, r.Y, r.W, r.H)
}
func (realAPI) Scissor(enabled bool, r glstate.Rect) {
if !enabled {
gl.Disable(gl.SCISSOR_TEST)
return
}
gl.Enable(gl.SCISSOR_TEST)
gl.Scissor(r.X, r.Y, r.W, r.H)
}
func (realAPI) BindArrayBuffer(id uint32) {
gl.BindBuffer(gl.ARRAY_BUFFER, id)
}
func (realAPI) BindElementBuffer(id uint32) {
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, id)
}
func (realAPI) AttribPointer(a glstate.Attrib) {
if a.Integer {
gl.VertexAttribIPointer(a.Location, a.Size, a.Type, a.Stride, offsetPtr(a.Offset))
return
}
gl.VertexAttribPointer(a.Location, a.Size, a.Type, a.Normalized, a.Stride, offsetPtr(a.Offset))
}