Results 1 to 4 of 4

Thread: SDL window does not open

  1. #1
    Join Date
    Mar 2008
    Posts
    672

    SDL window does not open

    I am trying to learn the use of SDL in C++ :
    Code:
     # include <stdlib.h> 
      # include <stdio.h> 
      # include <SDL/SDL.h> 
     
      void pause (); 
     
      int main (int argc, char * argv []) 
      ( 
          SDL_Init (SDL_INIT_VIDEO) / / Initialize SDL 
     
          SDL_SetVideoMode (640, 480, 32, SDL_HWSURFACE) / / open the window 
        
          pause () / / Pause program 
     
          SDL_Quit () / / stop the SDL 
     
          return EXIT_SUCCESS; / / Closing Program 
      ) 
     
      void pause () 
      ( 
          int continue = 1; 
          SDL_Event event; 
     
          while (continue) 
          ( 
              SDL_WaitEvent (& event); 
              switch (event. type) 
              ( 
                  SDL_QUIT box: 
                      continue = 0; 
              ) 
          ) 
      )
    I copied / pasted the code, have compiled no problem. But when I test, or even when I open the corresponding executable file, nothing happens. The window does not open. Can nay one give the example of SDL in C++.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: SDL window does not open

    Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.To use SDL You need to add the include file SDL/SDL.h to the top of your program like this:#include <SDL/SDL.h>.

    Code:
    SDL_INIT_TIMER
    SDL_INIT_AUDIO
    SDL_INIT_VIDEO
    SDL_INIT_CDROM
    SDL_INIT_JOYSTICK
    SDL_INIT_NOPARACHUTE
    SDL_INIT_EVENTTHREAD
    SDL_INIT_EVERYTHING

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: SDL window does not open

    First declare an area:
    Code:
     SDL_Surface * screen = NULL;

    Then replace your line:
    Code:
     SDL_SetVideoMode (640, 480, 32, SDL_HWSURFACE);
    For this:
    Code:
     Wallpapers SDL_SetVideoMode = (640, 480, 32, SDL_HWSURFACE);

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: SDL window does not open

    setting up SDL for keyboard input :
    Code:
    SDL_Surface *screen;
     
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    	printf("Unable to initialize SDL: %s\n", SDL_GetError());
    	return 1;
    }
     
    atexit(SDL_Quit);
     
    screen = SDL_SetVideoMode(320, 240, 0, SDL_ANYFORMAT);
    if (screen == NULL) {
    	printf("Unable to set video mode: %s\n", SDL_GetError());
    	return 1;
    }

Similar Threads

  1. Can't open new window or tab in IE8 32 bit?
    By Henri@ksen in forum Windows x64 Edition
    Replies: 6
    Last Post: 19-07-2011, 07:59 AM
  2. To open a link from Google, I have to open in a new tab or window
    By Bindaas-ER in forum Technology & Internet
    Replies: 3
    Last Post: 07-03-2011, 04:02 AM
  3. Replies: 4
    Last Post: 24-01-2011, 11:05 AM
  4. Open Each folder in its own window Bug
    By GTS in forum Vista Help
    Replies: 13
    Last Post: 24-08-2010, 05:57 AM
  5. How to set IE 7.0 to always open in new window
    By SmirnOFF in forum Tips & Tweaks
    Replies: 2
    Last Post: 06-06-2009, 04:19 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,003,404.86615 seconds with 17 queries