<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
Hi all!<br>
<br>
I try querying stats for each frame. Unfortunately all values stay
at 0.0. Any Ideas?<br>
<br>
here is my code, mainly copied from the StatsHandler:<br>
<br>
Initialisation:<br>
<pre><span style=" color:#000080;">#ifdef</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">PROFILE_FRAMES</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osgViewer</span>::<span style=" color:#800080;">ViewerBase</span>::<span style=" color:#800080;">Cameras</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">cameras</span>;</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Viewer</span>::<span style=" font-style:italic; color:#00677c;">getCameras</span>(<span style=" color:#092e64;">cameras</span>);</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Viewer</span>::<span style=" font-style:italic; color:#00677c;">getViewerStats</span>()-><span style=" color:#00677c;">collectStats</span>(<span style=" color:#008000;">"update"</span>,<span style=" color:#808000;">true</span>);</pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">for</span>(<span style=" color:#800080;">osgViewer</span>::<span style=" color:#800080;">ViewerBase</span>::<span style=" color:#800080;">Cameras</span>::<span style=" color:#800080;">iterator</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">itr</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">cameras</span>.<span style=" color:#00677c;">begin</span>();</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">itr</span><span style=" color:#c0c0c0;"> </span>!=<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">cameras</span>.<span style=" color:#00677c;">end</span>();</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span>++<span style=" color:#092e64;">itr</span>)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>((*<span style=" color:#092e64;">itr</span>)-><span style=" color:#00677c;">getStats</span>())<span style=" color:#c0c0c0;"> </span>(*<span style=" color:#092e64;">itr</span>)-><span style=" color:#00677c;">getStats</span>()-><span style=" color:#00677c;">collectStats</span>(<span style=" color:#008000;">"rendering"</span>,<span style=" color:#808000;">true</span>);</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>((*<span style=" color:#092e64;">itr</span>)-><span style=" color:#00677c;">getStats</span>())<span style=" color:#c0c0c0;"> </span>(*<span style=" color:#092e64;">itr</span>)-><span style=" color:#00677c;">getStats</span>()-><span style=" color:#00677c;">collectStats</span>(<span style=" color:#008000;">"gpu"</span>,<span style=" color:#808000;">true</span>);</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
After each frame the query:<br>
<br>
<pre><span style=" color:#000080;">#ifdef</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">PROFILE_FRAMES</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osgViewer</span>::<span style=" color:#800080;">ViewerBase</span>::<span style=" color:#800080;">Cameras</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">cameras</span>;</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Viewer</span>::<span style=" font-style:italic; color:#00677c;">getCameras</span>(<span style=" color:#092e64;">cameras</span>);</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">frameNumber</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Viewer</span>::<span style=" font-style:italic; color:#00677c;">getViewerStats</span>()-><span style=" color:#00677c;">getLatestFrameNumber</span>();</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">updateTime</span><span style=" color:#c0c0c0;"> </span>{<span style=" color:#000080;">0.0</span>};</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">renderingTime</span><span style=" color:#c0c0c0;"> </span>{<span style=" color:#000080;">0.0</span>};</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">gpuTime</span><span style=" color:#c0c0c0;"> </span>{<span style=" color:#000080;">0.0</span>};</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Viewer</span>::<span style=" font-style:italic; color:#00677c;">getViewerStats</span>()-><span style=" color:#00677c;">getAttribute</span>(<span style=" color:#092e64;">frameNumber</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::<span style=" color:#800080;">string</span>(<span style=" color:#008000;">"update"</span>),<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">updateTime</span>);</pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">for</span>(<span style=" color:#800080;">osgViewer</span>::<span style=" color:#800080;">ViewerBase</span>::<span style=" color:#800080;">Cameras</span>::<span style=" color:#800080;">iterator</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">itr</span><span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">cameras</span>.<span style=" color:#00677c;">begin</span>();</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">itr</span><span style=" color:#c0c0c0;"> </span>!=<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">cameras</span>.<span style=" color:#00677c;">end</span>();</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span>++<span style=" color:#092e64;">itr</span>)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span>{</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">tmp</span><span style=" color:#c0c0c0;"> </span>{<span style=" color:#000080;">0.0</span>};</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>((*<span style=" color:#092e64;">itr</span>)-><span style=" color:#00677c;">getStats</span>())<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>((*<span style=" color:#092e64;">itr</span>)-><span style=" color:#00677c;">getStats</span>()-><span style=" color:#00677c;">getAttribute</span>(<span style=" color:#092e64;">frameNumber</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::<span style=" color:#800080;">string</span>(<span style=" color:#008000;">"rendering"</span>),<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">tmp</span>))</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">renderingTime</span><span style=" color:#c0c0c0;"> </span>+=<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">tmp</span>;</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>((*<span style=" color:#092e64;">itr</span>)-><span style=" color:#00677c;">getStats</span>()-><span style=" color:#00677c;">getAttribute</span>(<span style=" color:#092e64;">frameNumber</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::<span style=" color:#800080;">string</span>(<span style=" color:#008000;">"gpu"</span>),<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">tmp</span>))</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">gpuTime</span><span style=" color:#c0c0c0;"> </span>+=<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">tmp</span>;</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span>}</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::cout<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"update:</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::fixed<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::<span style=" color:#00677c;">setprecision</span>(<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">2</span><span style=" color:#c0c0c0;"> </span>)<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">updateTime</span><span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1000.0</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">ms\trendering:</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::fixed<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::<span style=" color:#00677c;">setprecision</span>(<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">2</span><span style=" color:#c0c0c0;"> </span>)<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">renderingTime</span><span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1000.0</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">ms\tgpu:</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::fixed<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::<span style=" color:#00677c;">setprecision</span>(<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">2</span><span style=" color:#c0c0c0;"> </span>)<span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#092e64;">gpuTime</span><span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1000.0</span><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">ms"</span><span style=" color:#c0c0c0;"> </span><<<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">std</span>::endl;</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"></span>
</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
</body>
</html>