本文整理匯總了Golang中github.com/hajimehoshi/ebiten/internal/graphics/opengl.Context.NewTexture方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.NewTexture方法的具體用法?Golang Context.NewTexture怎麽用?Golang Context.NewTexture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hajimehoshi/ebiten/internal/graphics/opengl.Context
的用法示例。
在下文中一共展示了Context.NewTexture方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewTexture
func NewTexture(c *opengl.Context, width, height int, filter opengl.Filter) (*Texture, error) {
w := NextPowerOf2Int(width)
h := NextPowerOf2Int(height)
if w < 4 {
return nil, errors.New("width must be equal or more than 4.")
}
if h < 4 {
return nil, errors.New("height must be equal or more than 4.")
}
native, err := c.NewTexture(w, h, nil, filter)
if err != nil {
return nil, err
}
return &Texture{native, width, height}, nil
}
示例2: NewTextureFromImage
func NewTextureFromImage(c *opengl.Context, img image.Image, filter opengl.Filter) (*Texture, error) {
origSize := img.Bounds().Size()
if origSize.X < 4 {
return nil, errors.New("width must be equal or more than 4.")
}
if origSize.Y < 4 {
return nil, errors.New("height must be equal or more than 4.")
}
adjustedImage := adjustImageForTexture(img)
size := adjustedImage.Bounds().Size()
native, err := c.NewTexture(size.X, size.Y, adjustedImage.Pix, filter)
if err != nil {
return nil, err
}
return &Texture{native, origSize.X, origSize.Y}, nil
}