Page 1 of 1

[2.1] Can't see the mesh

Posted: Sat Nov 07, 2015 3:55 pm
by mrmclovin
Hi. I'm trying to get my custom mesh showing in the window but it does not work, nor can I get a sample mesh to be rendered. I've gone through my code a couple of times but I can't find what I'm missing. I've added compositor, registered Hlms, initialised resources, added light,,.. Any tips?

Code: Select all

ResourceGroupManager::getSingleton().addResourceLocation("./Media/2.0/scripts/materials/PbsMaterials", "FileSystem", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
  ResourceGroupManager::getSingleton().addResourceLocation("./Media/materials/textures", "FileSystem", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
  ResourceGroupManager::getSingleton().addResourceLocation("./Media/models", "FileSystem", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
  Ogre::SceneManager *scene_mgr = ogre.root->createSceneManager(Ogre::ST_GENERIC, 1, Ogre::INSTANCING_CULLING_SINGLETHREAD);
  Camera *camera = scene_mgr->createCamera("MainCamera");
  camera->setPosition(0, 10, 10);
  camera->lookAt(0, 0, 0);
  Light *light = scene_mgr->createLight();
  SceneNode* light_node = scene_mgr->getRootSceneNode()->createChildSceneNode(Ogre::SCENE_DYNAMIC);
  light_node->setPosition(0, 5, 0);
  light_node->lookAt(Vector3(0,0,0), Node::TS_WORLD);
  CompositorManager2 *compositor_mgr = ogre.root->getCompositorManager2();
  IdString name = "Workspace";
  compositor_mgr->createBasicWorkspaceDef(name, ColourValue(0.2, 0.2, 0.2));
  compositor_mgr->addWorkspace(scene_mgr, ogre.render_window, camera, name, true);
  CubeMesh cube(scene_mgr);
  Ogre::SceneNode *node = scene_mgr->getRootSceneNode()->createChildSceneNode(Ogre::SCENE_DYNAMIC);
  auto v1Mesh = Ogre::v1::MeshManager::getSingleton().load(
                                                      "athene.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
                                                      Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC );

  //Create a v2 mesh to import to, with a different name (arbitrary).
  auto v2Mesh = Ogre::MeshManager::getSingleton().createManual(
                                                          "athene.mesh Imported", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
  bool halfPosition   = true;
  bool halfUVs        = true;
  bool useQtangents   = true;
  //Import the v1 mesh to v2
  v2Mesh->importV1( v1Mesh.get(), halfPosition, halfUVs, useQtangents );
  //We don't need the v1 mesh. Free CPU memory, get it out of the GPU.
  //Leave it loaded if you want to use athene with v1 Entity.
  //Create an Item with the model we just imported.
  //Notice we use the name of the imported model. We could also use the overload
  //with the mesh pointer:
  //  item = sceneManager->createItem( v2Mesh, Ogre::SCENE_DYNAMIC );
  Ogre::Item *item = scene_mgr->createItem( "athene.mesh Imported",
                                              Ogre::SCENE_DYNAMIC );
//  item->setDatablock("Marble");
  node->scale( 0.1f, 0.1f, 0.1f );
  light->setPowerScale( Ogre::Math::PI );
  light->setType( Ogre::Light::LT_DIRECTIONAL );
  light->setDirection( Ogre::Vector3( -1, -1, -1 ).normalisedCopy() );
  bool quit = false;
  while (!quit) {
    SDL_Event event;
    while (SDL_PollEvent(&event)) {
      if (event.type == SDL_QUIT) {
        quit = true;
  std::cout << "Done" << std::endl;
  return 1;

Code: Select all

All done
Mesh: Loading athene.mesh.
WARNING: athene.mesh is an older format ([MeshSerializer_v1.8]); you should upgrade it as soon as possible using the OgreMeshTool tool.
Can't assign material 1 - Default because this Material does not exist. Have you forgotten to define it in a .material script?
Material not found is the default for athene.mesh I guess, but that shouldn't be a problem since I'm setting it to Marble later?

Also, I'm on Mac OSX 10.10. dark_sylinc said that it isn't supported. Does it mean that simple stuff like this may not be working?

Re: [2.1] Can't see the mesh

Posted: Sat Nov 07, 2015 6:07 pm
by dark_sylinc
On OS X you'll get a blatant crash or things like this; at least using the default Apple drivers.

If you're using NVIDIA's custom driver, it may work but I have not tested it. First place to start would be whether the samples work as intended.

Re: [2.1] Can't see the mesh

Posted: Sat Nov 07, 2015 8:27 pm
by mrmclovin
I think I use Apple's driver unfortunatley.

The ogre build on Mac OSX is a total mess. Files, included .frameworks, resources.cfg, Media folder etc etc is all spread out and duplicated in several folders when you build using XCode - there's no structure. I don't know if it's just my Cmake messing.... After two hours I could get the samples to almost run, but the assertion error I get this time I cannot solve:
Assertion failed: (_isManual && "depthFormat = GL_NONE && stencilFormat = GL_NONE but _isManual = false"), function GL3PlusDepthBuffer, file /ogre/ogre/RenderSystems/GL3Plus/src/OgreGL3PlusDepthBuffer.cpp, line 73.
This is the crash you are maybe talking about or any idea?

Re: [2.1] Can't see the mesh

Posted: Sat Nov 07, 2015 10:23 pm
by dark_sylinc
OK, [Warning: engaging rant mode] Not supported means not supported. Go complain to Apple.

It's not a matter of "hey we didn't test it but it may work". Their OpenGL implementation lacks several basic features required by Ogre in order to run and are missing from Apple's GL implementation:
  • GL_ARB_base_instance. Required in order to draw anything on screen efficiently. Became part of core in GL 4.2, had been as an extension since 2010.
  • GL_ARB_shading_language_420pack. Required. Allows us to do a lot of "advanced" (not really that advanced) syntax with GLSL in order to render efficiently and without tons of workarounds. Used by all the Hlms implementations. Introduced with GL 4.2 in 2011
  • GL_ARB_texture_buffer_range. Required. Allows us to bind a range of a buffer object and not the whole buffer object. Made into core in 4.3, but it has been around since 2011.
  • GL_ARB_multi_draw_indirect. Optional. We fallback to GL_ARB_base_instance when not present.
  • GL_ARB_texture_storage. Optional. Highly recommended. It is impossible to support BC5 compressed texture arrays (used for compressed normal mapping) without this extension. Became part of core in 4.2. Been there as an extension since 2009.
  • GL_ARB_buffer_storage. Optional. When supported we use better, less-stall-prone paths. Became part of core in 4.4; been there as an extension since 2013
There is at least three 4-year-old extensions (soon to be 5 year old) that are required and not provided by Apple's default GL implementation.

Either wait for Apple to dignify themselves by providing a more up to date and decent implementation, wait for us to finish the Metal backend, or wait for us to finish the GLES3 backend (in theory should run on OSX, albeit the performance will probably not be comparable with the other OSes).
The Metal approach is likely the brightest one.

In its current state left by Apple, the GL3+ backend will not run or walk. The best you may be able to do is to get to clear the screen. Try to render something and it will crash. There's a bazillion things missing in their GL dll.
There is no plan to make the GL3+ backend "more compatible" with OSX because that would seriously hurt all other platforms. The current way of rendering is how DX11 works, how Metal works, how DX12 works, and how Vulkan works.


Re: [2.1] Can't see the mesh

Posted: Mon Nov 09, 2015 9:34 am
by mrmclovin
Okey, I see. I think I'll have to wait for the Metal implementation then. :(

Thanks for clearing that up!

Re: [2.1] Can't see the mesh

Posted: Mon Nov 09, 2015 10:50 am
by al2950
I love how dark_sylinc always explicitly declares 'Rant Mode' :lol: