SDL Digest, Vol 86, Issue 53

I have traced down the problem. The problem was that i was passing the
wrong file xmlDoc.Parse(stateFile). It is resolved by passing the
file_contents buffer to the parse function. Now i am able to access and
parse xml/tmx file from assets directory.

The following code can be considered as example how to read any file from
assets in android folder using SDL_RWops using NDK framework. Thanks for
help.On Mon, Feb 17, 2014 at 5:39 PM, wrote:

Send SDL mailing list submissions to
sdl at lists.libsdl.org

To 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.org

You can reach the person managing the list at
sdl-owner at lists.libsdl.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of SDL digest…”

Today’s Topics:

  1. Re: Accessing xml/tmx file in assets folder issue (Gabriel Jacobo)
  2. SDL_GetRendererDriverInfo output. (keestu)

Message: 1
Date: Sun, 16 Feb 2014 20:47:45 -0300
From: Gabriel Jacobo
To: SDL Development List
Subject: Re: [SDL] Accessing xml/tmx file in assets folder issue
Message-ID:
<CAKDfeskcguSdTMyba4O-nj3Ux=
d0FegbeZmJf7OdB6vYGQeaYw at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

Which SDL version are you using? Which device or emulator are you getting
this problem with? There’s two paths through which a file is read in SDL
(depending on whether the file is compressed or not in the APK), so it may
make sense that one file is read fine and the other is not…(probably the
uncompressed path is failing given the .tmx extension)

2014-02-16 11:25 GMT-03:00 Raghuvendra Kumar <@Raghuvendra_Kumar

:

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,
Raghuvendra

On Sun, Feb 16, 2014 at 1:36 AM, wrote:

Send SDL mailing list submissions to
sdl at lists.libsdl.org

To 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.org

You can reach the person managing the list at
sdl-owner at lists.libsdl.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of SDL digest…”

Today’s Topics:

  1. Re: SDL for PSP (Jonathan Dearborn)
  2. 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.org

End of SDL Digest, Vol 86, Issue 50



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.
-------------- next part --------------
An HTML attachment was scrubbed…
URL: <
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140216/8a4c9f79/attachment-0001.htm


Message: 2
Date: Mon, 17 Feb 2014 12:09:30 +0000
From: “keestu”
To: sdl at lists.libsdl.org
Subject: [SDL] SDL_GetRendererDriverInfo output.
Message-ID: <1392638970.m2f.42064 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”

I ran the below code in the android, and i got 'renderer name ->
'opengles2’
but the max texture height, and with is zero. Is it expected behavior?.

int n,i;
SDL_RendererInfo info;

n  = SDL_GetNumRenderDrivers ();
if ( n== 0)
{
    LOGD ("built-in driver not available ");
    return -1;
}

for (i=0; i<n; i++) {
    SDL_GetRenderDriverInfo (i, &info);
    LOGD ("Renderer Name  %s ", info.name);
    // Texture Siz
    LOGD ("Max Texture Size H: (%d) : W (%d) ",

info.max_texture_height, info.max_texture_width);

}

-------------- next part --------------
An HTML attachment was scrubbed…
URL: <
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140217/ec441dbc/attachment.htm



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

End of SDL Digest, Vol 86, Issue 53