mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
opengl: Unexport Framebuffer
This commit is contained in:
parent
7bbc32ce0e
commit
beae772287
@ -96,7 +96,7 @@ func (c *Context) bindFramebuffer(f framebufferNative) {
|
|||||||
c.lastFramebuffer = f
|
c.lastFramebuffer = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) setViewport(f *Framebuffer) {
|
func (c *Context) setViewport(f *framebuffer) {
|
||||||
c.bindFramebuffer(f.native)
|
c.bindFramebuffer(f.native)
|
||||||
if c.lastViewportWidth != f.width || c.lastViewportHeight != f.height {
|
if c.lastViewportWidth != f.width || c.lastViewportHeight != f.height {
|
||||||
c.setViewportImpl(f.width, f.height)
|
c.setViewportImpl(f.width, f.height)
|
||||||
|
@ -169,7 +169,7 @@ func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) framebufferPixels(f *Framebuffer, width, height int) ([]byte, error) {
|
func (c *Context) framebufferPixels(f *framebuffer, width, height int) ([]byte, error) {
|
||||||
var pixels []byte
|
var pixels []byte
|
||||||
_ = c.runOnContextThread(func() error {
|
_ = c.runOnContextThread(func() error {
|
||||||
gl.Flush()
|
gl.Flush()
|
||||||
|
@ -51,7 +51,7 @@ var (
|
|||||||
clampToEdge js.Value
|
clampToEdge js.Value
|
||||||
colorAttachment0 js.Value
|
colorAttachment0 js.Value
|
||||||
compileStatus js.Value
|
compileStatus js.Value
|
||||||
framebuffer js.Value
|
framebuffer_ js.Value
|
||||||
framebufferBinding js.Value
|
framebufferBinding js.Value
|
||||||
framebufferComplete js.Value
|
framebufferComplete js.Value
|
||||||
linkStatus js.Value
|
linkStatus js.Value
|
||||||
@ -92,7 +92,7 @@ func init() {
|
|||||||
clampToEdge = c.Get("CLAMP_TO_EDGE")
|
clampToEdge = c.Get("CLAMP_TO_EDGE")
|
||||||
compileStatus = c.Get("COMPILE_STATUS")
|
compileStatus = c.Get("COMPILE_STATUS")
|
||||||
colorAttachment0 = c.Get("COLOR_ATTACHMENT0")
|
colorAttachment0 = c.Get("COLOR_ATTACHMENT0")
|
||||||
framebuffer = c.Get("FRAMEBUFFER")
|
framebuffer_ = c.Get("FRAMEBUFFER")
|
||||||
framebufferBinding = c.Get("FRAMEBUFFER_BINDING")
|
framebufferBinding = c.Get("FRAMEBUFFER_BINDING")
|
||||||
framebufferComplete = c.Get("FRAMEBUFFER_COMPLETE")
|
framebufferComplete = c.Get("FRAMEBUFFER_COMPLETE")
|
||||||
linkStatus = c.Get("LINK_STATUS")
|
linkStatus = c.Get("LINK_STATUS")
|
||||||
@ -201,10 +201,10 @@ func (c *Context) newTexture(width, height int) (textureNative, error) {
|
|||||||
|
|
||||||
func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
gl.Call("bindFramebuffer", framebuffer, js.Value(f))
|
gl.Call("bindFramebuffer", framebuffer_, js.Value(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) framebufferPixels(f *Framebuffer, width, height int) ([]byte, error) {
|
func (c *Context) framebufferPixels(f *framebuffer, width, height int) ([]byte, error) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
|
|
||||||
c.bindFramebuffer(f.native)
|
c.bindFramebuffer(f.native)
|
||||||
@ -257,8 +257,8 @@ func (c *Context) newFramebuffer(t textureNative) (framebufferNative, error) {
|
|||||||
f := gl.Call("createFramebuffer")
|
f := gl.Call("createFramebuffer")
|
||||||
c.bindFramebuffer(framebufferNative(f))
|
c.bindFramebuffer(framebufferNative(f))
|
||||||
|
|
||||||
gl.Call("framebufferTexture2D", framebuffer, colorAttachment0, texture2d, js.Value(t), 0)
|
gl.Call("framebufferTexture2D", framebuffer_, colorAttachment0, texture2d, js.Value(t), 0)
|
||||||
if s := gl.Call("checkFramebufferStatus", framebuffer); s.Int() != framebufferComplete.Int() {
|
if s := gl.Call("checkFramebufferStatus", framebuffer_); s.Int() != framebufferComplete.Int() {
|
||||||
return framebufferNative(js.Null()), errors.New(fmt.Sprintf("opengl: creating framebuffer failed: %d", s.Int()))
|
return framebufferNative(js.Null()), errors.New(fmt.Sprintf("opengl: creating framebuffer failed: %d", s.Int()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
|||||||
gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(f))
|
gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) framebufferPixels(f *Framebuffer, width, height int) ([]byte, error) {
|
func (c *Context) framebufferPixels(f *framebuffer, width, height int) ([]byte, error) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
gl.Flush()
|
gl.Flush()
|
||||||
|
|
||||||
|
@ -14,10 +14,8 @@
|
|||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
// Framebuffer is a wrapper of OpenGL's framebuffer.
|
// framebuffer is a wrapper of OpenGL's framebuffer.
|
||||||
//
|
type framebuffer struct {
|
||||||
// TODO: Create a new struct Image and embed this struct.
|
|
||||||
type Framebuffer struct {
|
|
||||||
native framebufferNative
|
native framebufferNative
|
||||||
proMatrix []float32
|
proMatrix []float32
|
||||||
width int
|
width int
|
||||||
@ -25,12 +23,12 @@ type Framebuffer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newFramebufferFromTexture creates a framebuffer from the given texture.
|
// newFramebufferFromTexture creates a framebuffer from the given texture.
|
||||||
func newFramebufferFromTexture(texture textureNative, width, height int) (*Framebuffer, error) {
|
func newFramebufferFromTexture(texture textureNative, width, height int) (*framebuffer, error) {
|
||||||
native, err := theContext.newFramebuffer(texture)
|
native, err := theContext.newFramebuffer(texture)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &Framebuffer{
|
return &framebuffer{
|
||||||
native: native,
|
native: native,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
@ -38,8 +36,8 @@ func newFramebufferFromTexture(texture textureNative, width, height int) (*Frame
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newScreenFramebuffer creates a framebuffer for the screen.
|
// newScreenFramebuffer creates a framebuffer for the screen.
|
||||||
func newScreenFramebuffer(width, height int) *Framebuffer {
|
func newScreenFramebuffer(width, height int) *framebuffer {
|
||||||
return &Framebuffer{
|
return &framebuffer{
|
||||||
native: theContext.getScreenFramebuffer(),
|
native: theContext.getScreenFramebuffer(),
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
@ -51,7 +49,7 @@ func newScreenFramebuffer(width, height int) *Framebuffer {
|
|||||||
// A projection matrix converts the coodinates on the framebuffer
|
// A projection matrix converts the coodinates on the framebuffer
|
||||||
// (0, 0) - (viewport width, viewport height)
|
// (0, 0) - (viewport width, viewport height)
|
||||||
// to the normalized device coodinates (-1, -1) - (1, 1) with adjustment.
|
// to the normalized device coodinates (-1, -1) - (1, 1) with adjustment.
|
||||||
func (f *Framebuffer) projectionMatrix() []float32 {
|
func (f *framebuffer) projectionMatrix() []float32 {
|
||||||
if f.proMatrix != nil {
|
if f.proMatrix != nil {
|
||||||
return f.proMatrix
|
return f.proMatrix
|
||||||
}
|
}
|
||||||
@ -59,7 +57,7 @@ func (f *Framebuffer) projectionMatrix() []float32 {
|
|||||||
return f.proMatrix
|
return f.proMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Framebuffer) delete() {
|
func (f *framebuffer) delete() {
|
||||||
if f.native != theContext.getScreenFramebuffer() {
|
if f.native != theContext.getScreenFramebuffer() {
|
||||||
theContext.deleteFramebuffer(f.native)
|
theContext.deleteFramebuffer(f.native)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func checkSize(width, height int) {
|
|||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
textureNative textureNative
|
textureNative textureNative
|
||||||
Framebuffer *Framebuffer
|
Framebuffer *framebuffer
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user