Nothing's happen

hi,
I have lots of prob with the fonction SDL_CreateRGBSurface

there , my code

#include
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
using namespace std;
const int WI = 800;
const int HI = 600;

unsigned rmask = 0x000000ff;
unsigned gmask = 0x0000ff00;
unsigned bmask = 0x00ff0000;
unsigned amask = 0xff000000;

SDL_Surface* Ecran;
SDL_Surface* Play;

main()
{
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
Ecran = SDL_SetVideoMode(WI,HI,0,
SDL_ANYFORMAT|SDL_DOUBLEBUF);
if (Ecran == NULL) {cout << SDL_GetError() << endl;
exit(0);}
int BPP = Ecran->format->BitsPerPixel;
SDL_Surface * Background = IMG_Load("./img/background.jpg");
Background = SDL_DisplayFormat(Background);
Play = SDL_CreateRGBSurface(SDL_HWSURFACE,WI/2
-80,100,BPP,rmask,gmask,bmask, amask);
SDL_BlitSurface(Play,0,Ecran,0);
SDL_Flip(Ecran);
sleep(2);
}

I just wanna create some simple white rect but nothing 's happen
(I just have a black screen)

thanks

a+++
PS :: kostas, in fact I had putted a Flip but he stay in my copy
paste mouse

Le Lundi 14 F?vrier 2005 06:23, elekis a ?crit?:

unsigned rmask = 0x000000ff;
unsigned gmask = 0x0000ff00;
unsigned bmask = 0x00ff0000;
unsigned amask = 0xff000000;

remove them and you will have your white rect :slight_smile:

I’ve made the same mistake in my prog, the SDL componant for gambas
http://gambas.sourceforge.net.

Regards,–

Laurent Carlier

Le Lundi 14 F?vrier 2005 08:54, Laurent Carlier a ?crit?:

remove them and you will have your white rect :slight_smile:

And it wont make a white one but a black one :)–

Laurent Carlier

Laurent Carlier wrote:

Le Lundi 14 F?vrier 2005 08:54, Laurent Carlier a ?crit :

remove them and you will have your white rect :slight_smile:

And it wont make a white one but a black one :slight_smile:

heu simple question, but that
#include
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
using namespace std;
const int WI = 800;
const int HI = 600;

SDL_Surface* Ecran;
SDL_Surface* Play;

main()
{
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
Ecran = SDL_SetVideoMode(WI,HI,0,
SDL_ANYFORMAT|SDL_DOUBLEBUF);
if (Ecran == NULL) {cout << SDL_GetError() << endl;
exit(0);}
int BPP = Ecran->format->BitsPerPixel;
SDL_Surface * Background = IMG_Load("./img/background.jpg");
Background = SDL_DisplayFormat(Background);
Play = SDL_CreateRGBSurface(SDL_HWSURFACE,WI/2
-80,100,BPP,rmask,gmask,bmask, amask);
SDL_BlitSurface(Play,0,Ecran,0);
SDL_Flip(Ecran);
sleep(2);
}

doesn’t compil.
must I replace mask , but by what??

thanks.

Play = SDL_CreateRGBSurface(SDL_HWSURFACE,WI/2
-80,100,BPP,0,0,0,0);
SDL_FillRect(play, NULL, SDL_MapRGB(play, 0xFF, 0xFF, 0xFF)); // white
color !–

Laurent Carlier

Play = SDL_CreateRGBSurface(SDL_HWSURFACE,WI/2

-80,100,BPP,rmask,gmask,bmask, amask);

The created surface is black by default, so you’re blitting a black
surface to a black surface and getting…a black surface. :slight_smile:

(The mask variables are not the color of the surface, they specify what
bits will represent which colors.)

SDL_BlitSurface(Play,0,Ecran,0);

If all you want is a white rectangle, use SDL_FillRect on Eran directly.

 Uint32 white = SDL_MapRGB(Play, 0xFF, 0xFF, 0xFF);
 SDL_Rect rect;
 rect.x = rect.y = 0;
 rect.w = (WI/2) - 80
 rect.h = 100;
 SDL_FillRect(Ecran, &rect, white);
 SDL_UpdateRects(Ecran, 1, &rect);

The UpdateRects call puts just that rectangle to the screen…in many
cases, this can be faster than SDL_Flip().

If you eventually plan to put bitmap data into “Play” that you’ll want
to put to Ecran, then you would need to use CreateRGBSurface and
BlitSurface.

To fix your example (making Play entirely white and then blitting it),
just use FillRect to wipe Play, then blit that to Ecran:

Uint32 white = SDL_MapRGB(Play, 0xFF, 0xFF, 0xFF);
SDL_FillRect(Play, NULL, white);  // make whole surface white.
SDL_BlitSurface(Play, NULL, Ecran, NULL);

…and don’t forget to SDL_Flip(Ecran) when you are done drawing the
whole frame.

–ryan.