Blitting

Hi! Didnt found any forum so i subscribed to this mailing list instead!

Ive done a rotozoomer that uses PutPixel() to plot every pixel in
fullscreen.
But it must be faster to draw these pixel directly to a surface, and then
blit it, right?

Right now, i’m reading the texture from a XOR function instead of a image.
But i want to read from let’s say another surface with a loaded BMP.

So i want to read a pixel from a source surface and put it onto another
surface, and then blit it.
How do i do that? I tried to find info on this (libgfx and rotozoom and
stuff) but all i cant find anything that explains it how its actually done. Can
anyone please give me an example of how this is done?

Thanks!

-N–
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr f?r 1 ct/ Min. surfen!

Hi! Didnt found any forum so i subscribed to this mailing list
instead!

Ive done a rotozoomer that uses PutPixel() to plot every pixel in
fullscreen.
But it must be faster to draw these pixel directly to a surface,
and then blit it, right?

Yes, at least if the screen is a hardware surface. (And with glSDL, it
would make a huge difference, as glSDL has to copy the whole screen
twice every time you mess with the screen pixels directly.)

Right now, i’m reading the texture from a XOR function instead of a
image. But i want to read from let’s say another surface with a
loaded BMP.

So i want to read a pixel from a source surface and put it onto
another surface, and then blit it.
How do i do that? I tried to find info on this (libgfx and rotozoom
and stuff) but all i cant find anything that explains it how its
actually done. Can anyone please give me an example of how this is
done?

Well… You just create another surface, using SDL_CreateRGBSurface(),
and then you get on with your stuff. Where’s the problem, more
specifically?

BTW, I would say it’s a better idea to hand an existing target surface
and an (x, y) offset to the rotation function. That way, you can do
things like blit directly to the screen, blit into any other surface,
fill a smaller surface with rotated pixels from another and other
stuff. The point, however, is that you can do all that without
implicit dynamic (== evil in real time apps) memory allocation.

//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`---------------------------> http://olofson.net/audiality -’
http://olofson.nethttp://www.reologica.se —On Monday 10 February 2003 20.29, Nikolaos Theologou wrote:

So i want to read a pixel from a source surface and put it onto
another surface, and then blit it.
How do i do that? I tried to find info on this (libgfx and rotozoom
and stuff) but all i cant find anything that explains it how its
actually done. Can anyone please give me an example of how this is
done?

Well… You just create another surface, using SDL_CreateRGBSurface(),
and then you get on with your stuff. Where’s the problem, more
specifically?

The problem is “get on with your stuff” =)
I have one surface with the image let us say *source,
and then the *destination surface wich i want to plot on.
And after that i want to blit *destination to the *screen.

I want to copy the pixel (for example x=2 & y=3) from *source and put it on
the *destination (x=1 & y=1). And thats where i dont get it anymore. I cant
find any docs on it, just some examples with alot of other confusing stuff.
Is it something like source.x.y->pixel or what? Please help me to straighten
this out. Any docs or simple examples. Or maby just type the syntax… Thank
you!
-N–
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l?cheln! Fotogalerie online mit GMX ohne eigene Homepage!

[…]

Well… You just create another surface, using
SDL_CreateRGBSurface(), and then you get on with your stuff.
Where’s the problem, more specifically?

The problem is “get on with your stuff” =)

I see. :slight_smile:

Here’s a snippet from the “Spitfire Engine” in Kobo Deluxe; sprite.c.
It’s an inline used to read pixels, and one with bi-linear
interpolation for image scaling:

/*

  • Pixel access operations for 32 bit RGBA
    */
    static pix_t getpix32_empty = {0x7f, 0x7f, 0x7f, 0x7f};

static inline pix_t getpix32(SDL_Surface *s, int x, int y)
{
pix_t *p;
if(x < 0 || x >= s->w || y < 0 || y >= s->h)
return getpix32_empty;

p = (pix_t *)((char *)s->pixels + y * s->pitch);
return p[x];

}

/* Interpolated; 28:4 fixed point coords. */
static inline pix_t getpix32i(SDL_Surface *s, int x, int y)
{
int c0x, c0y, c1x, c1y;
int c[4];
pix_t e = {0, 0, 0, 0};
pix_t p[4], r;
getpix32_empty = e;

/* Calculate filter core */
x -= 8;
y -= 8;
c1x = x & 0xf;
c1y = y & 0xf;
c0x = 16 - c1x;
c0y = 16 - c1y;
c[0] = c0x * c0y;
c[1] = c1x * c0y;
c[2] = c0x * c1y;
c[3] = c1x * c1y;

/* Grab input pixels */
x >>= 4;
y >>= 4;
p[0] = getpix32(s, x, y);
p[1] = getpix32(s, x+1, y);
p[2] = getpix32(s, x, y+1);
p[3] = getpix32(s, x+1, y+1);

/* Interpolate... */
r.r = (p[0].r*c[0] + p[1].r*c[1] + p[2].r*c[2] + p[3].r*c[3])>>8;
r.g = (p[0].g*c[0] + p[1].g*c[1] + p[2].g*c[2] + p[3].g*c[3])>>8;
r.b = (p[0].b*c[0] + p[1].b*c[1] + p[2].b*c[2] + p[3].b*c[3])>>8;
r.a = (p[0].a*c[0] + p[1].a*c[1] + p[2].a*c[2] + p[3].a*c[3])>>8;
return r;

}

Note that these are (obviously) for 32 bit RGBA only! They are also
very slow, and were “designed” for easy implementation of a bunch of
scaling methods I use in Kobo Deluxe. Plenty of optimization can be
done in that area. (If you run the game in 1280x1024 on a slow CPU,
you know what I mean…)

