MCPcopy Create free account
hub / github.com/baldurk/renderdoc / menu_callback

Function menu_callback

docs/python_api/ui_extension_tutorial/__init__.py:98–126  ·  view source on GitHub ↗
(ctx: qrd.CaptureContext, data)

Source from the content-addressed store, hash-verified

96
97
98def menu_callback(ctx: qrd.CaptureContext, data):
99 texid = rd.ResourceId.Null()
100 depth = ctx.CurPipelineState().GetDepthTarget()
101
102 # Prefer depth if possible
103 if depth.resourceId != rd.ResourceId.Null():
104 texid = depth.resourceId
105 else:
106 cols = ctx.CurPipelineState().GetOutputTargets()
107
108 # See if we can get the first colour target instead
109 if len(cols) > 1 and cols[0].resourceId != rd.ResourceId.Null():
110 texid = cols[0].resourceId
111
112 if texid == rd.ResourceId.Null():
113 ctx.Extensions().MessageDialog("Couldn't find any bound target!", "Extension message")
114 return
115 else:
116 mqt = ctx.Extensions().GetMiniQtHelper()
117 texname = ctx.GetResourceName(texid)
118
119 def get_minmax(r: rd.ReplayController):
120 minvals, maxvals = r.GetMinMax(texid, rd.Subresource(), rd.CompType.Typeless)
121
122 msg = '{} has min {:.4} and max {:.4} in red'.format(texname, minvals.floatValue[0], maxvals.floatValue[0])
123
124 mqt.InvokeOntoUIThread(lambda: ctx.Extensions().MessageDialog(msg, "Extension message"))
125
126 ctx.Replay().AsyncInvoke('', get_minmax)
127
128
129

Callers

nothing calls this directly

Calls 5

GetDepthTargetMethod · 0.80
GetOutputTargetsMethod · 0.80
MessageDialogMethod · 0.45
GetResourceNameMethod · 0.45
AsyncInvokeMethod · 0.45

Tested by

no test coverage detected