mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
opengl: Rename FramebufferStruct -> Framebuffer
This commit is contained in:
parent
9dae11808f
commit
c7ea761031
@ -43,7 +43,7 @@ func MaxImageSize() int {
|
||||
// Image represents an image that is implemented with OpenGL.
|
||||
type Image struct {
|
||||
texture opengl.Texture
|
||||
framebuffer *opengl.FramebufferStruct
|
||||
framebuffer *opengl.Framebuffer
|
||||
width int
|
||||
height int
|
||||
}
|
||||
@ -121,7 +121,7 @@ func (i *Image) IsInvalidated() bool {
|
||||
return !opengl.GetContext().IsTexture(i.texture)
|
||||
}
|
||||
|
||||
func (i *Image) ensureFramebuffer() (*opengl.FramebufferStruct, error) {
|
||||
func (i *Image) ensureFramebuffer() (*opengl.Framebuffer, error) {
|
||||
if i.framebuffer != nil {
|
||||
return i.framebuffer, nil
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ func (c *Context) bindFramebuffer(f framebufferNative) {
|
||||
c.lastFramebuffer = f
|
||||
}
|
||||
|
||||
func (c *Context) SetViewport(f *FramebufferStruct) {
|
||||
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 *FramebufferStruct, 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()
|
||||
|
@ -204,7 +204,7 @@ func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
||||
gl.Call("bindFramebuffer", framebuffer, js.Value(f))
|
||||
}
|
||||
|
||||
func (c *Context) FramebufferPixels(f *FramebufferStruct, width, height int) ([]byte, error) {
|
||||
func (c *Context) FramebufferPixels(f *Framebuffer, width, height int) ([]byte, error) {
|
||||
gl := c.gl
|
||||
|
||||
c.bindFramebuffer(f.native)
|
||||
|
@ -156,7 +156,7 @@ func (c *Context) bindFramebufferImpl(f framebufferNative) {
|
||||
gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(f))
|
||||
}
|
||||
|
||||
func (c *Context) FramebufferPixels(f *FramebufferStruct, width, height int) ([]byte, error) {
|
||||
func (c *Context) FramebufferPixels(f *Framebuffer, width, height int) ([]byte, error) {
|
||||
gl := c.gl
|
||||
gl.Flush()
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
package opengl
|
||||
|
||||
// FramebufferStruct is a wrapper of OpenGL's framebuffer.
|
||||
// Framebuffer is a wrapper of OpenGL's framebuffer.
|
||||
//
|
||||
// TODO: Create a new struct Image and embed this struct.
|
||||
type FramebufferStruct struct {
|
||||
type Framebuffer struct {
|
||||
native framebufferNative
|
||||
proMatrix []float32
|
||||
width int
|
||||
@ -25,12 +25,12 @@ type FramebufferStruct struct {
|
||||
}
|
||||
|
||||
// NewFramebufferFromTexture creates a framebuffer from the given texture.
|
||||
func NewFramebufferFromTexture(texture Texture, width, height int) (*FramebufferStruct, error) {
|
||||
func NewFramebufferFromTexture(texture Texture, width, height int) (*Framebuffer, error) {
|
||||
native, err := theContext.newFramebuffer(texture)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &FramebufferStruct{
|
||||
return &Framebuffer{
|
||||
native: native,
|
||||
width: width,
|
||||
height: height,
|
||||
@ -38,8 +38,8 @@ func NewFramebufferFromTexture(texture Texture, width, height int) (*Framebuffer
|
||||
}
|
||||
|
||||
// NewScreenFramebuffer creates a framebuffer for the screen.
|
||||
func NewScreenFramebuffer(width, height int) *FramebufferStruct {
|
||||
return &FramebufferStruct{
|
||||
func NewScreenFramebuffer(width, height int) *Framebuffer {
|
||||
return &Framebuffer{
|
||||
native: theContext.getScreenFramebuffer(),
|
||||
width: width,
|
||||
height: height,
|
||||
@ -51,7 +51,7 @@ func NewScreenFramebuffer(width, height int) *FramebufferStruct {
|
||||
// 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 *FramebufferStruct) ProjectionMatrix() []float32 {
|
||||
func (f *Framebuffer) ProjectionMatrix() []float32 {
|
||||
if f.proMatrix != nil {
|
||||
return f.proMatrix
|
||||
}
|
||||
@ -59,7 +59,7 @@ func (f *FramebufferStruct) ProjectionMatrix() []float32 {
|
||||
return f.proMatrix
|
||||
}
|
||||
|
||||
func (f *FramebufferStruct) Delete() {
|
||||
func (f *Framebuffer) Delete() {
|
||||
if f.native != theContext.getScreenFramebuffer() {
|
||||
theContext.deleteFramebuffer(f.native)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user