You’ll find clamping version and a few algorithms that use them in the
full source. (Scaling, alpha cleaning, brightness/contrast etc.)
You’ll not find a rotation algo, since I’ve had no need for one so
far, but that’s just basic trig anyway. (Though bi-linear
interpolation is pretty basic as well! :wink:

//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`---------------------------> http://olofson.net/audiality -’
http://olofson.nethttp://www.reologica.se —On Wednesday 12 February 2003 18.06, Nikolaos Theologou wrote:

[…]

Uhm, just in case you didn’t notice:

/* Calculate filter core */
x -= 8;
y -= 8;

This is a (-.5, -.5) pixel offset, to compensate for the fact that
interpolation is done from a grid of infinitely small pixels, while
output is to a grid of full size pixels. Without this, you’d get
images shifted half a pixel to the left and half a pixel up.
(Source/scaled pixels, that is.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`---------------------------> http://olofson.net/audiality -’
http://olofson.nethttp://www.reologica.se —On Wednesday 12 February 2003 19.25, David Olofson wrote:

ok, heres the deail simply…

even though we think of the screen as 2 dimensional, its only 1 dimension in
RAM.

lets say you had a Grid like this:****
*A


the coordinates of A is (2,1) in the above since the upper left is (0,0). In
RAM, since its really stored in a 1D array it would look like this:

*A

The index of A above is (6) since arrays start at 0.

So…what you need to do is convert from your 2D coordinates to the 1D
coordinates before you can access the pixel your trying to access. In our
grid, the width is 4, the width is also called the PITCH. Every surface in
SDL has a pitch. How you calculate the 1D coordinate is like this:

Index = y * Surface->Pitch + x;

if we plug the coordinates of A into the equation with our pitch of 4 we
get:

Index = 1 * 4 + 2 = 6

wow it works…amazing eh? Sometimes the pitch is bigger than the size of
your screen in width though, so never think “im in 800*600 so my pitch is
800, ill just use 800 instead of pitch”. Always multiply y by pitch,
otherwise your app wont always work.

this 1D array im speaking of, every surface has; It is Surface->pixels. If
you have 8 bit graphics youd do this (note there is no error checking
here!!!):

void DrawPixel(SDL_Surface *Surface, int x, int y, unsigned char Color)
{
unsigned char *Pixel;
Pixel=((char )Surface->Pixels)[ySurface->Pitch+x];
*Pixel=Color;
}

Heres a function also without error checking (for simplicity) to copy a
pixel (also assuming 8 bit color):

void CopyPixel(SDL_Surface *SrcSurface, int SrcX,int SrcY, SDL_Surface
*DestSurface, int DestX, int DestY)
{

unsigned char *Src, *Dest;
Src=((char )SrcSurface->Pixels)[SrcYSrcSurface->Pitch+SrcX];

Dest=((char )DestSurface->Pixels)[DestYDestSurface->Pitch+DestX];

*Dest=*Src;

}

One last point of interest for if you are using more than 8 bit (1 byte/256
colors) color. Your pitch is given in number of bytes. What that means is
if you are using 16 bit color lets say in 800x600 mode, your pitch will be
1600, not 800 since there are 2 bytes per pixel. So… heres a 16 bit draw
pixel function:

void DrawPixel16(SDL_Surface *Surface, int x, int y, unsigned short int
Color)
{
unsigned short int *Pixel;
Pixel=((unsigned short int )Surface->Pixels)[(ySurface->Pitch/2)+x];
*Pixel=Color;
}

and lets say you were in 32 bit color mode (4 bytes):

void DrawPixel16(SDL_Surface *Surface, int x, int y, unsigned int Color)
{
unsigned short int *Pixel;
Pixel=((unsigned int )Surface->Pixels)[(ySurface->Pitch/4)+x];
*Pixel=Color;
}

see how im dividing by the number of bytes? in drawing in 8 bit mode, youd
be dividing by 1 so you can leave that out.

Hope this gives you enough info to get started (:

Atrix

----- Original Message -----
From: nikkoz@gmx.net (Nikolaos Theologou)
To:
Sent: Wednesday, February 12, 2003 9:06 AM
Subject: Re: [SDL] Blitting

So i want to read a pixel from a source surface and put it onto
another surface, and then blit it.
How do i do that? I tried to find info on this (libgfx and rotozoom
and stuff) but all i cant find anything that explains it how its
actually done. Can anyone please give me an example of how this is
done?

Well… You just create another surface, using SDL_CreateRGBSurface(),
and then you get on with your stuff. Where’s the problem, more
specifically?

The problem is “get on with your stuff” =)
I have one surface with the image let us say *source,
and then the *destination surface wich i want to plot on.
And after that i want to blit *destination to the *screen.

I want to copy the pixel (for example x=2 & y=3) from *source and put it
on
the *destination (x=1 & y=1). And thats where i dont get it anymore. I
cant
find any docs on it, just some examples with alot of other confusing
stuff.
Is it something like source.x.y->pixel or what? Please help me to
straighten
this out. Any docs or simple examples. Or maby just type the syntax…
Thank
you!
-N


+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l?cheln! Fotogalerie online mit GMX ohne eigene Homepage!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

oops…the last functions should have been this:

void DrawPixel32(SDL_Surface *Surface, int x, int y, unsigned int Color)
{
unsigned int *Pixel;
Pixel=((unsigned int )Surface->Pixels)[(ySurface->Pitch/4)+x];
*Pixel=Color;
}> ----- Original Message -----

From: @atrix2 (atrix2)
To:
Sent: Wednesday, February 12, 2003 11:03 AM
Subject: Re: [SDL] Blitting

ok, heres the deail simply…

even though we think of the screen as 2 dimensional, its only 1 dimension
in
RAM.

lets say you had a Grid like this:


*A


the coordinates of A is (2,1) in the above since the upper left is (0,0).
In
RAM, since its really stored in a 1D array it would look like this:

*A

The index of A above is (6) since arrays start at 0.

So…what you need to do is convert from your 2D coordinates to the 1D
coordinates before you can access the pixel your trying to access. In our
grid, the width is 4, the width is also called the PITCH. Every surface
in
SDL has a pitch. How you calculate the 1D coordinate is like this:

Index = y * Surface->Pitch + x;

if we plug the coordinates of A into the equation with our pitch of 4 we
get:

Index = 1 * 4 + 2 = 6

wow it works…amazing eh? Sometimes the pitch is bigger than the size of
your screen in width though, so never think “im in 800*600 so my pitch is
800, ill just use 800 instead of pitch”. Always multiply y by pitch,
otherwise your app wont always work.

this 1D array im speaking of, every surface has; It is Surface->pixels.
If
you have 8 bit graphics youd do this (note there is no error checking
here!!!):

void DrawPixel(SDL_Surface *Surface, int x, int y, unsigned char Color)
{
unsigned char *Pixel;
Pixel=((char )Surface->Pixels)[ySurface->Pitch+x];
*Pixel=Color;
}

Heres a function also without error checking (for simplicity) to copy a
pixel (also assuming 8 bit color):

void CopyPixel(SDL_Surface *SrcSurface, int SrcX,int SrcY, SDL_Surface
*DestSurface, int DestX, int DestY)
{

unsigned char *Src, *Dest;
Src=((char )SrcSurface->Pixels)[SrcYSrcSurface->Pitch+SrcX];

Dest=((char )DestSurface->Pixels)[DestYDestSurface->Pitch+DestX];

*Dest=*Src;

}

One last point of interest for if you are using more than 8 bit (1
byte/256
colors) color. Your pitch is given in number of bytes. What that means
is
if you are using 16 bit color lets say in 800x600 mode, your pitch will be
1600, not 800 since there are 2 bytes per pixel. So… heres a 16 bit draw
pixel function:

void DrawPixel16(SDL_Surface *Surface, int x, int y, unsigned short int
Color)
{
unsigned short int *Pixel;
Pixel=((unsigned short int )Surface->Pixels)[(ySurface->Pitch/2)+x];
*Pixel=Color;
}

and lets say you were in 32 bit color mode (4 bytes):

void DrawPixel16(SDL_Surface *Surface, int x, int y, unsigned int Color)
{
unsigned short int *Pixel;
Pixel=((unsigned int )Surface->Pixels)[(ySurface->Pitch/4)+x];
*Pixel=Color;
}

see how im dividing by the number of bytes? in drawing in 8 bit mode, youd
be dividing by 1 so you can leave that out.

Hope this gives you enough info to get started (:

Atrix

----- Original Message -----
From: “Nikolaos Theologou”
To:
Sent: Wednesday, February 12, 2003 9:06 AM
Subject: Re: [SDL] Blitting

So i want to read a pixel from a source surface and put it onto
another surface, and then blit it.
How do i do that? I tried to find info on this (libgfx and rotozoom
and stuff) but all i cant find anything that explains it how its
actually done. Can anyone please give me an example of how this is
done?

Well… You just create another surface, using SDL_CreateRGBSurface(),
and then you get on with your stuff. Where’s the problem, more
specifically?

The problem is “get on with your stuff” =)
I have one surface with the image let us say *source,
and then the *destination surface wich i want to plot on.
And after that i want to blit *destination to the *screen.

I want to copy the pixel (for example x=2 & y=3) from *source and put it
on
the *destination (x=1 & y=1). And thats where i dont get it anymore. I
cant
find any docs on it, just some examples with alot of other confusing
stuff.
Is it something like source.x.y->pixel or what? Please help me to
straighten
this out. Any docs or simple examples. Or maby just type the syntax…
Thank
you!
-N


+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l?cheln! Fotogalerie online mit GMX ohne eigene Homepage!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Well… You just create another surface, using SDL_CreateRGBSurface(),
and then you get on with your stuff. Where’s the problem, more
specifically?

The problem is “get on with your stuff” =)
I have one surface with the image let us say *source,
and then the *destination surface wich i want to plot on.
And after that i want to blit *destination to the *screen.

I want to copy the pixel (for example x=2 & y=3) from *source and put it on
the *destination (x=1 & y=1). And thats where i dont get it anymore. I cant
find any docs on it, just some examples with alot of other confusing stuff.

As a matter of fact, there are two functions given in sdl docs
(See the examples) which do exactly this. Names : putpixel &
getpixel.

regards,
Pallav.On Wed, 12 Feb 2003, Nikolaos Theologou wrote:


The personal computer market is about the same size as the total potato chip
market. Next year it will be about half the size of the pet food market and
is fast approaching the total worldwide sales of pantyhose"
– James Finke, Commodore Int’l Ltd., 1982


| |
|Pallav Nawani |
|Sasken Communication Technologies Ltd. |
|Domlur, Bangalore. |
|_______________________________________________________________|

I want to thank you all for your replies on the blitting. They have been
very useful!
-N–
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l?cheln! Fotogalerie online mit GMX ohne eigene Homepage!

I got it with the terms pitch and pixels and such. Thank you. The
explanation was very helpful!
I had to rewrite the Surface-Pixels to Surface->pixels, though. But theres
still one problem i cant figure out.

I get the error C2440: ‘=’ : cannot convert from ‘char’ to 'unsigned char '
when compiling this code on the line "Pixel=((unigned int
)…"

I know that it makes the *Pixel pointer to point to the memory where the
pixels is stored.
But the conversion error?

-N> oops…the last functions should have been this:

void DrawPixel32(SDL_Surface *Surface, int x, int y, unsigned int Color)
{
unsigned int *Pixel;
Pixel=((unsigned int )Surface->Pixels)[(ySurface->Pitch/4)+x];
*Pixel=Color;
}


+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l?cheln! Fotogalerie online mit GMX ohne eigene Homepage!

paste your function to me (you can email me directly if you want) and ill
take a look.> ----- Original Message -----

From: nikkoz@gmx.net (Nikolaos Theologou)
To:
Sent: Thursday, February 13, 2003 11:58 AM
Subject: Re: [SDL] Blitting

I got it with the terms pitch and pixels and such. Thank you. The
explanation was very helpful!
I had to rewrite the Surface-Pixels to Surface->pixels, though. But theres
still one problem i cant figure out.

I get the error C2440: ‘=’ : cannot convert from ‘char’ to 'unsigned char

when compiling this code on the line "Pixel=((unigned int
)…"

I know that it makes the *Pixel pointer to point to the memory where the
pixels is stored.
But the conversion error?

-N

oops…the last functions should have been this:

void DrawPixel32(SDL_Surface *Surface, int x, int y, unsigned int Color)
{
unsigned int *Pixel;
Pixel=((unsigned int )Surface->Pixels)[(ySurface->Pitch/4)+x];
*Pixel=Color;
}


+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l?cheln! Fotogalerie online mit GMX ohne eigene Homepage!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello,
I can’t seem to get this code working. Can somebody help me? :

#include “SDL.h”
#include “SGE.h”

#include “point.h”

int main(int argc, char *argv[])
{
SDL_Surface *screen;

int angle = 0;

point a(320, 240);
point b(135, 240);

double x, y;

if(SDL_Init(SDL_INIT_VIDEO) < 0 )
{
    fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError());
    exit(1);
}

screen = SDL_SetVideoMode(640, 480, 16, 0);

if(screen == NULL)
{
    fprintf(stderr, "Failed to initialize surface's video mode at 

640x480x16: %s\n", SDL_GetError());
exit(1);
}

while(angle != 720 * 1000)
{
    angle++;

    b.rotate(a, angle);

    b.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    a.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    SDL_UpdateRect(screen, 0, 0, 640, 480);
}

SDL_Quit();
return 0;

}

What does “doesn’t work” mean? What is it supposed to do and what does it actually do?

Lic. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy> ----- Original Message -----

From: JVFF Programming [mailto:jvffprogramming@ieg.com.br]
Sent: Mi?rcoles, 21 de Mayo de 2003 02:26 p.m.
To: SDL Mailing List
Subject: [SDL] Blitting

Hello,
I can’t seem to get this code working. Can somebody help me? :

#include “SDL.h”
#include “SGE.h”

#include “point.h”

int main(int argc, char *argv[])
{
SDL_Surface *screen;

int angle = 0;

point a(320, 240);
point b(135, 240);

double x, y;

if(SDL_Init(SDL_INIT_VIDEO) < 0 )
{
    fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError());
    exit(1);
}

screen = SDL_SetVideoMode(640, 480, 16, 0);

if(screen == NULL)
{
    fprintf(stderr, "Failed to initialize surface's video mode at 

640x480x16: %s\n", SDL_GetError());
exit(1);
}

while(angle != 720 * 1000)
{
    angle++;

    b.rotate(a, angle);

    b.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    a.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    SDL_UpdateRect(screen, 0, 0, 640, 480);
}

SDL_Quit();
return 0;

}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Excuse my ignorance please…

What does “blitting” exactly means? i read a very poor definition of it in
the tutorial im doing. i cant get a good idea of it

tnx :slight_smile:
Eduardo Garcia Rajo (h)------------------------------------------------------------------
Visite: http://www.solucion-digital.com.ar
SOLUCION DIGITAL
Redes - Software - Servicios

----- Original Message -----
From: ggambett@artech.com.uy (Gabriel Gambetta)
To:
Sent: Wednesday, May 21, 2003 3:14 PM
Subject: RE: [SDL] Blitting

What does “doesn’t work” mean? What is it supposed to do and what does it
actually do?

Lic. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy

-----Original Message-----
From: JVFF Programming [mailto:jvffprogramming@ieg.com.br]
Sent: Mi?rcoles, 21 de Mayo de 2003 02:26 p.m.
To: SDL Mailing List
Subject: [SDL] Blitting

Hello,
I can’t seem to get this code working. Can somebody help me? :

#include “SDL.h”
#include “SGE.h”

#include “point.h”

int main(int argc, char *argv[])
{
SDL_Surface *screen;

int angle = 0;

point a(320, 240);
point b(135, 240);

double x, y;

if(SDL_Init(SDL_INIT_VIDEO) < 0 )
{
    fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError());
    exit(1);
}

screen = SDL_SetVideoMode(640, 480, 16, 0);

if(screen == NULL)
{
    fprintf(stderr, "Failed to initialize surface's video mode at

640x480x16: %s\n", SDL_GetError());
exit(1);
}

while(angle != 720 * 1000)
{
    angle++;

    b.rotate(a, angle);

    b.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    a.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    SDL_UpdateRect(screen, 0, 0, 640, 480);
}

SDL_Quit();
return 0;

}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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

I don’t see a real problem in the Code (especially as i don’t know your
sge_-Functions, but your prob might be, that you are not drawing a
background. This can be done by calling SDL_FillRect() with the appropirate
parameters before(!) drawing your points.Am Mittwoch, 21. Mai 2003 19:26 schrieb JVFF Programming:

Hello,
I can’t seem to get this code working. Can somebody help me? :

#include “SDL.h”
#include “SGE.h”

#include “point.h”

int main(int argc, char *argv[])
{
SDL_Surface *screen;

int angle = 0;

point a(320, 240);
point b(135, 240);

double x, y;

if(SDL_Init(SDL_INIT_VIDEO) < 0 )
{
    fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError());
    exit(1);
}

screen = SDL_SetVideoMode(640, 480, 16, 0);

if(screen == NULL)
{
    fprintf(stderr, "Failed to initialize surface's video mode at

640x480x16: %s\n", SDL_GetError());
exit(1);
}

while(angle != 720 * 1000)
{
    angle++;

    b.rotate(a, angle);

    b.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    a.getPoint(x, y);

    sge_PutPixel(screen, x, y, 32);

    SDL_UpdateRect(screen, 0, 0, 640, 480);
}

SDL_Quit();
return 0;

}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Matthias Bach | GPG/PGP-Key-ID: 0xACA73EC9
www.marix-world.de | On Keyserver: www.keyserver.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+zGSWlnJmS6ynPskRAvdvAJsGMQTF80DiLJqnrwPi+xnz3YWdmwCgqg9p
tYqsa5g0IXvolk9rCL2pbYE=
=K1xU
-----END PGP SIGNATURE-----

eDU! wrote:

What does “blitting” exactly means? i read a very poor definition of it in
the tutorial im doing. i cant get a good idea of it

here is a quote from one of the tutorials i did.

Definition: "blit"
In the next sections we will transform our program from using lists to
using real graphics on the screen. When displaying the graphics we will
use the term blit frequently. If you are new to doing graphics work, you
are probably unframiliar with this common term.

BLIT: Basically, blit means to copy graphics from one image to another.
A more formal definition is to copy an array of data to a bitmapped
array destination. You can think of blit as just “assigning” pixels.
Much like setting values in our screen-list above, blitting assigns the
color of pixels in our image.

Other graphics libraries will use the word bitblt, or just blt, but they
are talking about the same thing. It is basically copying memory from
one place to another. Actually, it is a bit more advanced than straight
copying of memory, since it needs to handle things like pixel formats,
clipping, and scanline pitches. Advanced blitters can also handle things
like transparancy and other special effects.