EDN Admin
Well-known member
Hi All,
This is my first post here. My application is throwing Debug Assertion Failed. Invalid Null pointer error. I have no idea what wrong i am doing. Below is the main method of my application. Obviously, there are other parts to the code as well but i would
not post that and hope i have problem in main method and you guys are able to me help me with it . Thanks
<br/>
std::string image_name;<br/>
std::vector<std::string> image_names;<br/>
char* folder_location = argv[1];<br/>
std::string folder_location_str (folder_location);<br/>
std::list<TextureAtlas *> atlases ;<br/>
<br/>
WIN32_FIND_DATA ffd;<br/>
TCHAR szDir[MAX_PATH];<br/>
size_t length_of_arg;<br/>
HANDLE hFind = INVALID_HANDLE_VALUE;<br/>
LARGE_INTEGER filesize;<br/>
DWORD dwError=0;<br/>
<br/>
if(argc != 2)<br/>
{<br/>
_tprintf(TEXT("nUsage: %s <directory name>n"), argv[0]);<br/>
return (-1);<br/>
}<br/>
StringCbLength(folder_location, MAX_PATH, &length_of_arg);<br/>
<br/>
if (length_of_arg > (MAX_PATH - 3))<br/>
{<br/>
_tprintf(TEXT("nDirectory path is too long.n"));<br/>
return (-1);<br/>
}<br/>
<br/>
_tprintf(TEXT("nTarget directory is %snn"), argv[1]);<br/>
StringCbCopy(szDir, MAX_PATH, argv[1]);<br/>
StringCbCat(szDir, MAX_PATH, TEXT("\*"));<br/>
<br/>
hFind = FindFirstFile(szDir, &ffd);<br/>
<br/>
do<br/>
{<br/>
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)<br/>
{<br/>
_tprintf(TEXT(" %s <DIR>n"), ffd.cFileName);<br/>
}<br/>
else<br/>
{<br/>
filesize.LowPart = ffd.nFileSizeLow;<br/>
filesize.HighPart = ffd.nFileSizeHigh;<br/>
image_name = ffd.cFileName;<br/>
<br/>
image_names.push_back (image_name);<br/>
}<br/>
}<br/>
while (FindNextFile(hFind, &ffd) != 0);<br/>
<br/>
FindClose(hFind);<br/>
<br/>
size_t idx;<br/>
// create the initial texture<br/>
atlases.push_back(new TextureAtlas( image_names.size()));<br/>
// load the texture<br/>
for (idx = 0; idx < image_names.size(); ++idx) {<br/>
<br/>
//load the image<br/>
TextureInformation *ti = new TextureInformation (idx, folder_location_str, image_names[idx]);<br/>
<br/>
for(std::list<TextureAtlas *>::iterator atlases_iter = atlases.begin();<br/>
atlases_iter != atlases.end();<br/>
atlases_iter++)<br/>
{<br/>
TextureAtlas* tai = *atlases_iter;<br/>
if (tai->addTexture(ti))<br/>
break;<br/>
<br/>
}<br/>
}<br/>
<br/>
//int idx = 0;<br/>
for(std::list<TextureAtlas *>::iterator atlases_iter = atlases.begin();<br/>
atlases_iter != atlases.end();<br/>
atlases_iter++)<br/>
{<br/>
TextureAtlas* tai = *atlases_iter;<br/>
// Set the atlas name<br/>
// calling some methods......<br/>
}<br/>
<br/>
}<br/>
View the full article
This is my first post here. My application is throwing Debug Assertion Failed. Invalid Null pointer error. I have no idea what wrong i am doing. Below is the main method of my application. Obviously, there are other parts to the code as well but i would
not post that and hope i have problem in main method and you guys are able to me help me with it . Thanks
<br/>
std::string image_name;<br/>
std::vector<std::string> image_names;<br/>
char* folder_location = argv[1];<br/>
std::string folder_location_str (folder_location);<br/>
std::list<TextureAtlas *> atlases ;<br/>
<br/>
WIN32_FIND_DATA ffd;<br/>
TCHAR szDir[MAX_PATH];<br/>
size_t length_of_arg;<br/>
HANDLE hFind = INVALID_HANDLE_VALUE;<br/>
LARGE_INTEGER filesize;<br/>
DWORD dwError=0;<br/>
<br/>
if(argc != 2)<br/>
{<br/>
_tprintf(TEXT("nUsage: %s <directory name>n"), argv[0]);<br/>
return (-1);<br/>
}<br/>
StringCbLength(folder_location, MAX_PATH, &length_of_arg);<br/>
<br/>
if (length_of_arg > (MAX_PATH - 3))<br/>
{<br/>
_tprintf(TEXT("nDirectory path is too long.n"));<br/>
return (-1);<br/>
}<br/>
<br/>
_tprintf(TEXT("nTarget directory is %snn"), argv[1]);<br/>
StringCbCopy(szDir, MAX_PATH, argv[1]);<br/>
StringCbCat(szDir, MAX_PATH, TEXT("\*"));<br/>
<br/>
hFind = FindFirstFile(szDir, &ffd);<br/>
<br/>
do<br/>
{<br/>
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)<br/>
{<br/>
_tprintf(TEXT(" %s <DIR>n"), ffd.cFileName);<br/>
}<br/>
else<br/>
{<br/>
filesize.LowPart = ffd.nFileSizeLow;<br/>
filesize.HighPart = ffd.nFileSizeHigh;<br/>
image_name = ffd.cFileName;<br/>
<br/>
image_names.push_back (image_name);<br/>
}<br/>
}<br/>
while (FindNextFile(hFind, &ffd) != 0);<br/>
<br/>
FindClose(hFind);<br/>
<br/>
size_t idx;<br/>
// create the initial texture<br/>
atlases.push_back(new TextureAtlas( image_names.size()));<br/>
// load the texture<br/>
for (idx = 0; idx < image_names.size(); ++idx) {<br/>
<br/>
//load the image<br/>
TextureInformation *ti = new TextureInformation (idx, folder_location_str, image_names[idx]);<br/>
<br/>
for(std::list<TextureAtlas *>::iterator atlases_iter = atlases.begin();<br/>
atlases_iter != atlases.end();<br/>
atlases_iter++)<br/>
{<br/>
TextureAtlas* tai = *atlases_iter;<br/>
if (tai->addTexture(ti))<br/>
break;<br/>
<br/>
}<br/>
}<br/>
<br/>
//int idx = 0;<br/>
for(std::list<TextureAtlas *>::iterator atlases_iter = atlases.begin();<br/>
atlases_iter != atlases.end();<br/>
atlases_iter++)<br/>
{<br/>
TextureAtlas* tai = *atlases_iter;<br/>
// Set the atlas name<br/>
// calling some methods......<br/>
}<br/>
<br/>
}<br/>
View the full article