C++ SDL2 blitting BMP文件

C++ SDL2 blitting BMP文件,c++,sdl-2,game-development,C++,Sdl 2,Game Development,当前正在尝试通过SDL2在窗口上显示BMP文件 这是我的main.cpp文件: `#include "pch.h" #include <iostream> #include<SDL.h> using namespace std; int main(int argc, char* args[]) { bool run=true; sdl a; if (a.init() == false) {

当前正在尝试通过SDL2在窗口上显示BMP文件

这是我的main.cpp文件:

  `#include "pch.h"
   #include <iostream>
   #include<SDL.h>
   using namespace std;
   int main(int argc, char* args[])
   {
     bool run=true;
     sdl a;
     if (a.init() == false)
      {
        cout << "SDL not working" << endl;
        return 0;
      }
      else
        if (a.screendisplay() == false)
        {
            cout << "Enable to open the window" << endl;
            return 0;
        }
        else
             if (a.loadmedia() == false)
             {
             cout << "Unable to load the image" << endl << SDL_GetError()<<endl;
              return 0;
             }
             else
              a.imageprocessing();
          SDL_Delay(2000);
          a.quit();
    return 0;
}`.   
 #include "pch.h"
using namespace std;
bool sdl::init()
{
    bool sucess = true;
    if (SDL_Init(SDL_INIT_VIDEO) <0)
    {
        cout << "SDL not Working properply" << endl;
        return false;
    }
    else return true;
};
bool sdl::screendisplay()
{
    bool sucess;
    Window = SDL_CreateWindow("SDL Tutorial", 0, 0,640, 280, SDL_WINDOW_SHOWN);
    if (Window = NULL)
    {
        return sucess = false;
    }
    else
        screenSurface= SDL_GetWindowSurface(Window);
        return sucess = true;
};
bool sdl::loadmedia()
{
    bool success = true;
        gsurface = SDL_LoadBMP("asd.bmp");
        if (gsurface == NULL)
        {
            success = false;
        }
        return success;

};
bool sdl::imageprocessing()
{
    bool success = true;
    if (SDL_BlitSurface(gsurface, NULL, screenSurface, NULL) < 0)
    {
        return success = false;
    }
    else
    SDL_UpdateWindowSurface(Window);
    SDL_Delay(2000);
    return success;
};
bool sdl::quit()
{
    bool sucess;

    SDL_DestroyWindow(Window);
        SDL_Quit();
        return sucess = true;

};
Pch.cpp文件:

  `#include "pch.h"
   #include <iostream>
   #include<SDL.h>
   using namespace std;
   int main(int argc, char* args[])
   {
     bool run=true;
     sdl a;
     if (a.init() == false)
      {
        cout << "SDL not working" << endl;
        return 0;
      }
      else
        if (a.screendisplay() == false)
        {
            cout << "Enable to open the window" << endl;
            return 0;
        }
        else
             if (a.loadmedia() == false)
             {
             cout << "Unable to load the image" << endl << SDL_GetError()<<endl;
              return 0;
             }
             else
              a.imageprocessing();
          SDL_Delay(2000);
          a.quit();
    return 0;
}`.   
 #include "pch.h"
using namespace std;
bool sdl::init()
{
    bool sucess = true;
    if (SDL_Init(SDL_INIT_VIDEO) <0)
    {
        cout << "SDL not Working properply" << endl;
        return false;
    }
    else return true;
};
bool sdl::screendisplay()
{
    bool sucess;
    Window = SDL_CreateWindow("SDL Tutorial", 0, 0,640, 280, SDL_WINDOW_SHOWN);
    if (Window = NULL)
    {
        return sucess = false;
    }
    else
        screenSurface= SDL_GetWindowSurface(Window);
        return sucess = true;
};
bool sdl::loadmedia()
{
    bool success = true;
        gsurface = SDL_LoadBMP("asd.bmp");
        if (gsurface == NULL)
        {
            success = false;
        }
        return success;

};
bool sdl::imageprocessing()
{
    bool success = true;
    if (SDL_BlitSurface(gsurface, NULL, screenSurface, NULL) < 0)
    {
        return success = false;
    }
    else
    SDL_UpdateWindowSurface(Window);
    SDL_Delay(2000);
    return success;
};
bool sdl::quit()
{
    bool sucess;

    SDL_DestroyWindow(Window);
        SDL_Quit();
        return sucess = true;

};
#包括“pch.h”
使用名称空间std;
boolsdl::init()
{
布尔成功=真;

如果(SDL_Init(SDL_Init_VIDEO)我认为问题出在您的
screensdisplay()
函数中:

bool sdl::screendisplay()
{
    bool sucess;
    Window = SDL_CreateWindow("SDL Tutorial", 0, 0,640, 280, SDL_WINDOW_SHOWN);
    if (Window = NULL) // <- Right here
    {
        return sucess = false;
    }
    else
        screenSurface= SDL_GetWindowSurface(Window);
        return sucess = true;
};
boolsdl::screensdisplay()
{
布尔成功;
Window=SDL_CreateWindow(“SDL教程”,0,0640,280,显示SDL_窗口);

if(Window=NULL)//
SDL\u BlitSurface()
返回什么值?这可能会告诉您问题所在。