[SOLVE] - Simple object is not shown above basic tutorial.

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
User avatar
remizero
Gnoblar
Posts: 4
Joined: Mon May 08, 2023 3:50 pm

[SOLVE] - Simple object is not shown above basic tutorial.

Post by remizero »

Hi everyone.

First introduce myself, I'm a remizero, I hope you have a good day. I am new to the forum and to this world of Ogre3D. My English is not very good, but I think you can understand me.

I have been studying this interesting library for a few weeks now, I have to say that I have done all the tutorials presented in the Ogre3D-Next 2.3 version and I have to say that I have managed to compile and run them with great satisfaction.

I have been searching the documentation and this forum for days, but I don't see that many are working with version 2.3.1, but I still can't find any publication that helps me with my problem.

Now, I have decided to start with the tutorial "Tutorial00_Basic", trying to add a simple object "cube.mesh" to understand step by step the dynamics of object creation, but until now it has been impossible.

The only thing I added was the following code

Code: Select all

Ogre::HlmsManager *hlmsManager = root->getHlmsManager ();
Ogre::Hlms *hlms = hlmsManager->getHlms ( Ogre::HLMS_PBS );
Ogre::Item *cubeItem = sceneManager->createItem ( "../data/cube.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, Ogre::SCENE_DYNAMIC );
cubeItem->setDatablock ( hlms->getDatablock ( "BaseWhite" ) );
Ogre::SceneNode *cubeNode = sceneManager->getRootSceneNode ( Ogre::SCENE_DYNAMIC )->createChildSceneNode ( Ogre::SCENE_DYNAMIC );
cubeNode->setPosition ( 0, 0, -100 );
cubeNode->attachObject ( cubeItem );

From what I have studied from the documentation, this "cubeNode" node is attached to the previously created scenario automatically, but well that is not the error in any case.

The error is the following:

When I run the binary, if I select "Vulkan Rendering Subsystem", I get the following error output

Code: Select all

terminate called after throwing an instance of 'Ogre::RenderingAPIException'
   what(): OGRE EXCEPTION(3:RenderingAPIException): vkGetPhysicalDeviceSurfaceFormatsKHR failed
VkResult = VK_ERROR_SURFACE_LOST_KHR in Ogre::PixelFormatGpu Ogre::VulkanWindowSwapChainBased::chooseSurfaceFormat(bool) at /home/user/projects/ogre2.3.1/RenderSystems/Vulkan/src/OgreVulkanWindow.cpp (line 226)

I understand that an error is being generated when obtaining the surface format or something like that.

Then if I run the binary again and select "OpenGL 3+ Rendering Subsystem", I get the following error output

Code: Select all

GL3PlusRenderSystem::_createRenderWindow "Tutorial 00: Basic", 0x0 windowed miscParams: FSAA=0 displayFrequency=N/A gamma=Yes vsync=No
X Error of failed request: BadValue (integer parameter out of range for operation)
   Major opcode of failed request: 1 (X_CreateWindow)
   Value in failed request: 0x0
   Serial number of failed request: 17
   Current serial number in output stream: 22

At this point I have run out of arguments because I don't understand what parameter I am supplying incorrectly. I have played with all the possible combinations in the configuration box and I have not been able to get it to recognize any parameters correctly.

What am I doing wrong?. If you could give me some light to help me understand what is happening or if I am missing something that I am not including or if that code is not enough to add a simple object.

I have to admit that I do not have a good team to work with, since the Vulkan implementation is not fully implemented for my graphics card.

Code: Select all

Operating System: Debian GNU/Linux 11
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2
Kernel Version: 6.1.0-0.deb11.13-amd64
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-3630QM CPU @ 2.40GHz
Memory: 7.6 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 4000

I am currently managing the project with qmake

In the following link, I have posted the fully functional base project on which I am working, where it is shown

https://github.com/remizero/ogre3dstart

or if you like, you can download it directly

Code: Select all

git clone https://github.com/remizero/ogre3dstart.git

Waiting for a response to help me. I will be quite active on this forum from now on.

Thanks in advance.

Last edited by remizero on Tue Mar 12, 2024 3:21 pm, edited 1 time in total.
rpgplayerrobin
Orc Shaman
Posts: 715
Joined: Wed Mar 18, 2009 3:03 am
x 396

Re: Simple object is not shown above basic tutorial.

Post by rpgplayerrobin »

I have watched this post for a while now, hoping someone could help you (I cannot, since I don't use that version of Ogre).

I think you should move this thread to the Help forums instead, as it is more active, especially with the creator of your version of the engine, @dark_sylinc.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5451
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1352

Re: Simple object is not shown above basic tutorial.

Post by dark_sylinc »

Thanks for the ping!

The error in particular:

The errors you're having sounds like an ABI (Application Binary Interface) mismatch.
This can happen if Debug and Release versions are mixed together when they shouldn't.
Because I don't see anything particularly wrong with your C++ code.

Maybe defining _DEBUG and/or NDEBUG in ogre3dstart.pro will fix it?
I suspect adding the following to ogre3dstart.pro may fix it:

Code: Select all

DEFINES += NDEBUG

In OgreNext 3.0 (currently master branch) we added the CMake option OGRE_EMBED_DEBUG_MODE to avoid this problem entirely.

About your createItem:

OgreNext resource system creates a "virtual" filesystem. This is because your assets could be source from disk, but could also be sourced from a compressed or encrypted file, from network, etc.

This means that instead of doing this:

Code: Select all

Ogre::Item *cubeItem = sceneManager->createItem ( "../data/cube.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, Ogre::SCENE_DYNAMIC );

You should simply do this:

Code: Select all

Ogre::Item *cubeItem = sceneManager->createItem ( "cube.mesh", "General", Ogre::SCENE_DYNAMIC );

BUT you have to add ../data to the ResourceGroupManager so that the ResourceGroupManager knows that it must add all files in that folder to be available:

Code: Select all

Ogre::ResourceGroupManager::getSingleton().addResourceLocation( "../data", "FileSystem", "General" );
User avatar
remizero
Gnoblar
Posts: 4
Joined: Mon May 08, 2023 3:50 pm

Re: Simple object is not shown above basic tutorial.

Post by remizero »

Hi guys, thank you very much for your answers, I had not responded due to work issues and testing the dark_sylinc solution.

Although the solution did not help me directly solve the problem, it did help me solve a later problem.

Anyway, for some reason that I still can't understand, in the initial code shown, which is the same as the "Tutorial00_Basic" tutorial, the line that initializes Ogre::Root, when defined in the original way,

Code: Select all

Window *window = root->initialize( true, "Tutorial 00: Basic" );

Apparently it does not allow any object to be displayed correctly, so I had to review several of the tutorials to clearly identify what was not being done in the "Tutorial00_Basic" tutorial. And basically what was done differently in the rest of the tutorials is the way to initialize Ogre::Root, and in the end it was this line

Code: Select all

// Window *window = root->initialize( true, "Tutorial 00: Basic" );
root->initialize( false, "Tutorial 00: Basic" );

But since the Ogre::Window instance is later required, it is necessary to configure it appropriately. For testing purposes I have chosen to assign the values manually as follows:

Code: Select all

Ogre::NameValuePairList params;
params.insert ( std::make_pair ( "title", "Tutorial 00: Basic" ) );
params.insert ( std::make_pair ( "vsync_method", "Render Ahead / FIFO" ) );
params.insert ( std::make_pair ( "FSAA", "1" ) );
params.insert ( std::make_pair ( "vsync", "Yes" ) );
params.insert ( std::make_pair ( "reverse_depth", "Yes" ) );
Window *window = Ogre::Root::getSingleton ().createRenderWindow ( "Tutorial 00: Basic", 1280, 720, false, &params );

and now it does show the cube "cube.mesh", which thanks to dark_sylinc's comment I solved the mesh location problem, although I have also understood that if I add the path in the resources.cfg file, it is also resolved, at the time of load the resources and routes thereof and/or the system.

Although now another problem has arisen and it is the following:

Code: Select all

Mesh: Loading cube.mesh.
OGRE EXCEPTION(3:RenderingAPIException): Fixed Function pipeline is no longer allowed nor supported. The material BaseWhite must use shaders in HlmsLowLevel::calculateHashFor at /home/remizero/Facilities/Librerias/Ogre/OgreMain/src/OgreHlmsLowLevel.cpp (line 160)
Couldn't apply datablock '[Hash 0xc4be0758]' to this renderable. Using default one. Check previous log messages to see if there's more information.
Segment violation

For now I have solved it by commenting the line:

Code: Select all

// cubeItem->setDatablock ( hlms->getDatablock ( "BaseWhite" ) );

and so, if it shows me the cube, but without any type of material or color associated except that it looks black. I understand that the default material "BaseWhite" is not spelled correctly or something, but I can't identify it and so far I'm having a hard time understanding the whole issue of shadows, materials, etc.

I have uploaded the changes so that anyone who has the same problem can review the code and follow the evolution as a learning experience.

Code: Select all

git clone https://github.com/remizero/ogre3dstart.git

If you can give me any help it would be greatly appreciated.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5451
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1352

Re: [SOLVE] - Simple object is not shown above basic tutorial.

Post by dark_sylinc »

Hi!

IIRC the older low level material system creates a "BaseWhite" material without shaders for legacy reasons, but there is no such material created automatically for HLMS.

You can however create one for PBS:

Code: Select all

hlms BaseWhite pbs
{
    diffuse 1 1 1 1
}

although I have also understood that if I add the path in the resources.cfg file, it is also resolved, at the time of load the resources and routes thereof and/or the system.

Yes! The point of the cfg is that it can be more easily edited by users.

Please note that ultimately your code is the one parsing resources.cfg. See that GraphicsSystem::setupResources in the samples performs the following:

Code: Select all

// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load( AndroidSystems::openFile( mResourcePath + "resources2.cfg" ) );

// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

Ogre::String secName, typeName, archName;
while( seci.hasMoreElements() )
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();

if( secName != "Hlms" )
{
    Ogre::ConfigFile::SettingsMultiMap::iterator i;
    for( i = settings->begin(); i != settings->end(); ++i )
    {
        typeName = i->first;
        archName = i->second;
        addResourceLocation( archName, typeName, secName );
    }
}

In other words, it parses resources cfg and calls addResourceLocation for each item in it (except the ones under the [Hlms] tag).

but without any type of material or color associated except that it looks black

Please note that you're not creating any light, and without lights any PBS material will look black.

See Ogre 2.1+ FAQ question regarding this.

Also note that point & spot lights may not show up without further setup (either enable shadows, or use Forward+).

It's best to start with directional and ambient light to get things started.