Porting to linux

Hi Guys
Firstly i must say your doing an awesome job, as using SDL i have
just finished the windows version of my game and now i am porting it to
Linux. On windows i used Unicode text files so they can be translated, and i
wish to use the same files on Linux. however when i read the files in and
use wscpy and all the other wide string function (the same as used on
windows) the strings all become 32bit characters and wschar_t is also 32bits
where as on windows it was 16bits.

This is all cool apart from TTF_SizeUnicode and all the other TTF
Unicode functions like TTF_RenderUNICODE_Blended expect my strings to be
16biits (Uint16), so what can i do to cure it, as i cant just use chars
because they are 8bits. i hope this makes sense.

I hope someone out there can understand what i am talking about and offer
some advice.

Trish x–
In a time of universal deceit, telling the truth is a revolutionary act.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Something else to keep in mind when processing text files. Maybe it’s
different with unicode not sure, but windows uses a different end of
line than linux. In C, c++, this is a a “\r\n” for windows, and “\n” for
linux.

Jim

Patricia Curtis wrote:

Hi Guys
Firstly i must say your doing an awesome job, as using SDL i
have just finished the windows version of my game and now i am porting
it to Linux. On windows i used Unicode text files so they can be
translated, and i wish to use the same files on Linux. however when i
read the files in and use wscpy and all the other wide string function
(the same as used on windows) the strings all become 32bit characters
and wschar_t is also 32bits where as on windows it was 16bits.

This is all cool apart from TTF_SizeUnicode and all the other TTF
Unicode functions like TTF_RenderUNICODE_Blended expect my strings to be
16biits (Uint16), so what can i do to cure it, as i cant just use chars
because they are 8bits. i hope this makes sense.

I hope someone out there can understand what i am talking about and
offer some advice.

Trish x

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFuessQuDJiZ/QrH0RAv5GAJ93w/v1LqkHZxZnSbWGpmlPC5CLOwCgp3Od
Ic90zzJt4CXKbjdSmiElHLg=
=s1it
-----END PGP SIGNATURE-----

hi,

if you are using ansi c or c++ in the game, the bigest problem will do the
file encoding fix and some warnings from gcc…

Regards,

R?benOn 1/26/07, James Barrett wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Something else to keep in mind when processing text files. Maybe it’s
different with unicode not sure, but windows uses a different end of
line than linux. In C, c++, this is a a “\r\n” for windows, and “\n” for
linux.

Jim

Patricia Curtis wrote:

Hi Guys
Firstly i must say your doing an awesome job, as using SDL i
have just finished the windows version of my game and now i am porting
it to Linux. On windows i used Unicode text files so they can be
translated, and i wish to use the same files on Linux. however when i
read the files in and use wscpy and all the other wide string function
(the same as used on windows) the strings all become 32bit characters
and wschar_t is also 32bits where as on windows it was 16bits.

This is all cool apart from TTF_SizeUnicode and all the other TTF
Unicode functions like TTF_RenderUNICODE_Blended expect my strings to be
16biits (Uint16), so what can i do to cure it, as i cant just use chars
because they are 8bits. i hope this makes sense.

I hope someone out there can understand what i am talking about and
offer some advice.

Trish x

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFuessQuDJiZ/QrH0RAv5GAJ93w/v1LqkHZxZnSbWGpmlPC5CLOwCgp3Od
Ic90zzJt4CXKbjdSmiElHLg=
=s1it
-----END PGP SIGNATURE-----


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


R?ben L?cio Reis

Linux Gamming Programming
Linux user #433535

This is all cool apart from TTF_SizeUnicode and all the other TTF
Unicode functions like TTF_RenderUNICODE_Blended expect my strings to be
16biits (Uint16), so what can i do to cure it, as i cant just use chars
because they are 8bits. i hope this makes sense.

I hope someone out there can understand what i am talking about and
offer some advice.

You can go cheap and say there’s never going to be a Unicode character
you’ll need that’s greater than 0xFFFF (which is almost certainly
true…there aren’t many codepoints above the 16-bit mark and they are
probably Really Important Things like Klingon-from-Star-Trek
glyphs)…if you’re dealing with Windows, technically, you have this
limitation anyhow.

In which case, just convert by downcasting each char:

// take a UCS4 string (32-bit) and make it a UCS2 string (16-bit).
// (dst) should be a buffer at least half as many bytes as (src)!
void convertUCS4toUCS2(const wchar_t *src, Uint16 *dst)
{
do {
*(dst++) = (Uint16) *(src++);
} while (*src);
}

