opengl: Rename FramebufferStruct -> Framebuffer

This commit is contained in:
Hajime Hoshi 2018-11-04 17:49:40 +09:00
parent 9dae11808f
commit c7ea761031
6 changed files with 14 additions and 14 deletions

View File

@ -43,7 +43,7 @@ func MaxImageSize() int {
// Image represents an image that is implemented with OpenGL. // Image represents an image that is implemented with OpenGL.
type Image struct { type Image struct {
texture opengl.Texture texture opengl.Texture
framebuffer *opengl.FramebufferStruct framebuffer *opengl.Framebuffer
width int width int
height int height int
} }
@ -121,7 +121,7 @@ func (i *Image) IsInvalidated() bool {
return !opengl.GetContext().IsTexture(i.texture) return !opengl.GetContext().IsTexture(i.texture)
} }
func (i *Image) ensureFramebuffer() (*opengl.FramebufferStruct, error) { func (i *Image) ensureFramebuffer() (*opengl.Framebuffer, error) {
if i.framebuffer != nil { if i.framebuffer != nil {
return i.framebuffer, nil return i.framebuffer, nil
} }

View File

@ -96,7 +96,7 @@ func (c *Context) bindFramebuffer(f framebufferNative) {
c.lastFramebuffer = f c.lastFramebuffer = f
} }
func (c *Context) SetViewport(f *FramebufferStruct) { 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)

View File

@ -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 var pixels []byte
_ = c.runOnContextThread(func() error { _ = c.runOnContextThread(func() error {
gl.Flush() gl.Flush()

View File

@ -204,7 +204,7 @@ func (c *Context) bindFramebufferImpl(f framebufferNative) {
gl.Call("bindFramebuffer", framebuffer, js.Value(f)) 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 gl := c.gl
c.bindFramebuffer(f.native) c.bindFramebuffer(f.native)

View File

@ -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 *FramebufferStruct, 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()

View File

@ -14,10 +14,10 @@
package opengl 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. // TODO: Create a new struct Image and embed this struct.
type FramebufferStruct struct { type Framebuffer struct {
native framebufferNative native framebufferNative
proMatrix []float32 proMatrix []float32
width int width int
@ -25,12 +25,12 @@ type FramebufferStruct struct {
} }
// NewFramebufferFromTexture creates a framebuffer from the given texture. // 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) native, err := theContext.newFramebuffer(texture)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &FramebufferStruct{ return &Framebuffer{
native: native, native: native,
width: width, width: width,
height: height, height: height,
@ -38,8 +38,8 @@ func NewFramebufferFromTexture(texture Texture, width, height int) (*Framebuffer
} }
// NewScreenFramebuffer creates a framebuffer for the screen. // NewScreenFramebuffer creates a framebuffer for the screen.
func NewScreenFramebuffer(width, height int) *FramebufferStruct { func NewScreenFramebuffer(width, height int) *Framebuffer {
return &FramebufferStruct{ return &Framebuffer{
native: theContext.getScreenFramebuffer(), native: theContext.getScreenFramebuffer(),
width: width, width: width,
height: height, height: height,
@ -51,7 +51,7 @@ func NewScreenFramebuffer(width, height int) *FramebufferStruct {
// 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 *FramebufferStruct) ProjectionMatrix() []float32 { func (f *Framebuffer) ProjectionMatrix() []float32 {
if f.proMatrix != nil { if f.proMatrix != nil {
return f.proMatrix return f.proMatrix
} }
@ -59,7 +59,7 @@ func (f *FramebufferStruct) ProjectionMatrix() []float32 {
return f.proMatrix return f.proMatrix
} }
func (f *FramebufferStruct) Delete() { func (f *Framebuffer) Delete() {
if f.native != theContext.getScreenFramebuffer() { if f.native != theContext.getScreenFramebuffer() {
theContext.deleteFramebuffer(f.native) theContext.deleteFramebuffer(f.native)
} }