Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: ,

Sponsored Links



SDL window does not open

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 16-10-2009
Allan.d's Avatar
Member
 
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++.
Reply With Quote
  #2  
Old 16-10-2009
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
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
Reply With Quote
  #3  
Old 16-10-2009
Member
 
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);
Reply With Quote
  #4  
Old 16-10-2009
Member
 
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;
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SDL window does not open"
Thread Thread Starter Forum Replies Last Post
Can't open new window or tab in IE8 32 bit? GaryG Windows x64 Edition 12 19-07-2011 08:59 AM
To open a link from Google, I have to open in a new tab or window Bindaas-ER Technology & Internet 3 07-03-2011 04:02 AM
Folders open in new window despite selecting the option of open in same window Hahtalekin Operating Systems 4 24-01-2011 11:05 AM
How to set IE 7.0 to always open in new window SmirnOFF Tips & Tweaks 2 06-06-2009 05:19 PM
Vista how to Open in new window? christheart Operating Systems 3 02-06-2009 02:02 PM


All times are GMT +5.5. The time now is 07:38 AM.