Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualswiftcoder

Posted 31 December 2011 - 11:20 AM

Hi...  After having to install Windows 7, I've set up Codeblocks with MinGW and SDL.  Now, then, I've been trying to get some things working.  I've gotten a window open (just a simple, stupid test program) and can keep it open, but it won't close unless I use Task Manager to force it shut.  I've tried everything I could think of and I never had this particular problem on Linux.

It closes on its own, like any other window, if I don't have a loop to keep it open, but with the loop?  Complete and total failure to terminate.

#include "SDL.h"
#include <stdio.h>
#include <stdlib.h>
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
SDL_Surface *window;
union SDL_Event event;
int main(int argc,char *argv[]){
  if(SDL_Init(SDL_INIT_VIDEO)!=0){
	printf("Unable to initialise SDL: %s\n",SDL_GetError());
	  return 1;
	  atexit(SDL_Quit);
	return 1;
  }
  SDL_WM_SetCaption("Windows SDL Test",NULL);
  window=SDL_SetVideoMode(WINDOW_WIDTH,WINDOW_HEIGHT,32,SDL_DOUBLEBUF);
  if(window==NULL){
	printf("Unable to set video mode: %s\n",SDL_GetError());
	return 1;
  }
  while(1){
	while(SDL_WaitEvent(&event)==0){
	  switch(event.type){
		case SDL_QUIT:
		SDL_Quit();
	  }
	}
  }
}

As with other code I've shown on this site, there are things I wouldn't want to do in a program I plan to release.  I can't move onto the next bit of SDL testing on Windows until I get this issue resolved, though, and searching for hours has revealed nothing helpful.  The outer loop is there because, without it, the window closes instantly.

#2That One Guy

Posted 29 December 2011 - 12:57 PM

Hi...  After having to install Windows 7, I've set up Codeblocks with MinGW and SDL.  Now, then, I've been trying to get some things working.  I've gotten a window open (just a simple, stupid test program) and can keep it open, but it won't close unless I use Task Manager to force it shut.  I've tried everything I could think of and I never had this particular problem on Linux.

It closes on its own, like any other window, if I don't have a loop to keep it open, but with the loop?  Complete and total failure to terminate.

#include "SDL.h"
#include <stdio.h>
#include <stdlib.h>
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
SDL_Surface *window;
union SDL_Event event;
int main(int argc,char *argv[]){
  if(SDL_Init(SDL_INIT_VIDEO)!=0){
	printf("Unable to initialise SDL: %s\n",SDL_GetError());
	  return 1;
	  atexit(SDL_Quit);
	return 1;
  }
  SDL_WM_SetCaption("Windows SDL Test",NULL);
  window=SDL_SetVideoMode(WINDOW_WIDTH,WINDOW_HEIGHT,32,SDL_DOUBLEBUF);
  if(window==NULL){
	printf("Unable to set video mode: %s\n",SDL_GetError());
	return 1;
  }
  while(1){
    while(SDL_WaitEvent(&event)==0){
	  switch(event.type){
	    case SDL_QUIT:
	    SDL_Quit();
	  }
    }
  }
}

As with other code I've shown on this site, there are things I wouldn't want to do in a program I plan to release.  I can't move onto the next bit of SDL testing on Windows until I get this issue resolved, though, and searching for hours has revealed nothing helpful.  The outer loop is there because, without it, the window closes instantly.

#1That One Guy

Posted 29 December 2011 - 12:56 PM

Hi...  After having to install Windows 7, I've set up Codeblocks with MinGW and SDL.  Now, then, I've been trying to get some things working.  I've gotten a window open (just a simple, stupid test program) and can keep it open, but it won't close unless I use Task Manager to force it shut.  I've tried everything I could think of and I never had this particular problem on Linux.

It closes on its own, like any other window, if I don't have a loop to keep it open, but with the loop?  Complete and total failure to terminate.

#include "SDL.h"
#include <stdio.h>
#include <stdlib.h>
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
SDL_Surface *window;
union SDL_Event event;
int main(int argc,char *argv[]){
  if(SDL_Init(SDL_INIT_VIDEO)!=0){
    printf("Unable to initialise SDL: %s\n",SDL_GetError());
	  return 1;
	  atexit(SDL_Quit);
    return 1;
  }
  SDL_WM_SetCaption("Windows SDL Test",NULL);
  window=SDL_SetVideoMode(WINDOW_WIDTH,WINDOW_HEIGHT,32,SDL_DOUBLEBUF);
  if(window==NULL){
    printf("Unable to set video mode: %s\n",SDL_GetError());
    return 1;
  }
  while(1){
    while(SDL_WaitEvent(&event)==0){
	  switch(event.type){
	    case SDL_QUIT:
	    SDL_Quit();
	  }
    }
  }
}

As with other code I've shown on this site, there are things I wouldn't want to do in a program I plan to release.  I can't move onto the next bit of SDL testing on Windows until I get this issue resolved, though, and searching for hours has revealed nothing helpful.  The outer loop is there because, without it, the window closes instantly.

PARTNERS