概述:
SDL使用SDL_Surface和SDL_Texture这2种结构绘图到屏幕。SDL_Surface包含了一个像素集合(pixels成员),它使用软件渲染(非GPU);SDL_Textur可使用硬件加速器。
使用SDL_Texture的示例程序:
使用SDL_Texture的示例程序:
#include "SDL.h"
class Game2
{
public:
Game2():m_pWindow(NULL),m_pRenderer(NULL), m_bRunning(false){};
~Game2(){};
bool init(const char* title, int xpos, int ypos, int width, int height, int flags);
void render();
void update();
void handleEvents();
bool running() {return m_bRunning; }
void clean();
private:
SDL_Window *m_pWindow;
SDL_Renderer *m_pRenderer;
// new
SDL_Texture *m_pTexture;
SDL_Rect m_srcRect; // 源矩形
SDL_Rect m_dstRect; // 目标矩形
bool m_bRunning;
};
bool Game2::init(const char *title, int xpos, in