SDL printer lib

Hello!

Like Enzo, I have also been working on printer support for SDL,
but it doesn’t quite work yet - but here’s my latest code…

I hope this might be useful… but I’m not working on it
any further right now.

Cheers–
http://www.HardcoreProcessing.com
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDLPrinting.c
Type: application/x-unknown-content-type-projectbuilder.c
Size: 8036 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20000714/b9036bc1/attachment.bin

Hello!

Like Enzo, I have also been working on printer support for SDL,
but it doesn’t quite work yet - but here’s my latest code…

I hope this might be useful… but I’m not working on it
any further right now.

I doubt if it will be useful. SDL is supposed to be a game graphics
library.On Fri, 14 Jul 2000, ANOQ of the Sun wrote:


Rafael R. Sevilla <@Rafael_R_Sevilla> +63 (2) 4342217
ICSM-F Development Team, UP Diliman +63 (917) 4458925
PGP Key available at http://home.pacific.net.ph/~dido/dido.pgp

Like Enzo, I have also been working on printer support for SDL,
but it doesn’t quite work yet - but here’s my latest code…

I hope this might be useful… but I’m not working on it
any further right now.

I doubt if it will be useful. SDL is supposed to be a game graphics
library.

Oh, I don’t know, it could be useful!

We’ve got at least one game at Creature Labs which can print
(Creatures Playground). It’s a children’s game.

FrancisOn Sat, 15 Jul 2000 00:16:17 +0800 (PHT), you wrote:

On Fri, 14 Jul 2000, ANOQ of the Sun wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1On Sat, 15 Jul 2000, Sean Middleditch wrote:

“Rafael R. Sevilla” wrote:

On Fri, 14 Jul 2000, ANOQ of the Sun wrote:

Hello!

Like Enzo, I have also been working on printer support for SDL,
but it doesn’t quite work yet - but here’s my latest code…

I hope this might be useful… but I’m not working on it
any further right now.

I doubt if it will be useful. SDL is supposed to be a game graphics
library.

No, it’s the Simple DirectMedia Layer. Don’t see anything game specific
about it… OpenGL isn’t a 3D game library, it’s a 3D library.
Difference. ^,^

“simple” directmedia layer. If we add too many features to it, sometime
soon, libSDL will no longer be worthy of the name.


Rafael R. Sevilla <@Rafael_R_Sevilla> +63 (2) 4342217
ICSM-F Development Team, UP Diliman +63 (917) 4458925
PGP Key available at http://home.pacific.net.ph/~dido/dido.pgp

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1i
Filter: gpg4pine 4.1 (http://azzie.robotics.net)

iQA/AwUBOW95EGqsapcaCwm7EQIc4ACgogIurejpZ1VXuNYJs8fgOZm3/qAAmwbY
CfTSbUNe8epeMCGjebjBx/vc
=Rw8h
-----END PGP SIGNATURE-----

“simple” directmedia layer. If we add too many features to it, sometime
soon, libSDL will no longer be worthy of the name.

thats why its a seperate library, so you can either choose to use it or
not :-)–
Brian

“Rafael R. Sevilla” wrote:> On Fri, 14 Jul 2000, ANOQ of the Sun wrote:

Hello!

Like Enzo, I have also been working on printer support for SDL,
but it doesn’t quite work yet - but here’s my latest code…

I hope this might be useful… but I’m not working on it
any further right now.

I doubt if it will be useful. SDL is supposed to be a game graphics
library.

No, it’s the Simple DirectMedia Layer. Don’t see anything game specific
about it… OpenGL isn’t a 3D game library, it’s a 3D library.
Difference. ^,^

Sean Middleditch

“Rafael R. Sevilla” wrote:

“simple” directmedia layer. If we add too many features to it, sometime
soon, libSDL will no longer be worthy of the name.

I haven’t added it to SDL (and it’s still not complete) -
and the printing API is completely orthogonal to
the rest of SDL, so seeing it as an "optional extention"
it shouldn’t hurt anyone :slight_smile:

And the reason I wrote it was to allow printing
of the game-scores to paper to be sent in for
the competitions in the games I wrote - rather
than having to write a separate printing program.
So it is useful to games too :slight_smile:

Cheers–
http://www.HardcoreProcessing.com

“Rafael R. Sevilla” wrote:

“simple” directmedia layer. If we add too many features to it, sometime
soon, libSDL will no longer be worthy of the name.

I haven’t added it to SDL (and it’s still not complete) -
and the printing API is completely orthogonal to
the rest of SDL, so seeing it as an "optional extention"
it shouldn’t hurt anyone :slight_smile:

And the reason I wrote it was to allow printing
of the game-scores to paper to be sent in for
the competitions in the games I wrote - rather
than having to write a separate printing program.
So it is useful to games too :slight_smile:

It’s definitely suitable as one of the SDL “helper libs” like SDL_net.

Let me know when it’s done! :slight_smile:

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I haven’t added it to SDL (and it’s still not complete) -
and the printing API is completely orthogonal to
the rest of SDL, so seeing it as an "optional extention"
it shouldn’t hurt anyone :slight_smile:

And the reason I wrote it was to allow printing
of the game-scores to paper to be sent in for
the competitions in the games I wrote - rather
than having to write a separate printing program.
So it is useful to games too :slight_smile:

I completely agree…
I make educational games for children and the print feature
is very important for teachers to have a log of the results
of the exercices/games.

Enzo.–
E-mail enzo.gupi at tiscalinet.it
Home page http://enzogupi.interfree.it

Thanks for the code…

Now I will merge it with the one I’ve written in these days.