This is a little harder if you want to handle UTF-16 surrogates, which
Windows didn’t support before XP, but if you don’t know what they are,
you probably don’t.

Another solution is to compile on Linux with gcc’s -fshort-wchar command
line option…this makes “wchar_t” into a 16-bit type, and constructs
like this:

L"hello";

Will produce the equivalent of _T(“hello”) on Windows (indeed, you can
create the _T macro using that)…that string will be 12 bytes (2 for
each letter, two for the terminator char) instead of 24 (4 for each).

We used this to really good effect in Unreal Engine, which uses TCHARs
all over the place, so it was easier to ensure that the strings and
characters looked the same on every platform and that strings going over
the network or to disk would match.

There’s only one problem with this method: you absolutely can NOT call
any function that wants a wchar_t that hasn’t been compiled with this
flag, since you’ll pass it either the wrong size data on the stack, or
you’ll pass it a buffer with data it doesn’t expect. This means you
can’t use any of the C runtime wchar facilities, like wstrcpy, etc.
Unreal had it’s own C++ String class which handled all that.

One of those two methods will get you going.

–ryan.

Hello,

Maybe you’d like to check out a new release of my image viewer. It can be found here:
http://corp.efnet.net/~lamer/pegasosppc/ as well as here:
http://freshmeat.net/projects/shim/ . To quote the text on freshmeat:

“shim is a small shell based utility to display images in a variety of formats. It has a few
features, such as slideshow, saving to a file, rotating, zooming, and fullscreen display. It
needs the SDL and SDL_image libraries. Depending on your SDL_image library, it will support
the following formats: PNG, LBM, JPEG, TIFF, GIF, PCX, TGA, BMP, PNM, XPM, and XCF.”

And while you’re at it check my bush countdown utility and silly “AI” bouncing ball demo:


Use for your own pleasure, rip the source, whatever you like… well, within the gpl
license. :wink:

Thank you–
http://home.earthlink.net/~pegasosppc/bahcount.html
If you feel you are not properly sedated, call 348844 immediately.
Failure to do so may result in prosecution for criminal drug evasion.

You might want to fix your ‘compile_bahcount.sh’ so it works:

#! /bin/sh
gcc sdl-config --cflags --libs -lSDL -lSDL_image -ansi -pedantic -O2 -o
bahcount bahcount.c

shim won’t compile at all. Errors in your SDL_rotozoom.c file that I have
neither time nor inclination to debug right now.

JeffOn Sat January 27 2007 13:34, amorel wrote:

Hello,

Maybe you’d like to check out a new release of my image viewer. It can be
found here: http://corp.efnet.net/~lamer/pegasosppc/ as well as here:
http://freshmeat.net/projects/shim/ . To quote the text on freshmeat:

“shim is a small shell based utility to display images in a variety of
formats. It has a few features, such as slideshow, saving to a file,
rotating, zooming, and fullscreen display. It needs the SDL and SDL_image
libraries. Depending on your SDL_image library, it will support the
following formats: PNG, LBM, JPEG, TIFF, GIF, PCX, TGA, BMP, PNM, XPM, and
XCF.”

And while you’re at it check my bush countdown utility and silly "AI"
bouncing ball demo: http://freshmeat.net/projects/bahcount/
http://freshmeat.net/projects/baq/

Use for your own pleasure, rip the source, whatever you like… well,
within the gpl license. :wink:

Thank you

You might want to fix your ‘compile_bahcount.sh’ so it works:

#! /bin/sh
gcc sdl-config --cflags --libs -lSDL -lSDL_image -ansi -pedantic -O2 -o
bahcount bahcount.c

Yeah, leave out -ansi, here I mostly just do "gcc -lSDL -lSDL_image -o name name.c"
That’s why I call it lame pointless cript to compile xxx.

shim won’t compile at all. Errors in your SDL_rotozoom.c file that I have
neither time nor inclination to debug right now.

Leaving out -ansi again perhaps, that at least stops the errors in rotooom
(which is not my source). Anyways I don’t know, works here, it’s gpl, your
mileage may vary, oh and of course: “This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.” . :slight_smile:

GreetingsOn Sat, Jan 27, 2007 at 02:49:12PM -0800, Jeff wrote:


http://home.earthlink.net/~pegasosppc/bahcount.html
If you feel you are not properly sedated, call 348844 immediately.
Failure to do so may result in prosecution for criminal drug evasion.