[SOLVED]Ogre::profiler display of profiling data not working

Problems building or running the engine, queries about how to use features etc.
Post Reply
scherzer.daniel
Gnoblar
Posts: 4
Joined: Sat Nov 19, 2005 10:39 am
Location: vienna, austria
Contact:

[SOLVED]Ogre::profiler display of profiling data not working

Post by scherzer.daniel »

i was trying to use the Ogre::Profiler. After initial crashes I realised that I had to explicitly instance it to get it to work

Code: Select all

new Ogre::Profiler();
but when I use it to profile some of my code I only get a window at the top of my Ogre window without any bars or textlabels for my profiled code parts. What am I doing wrong? Is maybe the explicit instance of the profiler the problem, because this step was not mentioned in the profiler tutorial at http://www.ogre3d.org/wiki/index.php/OgreProfiler ?
Last edited by scherzer.daniel on Mon Nov 21, 2005 10:05 pm, edited 1 time in total.

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

You need to define OGRE_PROFILING to 1 in order to enable profiling (the OgreProfileBegin macros etc), this flag globally enables / disables the sampling. Do it in OgreConfig.h. This will also cause a Profiler instance to be created for you by Root.

This way you can leave all your profiling code in but undefine this value to disable it in final builds if you want.

scherzer.daniel
Gnoblar
Posts: 4
Joined: Sat Nov 19, 2005 10:39 am
Location: vienna, austria
Contact:

Post by scherzer.daniel »

Thank you for the quick response and the help. I have already tried to set OGRE_PROFILING to 1.
When I do this and I remove all Profiler code everything is fine.
If I just add the line

Code: Select all

Ogre::Profiler::getSingleton().setEnabled(true);
I get an assertion failed for expression ms_Singleton. Well I do not create another instance of the profiler, but who does? The same happens for any other profiler code, like OgreProfileBegin. I don't understand what I'm doing wrong.

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

You have to set OGRE_PROFILING to 1 in OgreConfig.h and rebuild OGRE, not just set it in your app. If you do this, Root will construct a Profiler for you, see the code in OgreRoot.cpp in the constructor:

Code: Select all

#if OGRE_PROFILING
        // Profiler
        mProfiler = new Profiler();
		Profiler::getSingleton().setTimer(mTimer);
#endif

scherzer.daniel
Gnoblar
Posts: 4
Joined: Sat Nov 19, 2005 10:39 am
Location: vienna, austria
Contact:

Post by scherzer.daniel »

Ah! Thank you very much for the tip.
Now everything is working perfectly! :D

71puccini
Gnoblar
Posts: 16
Joined: Sun Jun 07, 2020 5:14 pm

Re: [SOLVED]Ogre::profiler display of profiling data not working

Post by 71puccini »

I have the same problem. I am running Ogre 1.12.8. I am getting no error, but Profiler does not show up. Do I have to do anything to get it displayed?

Code: Select all

// Create dummy profile to set singleton pointer
	new Ogre::Profiler();

	// Give it a timer and enable it
	Ogre::Profiler::getSingleton().setTimer(Root::getSingleton().getTimer());
	Ogre::Profiler::getSingleton().setEnabled(true);
	OgreProfileBegin("Ogre Main Loop");
	{ 
		OgreProfile("Profile Terrain");

                ///some code

	} //end of terrain profiling
	OgreProfileEnd("Ogre Main Loop");
If I remove

Code: Select all

new Ogre::Profiler();
I will get singleton error.

I have set

Code: Select all

#define OGRE_PROFILING 1
in OgreBuildSettings.h

paroj
OGRE Team Member
OGRE Team Member
Posts: 1271
Joined: Sun Mar 30, 2014 2:51 pm
x 526
Contact:

Re: [SOLVED]Ogre::profiler display of profiling data not working

Post by paroj »

I guess you already read?
https://ogrecave.github.io/ogre/api/lat ... filer.html

71puccini wrote:
Thu Aug 13, 2020 7:07 pm
I have set

Code: Select all

#define OGRE_PROFILING 1
in OgreBuildSettings.h
this has no effect. You have to set it in CMake and recompile Ogre.
However, if you only want to profile your own code, you do not need to.

Note that the profiler is drawn with the Overlay System. So that must be correctly set-up to see anything.

71puccini
Gnoblar
Posts: 16
Joined: Sun Jun 07, 2020 5:14 pm

Re: [SOLVED]Ogre::profiler display of profiling data not working

Post by 71puccini »

Do you have an example to display profiler data in the tray?

Thanks!

71puccini
Gnoblar
Posts: 16
Joined: Sun Jun 07, 2020 5:14 pm

Re: [SOLVED]Ogre::profiler display of profiling data not working

Post by 71puccini »

I figured it out

//you must add this
#include "OgreTrays.h"
mScnMgr->addRenderQueueListener(mOverlaySystem);

Post Reply