mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 13:07:26 +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
|
||||
}
|
||||
|
||||
func (c *Context) setViewport(f *Framebuffer) {
|
||||
func (c *Context) setViewport(f *framebuffer) {
|
||||
c.bindFramebuffer(f.native)
|
||||
if c.lastViewportWidth != f.width || c.lastViewportHeight != 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
|
||||
_ = c.runOnContextThread(func() error {
|
||||
gl.Flush()
|
||||
|
@ -51,7 +51,7 @@ var (
|
||||
clampToEdge js.Value
|
||||
colorAttachment0 js.Value
|
||||
compileStatus js.Value
|
||||
framebuffer js.Value
|
||||
framebuffer_ js.Value
|
||||
framebufferBinding js.Value
|
||||
framebufferComplete js.Value
|
||||
linkStatus js.Value
|
||||
@ -92,7 +92,7 @@ func init() {
|
||||
clampToEdge = c.Get("CLAMP_TO_EDGE")
|
||||
compileStatus = c.Get("COMPILE_STATUS")
|
||||
colorAttachment0 = c.Get("COLOR_ATTACHMENT0")
|
||||
framebuffer = c.Get("FRAMEBUFFER")
|
||||
framebuffer_ = c.Get("FRAMEBUFFER")
|
||||
framebufferBinding = c.Get("FRAMEBUFFER_BINDING")
|
||||
framebufferComplete = c.Get("FRAMEBUFFER_COMPLETE")
|
||||
linkStatus = c.Get("LINK_STATUS")
|
||||
@ -201,10 +201,10 @@ func (c *Context) newTexture(width, height int) (textureNative, error) {
|
||||
|
||||
func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
||||
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
|
||||
|
||||
c.bindFramebuffer(f.native)
|
||||
@ -257,8 +257,8 @@ func (c *Context) newFramebuffer(t textureNative) (framebufferNative, error) {
|
||||
f := gl.Call("createFramebuffer")
|
||||
c.bindFramebuffer(framebufferNative(f))
|
||||
|
||||
gl.Call("framebufferTexture2D", framebuffer, colorAttachment0, texture2d, js.Value(t), 0)
|
||||
if s := gl.Call("checkFramebufferStatus", framebuffer); s.Int() != framebufferComplete.Int() {
|
||||
gl.Call("framebufferTexture2D", framebuffer_, colorAttachment0, texture2d, js.Value(t), 0)
|
||||
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()))
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
||||
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.Flush()
|
||||
|
||||
|
@ -14,10 +14,8 @@
|
||||
|
||||
package opengl
|
||||
|
||||
// Framebuffer is a wrapper of OpenGL's framebuffer.
|
||||
//
|
||||
// TODO: Create a new struct Image and embed this struct.
|
||||
type Framebuffer struct {
|
||||
// framebuffer is a wrapper of OpenGL's framebuffer.
|
||||
type framebuffer struct {
|
||||
native framebufferNative
|
||||
proMatrix []float32
|
||||
width int
|
||||
@ -25,12 +23,12 @@ type Framebuffer struct {
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Framebuffer{
|
||||
return &framebuffer{
|
||||
native: native,
|
||||
width: width,
|
||||
height: height,
|
||||
@ -38,8 +36,8 @@ func newFramebufferFromTexture(texture textureNative, width, height int) (*Frame
|
||||
}
|
||||
|
||||
// newScreenFramebuffer creates a framebuffer for the screen.
|
||||
func newScreenFramebuffer(width, height int) *Framebuffer {
|
||||
return &Framebuffer{
|
||||
func newScreenFramebuffer(width, height int) *framebuffer {
|
||||
return &framebuffer{
|
||||
native: theContext.getScreenFramebuffer(),
|
||||
width: width,
|
||||
height: height,
|
||||
@ -51,7 +49,7 @@ func newScreenFramebuffer(width, height int) *Framebuffer {
|
||||
// A projection matrix converts the coodinates on the framebuffer
|
||||
// (0, 0) - (viewport width, viewport height)
|
||||
// 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 {
|
||||
return f.proMatrix
|
||||
}
|
||||
@ -59,7 +57,7 @@ func (f *Framebuffer) projectionMatrix() []float32 {
|
||||
return f.proMatrix
|
||||
}
|
||||
|
||||
func (f *Framebuffer) delete() {
|
||||
func (f *framebuffer) delete() {
|
||||
if f.native != theContext.getScreenFramebuffer() {
|
||||
theContext.deleteFramebuffer(f.native)
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func checkSize(width, height int) {
|
||||
|
||||
type Image struct {
|
||||
textureNative textureNative
|
||||
Framebuffer *Framebuffer
|
||||
Framebuffer *framebuffer
|
||||
width int
|
||||
height int
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user