1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
SDL_Surface* pTempSurface = SDL_LoadBMP("assets/rider.bmp");
m_pTexture = SDL_CreateTextureFromSurface(m_pRenderer,pTempSurface);
SDL_FreeSurface(pTempSurface);
SDL_QueryTexture(m_pTexture, NULL,NULL,&m_pSourceRect.w, &m_pSourceRect.h);
//DEBUGXX
std::cout << m_pSourceRect.w<<std::endl;
std::cout <<m_pSourceRect.h<<std::endl;
std::cout << m_pSourceRect.x<<std::endl;
std::cout <<m_pSourceRect.y<<std::endl;
m_pDestinationRect.x = m_pSourceRect.x = 0;
m_pDestinationRect.y = m_pSourceRect.y = 0;
m_pDestinationRect.w = m_pSourceRect.w;
m_pDestinationRect.h = m_pSourceRect.h;
std::cout << m_pDestinationRect.w<<std::endl;
std::cout <<m_pDestinationRect.h<<std::endl;
std::cout << m_pDestinationRect.x<<std::endl;
std::cout <<m_pDestinationRect.y<<std::endl;
int flags = 0;
if(fullScreen)
{
flags = SDL_WINDOW_FULLSCREEN;
}
if(SDL_Init(SDL_INIT_EVERYTHING) ==0)
{
std::cout << "SDL Init Success\n";
m_pWindow = SDL_CreateWindow(title,xpos,ypos,width,height,flags);
if(m_pWindow != 0)
{
std::cout << "Window creation success!\n";
m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, 0);
if(m_pRenderer !=0)
{
std::cout << "renderer creation success\n";
SDL_SetRenderDrawColor(m_pRenderer,0,0,0,255);
}
else
{
std::cout << "Renderer creation failed\n";
return false;
}
}
else
{
std::cout<< "SDL init fail\n";
return false;
}
}
else
{
std::cout << "SDL Init Fail\n";
return false;
}
std::cout << "Init Success\n";
m_bRunning = true;
return true;
}
|