Skip to content

Commit

Permalink
Crashes at 60_scuba042
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimbbp committed Mar 11, 2024
1 parent 5e1bc9d commit 5fadf2a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ Database and resized sprites must be generated before creating mosaic

## Sprites
Project has been tested with the google noto emoji pack as the sprites. These can be found in the asset folder.
You can also create your own sprites. However "blanktile" is a keyword and cannot be used as a sprite name
You can also create your own sprites. However "blanktile" is a keyword and cannot be used as a sprite name

## After Effects Resolution Switcher
The AE file included provides a template for switching quickly between resolutions. You may reporpose it for your liking, but if you wish to generate the exact test footage used, please use the batchRes case in main with batchResIndices := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.
3 changes: 2 additions & 1 deletion devnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ Introduced some restrictions on the goroutines (from copilot). I need to brush u

March 11 2024:
Was pretty tired on friday so made some less than stellar decisions with the batch processing. Refactored today and it's much better.
However, there seems to be a memory leak (or something) that causes the program to crash after processing many sprites, especially at a higher "reslolution" (meaning, confusingly, a lower sprite resolution, thus more sprites per image)
However, there seems to be a memory leak (or something) that causes the program to crash after processing many sprites, especially at a higher "reslolution" (meaning, confusingly, a lower sprite resolution, thus more sprites per image)
Adding After Effects switcher.
2 changes: 1 addition & 1 deletion src/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {
false,
)
case "batchRes":
batchResIndices := []int{1}
batchResIndices := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
util.TimeIt(
"generating video for multiple resolutions",
video.BatchSequence,
Expand Down
14 changes: 12 additions & 2 deletions src/mosaic/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import (
"github.com/joachimbbp/spritefire/src/util"
)

var textures []rl.Texture2D

func Draw(canvas []util.IndexedSprite, prefix string, frameName string, spriteSizeIndex int) {
spriteSize := util.ResizeResolutions[spriteSizeIndex]

fmt.Println("\nDrawing and saving image to disk")
fmt.Println("\n\n\nDrawing and saving image to disk")
fmt.Println("frame:\n", frameName)
fmt.Println("sprite size:\n", spriteSize)
fmt.Printf("\n\n\n")

util.CreateIfNotExist(util.ImageOutput)
texX := int32(util.SaveResolutionX)
Expand Down Expand Up @@ -43,15 +46,22 @@ func Draw(canvas []util.IndexedSprite, prefix string, frameName string, spriteSi
rl.EndTextureMode()

img := rl.LoadImageFromTexture(targetTexture.Texture)

rl.ExportImage(*img, util.ImageOutput+"/"+prefix+frameName)

for _, texture := range textures {
rl.UnloadTexture(texture)
fmt.Println("unloading texture: ", texture)
}

rl.UnloadImage(img)
rl.UnloadRenderTexture(targetTexture)

}

func drawSprite(tile util.IndexedSprite, spriteSize int, oX int32, oY int32) {
tilePath := filepath.Join(util.SpriteSizes, strconv.Itoa(spriteSize), tile.Sprite)
tileTexture := rl.LoadTexture(tilePath)
textures = append(textures, tileTexture)

sourceRec := rl.NewRectangle(0, 0, float32(tileTexture.Width), -float32(tileTexture.Height))
destRec := rl.NewRectangle(float32(oX), float32(oY), float32(tileTexture.Width), float32(tileTexture.Height))
Expand Down
3 changes: 0 additions & 3 deletions src/video/batchResSequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ func BatchSequence(sequencePath string, spriteColorDbPath string, spriteResIndic
fmt.Println(sequencePath, spriteColorDbPath, spriteResIndices)

for _, resIndex := range spriteResIndices {
fmt.Println(resIndex, "\n")

res := strconv.Itoa(int(util.ResizeResolutions[resIndex]))
util.ImageOutput = util.ImageOutputConst + "/" + res
util.CreateIfNotExist(util.ImageOutput)

fmt.Println("\noutput: ", util.ImageOutput)

Sequence(sequencePath, spriteColorDbPath, resIndex)
}
util.ImageOutput = util.ImageOutputConst
Expand Down

0 comments on commit 5fadf2a

Please sign in to comment.