• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

364 Neutral

About floatingwoods

  • Rank
  1. Cloud license manager. How?

    Thank you Frob, that helps already a lot!
  2. Hello,   I am looking for a solution that allows me to easily generate licenses that users can then check-in and check-out on their computers. I am currently working with a dongle-based license lock solution, but it is not flexible enough.   The best would be if I could install a license management system on my website, so that I am not dependent on the success/failure of some company that provides this service.   Would you happen to know such a system?   Thanks for any input
  3. Cloud license manager

    Hello,   I am looking for a solution that allows me to easily generate licenses that users can then check-in and check-out on their computers. I am currently working with a dongle-based license lock solution, but it is not flexible enough.   Then best would be if I could install a license management system on my website, so that I am not dependent on the success/failure of some company that provides this service.   Would you happen to know such a system?   Thanks for any input
  4. Sharing object between 2 threads

    Well, all this makes perfect sense. It seems I got scared (and mixed-up my thoughts) because of the thread, separate entities (exe + dll) and existing code aspect.   The fact that I need different threads is that my game logic already works using several dozens of threads (but perfectly synchronized). So it only makes sense to have a separate thread for the GUI and rendering (e.g. Qt also requires to run the main Qt code via the application main thread)
  5. Sharing object between 2 threads

    Phil, perfectly agree with you. If I had to rewrite the whole project, that's how I would do it. Unfortunately I have to modify an existing code (written by another person) that has several hundreds of thousands lines. It would take several months to do that. On the other hand, if I have a solution (maybe not that elegant) that works, and that can slowly be refactored while keeping current working solution, it would be great.   With the initial idea of simply casting an object of class A to and object of class B (where the two classes are identical except for the member functions), I could put a few ifdefs in the class definitions, I could compile class A in item A, and class B in item B, but using the common, existing class AB.
  6. Sharing object between 2 threads

    I need option 3 in what you mention.   My problem is not only the rendering, but also all the GUI. So I have:   Game logic thread: runs the game and modifies the resources. GUI thread: handles the GUI events and also renders the views.   I want the game logic to be compilable in headless mode, and optionally have a plugin with the GUI and rendering. Think of it as a simulation of some physical process: a) we can have the simulation configured and modified via a GUI, and also visualized. This situation requires the headless mode game logic executable, and the GUI/rendering plugin loaded b) But other times, we simply want to be able to run, say, 10 simulations in parallel, in headless mode: in that case, we are only interested in the data the simulation produces. This situation only requires the headless mode game logic executable   So all the dependencies to the GUI and OpenGl should be in the plugin, so that the game logic can also easily run on machines that do not have any display (i.e. no OpenGl or graphic card installed)   So I agree that duplicating the resources is a tremendous amount of work, and many things can go wrong if not done properly. So, let's for now forget the resource duplication, and consider that we have only one thread doing everything. What I currently have is following:   class CObject_A {     CObject_A();     virtual ~CObject_A();     void doCalculationAndModifyObject();     void renderObject()     CData* data; }; I basically currently have everything in one class (actually many classes, but for simplification sake). Because of that I cannot compile the gamelogic in headless mode (above class has the dependencies to the GUI/OpenGl). I need to separate the above class in 2 separately compilable entities, with least effort. For that reason I mentioned the possibility to simply cast a class to another class, if the member variables are the same.   So I want to be able to do following: // gameLogic executable: CObject_A* object=new CObject_A(); object->doCalculationAndModifyObject(); callPluginRoutine(object); And in my plugin: void callPluginRoutine(CObject_A* obj) {     obj->renderObject(); } If I want to be able to compile my gameLogic executable in headless mode, I am not allowed to have routine "renderObject()" in class CObject_A during compilation.
  7. Sharing object between 2 threads

    Thanks for all the good answers. I realize that the better approach would be to use the same data structure in both threads, while having different classes. What I am actually trying to do is:   The main thread handles the game logic and works on the resources (reading/writing them). The auxiliary thread handles the display only, reading only from the resources.   I want at a later point to be able to either have the render thread:   1. either read from the original data while the game logic thread waits (thus avoiding copying the resources at all). 2. either read from a copy of the original data, while the game logic continues its work.   In case 2 above, copying the resources will be done as a light copy first (i.e. actually sharing the resource until the point where the main thread modifies it: in that case, the main thread will first deep-copy the resource before modifying it, while the render thread will still read from the old, unmodified resource, thus avoiding a crash).
  8. Hello,   I have following problem:   I have an object that belongs to a main thread, and that I want to share with an auxiliary thread. The main thread does calculation on the object and modifies it, and the auxiliary thread simply reads and visualizes that object.   I want the auxiliary thread to be able to:   1. Directly read the main thread object. In that case, the main thread needs to be locked during that time. 2. Read a copy of the main thread object. In that case, the main thread does not need to be locked during that time.   Depending on the user settings, I want to have situation 1 or 2 described above.   Imagine the main thread object to be following class: class CObject_A { // the main thread creates/destroys and uses this object     CObject_A();     virtual ~CObject_A();     void doCalculationAndModifyObject(); CObject_A* duplicateObject();     int data1;     int data2; }; And imagine the auxiliary thread to have following class declaration:  class CObject_B { // the auxiliary thread uses this class. But it does not create/destroy the object.     CObject_B();     virtual ~CObject_B();     void displayObject();     int data1;     int data2; }; So, is following legal if I do this in the auxiliary thread: CData_A* objectCreatedFromTheMainThread=getObjectFromMainThread(); CData_B* objectForTheAuxiliaryThread=(CData_B*)objectCreatedFromTheMainThread; objectForTheAuxiliaryThread->displayObject(); The question is basically: given two different classes that have exactly the same data definition (including order and same compiler), but that have different member functions, is it legal to cast the object from one class to the other?   Thanks for any insight!
  9. Data alignment on ARM processors

    Thanks to both of you for the very clear explanations!
  10. Hello,   I recently faced a problem with some C code, on ARM processors, where data alignment is of importance. I typically have following 2 scenarios: float value=doLittleBigEndianConversion(((int*)(ucharPtr+offset))[0]); and ((int*)(ucharPtr+offset))[0]=someIntValue; Depending on the offset, I get some crashes. So the solution to scenario 1 is (for instance): float value; memcpy (&value,ucharPtr+offset,sizeof(float)); value=doLittleBigEndianConversion(value); Which solves the alignment problem. My question is now: How can I fix the scenario2 code, so that it also works on ARM processors?   Thanks for any insight!
  11. std::sort corrupts my memory

    Oh, forgot to mention: I am using MinGW
  12. std::sort corrupts my memory

    Thanks to both of you, that makes perfect sense in hindsight!
  13. Hello,   I have a strange behaviour I can't explain. I have this structure:   struct SMyStruct { int x; int y; bool operator< (const SMyStruct& m) const {return true;} }; with following code: std::vector<std::pair<float,SMyStruct > > items; for (size_t i=0;i<8;i++) { SMyStruct a; a.x=i; for (size_t j=0;j<8;j++) { a.y=j; items.push_back(std::make_pair(0.0,a)); } } std::sort(items.begin(),items.end()); for (size_t i=0;i<items.size();i++) { int x=items[i].second.x; int y=items[i].second.y; printf("i: %i --> %i, %i\n",i,x,y); } The above code was simplified, but the idea is to basically sort items according to a float value (in above code that float value is always 0.0). Above will corrupt my memory and later crash. Also, the output is mostly correct, but sometimes I get very large, non-logical values for x and y, after the sort. I can't figure out where I made a mistake. But I can fix that strange behaviour by having the comparison operation of the struct always return false instead of true (since I only care about sorting according to the float value of the pair I can return true or false).   Can anyone see where there is a bug in above code?    
  14. Data organization with graphics front-end

    Thanks for the interesting replies!   A question related to my first question: next to the graphics visualization, the GUI is in my case also running in a different thread (actually in the same thread as the graphics). How do people usually do? Query the calculation thread for the info that needs to be displayed, and then, if something was changed, send the update back to the calculation thread so that it can update its objects? Just wondering since the GUI thread has one requirement less, and one requirement more compared to the graphics thread:   1. The GUI thread doesn't need to refresh that often (less constraining than for the graphics thread) 2. But the GUI thread needs to send back changes to the calculation thread (that constraint doesn't exist for the graphics thread)   Thanks
  15. Hello,   I am wondering what the common approaches to following problem are:   Imagine an application that does some sort of computation or simulation on a complex data structure (e.g. several hundreds of different objects types). That application can run in headless mode (i.e. without GUI or graphics fron-end). Imagine also that this application just needs a single thread. In case of a game, this thread would handle the game logic and read/write the data.   Above is not too complicated, but what happens when we want the user to be able to constantly visualize the data structure (e.g. display the game evolution in 2D/3D for instance). Imagine that for this part, a second thread is used.   Now, how can we optimized everything for fastest and safest operation? I mean, the graphics thread and the computation thread cannot access the data at the same time, unless we read it only, which is not the case (or rarely).   So I see several options:   1. The two threads access the same data alternately, but never at the same time. This is not very elegant, since the two threads would have to wait for each other.   2. The computation thread duplicates the complex data on a regular basis, and the graphics thread only accesses the duplicate portion of the data. My worries here is that the duplication process could take time (even if in the end it is just a complex memory copy operation).   3. The computation thread simply sends messages to the graphics thread when it modified something: we would have a kind of complex synchronization process that can easily break down. My worries here are: the synchronization can break if not very carefully implemented and the implementation is quite complex.   So my question is: what would be the best solution generally speaking? Or is there another solution to my problem?
  • Advertisement