Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ SDL_SetVideoMode挂起进程_C++_Graphics_Sdl - Fatal编程技术网

C++ SDL_SetVideoMode挂起进程

C++ SDL_SetVideoMode挂起进程,c++,graphics,sdl,C++,Graphics,Sdl,在初始化程序的过程中,我在SDL_Init()之后调用SDL_SetVideoMode(),它将挂起我的程序。 在执行程序时,如果我在挂起期间按Ctrl-C,它将继续正常运行,并且一切正常 显然,每次必须中断SDL_SetVideoMode()并不理想!有人知道这是什么吗 下面是我正在使用的简单测试代码: main.cpp int main(int argc, char* argv[]) { Presentation* p = new Presentation(); //Presenta

在初始化程序的过程中,我在SDL_Init()之后调用SDL_SetVideoMode(),它将挂起我的程序。 在执行程序时,如果我在挂起期间按Ctrl-C,它将继续正常运行,并且一切正常

显然,每次必须中断SDL_SetVideoMode()并不理想!有人知道这是什么吗

下面是我正在使用的简单测试代码:

main.cpp

int main(int argc, char* argv[])
{
  Presentation* p = new Presentation();  //Presentation is used to display JPEGs
  p->Initialise();

  while (p->hasSlides())
  {
    p->DisplayNextSlide();
    sleep(5);
  }
  return 0;
}


Presentation.cpp

Presentation::Initialise()
{
  SDL_Init(SDL_INIT_VIDEO);
  m_pScreen = SDL_SetVideoMode(1280,720,16, SDL_DOUBLEBUF | SDL_FULLSCREEN);
  if (!m_pScreen)
  {
    //error handling...
  }

  SDL_ShowCursor(SDL_DISABLE);
  initialised = true;
}


SDL_Surface* m_pImage;

Presentation::DisplayNextSlide()
{
  m_pImage = IMG_Load(filename);
  if(!m_pImage)
  {
    //error handling...
  }

  SDL_BlitSurface(m_pImage,0,m_pScreen,0);
  SDL_Flip(m_pScreen);
}

我发现了这个问题。我只是在显示后没有释放图像表面,这意味着SDL_Quit没有被正确调用! 修复了下面示例中的代码:

SDL_Surface* m_pImage;

 Presentation::DisplayNextSlide()
 {
   m_pImage = IMG_Load(filename);
   if(!m_pImage)
   {
    //error handling...
   }

   SDL_BlitSurface(m_pImage,0,m_pScreen,0);
   SDL_Flip(m_pScreen);
   SDL_FreeSurface(m_pImage);
   m_pImage = NULL;
}

请显示您使用的代码。