gpu/internal/opengl: restore BeginFrame state in EndFrame

To ease the integration with foreign OpenGL contexts, carefully save the
context state before rendering a frame and restore it afterwards. Gio
rendering can then be mixed with OpenGL code that expects exclusive
control over context state.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-06-10 20:14:32 +02:00
parent 200957f924
commit 9b5e9ae607
9 changed files with 813 additions and 188 deletions
+53 -13
View File
@@ -3,20 +3,28 @@
package gl
type (
Buffer struct{ V uint }
Framebuffer struct{ V uint }
Program struct{ V uint }
Renderbuffer struct{ V uint }
Shader struct{ V uint }
Texture struct{ V uint }
Query struct{ V uint }
Uniform struct{ V int }
VertexArray struct{ V uint }
Object struct{ V uint }
Buffer Object
Framebuffer Object
Program Object
Renderbuffer Object
Shader Object
Texture Object
Query Object
Uniform struct{ V int }
VertexArray Object
)
func (o Object) valid() bool {
return o.V != 0
}
func (o Object) equal(o2 Object) bool {
return o == o2
}
func (u Framebuffer) Valid() bool {
return u.V != 0
return Object(u).valid()
}
func (u Uniform) Valid() bool {
@@ -24,13 +32,45 @@ func (u Uniform) Valid() bool {
}
func (p Program) Valid() bool {
return p.V != 0
return Object(p).valid()
}
func (s Shader) Valid() bool {
return s.V != 0
return Object(s).valid()
}
func (a VertexArray) Valid() bool {
return a.V != 0
return Object(a).valid()
}
func (f Framebuffer) Equal(f2 Framebuffer) bool {
return Object(f).equal(Object(f2))
}
func (p Program) Equal(p2 Program) bool {
return Object(p).equal(Object(p2))
}
func (s Shader) Equal(s2 Shader) bool {
return Object(s).equal(Object(s2))
}
func (u Uniform) Equal(u2 Uniform) bool {
return u == u2
}
func (a VertexArray) Equal(a2 VertexArray) bool {
return Object(a).equal(Object(a2))
}
func (r Renderbuffer) Equal(r2 Renderbuffer) bool {
return Object(r).equal(Object(r2))
}
func (t Texture) Equal(t2 Texture) bool {
return Object(t).equal(Object(t2))
}
func (b Buffer) Equal(b2 Buffer) bool {
return Object(b).equal(Object(b2))
}