(controller)
| 22 | return ret |
| 23 | |
| 24 | def sampleCode(controller): |
| 25 | # Find the biggest drawcall in the whole capture |
| 26 | draw = None |
| 27 | for d in controller.GetRootActions(): |
| 28 | draw = biggestDraw(draw, d) |
| 29 | |
| 30 | # Move to that draw |
| 31 | controller.SetFrameEvent(draw.eventId, True) |
| 32 | |
| 33 | texsave = rd.TextureSave() |
| 34 | |
| 35 | # Select the first color output |
| 36 | texsave.resourceId = draw.outputs[0] |
| 37 | |
| 38 | if texsave.resourceId == rd.ResourceId.Null(): |
| 39 | return |
| 40 | |
| 41 | filename = str(int(texsave.resourceId)) |
| 42 | |
| 43 | print("Saving images of %s at %d: %s" % (filename, draw.eventId, draw.GetName(controller.GetStructuredFile()))) |
| 44 | |
| 45 | # Save different types of texture |
| 46 | |
| 47 | # Blend alpha to a checkerboard pattern for formats without alpha support |
| 48 | texsave.alpha = rd.AlphaMapping.BlendToCheckerboard |
| 49 | |
| 50 | # Most formats can only display a single image per file, so we select the |
| 51 | # first mip and first slice |
| 52 | texsave.mip = 0 |
| 53 | texsave.slice.sliceIndex = 0 |
| 54 | |
| 55 | texsave.destType = rd.FileType.JPG |
| 56 | controller.SaveTexture(texsave, filename + ".jpg") |
| 57 | |
| 58 | texsave.destType = rd.FileType.HDR |
| 59 | controller.SaveTexture(texsave, filename + ".hdr") |
| 60 | |
| 61 | # For formats with an alpha channel, preserve it |
| 62 | texsave.alpha = rd.AlphaMapping.Preserve |
| 63 | |
| 64 | texsave.destType = rd.FileType.PNG |
| 65 | controller.SaveTexture(texsave, filename + ".png") |
| 66 | |
| 67 | # DDS textures can save multiple mips and array slices, so instead |
| 68 | # of the default behaviour of saving mip 0 and slice 0, we set -1 |
| 69 | # which saves *all* mips and slices |
| 70 | texsave.mip = -1 |
| 71 | texsave.slice.sliceIndex = -1 |
| 72 | |
| 73 | texsave.destType = rd.FileType.DDS |
| 74 | controller.SaveTexture(texsave, filename + ".dds") |
| 75 | |
| 76 | def loadCapture(filename): |
| 77 | # Open a capture file handle |
no test coverage detected