I am facing a very interesting issue with SDL + NDK framework.
I have kept my .xml and .tmx file in assets folder. Now i am
using SDL_RWops to read the xml and tmx file from assets directory and
parsing using tinyxml lib.
bool StateParser::read_text(const char* source_file, char** destination)
{
// Open the file
SDL_RWops *file;
file = SDL_RWFromFile(source_file, “r”);
#ifdef DEBUG
Logger::Instance()->Log(MODNAME, func,“Opening file using SDL_RWops
%s”,
source_file);
#endif
size_t file_length = SDL_RWseek(file, 0, SEEK_END);
(*destination) = new char[file_length+1]; // allow an extra character
for ‘\0’
// Reset seek to beginning of file and read text
SDL_RWseek(file, 0, SEEK_SET);
int n_blocks = SDL_RWread(file, (*destination), 1, file_length);
if (n_blocks <= 0)
{
#ifdef DEBUG
Logger::Instance()->Log(MODNAME, func,“SDL_RWread failed Read Block
[%d]”, n_blocks);
#endif
}
SDL_RWclose(file);
(*destination)[file_length] = '\0';
#ifdef DEBUG
Logger::Instance()->Log(MODNAME, func,“Blocks [%d], file lingth[%d] xml
file [%s]”, n_blocks, file_length, *destination);
#endif
return true;
}
Parsing function :-
bool StateParser::parseState(const char *stateFile, std::string stateID,
std::vector<GameObject *> *pObjects,
std::vectorstd::string *pTextureIDs)
{
char* file_contents = NULL;
if (read_text(stateFile, &file_contents) != true)
{
#ifdef DEBUG
Logger::Instance()->Log(MODNAME, func,“read_text failed”);
#endif
return false;
}
// create the XML document
TiXmlDocument xmlDoc;
// load the state file
//if(!xmlDoc.LoadFile(file_contents))
if(!xmlDoc.Parse(file_contents))
{
#ifdef DEBUG
Logger::Instance()->Log(MODNAME, func,“Loadfile failed %s”,
xmlDoc.ErrorDesc());
#endif
return false;
}
delete[] file_contents;
…
…
}
i am able to access & parse xml file but the same function fails to access
.tmx file. The NDK fails with following error:-
Error Log:-
2-16 19:25:16.478: I/Log(27964): sdlGameObject:void
TextureManager::clearFromTextureMap(std::string),Erasing id:exitbutton from
map
02-16 19:25:16.478: I/Log(27964): menuState:virtual bool
MainMenuState::onExit(),removing texture [exitbutton]
02-16 19:25:16.478: I/Log(27964): GameStateMachine:void
GameStateMachine::ChangeState(GameState*),deleting MENU
02-16 19:25:16.478: I/Log(27964): GameStateMachine:void
GameStateMachine::ChangeState(GameState*),push_back (PLAY)
02-16 19:25:16.478: I/Log(27964): playerState:virtual bool
PlayState::onEnter(),Level Parser (map1.tmx)
02-16 19:25:16.478: I/Log(27964): LevelParser:bool
LevelParser::read_text(char const*, char**),Opening file using SDL_RWops
map1.tmx
02-16 19:25:16.479: I/Log(27964): LevelParser:bool
LevelParser::read_text(char const*, char**),Blocks [1312], file
lingth[1312] xml file [<?xml version="1.0" encoding="UTF-8"?>
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
eJxjYBgFcUAcD8QJVDIvGYhTgDiVSuYNFbuHMhjIcKN2+hsoMFz8MQoGF7gPxA+A+CERah8B8WMgfkKmPLF2EmMOKe5GBh+B+BMQfyZC7Rcg/grE38iUJ9ZOYswhxd3ogIWReLXsBNQSkifWTmLMIdbdT9H4YlB9bGj6f2HRJ4nDDphemDyyHb+wqBPDog7dHGLMwKUfBuqBuAGIG4G4aZjiViT/egJx9TDHXqP+HdYY5l8AuJOg6A==
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964):
02-16 19:25:16.479: I/Log(27964): <objec
02-16 19:25:16.479: A//system/bin/app_process(27964): stack corruption
detected: aborted
02-16 19:25:16.479: A/libc(27964): Fatal signal 11 (SIGSEGV) at 0xdead2aed
(code=1), thread 27980 (SDLThread)
You can see that there is some issue with line marked in bold character.
I am not able to reslove the issue and stuck on the same from last two days.
Please help.
Attached .tmx file.
Regards,
RaghuvendraOn Sun, Feb 16, 2014 at 1:36 AM, wrote:
Send SDL mailing list submissions to
sdl at lists.libsdl.orgTo subscribe or unsubscribe via the World Wide Web, visit
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
or, via email, send a message with subject or body ‘help’ to
sdl-request at lists.libsdl.orgYou can reach the person managing the list at
sdl-owner at lists.libsdl.orgWhen replying, please edit your Subject line so it is more specific
than “Re: Contents of SDL digest…”Today’s Topics:
- Re: SDL for PSP (Jonathan Dearborn)
- Re: SDL for PSP (BenoitRen)
Message: 1
Date: Sat, 15 Feb 2014 15:00:17 -0500
From: Jonathan Dearborn
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Subject: Re: [SDL] SDL for PSP
Message-ID:
<
CA+DSiHaNciFmzDRh30eO9yj-65uhxQGPTKrrfwsUH1WDPf_wyw at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”Have you tried using SDL_Log(), SDL_LogError(), etc.? I would suppose that
they wrap the PSP’s proper logging commands.Jonny D
On Sat, Feb 15, 2014 at 12:16 PM, BenoitRen wrote:
After some milk and cookies, I looked up the references that were
missing, and it turns out that it’s because some libraries weren’t
linked.
Aside from linking stdc++ to be able to use C++ code, you have to add
pspirkeyb and psppower.I ended up with a working application, but it froze my PSP before
shutting
it down. printf doesn’t work; you have to use pspDebugScreenPrintf
instead
(which works just like printf), which will output to the screen. This
way I
was able to diagnose my problem. My SDL_SetVideoMode function call was
failing. Turns out you can’t use 24-bit colour depth; you have to use
32-bit colours.With software surfaces, performance is bad, even with optimised surfaces.
Switching to hardware surfaces solves this, but I’m having a problem
related to colour keying, as every other frame the transparent colour of
my
surfaces are being drawn. I have yet to look into this.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org-------------- next part --------------
An HTML attachment was scrubbed…
URL: <
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140215/175ec26e/attachment.html
Message: 2
Date: Sat, 15 Feb 2014 20:04:19 +0000
From: “BenoitRen”
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL for PSP
Message-ID: <1392494659.m2f.42053 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”There’s definitely something wrong with the colour key functionality when
using hardware surfaces.With single buffering, there’s the flickering I mentioned.
With double buffering, if I set the colour key on a 24-bit surface before
converting it to a 32-bit surface, it doesn’t work. If I set the colour key
after converting it, nothing gets drawn.So it’s back to software surfaces. At least I found out that I forgot to
convert one surface, so performance is good now. The only thing that
bothers me is that the image is stretched across the screen.-------------- next part --------------
An HTML attachment was scrubbed…
URL: <
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140215/5a4d0c92/attachment-0001.htm
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.orgEnd of SDL Digest, Vol 86, Issue 50
-------------- next part --------------
A non-text attachment was scrubbed…
Name: map1.tmx
Type: application/octet-stream
Size: 1311 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140216/742ea797/attachment-0001.obj