Rename AdjustSizeForTexture -> NextPowerOf2Int

This commit is contained in:
Hajime Hoshi 2014-12-21 02:05:08 +09:00
parent 59270a6b54
commit 79b67db0d8
6 changed files with 16 additions and 16 deletions

View File

@ -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)))
}

View File

@ -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

View File

@ -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,

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {