Tahnks for replies.
After reading, I realized that instead of describe the problem, I wrote an observation, that I (mistakenly) thought explained the source of the problem.
A potential bug, as correctly described Dreikblack, is that:
Once a window has been created, it cannot be physically closed other than by completely terminating the program.
I think this is a minor, low priority thing, but could be looked into at some point. Or maybe there is a workaround?
#include "UltraEngine.h"
#include <iostream>
#include <chrono>
#include <thread>
using namespace UltraEngine;
void RunTestProc() {
auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, GetDisplays()[0], WINDOW_CENTER | WINDOW_TITLEBAR);
auto world = CreateWorld();
auto framebuffer = CreateFramebuffer(window);
auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); }
window->FlushKeys(); window->FlushMouse();
FlushEvents();
std::cout << "before exit func window.use_count = " << window.use_count() << std::endl;
}
int main(int argc, const char* argv[])
{
RunTestProc();
// theoretically there are no user object references left at this point, so the window should be closed ?
// but it is still open, although non - functional.
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // just to be sure...
Print("\nCan you still see the window?\n");
system("pause");
return 0;
}
It seems to me that some resources are not being deleted, even though all user-created references have gone out of scope.
Perhaps they are what keep the window alive?