Archived

This topic is now archived and is closed to further replies.

Ziphnor

Fullscreen problems

Recommended Posts

Ziphnor    122
To check that i had SDL properly installed and everything, i made the little silly program below(it display a background picture and draws a smaller picture where the mouse is clicked, if a key is pressed it takes a screenshot and restores the background). It works fine windowed, but when i added the SDL_FULLSCREEN flag i ran into trouble, weird things happened when i clicked the mouse. Depending on the other flags, the background disappeared, or the small pictures moved(!) when i clicked the mouse, or just became transparent in the center... Can anyone help me fix this, i would like to know if its because im using it wrong(likely) or because of something else beyond my control. Here is the very simple code EDIT: Just wanted to add that im working in Windows XP with a Geforce 2 64MB card, could that be the cause?
      
#include "SDL.h"
int main( int argc, char* argv[] )
{
  //initialize systems

	SDL_Init ( SDL_INIT_VIDEO ) ;	
	atexit ( SDL_Quit ) ;
  //create a window

	SDL_Surface* pSurface = SDL_SetVideoMode ( 640 , 480 , 0, SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF ) ;
	SDL_Surface* imageTile = SDL_LoadBMP("boom.bmp");
	SDL_Surface* background = SDL_LoadBMP("background.bmp");
        SDL_SetColorKey(imageTile, SDL_SRCCOLORKEY, SDL_MapRGB(imageTile->format, 255, 0, 128)); 
	SDL_WM_SetCaption("Stupid SDL test program", NULL);
	 SDL_Event event;//declare event variable

	 SDL_BlitSurface(background, NULL, pSurface, NULL);
	 SDL_Flip(pSurface);
	 for ( ; ; )	//message pump

	 {
		if ( SDL_PollEvent ( &event ) )	//look for an event

		{
		  //an event was found

		  if ( event.type == SDL_QUIT ) break ;
		  if ( event.type == SDL_KEYDOWN ) {
			SDL_SaveBMP(pSurface, "screenshot.bmp");
			SDL_BlitSurface(background, NULL, pSurface, NULL); // propper baggrunden ind

			SDL_Flip(pSurface);
			}
		if ( event.type == SDL_MOUSEBUTTONDOWN) {
			SDL_Rect target;
			target.x = event.button.x - 10;
			target.y = event.button.y - 10;
			SDL_BlitSurface(imageTile, NULL, pSurface, &target);
			SDL_Flip(pSurface);
			}
		}
	  }
	  return ( 0 ) ;
}


      
Edited by - ziphnor on December 10, 2001 4:55:26 PM Edited by - ziphnor on December 11, 2001 6:31:46 AM

Share this post


Link to post
Share on other sites
Ziphnor    122
I tested on 2 other machines(1 Win2000 the other WinXP) and the exact same thing happened
More exactly, when i click the mouse, ONLY my little boom.bmp image is show, the next time i click, the background comes back, but there are little black boxes missing from it, and when i keep clicking the boom.bmp sprites move around in a very strange way...
Please i need some help here...

Share this post


Link to post
Share on other sites
Ziphnor    122
I found out from some nice people at the SDL mailing list that SDL_Flip(pSurface) leaves pSurface undefined, causing some of the things i saw.
Im still having problem with the mouse cursor though, in SW mode it leaves transparent artifacts, and in HW mode it just doesnt show.

Share this post


Link to post
Share on other sites