Add texture.NewEmpty

This commit is contained in:
Hajime Hoshi 2013-10-27 22:12:28 +09:00
parent f290a137a9
commit f6523b28f4
3 changed files with 11 additions and 5 deletions

View File

@ -52,8 +52,7 @@ func (context *Context) Init() {
context.mainFramebufferTexture, err = rendertarget.NewWithFramebuffer(
context.screenWidth*context.screenScale,
context.screenHeight*context.screenScale,
rendertarget.Framebuffer(mainFramebuffer),
texture.FilterLinear)
rendertarget.Framebuffer(mainFramebuffer))
if err != nil {
panic("creating main framebuffer failed: " + err.Error())
}

View File

@ -46,9 +46,9 @@ func New(width, height int, filter texture.Filter) (
Framebuffer(framebuffer.(C.GLuint))), tex, nil
}
func NewWithFramebuffer(width, height int, framebuffer Framebuffer,
filter texture.Filter) (*rendertarget.RenderTarget, error) {
tex, err := texture.New(width, height, filter)
func NewWithFramebuffer(width, height int, framebuffer Framebuffer) (
*rendertarget.RenderTarget, error) {
tex, err := texture.NewEmpty(width, height)
if err != nil {
return nil, err
}

View File

@ -70,6 +70,13 @@ func New(width, height int, filter Filter) (*gtexture.Texture, error) {
return gtexture.New(width, height, f)
}
func NewEmpty(width, height int) (*gtexture.Texture, error) {
f := func(textureWidth, textureHeight int) (interface{}, error) {
return nil, nil
}
return gtexture.New(width, height, f)
}
func NewFromImage(img image.Image) (*gtexture.Texture, error) {
return gtexture.NewFromImage(img, createFromImage)
}