mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
Rename AdjustSizeForTexture -> NextPowerOf2Int
This commit is contained in:
parent
59270a6b54
commit
79b67db0d8
@ -27,6 +27,6 @@ func NextPowerOf2(x uint64) uint64 {
|
||||
return x + 1
|
||||
}
|
||||
|
||||
func AdjustSizeForTexture(size int) int {
|
||||
func NextPowerOf2Int(size int) int {
|
||||
return int(NextPowerOf2(uint64(size)))
|
||||
}
|
||||
|
@ -114,8 +114,8 @@ func DrawTexture(native gl.Texture, target gl.Texture, width, height int, projec
|
||||
u1, v1,
|
||||
)
|
||||
if program == programColorMatrix.native {
|
||||
w := float32(internal.AdjustSizeForTexture(width))
|
||||
h := float32(internal.AdjustSizeForTexture(height))
|
||||
w := float32(internal.NextPowerOf2Int(width))
|
||||
h := float32(internal.NextPowerOf2Int(height))
|
||||
xx0 := x0 / w
|
||||
xx1 := x1 / w
|
||||
yy0 := y0 / h
|
||||
|
@ -97,8 +97,8 @@ func useProgramColorMatrix(projectionMatrix [16]float32, width, height int, geo
|
||||
}
|
||||
getUniformLocation(program.native, "modelview_matrix").UniformMatrix4fv(false, glModelviewMatrix)
|
||||
|
||||
txn := tx / float32(internal.AdjustSizeForTexture(width))
|
||||
tyn := ty / float32(internal.AdjustSizeForTexture(height))
|
||||
txn := tx / float32(internal.NextPowerOf2Int(width))
|
||||
tyn := ty / float32(internal.NextPowerOf2Int(height))
|
||||
glModelviewMatrixN := [...]float32{
|
||||
a, c, 0, 0,
|
||||
b, d, 0, 0,
|
||||
|
@ -100,19 +100,19 @@ func (r *RenderTarget) SetAsViewport() error {
|
||||
return errors.New("glBindFramebuffer failed: the context is different?")
|
||||
}
|
||||
|
||||
width := internal.AdjustSizeForTexture(r.width)
|
||||
height := internal.AdjustSizeForTexture(r.height)
|
||||
width := internal.NextPowerOf2Int(r.width)
|
||||
height := internal.NextPowerOf2Int(r.height)
|
||||
gl.Viewport(0, 0, width, height)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RenderTarget) ProjectionMatrix() [4][4]float64 {
|
||||
width := internal.AdjustSizeForTexture(r.width)
|
||||
height := internal.AdjustSizeForTexture(r.height)
|
||||
width := internal.NextPowerOf2Int(r.width)
|
||||
height := internal.NextPowerOf2Int(r.height)
|
||||
m := orthoProjectionMatrix(0, width, 0, height)
|
||||
if r.flipY {
|
||||
m[1][1] *= -1
|
||||
m[1][3] += float64(r.height) / float64(internal.AdjustSizeForTexture(r.height)) * 2
|
||||
m[1][3] += float64(r.height) / float64(internal.NextPowerOf2Int(r.height)) * 2
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ func adjustImageForTexture(img image.Image) *image.NRGBA {
|
||||
adjustedImageBounds := image.Rectangle{
|
||||
image.ZP,
|
||||
image.Point{
|
||||
internal.AdjustSizeForTexture(width),
|
||||
internal.AdjustSizeForTexture(height),
|
||||
internal.NextPowerOf2Int(width),
|
||||
internal.NextPowerOf2Int(height),
|
||||
},
|
||||
}
|
||||
if nrgba, ok := img.(*image.NRGBA); ok && img.Bounds() == adjustedImageBounds {
|
||||
@ -77,8 +77,8 @@ func createNativeTexture(textureWidth, textureHeight int, pixels []uint8, filter
|
||||
}
|
||||
|
||||
func NewTexture(width, height int, filter int) (*Texture, error) {
|
||||
w := internal.AdjustSizeForTexture(width)
|
||||
h := internal.AdjustSizeForTexture(height)
|
||||
w := internal.NextPowerOf2Int(width)
|
||||
h := internal.NextPowerOf2Int(height)
|
||||
native := createNativeTexture(w, h, nil, filter)
|
||||
return &Texture{native, width, height}, nil
|
||||
}
|
||||
|
@ -86,11 +86,11 @@ func (r *innerRenderTarget) DrawTexture(texture *Texture, parts []TexturePart, g
|
||||
}
|
||||
|
||||
func u(x float64, width int) float32 {
|
||||
return float32(x) / float32(internal.AdjustSizeForTexture(width))
|
||||
return float32(x) / float32(internal.NextPowerOf2Int(width))
|
||||
}
|
||||
|
||||
func v(y float64, height int) float32 {
|
||||
return float32(y) / float32(internal.AdjustSizeForTexture(height))
|
||||
return float32(y) / float32(internal.NextPowerOf2Int(height))
|
||||
}
|
||||
|
||||
func textureQuads(parts []TexturePart, width, height int) []shader.TextureQuad {
|
||||
|
Loading…
Reference in New Issue
Block a user