Loading a mesh in a FrameListener

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
andrecaldas
Halfling
Posts: 54
Joined: Mon May 06, 2024 1:06 am
x 3

Loading a mesh in a FrameListener

Post by andrecaldas »

In my program, I load meshes in different threads. However, it seems GL commands need to be executed in the thread that holds the GL context.

Probably I am doing things in a very wrong way, but my solution to this problem was:

  1. Set up a FrameListener with a queue of lambda functions.
    https://github.com/andre-caldas/ParaCAD ... ueue.h#L40

  2. When "frameRenderingQueued()" runs, it just executes all lambdas registered in the queue.
    https://github.com/andre-caldas/ParaCAD ... ue.cpp#L29

  3. The mesh is "prepared" normally, but when it is to be loaded, it registers a lambda function in the queue.
    https://github.com/andre-caldas/ParaCAD ... h.cpp#L301

OBS: Registering the listener happens here:
https://github.com/andre-caldas/ParaCAD ... sh.cpp#L43
This ensures (I hope!) the listener is registered only once.

Seems to be working. But I wonder if I shouldn't use "frameEnded()" instead of "frameRenderingQueued()", because it might be not correct to change the buffers just before swapping them.

paroj
OGRE Team Member
OGRE Team Member
Posts: 2108
Joined: Sun Mar 30, 2014 2:51 pm
x 1134

Re: Loading a mesh in a FrameListener

Post by paroj »