From beae772287d77d1f5565aee8efde1012cb0ef541 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 4 Nov 2018 19:49:09 +0900 Subject: [PATCH] opengl: Unexport Framebuffer --- internal/opengl/context.go | 2 +- internal/opengl/context_desktop.go | 2 +- internal/opengl/context_js.go | 12 ++++++------ internal/opengl/context_mobile.go | 2 +- internal/opengl/framebuffer.go | 18 ++++++++---------- internal/opengl/image.go | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/internal/opengl/context.go b/internal/opengl/context.go index acadb55af..6a749edc1 100644 --- a/internal/opengl/context.go +++ b/internal/opengl/context.go @@ -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) diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index d81eb2c3b..55a9d37c0 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -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() diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index 4b7fc71f8..cf6864082 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -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())) } diff --git a/internal/opengl/context_mobile.go b/internal/opengl/context_mobile.go index 76b835735..f539dc888 100644 --- a/internal/opengl/context_mobile.go +++ b/internal/opengl/context_mobile.go @@ -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() diff --git a/internal/opengl/framebuffer.go b/internal/opengl/framebuffer.go index 1dda3718e..3b5d0195e 100644 --- a/internal/opengl/framebuffer.go +++ b/internal/opengl/framebuffer.go @@ -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) } diff --git a/internal/opengl/image.go b/internal/opengl/image.go index 73526549f..bb3e22eeb 100644 --- a/internal/opengl/image.go +++ b/internal/opengl/image.go @@ -38,7 +38,7 @@ func checkSize(width, height int) { type Image struct { textureNative textureNative - Framebuffer *Framebuffer + Framebuffer *framebuffer width int height int }