mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Rename create* -> new*
This commit is contained in:
parent
ca99e94b5c
commit
43fbffebfb
@ -55,9 +55,9 @@ func newContext(screenWidth, screenHeight, screenScale int) *context {
|
|||||||
c.defaultId = idsInstance.addRenderTarget(defaultRenderTarget)
|
c.defaultId = idsInstance.addRenderTarget(defaultRenderTarget)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
c.screenId, err = idsInstance.createRenderTarget(screenWidth, screenHeight, graphics.FilterNearest)
|
c.screenId, err = idsInstance.newRenderTarget(screenWidth, screenHeight, graphics.FilterNearest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("opengl.NewContext: initializing the offscreen failed: " + err.Error())
|
panic("opengl.newContext: initializing the offscreen failed: " + err.Error())
|
||||||
}
|
}
|
||||||
c.ResetOffscreen()
|
c.ResetOffscreen()
|
||||||
c.Clear()
|
c.Clear()
|
||||||
|
@ -27,11 +27,11 @@ var idsInstance = &ids{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRenderTargetID(width, height int, filter graphics.Filter) (graphics.RenderTargetID, error) {
|
func NewRenderTargetID(width, height int, filter graphics.Filter) (graphics.RenderTargetID, error) {
|
||||||
return idsInstance.createRenderTarget(width, height, filter)
|
return idsInstance.newRenderTarget(width, height, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTextureID(img image.Image, filter graphics.Filter) (graphics.TextureID, error) {
|
func NewTextureID(img image.Image, filter graphics.Filter) (graphics.TextureID, error) {
|
||||||
return idsInstance.createTexture(img, filter)
|
return idsInstance.newTexture(img, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ids) textureAt(id graphics.TextureID) *texture {
|
func (i *ids) textureAt(id graphics.TextureID) *texture {
|
||||||
@ -52,8 +52,8 @@ func (i *ids) toTexture(id graphics.RenderTargetID) graphics.TextureID {
|
|||||||
return i.renderTargetToTexture[id]
|
return i.renderTargetToTexture[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ids) createTexture(img image.Image, filter graphics.Filter) (graphics.TextureID, error) {
|
func (i *ids) newTexture(img image.Image, filter graphics.Filter) (graphics.TextureID, error) {
|
||||||
texture, err := createTextureFromImage(img, filter)
|
texture, err := newTextureFromImage(img, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -66,12 +66,12 @@ func (i *ids) createTexture(img image.Image, filter graphics.Filter) (graphics.T
|
|||||||
return textureId, nil
|
return textureId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ids) createRenderTarget(width, height int, filter graphics.Filter) (graphics.RenderTargetID, error) {
|
func (i *ids) newRenderTarget(width, height int, filter graphics.Filter) (graphics.RenderTargetID, error) {
|
||||||
texture, err := createTexture(width, height, filter)
|
texture, err := newTexture(width, height, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
framebuffer := createFramebuffer(gl.Texture(texture.native))
|
framebuffer := newFramebuffer(gl.Texture(texture.native))
|
||||||
// The current binded framebuffer can be changed.
|
// The current binded framebuffer can be changed.
|
||||||
i.currentRenderTargetId = -1
|
i.currentRenderTargetId = -1
|
||||||
r := &renderTarget{
|
r := &renderTarget{
|
||||||
|
@ -27,7 +27,7 @@ type renderTarget struct {
|
|||||||
flipY bool
|
flipY bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFramebuffer(nativeTexture gl.Texture) gl.Framebuffer {
|
func newFramebuffer(nativeTexture gl.Texture) gl.Framebuffer {
|
||||||
framebuffer := gl.GenFramebuffer()
|
framebuffer := gl.GenFramebuffer()
|
||||||
framebuffer.Bind()
|
framebuffer.Bind()
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ type texture struct {
|
|||||||
height int
|
height int
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNativeTexture(textureWidth, textureHeight int, pixels []uint8, filter graphics.Filter) gl.Texture {
|
func newNativeTexture(textureWidth, textureHeight int, pixels []uint8, filter graphics.Filter) gl.Texture {
|
||||||
nativeTexture := gl.GenTexture()
|
nativeTexture := gl.GenTexture()
|
||||||
if nativeTexture < 0 {
|
if nativeTexture < 0 {
|
||||||
panic("glGenTexture failed")
|
panic("glGenTexture failed")
|
||||||
@ -67,17 +67,17 @@ func createNativeTexture(textureWidth, textureHeight int, pixels []uint8, filter
|
|||||||
return nativeTexture
|
return nativeTexture
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTexture(width, height int, filter graphics.Filter) (*texture, error) {
|
func newTexture(width, height int, filter graphics.Filter) (*texture, error) {
|
||||||
w := shader.AdjustSizeForTexture(width)
|
w := shader.AdjustSizeForTexture(width)
|
||||||
h := shader.AdjustSizeForTexture(height)
|
h := shader.AdjustSizeForTexture(height)
|
||||||
native := createNativeTexture(w, h, nil, filter)
|
native := newNativeTexture(w, h, nil, filter)
|
||||||
return &texture{native, width, height}, nil
|
return &texture{native, width, height}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTextureFromImage(img image.Image, filter graphics.Filter) (*texture, error) {
|
func newTextureFromImage(img image.Image, filter graphics.Filter) (*texture, error) {
|
||||||
adjustedImage := adjustImageForTexture(img)
|
adjustedImage := adjustImageForTexture(img)
|
||||||
size := adjustedImage.Bounds().Size()
|
size := adjustedImage.Bounds().Size()
|
||||||
native := createNativeTexture(size.X, size.Y, adjustedImage.Pix, filter)
|
native := newNativeTexture(size.X, size.Y, adjustedImage.Pix, filter)
|
||||||
return &texture{native, size.X, size.Y}, nil
|
return &texture{native, size.X, size.Y}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user