Can someone help me implement printing for linux too?

Enzo.

-------------- next part --------------
#ifdef linux
#include <stdio.h>
#else
#include <windows.h>
#endif

#ifdef WIN32

HDC GetPrinterDC()
{
char szPrinter[80];
char *szDevice, *szDriver, *szOutput;
DEVMODE PrintDev;
GetProfileString(“windows”, “device”, “,” ,szPrinter, 80);
if (NULL != (szDevice = strtok (szPrinter, “,”)) &&
NULL != (szDriver = strtok (NULL, “,”)) &&
NULL != (szOutput = strtok (NULL, “,”))) {
memset (&PrintDev, 0, sizeof (PrintDev));
PrintDev.dmOrientation = DMORIENT_LANDSCAPE;
return CreateDC(szDriver, szDevice, szOutput,&PrintDev);
}
return 0;
}

#endif

void PrintSurface (char* Info, SDL_Surface* Surface, Uint32 Flags)
{
#ifdef linux
printf (“Printing request: (image %d x %d)\n”,
Surface->w, Surface->h);
#else
HDC PrinterDC;
static DOCINFO di = {sizeof (DOCINFO), Info, NULL};
PrinterDC = GetPrinterDC();
int lx = GetDeviceCaps (PrinterDC, HORZRES);
int ly = GetDeviceCaps (PrinterDC, VERTRES);
int px = (lySurface->w)/Surface->h;
int py = (lx
Surface->h)/Surface->w;
if (py>ly) {
py = ly;
} else {
px = lx;
}
if (PrinterDC) {
if (StartDoc (PrinterDC, &di) > 0) {
if (StartPage (PrinterDC) > 0) {
HDC ImageDC;
BITMAPINFO BitmapInfo;
HBITMAP Bitmap;
DWORD TotalSize;
HGDIOBJ Prev;
void
Pixels;
BitmapInfo = (BITMAPINFO*)
malloc (sizeof (BITMAPINFO)+255*sizeof (RGBQUAD));
memset (BitmapInfo,0,sizeof (Bitmap));
BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
BitmapInfo->bmiHeader.biWidth = Surface->w;
BitmapInfo->bmiHeader.biHeight = -Surface->h;
BitmapInfo->bmiHeader.biPlanes = 1;
BitmapInfo->bmiHeader.biBitCount = Surface->format->BitsPerPixel;
BitmapInfo->bmiHeader.biCompression = BI_RGB;
BitmapInfo->bmiHeader.biSizeImage = Surface->h * Surface->pitch;
BitmapInfo->bmiHeader.biXPelsPerMeter = 0;
BitmapInfo->bmiHeader.biYPelsPerMeter = 0;
BitmapInfo->bmiHeader.biClrUsed = Surface->format->palette->ncolors;
BitmapInfo->bmiHeader.biClrImportant = 0;
if (Surface->format->palette) {
for (int I=0; Iformat->palette->ncolors; I++) {
BitmapInfo->bmiColors[I].rgbRed =
(Surface->format->palette->colors+I)->r;
BitmapInfo->bmiColors[I].rgbGreen =
(Surface->format->palette->colors+I)->g;
BitmapInfo->bmiColors[I].rgbBlue =
(Surface->format->palette->colors+I)->b;
}
}
ImageDC = CreateCompatibleDC(PrinterDC);
if (ImageDC) {
Bitmap = CreateDIBSection(ImageDC, BitmapInfo, DIB_RGB_COLORS,
(&Pixels), NULL, 0);
if (Bitmap) {
memcpy (Pixels, Surface->pixels,
BitmapInfo->bmiHeader.biSizeImage);
Prev = SelectObject (ImageDC, Bitmap);
StretchBlt (PrinterDC, 0, 0, px, py,
ImageDC, 0, 0, Surface->w, Surface->h, SRCCOPY);
SelectObject (ImageDC,Prev);
DeleteObject (Bitmap);
}
DeleteDC (ImageDC);
}
free (BitmapInfo);
if (EndPage(PrinterDC) > 0) {
EndDoc (PrinterDC);
}
}
}
DeleteDC (PrinterDC);
}
#endif
}

Enzo wrote:

And the reason I wrote it was to allow printing
of the game-scores to paper to be sent in for
the competitions in the games I wrote - rather
than having to write a separate printing program.
So it is useful to games too :slight_smile:

I completely agree…
I make educational games for children and the print
feature is very important for teachers to have a log
of the results of the exercices/games.

Another use is the game “souvenir” printout. One type would be a typical
"certificate of achievement" for little kids games. Another type would be a
multiplayer game log, complete with final scores and timestamped highlights
listing when and where major events occurred.

  • Randi

Regimental Command
Generic Armored Combat System
http://regcom.sourceforge.net

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1On Mon, 17 Jul 2000, Enzo wrote:

Thanks for the code…

Now I will merge it with the one I’ve written in these days.

Can someone help me implement printing for linux too?

The best way to do printing for Linux is to learn how to use GhostScript.
It’s the most flexible.


Rafael R. Sevilla <@Rafael_R_Sevilla> +63 (2) 4342217
ICSM-F Development Team, UP Diliman +63 (917) 4458925
PGP Key available at http://home.pacific.net.ph/~dido/dido.pgp

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1i
Filter: gpg4pine 4.1 (http://azzie.robotics.net)

iQA/AwUBOXOBPGqsapcaCwm7EQIcuACgrRX5+5B0bfHUC+BvbmW4ziJhkjsAoOKd
ca/tjrA422sf22tx0VhDskc4
=QyDl
-----END PGP SIGNATURE-----