Fixed memory leaks
This commit is contained in:
parent
0bda0c5484
commit
f7eba79907
|
@ -11,6 +11,19 @@
|
||||||
"buildCommandArgs": "",
|
"buildCommandArgs": "",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"cmakeToolchain": "C:/Users/Robert/source/repos/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
"cmakeToolchain": "C:/Users/Robert/source/repos/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Release",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "RelWithDebInfo",
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"cmakeToolchain": "C:/Users/Robert/source/repos/vcpkg/scripts/buildsystems/vcpkg.cmake",
|
||||||
|
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||||
|
"variables": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
13
src/main.cpp
13
src/main.cpp
|
@ -30,12 +30,18 @@ typedef struct sHighway
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
// Load map data and calculate window size
|
// Load map data and calculate window size
|
||||||
|
SDL_DisplayMode DM;
|
||||||
|
SDL_GetCurrentDisplayMode(0, &DM);
|
||||||
|
|
||||||
|
std::cout << "Loading and parsing OSM XML file. This might take a bit..." << std::flush;
|
||||||
osmp::Object* obj = new osmp::Object("leipzig.osm");
|
osmp::Object* obj = new osmp::Object("leipzig.osm");
|
||||||
|
std::cout << "Done!" << std::endl;
|
||||||
osmp::Bounds bounds = obj->bounds;
|
osmp::Bounds bounds = obj->bounds;
|
||||||
float aspectRatio = (float)(bounds.maxlon - bounds.minlon) / (float)(bounds.maxlat - bounds.minlat);
|
float aspectRatio = (float)(bounds.maxlon - bounds.minlon) / (float)(bounds.maxlat - bounds.minlat);
|
||||||
int windowWidth = 2000;
|
int windowHeight = DM.h - 100;
|
||||||
int windowHeight = windowWidth / aspectRatio;
|
int windowWidth = windowHeight * aspectRatio;
|
||||||
|
|
||||||
// Fetch all the ways
|
// Fetch all the ways
|
||||||
std::vector<std::shared_ptr<osmp::Way>> ways = obj->GetWays();
|
std::vector<std::shared_ptr<osmp::Way>> ways = obj->GetWays();
|
||||||
|
@ -132,9 +138,6 @@ int main(int argc, char** argv)
|
||||||
ways.clear();
|
ways.clear();
|
||||||
delete obj;
|
delete obj;
|
||||||
|
|
||||||
// Initiaize graphics API
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
|
||||||
|
|
||||||
// Create Window + Renderer
|
// Create Window + Renderer
|
||||||
SDL_Window* window = SDL_CreateWindow("MapViewer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowWidth, windowHeight, SDL_WINDOW_SHOWN);
|
SDL_Window* window = SDL_CreateWindow("MapViewer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowWidth, windowHeight, SDL_WINDOW_SHOWN);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
|
|
Loading…
Reference in a new issue