Crash at Hlms::getDefaultDatablock when building custom mesh

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
mrmclovin
Gnome
Posts: 308
Joined: Sun May 11, 2008 9:27 pm
x 12

Crash at Hlms::getDefaultDatablock when building custom mesh

Post by mrmclovin »

I'm playing around with VAO and wanna make a simple Cube mesh. I get a crash at

Code: Select all

    HlmsDatablock* Hlms::getDefaultDatablock(void) const
    {
        return mDefaultDatablock;
    }
when I try to create en Item out of my mesh

Code: Select all

  Ogre::SceneManager *scene_mgr = ogre.root->createSceneManager(Ogre::ST_GENERIC, 1, Ogre::INSTANCING_CULLING_SINGLETHREAD);
  Camera *camera = scene_mgr->createCamera("MainCamera");
  
  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);
  
  auto *node = scene_mgr->createSceneNode();
  auto *item = scene_mgr->createItem(cube.mesh, Ogre::SCENE_DYNAMIC);
And my mesh code:

Code: Select all

using namespace Ogre;
ShapeBase::ShapeBase(Avocada::String shapename, Ogre::SceneManager* scnmgr, int16 idxsize, int16 vsize) :
scene_mgr(scnmgr) {
  MeshManager *mesh_mgr = Ogre::MeshManager::getSingletonPtr();
  this->mesh = mesh_mgr->createManual(shapename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
  this->submesh = mesh->createSubMesh();
  
  VertexElement2Vec elements {
    VertexElement2(VET_FLOAT3, VES_POSITION),
    VertexElement2(VET_FLOAT3, VES_NORMAL),
  };

  Ogre::RenderSystem *render_system = Ogre::Root::getSingleton().getRenderSystem();
  
  // Temp data
  int16 *tmpv = new int16[vsize*6];
  int16 *tmpi = new int16[idxsize];
  
  this->vao_mgr = scnmgr->getDestinationRenderSystem()->getVaoManager();
  this->index_buf = vao_mgr->createIndexBuffer(IndexBufferPacked::IT_16BIT, idxsize, BufferType::BT_DYNAMIC_DEFAULT, tmpi, false);
  this->vertex_buf = vao_mgr->createVertexBuffer(elements, vsize, BufferType::BT_DYNAMIC_DEFAULT, tmpv, false);
  delete tmpv;
  delete tmpi;
  
  VertexBufferPackedVec vbuffer {
    this->vertex_buf
  };
  
  VertexArrayObject *vao = this->vao_mgr->createVertexArrayObject(vbuffer, this->index_buf, v1::RenderOperation::OT_TRIANGLE_LIST);
  
  this->submesh->mVao[0].push_back(vao);
  this->submesh->mVao[1].push_back(vao);
}

ShapeBase::~ShapeBase() {

}

CubeMesh::CubeMesh(SceneManager *scnmgr) :
ShapeBase("Cube", scnmgr, 3*2*6, 8) {
  float vertices[] = {
    -.5, -.5, .5, // Back
    .5, -.5, .5,
    -.5, .5, .5,
    .5, .5, .5,
    
    -.5, -.5, -.5, // Front
    .5, -.5, -.5,
    -.5, .5, -.5,
    .5, .5, -.5,
  };
  
  float indicies[] = {
    0, 1, 3, // Back
    3, 2, 0,
    
    3, 7, 6, // Top
    3, 6, 2,
    
    5, 6, 7, // Front
    5, 4, 6,
    
    5, 7, 3, // Right
    5, 3, 1,
    
    2, 4, 0, // Left
    2, 6, 4,
    
    1, 0, 4,
    1, 4, 5
  };
  
  this->index_buf->upload(indicies, 0, 3*2*6);
  this->vertex_buf->upload(vertices, 0, 8);

}
Using Ogre 2.1 on OSX 10.10 with GL3Plus render system.

Any idea what might cause it? Do I have to define some material?

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

Re: Crash at Hlms::getDefaultDatablock when building custom

Post by dark_sylinc »

  • Do you register the Hlms'es? See GraphicsSystem::registerHlms from the samples.
  • OS X is not supported by 2.1. Apple is using an extremely outdated OpenGL implementation and thus lacks necessary extensions & functionality. It may work with NVIDIA's custom drivers, but I haven't tested. A Metal RenderSystem is in the works, but there is no ETA.

User avatar
Thyrion
Goblin
Posts: 224
Joined: Wed Jul 31, 2013 1:58 pm
Location: germany
x 8

Re: Crash at Hlms::getDefaultDatablock when building custom

Post by Thyrion »

dark_sylinc wrote:OS X is not supported by 2.1.
ouch! :shock:

mrmclovin
Gnome
Posts: 308
Joined: Sun May 11, 2008 9:27 pm
x 12

Re: Crash at Hlms::getDefaultDatablock when building custom

Post by mrmclovin »

Thank you. I haven't tried to register hlms so I'll try that and see what happens.

My Mac runs Open GL 4.1 (which was released 2010) so I guess it's kind of old.. but extremely old? :)

mrmclovin
Gnome
Posts: 308
Joined: Sun May 11, 2008 9:27 pm
x 12

Re: Crash at Hlms::getDefaultDatablock when building custom

Post by mrmclovin »

dark_sylinc wrote:
  • Do you register the Hlms'es? See GraphicsSystem::registerHlms from the samples.
  • OS X is not supported by 2.1. Apple is using an extremely outdated OpenGL implementation and thus lacks necessary extensions & functionality. It may work with NVIDIA's custom drivers, but I haven't tested. A Metal RenderSystem is in the works, but there is no ETA.
I missed the part about registering Hlms. Now it doesn't crash no more. Thanks!

Post Reply