Jump to content
  • Advertisement
Sign in to follow this  
Rocko

Problem with Fill Rect

This topic is 4611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, im new here. I am having some problems with the fill rect function in SDL. If I run the program in fullscreen the screen flashes a lot but if i run it windowed it works just fine. I dont know if the problem is the fill rect function or something else, i would appreciate if you could help me. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Try using a double buffer in fullscreen mode, and see if that corrects the problem.

To do this or in the SDL_DOUBLEBUF flag when you make the call to SDL_SetVideoMode. You'll need to call SDL_Flip instead of updating the screen surface though.

Share this post


Link to post
Share on other sites
Hmmm

Weird if it's bug only in full screen mode but.... make sure SDL_Flip is really called at the very end of the calculation and when you are ready to swap the buffers.

Share this post


Link to post
Share on other sites
//This is the function we call from the gameloop every cicle:

void CTetris::Draw()
{
bool bEsPieza;

SDL_Rect rectFondo;
rectFondo.x = (ANCHO_VENTANA / 3) + 18;
rectFondo.y = 85;
rectFondo.w = 191;
rectFondo.h = 388;

SDL_Rect rectLineas;
rectLineas.x = 500;
rectLineas.y = 103;
rectLineas.w = 50;
rectLineas.h = 20;

SDL_FillRect(sfcScreen, &rectFondo, SDL_MapRGB(sfcScreen->format, 0, 0, 0));
for (int i = 0; i < ALTO_TABLERO; i++)
{
for (int j = 0; j < ANCHO_TABLERO; j++)
{
bEsPieza = false;
int k = 0;
while (k < 4 && !bEsPieza)
{
if (p.cuadrado[k].x == j && p.cuadrado[k].y == i)
bEsPieza = true;
k++;
}

if (bEsPieza)
DrawSprite(sfcPiezas, sfcScreen, TAM_PIEZA * (p.tipo - 1), 0, j * TAM_PIEZA+ (ANCHO_VENTANA /3), i * TAM_PIEZA + 93, TAM_PIEZA, TAM_PIEZA);

else
{
if (tablero[j] != LIBRE)
DrawSprite(sfcPiezas, sfcScreen, TAM_PIEZA * (tablero[j] - 1), 0, j * TAM_PIEZA+(ANCHO_VENTANA/3), i * TAM_PIEZA + 93, TAM_PIEZA, TAM_PIEZA);
}
}
}

SDL_FillRect(sfcScreen, &rectLineas, SDL_MapRGB(sfcScreen->format, 0, 0, 0));
DrawText( sfcScreen, IntToString(iLineasTotales), 505, 100, 255, 255, 255 );

SDL_Flip( sfcScreen );
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!