Files
aego/gpu/gl33/api.go
T
sanspie 17cb5e4291 Stage 2-5: assets, scene/ECS, editor, 3D, and Aego Script
Stage 2: render pipeline and UI toolkit over gpu/platform.
Stage 3: schema registry, asset pipeline + runtime loader, scene graph and ECS.
Stage 4: editor — docking, inspector, scene/game views, play mode, asset browser, console, profiler; 4.5 adds the 3D foundation (mixed 2D/3D spaces, meshes, depth).
Stage 5: Aego Script — compiler (lexer/parser/types/resolver/checker/asm/compiler), bytecode with verifier and register VM, instance runtime, stdlib, native bindings, and editor/CLI integration (aego run/edit/check/test/dump).
2026-10-08 13:17:28 +03:00

99 lines
1.9 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) FrontFace(cw bool) {
if cw {
gl.FrontFace(gl.CW)
return
}
gl.FrontFace(gl.CCW)
}
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))
}