How to finalize openframeworks without exit all process?

Hello,
I’m using OF, v. 0.061, as a C++ DLL with no problem. I can create and use OF functions as objects.
The problem occurs after, when I try to destroy the object. Or the application stops or OF closes all, not only the DLL but the application too.

Can somebody helpe me, please?

Thanks in advance.

No answers… :frowning:
Is this an indication that it is impossible to finely exit OF?
I’m really need to do this…
Help me!

Thanks!

sorry, but your question isn’t really clear…

you have compiled OF into a DLL?

is it possible to explain in more detail what your problem is?

take care,
zach

ok… I’m sorry. My english isn’t so good.
Yes, I have compiled OF as a DLL and I can use all OF functions in a simple app without problems.
When I start OF, I call the following code:

  
ofSetupOpenGL(&window, 680, 385, OF_WINDOW);  
ofSetFrameRate(FRAME_RATE);  
ofRunApp(new MVCore());  
core = (MVCore*)ofGetAppPtr();  
window.runAppViaInfiniteLoop(core);    

This works fine and I can access everything through the object ‘core’.
My question is: what functions and in what sequence should I call to stop OF and to free all resources without need to call OF_EXIT_APP (that is called when a OF_KEY_ESC is pressed in a common OF application) that internally calls std::exit, that in turn (by http://www.cplusplus.com/reference/clib-…-dlib/exit/) terminates all process.
Remember, I don’t want to terminate the process. I want to stop OF and to free all OF allocated resources.
Can anybody help me?

Thanks a lot!

No news?
Is this impossible?

glut does never terminate so to end an OF application you need to call exit. one simple thing you can do is start OF in a different thread and then kill that thread when you’re done

That might not work though as you can’t have OpenGL being used across threads. So if his main app uses any OpenGL too I think you might have issues.

GLUT once started never returns - so std::exit() is really the only way to terminate it.

There is some info on this issue here:
http://www.gamedev.net/community/forums-…-1&#2485374

One solution is to use a different windowing environment the ofAppBaseWindow is designed to be extended so you could wrap a different windowing environment like GLFW that may allow a way to do what you want.

What is your reason for using OF in this way? What does your main app do?
I think if we can understand the way you are using it, it might make it easier for us to help you.

Theo

Hello Theo and Arturo. Thanks a lot for the attention.
I will try the solutions but I’m trying other solutions too.

In this case, answering the Theo question: I’m modeling OF to work in a DLL as a “service” and I need to insert OF in something like a state machine (init, play, pause, finalize). In this way, I need to finalize OF in some way. Can you see other type of solution for me? And “I don’t know” what the main app will be. I’ve done some tests with a simple .Net app, a .Net web service, and a Flex/AS3 project.

What I’m trying now is to remove all callback functions from Glut and, in this way, “to stop” the OpenGL and to kill my OF object.

I’m studying a lot about this and others issues now. OF is really a good tool!!! I have created a addon for LocalConnection in Windows. Using it, I can remove the udp-flashlc-bridge when operating in a same machine. Is this addon of interest for the OpenFramewoks? I can work on this but I will need some help in implementations to Linux and others OS.

i think is no problem to use a thread as long as everything opengl is called from that thread, the problem with threads and opengl is when you try to do calls from two or more threads but if every opengl call is in one thread it should be ok no matter if the main app is in a different one.

i’ve done that with sdl and it works without problem

The solution of http://www.gamedev.net/community/forums … 1&#2485374 didn’t work.

The solution using threads didn’t work too. I can’t draw the window correctly after to create the new thread, and calls to OF_EXIT_APP continues closing all process. :smiley:

Thanks for the tips.