CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2007
    Posts
    26

    SDL & Win32 in Vista

    Hi

    I've done an application using SDL and Win32 which runs fine in Windows XP but when running it in Vista it closes immediately during startup.

    Heres the code used to start the application and initialize SDL & Win32:

    Code:
    	try
    	{
        	char *msg;
        	int done;
        	
        	SDL_Init(SDL_INIT_VIDEO);
        	TTF_Init();
        	
        	atexit(SDL_Quit);
        	screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_HWSURFACE);
        	cur_hand = init_system_cursor(hand);
        	cur_orig = SDL_GetCursor();
        	SDL_SetCursor(cur_orig);
        	
        	SDL_WM_SetCaption("Gallery Viewer 1.0", NULL);
    		
        	loadBinaryFile(&dataHeader);
        	pages = dataHeader.pictures / 8;
        	if(((float)dataHeader.pictures / 8) > (float)(dataHeader.pictures / 8))
        		pages ++;
        	
        	// Load Thumbnails
        	for(int i = 0; i < dataHeader.pictures; i++)
        	{
    			loadImage(i, &dataHeader.thumbs[i], "thumbs.bin");	
    		}
    		
        	hhkLowLevelKybd  = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hThisInstance, 0);
        	done = 0;
        	draw ();
            
        	while(!done)
        	{
            	SDL_Event event;
            	
            	while (SDL_PollEvent(&event))
            	{
                	switch (event.type)
                	{
                    	case SDL_MOUSEMOTION:
                        	mouseX = event.motion.x;
                        	mouseY = event.motion.y;
                        	checkHover();
                        	break;
                    	case SDL_MOUSEBUTTONDOWN:
                        	clicked = true;
                        	break;
                    	case SDL_MOUSEBUTTONUP:
    						if(clicked) checkAreaClick();
                        	clicked = false;
                        	break;
                    	case SDL_QUIT:
                        	done = 1;
                        	break;
                    	default:
                        	break;
                	}
            	}
            	Sleep(50);
        	}
        	SDL_Quit();
        	return 0;
    	}
        catch(std::exception e) 
    	{
    		exit(0);	
    	}
    Any ideas why this code causes problems in Vista?

    Thanks
    // Lasse

  2. #2
    Join Date
    Oct 2007
    Posts
    26

    Re: SDL & Win32 in Vista

    Anyone have any ideas? I really need to fix this problem.

    Thanks
    // Lasse

  3. #3
    Join Date
    May 2007
    Posts
    811

    Re: SDL & Win32 in Vista

    Where you able to use debugger and see where it was stopping execution and exiting?

  4. #4
    Join Date
    Oct 2007
    Posts
    26

    Re: SDL & Win32 in Vista

    Since I don't have any computer with Vista I can't get the error myself. The person I'm making the application for is running Vista and he was the one that found out that it wasn't working.

    He just said that the window just blinked during the startup.

    If anyone runs Vista and could debug it for me I would appreciate it.

  5. #5
    Join Date
    May 2005
    Location
    Estonia
    Posts
    235

    Re: SDL & Win32 in Vista

    For start i would comment out the thumbnail stuff and mouse events.
    Then i would run it again, too see it runs or not.

    If it runs then i would start looking the code i commented out.

    What the: atexit(SDL_Quit); does below the TTF_Init() ??
    Last edited by BytePtr; December 23rd, 2007 at 04:17 PM.
    Rate my post if i it was useful!

  6. #6
    Join Date
    Oct 2007
    Posts
    26

    Re: SDL & Win32 in Vista

    I would do it if I had a computer running Vista. Since it works fine on XP I can't debug it on my own.

    atexit(SDL_QUIT); just sets how SDL should handle exit requests.

    Thanks
    // Lasse

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: SDL & Win32 in Vista

    Tell him to start the program as Administrator to rule out UAC problems.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Oct 2007
    Posts
    26

    Re: SDL & Win32 in Vista

    He have tried running it as administrator.

  9. #9
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762

    Re: SDL & Win32 in Vista

    I developed an SDL game without issues on Vista so it's most likely not due to the OS being Vista though I'm not exactly sure what the problem is.

  10. #10
    Join Date
    Oct 2007
    Posts
    26

    Re: SDL & Win32 in Vista

    Thanks for the info, will look after something else that may cause the error.

  11. #11
    Join Date
    Oct 2007
    Posts
    26

    Re: SDL & Win32 in Vista

    Solved it, it was the free command that caused the problem.

    Thanks for all the help
    // Lasse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured