graphics: Hide Texture/Framebuffer

This commit is contained in:
Hajime Hoshi 2016-06-12 01:41:50 +09:00
parent eca175e0f4
commit 68c19d7cae
3 changed files with 23 additions and 23 deletions

View File

@ -72,7 +72,7 @@ func FlushCommands(context *opengl.Context) error {
} }
type fillCommand struct { type fillCommand struct {
dst *Framebuffer dst *framebuffer
color color.Color color color.Color
} }
@ -90,8 +90,8 @@ func (c *fillCommand) Exec(context *opengl.Context) error {
} }
type drawImageCommand struct { type drawImageCommand struct {
dst *Framebuffer dst *framebuffer
src *Texture src *texture
vertices []int16 vertices []int16
geo Matrix geo Matrix
color Matrix color Matrix
@ -127,8 +127,8 @@ func (c *drawImageCommand) Exec(context *opengl.Context) error {
} }
type replacePixelsCommand struct { type replacePixelsCommand struct {
dst *Framebuffer dst *framebuffer
texture *Texture texture *texture
pixels []uint8 pixels []uint8
} }
@ -147,8 +147,8 @@ func (c *replacePixelsCommand) Exec(context *opengl.Context) error {
} }
type disposeCommand struct { type disposeCommand struct {
framebuffer *Framebuffer framebuffer *framebuffer
texture *Texture texture *texture
} }
func (c *disposeCommand) Exec(context *opengl.Context) error { func (c *disposeCommand) Exec(context *opengl.Context) error {
@ -162,8 +162,8 @@ func (c *disposeCommand) Exec(context *opengl.Context) error {
} }
type newImageFromImageCommand struct { type newImageFromImageCommand struct {
texture *Texture texture *texture
framebuffer *Framebuffer framebuffer *framebuffer
img *image.RGBA img *image.RGBA
filter opengl.Filter filter opengl.Filter
} }
@ -192,8 +192,8 @@ func (c *newImageFromImageCommand) Exec(context *opengl.Context) error {
} }
type newImageCommand struct { type newImageCommand struct {
texture *Texture texture *texture
framebuffer *Framebuffer framebuffer *framebuffer
width int width int
height int height int
filter opengl.Filter filter opengl.Filter

View File

@ -34,7 +34,7 @@ func orthoProjectionMatrix(left, right, bottom, top int) *[4][4]float64 {
} }
} }
type Framebuffer struct { type framebuffer struct {
native opengl.Framebuffer native opengl.Framebuffer
width int width int
height int height int
@ -43,7 +43,7 @@ type Framebuffer struct {
} }
func NewZeroFramebufferImage(width, height int) (*Image, error) { func NewZeroFramebufferImage(width, height int) (*Image, error) {
f := &Framebuffer{ f := &framebuffer{
width: width, width: width,
height: height, height: height,
flipY: true, flipY: true,
@ -53,7 +53,7 @@ func NewZeroFramebufferImage(width, height int) (*Image, error) {
}, nil }, nil
} }
func (f *Framebuffer) initFromTexture(context *opengl.Context, texture *Texture) error { func (f *framebuffer) initFromTexture(context *opengl.Context, texture *texture) error {
native, err := context.NewFramebuffer(opengl.Texture(texture.native)) native, err := context.NewFramebuffer(opengl.Texture(texture.native))
if err != nil { if err != nil {
return err return err
@ -75,13 +75,13 @@ func (i *Image) Dispose() error {
const viewportSize = 4096 const viewportSize = 4096
func (f *Framebuffer) setAsViewport(c *opengl.Context) error { func (f *framebuffer) setAsViewport(c *opengl.Context) error {
width := viewportSize width := viewportSize
height := viewportSize height := viewportSize
return c.SetViewport(f.native, width, height) return c.SetViewport(f.native, width, height)
} }
func (f *Framebuffer) projectionMatrix() *[4][4]float64 { func (f *framebuffer) projectionMatrix() *[4][4]float64 {
if f.proMatrix != nil { if f.proMatrix != nil {
return f.proMatrix return f.proMatrix
} }

View File

@ -44,11 +44,11 @@ func adjustImageForTexture(img *image.RGBA) *image.RGBA {
} }
type Image struct { type Image struct {
texture *Texture texture *texture
framebuffer *Framebuffer framebuffer *framebuffer
} }
type Texture struct { type texture struct {
native opengl.Texture native opengl.Texture
width int width int
height int height int
@ -56,8 +56,8 @@ type Texture struct {
func NewImage(width, height int, filter opengl.Filter) (*Image, error) { func NewImage(width, height int, filter opengl.Filter) (*Image, error) {
i := &Image{ i := &Image{
texture: &Texture{}, texture: &texture{},
framebuffer: &Framebuffer{}, framebuffer: &framebuffer{},
} }
c := &newImageCommand{ c := &newImageCommand{
texture: i.texture, texture: i.texture,
@ -72,8 +72,8 @@ func NewImage(width, height int, filter opengl.Filter) (*Image, error) {
func NewImageFromImage(img *image.RGBA, filter opengl.Filter) (*Image, error) { func NewImageFromImage(img *image.RGBA, filter opengl.Filter) (*Image, error) {
i := &Image{ i := &Image{
texture: &Texture{}, texture: &texture{},
framebuffer: &Framebuffer{}, framebuffer: &framebuffer{},
} }
c := &newImageFromImageCommand{ c := &newImageFromImageCommand{
texture: i.texture, texture: i.texture,