456
社区成员




bool Game2::init(const char *title, int xpos, int ypos, int height, int width, int flags)
{
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) return false;
m_pWindow = SDL_CreateWindow(title, xpos, ypos, height, width, flags);
if (NULL == m_pWindow) return false;
m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, 0);
SDL_SetRenderDrawColor(m_pRenderer, 255, 255, 255, 255);
// new
//SDL_Surface *pTmpSurface = SDL_LoadBMP("D:\\sample.bmp"); // 按照实际更改图片名称及路径
SDL_Surface *pTmpSurface = IMG_Load("C:\\Users\\87070\\Desktop\\1.gif");
if (NULL == pTmpSurface) return false;
m_pTexture = SDL_CreateTextureFromSurface(m_pRenderer, pTmpSurface);
if (NULL == m_pTexture) return false;
SDL_FreeSurface(pTmpSurface);
SDL_QueryTexture(m_pTexture,NULL, NULL, &m_srcRect.w, &m_srcRect.h);
m_dstRect.x = m_srcRect.x = 0;
m_dstRect.y = m_srcRect.y = 0;
// for debug
//m_srcRect.w /= 2;
//m_srcRect.h /= 2;
m_dstRect.w = m_srcRect.w;
m_dstRect.h = m_srcRect.h;