Skip to content

Commit

Permalink
Fix floating point mipmap size calc error
Browse files Browse the repository at this point in the history
  • Loading branch information
Galaco committed Feb 12, 2019
1 parent 1fd609c commit c6c1f35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions utils/mipmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import (
"math"
)

// computeMipmapSizes: Compute all mipmap sizes
// ComputeMipmapSizes computes all mipmap sizes
func ComputeMipmapSizes(num int, width int, height int) [][2]int {
mipmaps := make([][2]int, num)

for i := num - 1; i >= 0; i-- {
mipmaps[i] = [2]int{width, height}

width = int(math.Ceil(float64(width / 2)))
height = int(math.Ceil(float64(height / 2)))
width = int(math.Ceil(float64(width) / 2))
height = int(math.Ceil(float64(height) / 2))
}

return mipmaps
}

// computeSizeOfMipmapData: Returns the size in bytes
// ComputeSizeOfMipmapData returns the size in bytes
func ComputeSizeOfMipmapData(width int, height int, storedFormat format.Colour) int {
// Supported compressed formats must be at least 4x4.
// The format pads smaller sizes out to 4
if isCompressedFormat(storedFormat) == true {
if isCompressedFormat(storedFormat) {
if width < 4 {
width = 4
}
Expand Down

0 comments on commit c6c1f35

Please sign in to comment.