本文整理汇总了C++中SDL_QueryTexture函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_QueryTexture函数的具体用法?C++ SDL_QueryTexture怎么用?C++ SDL_QueryTexture使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_QueryTexture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Free
SDL_Texture* Image::Load(SDL_Renderer* renderer, std::string fname) {
Free();
//load the file into a surface
SDL_Surface* surface = IMG_Load(fname.c_str());
if (!surface) {
std::ostringstream msg;
msg << "Failed to load an image file: " << fname;
msg << "; " << IMG_GetError();
throw(std::runtime_error(msg.str()));
}
//create a texture from this surface
texture = SDL_CreateTextureFromSurface(renderer, surface);
if (!texture) {
std::ostringstream msg;
msg << "Failed to convert a newly loaded image file: " << fname;
msg << "; " << SDL_GetError();
throw(std::runtime_error(msg.str()));
}
//set the metadata
clip.x = 0;
clip.y = 0;
if (SDL_QueryTexture(texture, nullptr, nullptr, &clip.w, &clip.h)) {
std::ostringstream msg;
msg << "Failed to record metadata for a newly loaded image file: " << fname;
msg << "; " << SDL_GetError();
throw(std::runtime_error(msg.str()));
}
local = true;
//free the surface & return
SDL_FreeSurface(surface);
return texture;
}
示例2: Unload
void Images::Load(int i_id, string i_path, int i_x, int i_y, int i_mtime, int i_a, int i_atime)
{
//detect that if it exist an images,unload it
for (auto it = m_imgs.begin(); it != m_imgs.end(); ++it)
if (it->id == i_id)
Unload(i_id);
//create a new texture struct and add it to the vector
Image newImg;
if (m_files->ReadRW(i_path, &(newImg.rw), newImg.index)){
if (!(newImg.sur = IMG_Load_RW(newImg.rw, AUTOFREE))){
SekaiAlert("cannot analyse the picture file from " + i_path);
return;
}
newImg.tex = SDL_CreateTextureFromSurface(m_ren, newImg.sur);
SDL_FreeSurface(newImg.sur);
newImg.id = i_id;
SDL_QueryTexture(newImg.tex, NULL, NULL, &(newImg.rect.w), &newImg.rect.h);
newImg.rect.x = i_x;
newImg.rect.y = i_y;
newImg.a = i_a;
newImg.path = i_path;
m_imgs.push_back(newImg);
}
}
示例3: SDL_QueryTexture
Sprite::Sprite(SDL_Renderer* passed_renderer, SDL_Texture* passed_image, int x, int y, int w, int h, CollisionRectangle passed_collision_rect)
{
renderer = passed_renderer;
image = NULL;
image = passed_image;
collision_rect = passed_collision_rect;
collisionSDLRect = collision_rect.GetRectangle();
//location and size
rect.x = x;
rect.y = y;
rect.w = w;
rect.h = h;
SDL_QueryTexture(image, NULL, NULL, &img_width, &img_height);
//cropped location and size (used for sprite animation)
crop.x = 0;
crop.y = 0;
crop.w = img_width;
crop.h = img_height;
//position as double (for distance function)
X_pos = x;
Y_pos = y;
//allows for unit to stand directly on top of target, instead of offset
origin_x = 0;
origin_y = 0;
currentFrame = 0;
animationDelay = 0;
amount_frame_x = 0;
amount_frame_y = 0;
}
示例4: maj_panneau
void maj_panneau(SDL_Renderer* ren, int nb_fleche[]){
SDL_Texture *texture_directions = NULL;
SDL_Surface *Directions = IMG_Load("IMG/Directions.png");
texture_directions = SDL_CreateTextureFromSurface(ren,Directions);
SDL_FreeSurface(Directions);
SDL_Rect dst_directions;
dst_directions.x = 730;
dst_directions.y = 80;
SDL_QueryTexture(texture_directions, NULL, NULL, &dst_directions.w, &dst_directions.h);
SDL_RenderCopy(ren, texture_directions, NULL, &dst_directions);
SDL_DestroyTexture(texture_directions);
affichage_nb(ren,768,210,nb_fleche[0]);//d1
affichage_nb(ren,818,210,nb_fleche[1]);//d2
affichage_nb(ren,868,210,nb_fleche[2]);//d3
affichage_nb(ren,768,160,nb_fleche[3]);//d4
affichage_nb(ren,868,160,nb_fleche[5]);//d6
affichage_nb(ren,768,110,nb_fleche[6]);//d7
affichage_nb(ren,818,110,nb_fleche[7]);//d8
affichage_nb(ren,868,110,nb_fleche[8]);//d9
SDL_RenderPresent(ren);
}
示例5: SDL_QueryTexture
// //EXERCISE 1 ---------------------------------------------------
ScrollBar::ScrollBar(const int& x, const int& y, const SDL_Rect* s_b, const SDL_Rect* s_t, SDL_Texture* t_b, SDL_Texture* t_t, bool d, j1Module* l, UIelement* p)
{
thumb = App->gui->CreateImage(50, 0, *s_t, t_t, true, l, this);
texture = t_b;
if (s_b != NULL)
{
section = *s_b;
pos.w = section.w;
pos.h = section.h;
}
else
{
section = { 0, 0, 0, 0 };
SDL_QueryTexture(texture, NULL, NULL, &pos.w, &pos.h);
}
pos.x = x;
pos.y = y;
type = SCROLL_BAR;
listener = l;
parent = p;
was_cursor_inside = false;
dragable = false;
moving_thumb = false;
}
示例6: SDL_DestroyTexture
void Block::change_type(int tipo)
{
SDL_DestroyTexture(this->texture);
switch(tipo)
{
case 0:
this->texture = IMG_LoadTexture(renderer, "FLOOR.png");
this->isFloor = true;
this->isWall = false;
this->is_mino = false;
break;
case 1:
this->texture = IMG_LoadTexture(renderer, "WALL.png");
this->isFloor = false;
this->isWall = true;
this->is_mino = false;
break;
case 2:
this->texture = IMG_LoadTexture(renderer, "TILE_STAR.png");
this->isFloor = true;
this->isWall = false;
this->is_exit = true;
this->is_mino = false;
break;
case 3:
this->texture = IMG_LoadTexture(renderer, "FLOOR.png");
this->isFloor = true;
this->isWall = false;
this->is_mino = true;
break;
}
SDL_QueryTexture(this->texture,NULL,NULL,&rect_block.w,&rect_block.h);
}
示例7: SDL_QueryTexture
void SpriteBatch::sbDrawTextureScaled(SDL_Texture *tex, int x, int y, float scale)
{
if(!drawingInProgress)
throw std::runtime_error("sbBegin must be called.");
SDL_Rect dst;
if(mainGameCamera == NULL)
{
dst.x = x;
dst.y = y;
}
else
{
dst.x = x + mainGameCamera->getCameraX();
dst.y = y + mainGameCamera->getCameraY();
}
SDL_QueryTexture(tex, NULL, NULL, &dst.w, &dst.h);
dst.w = int(float(dst.w) * scale);
dst.h = int(float(dst.h) * scale);
SDL_RenderCopy(__renderer, tex, NULL, &dst);
}
示例8: print_absolute
Code print_absolute(const int x, const int y, const char *string, const ColorPair color_pair, Renderer *renderer) {
char log_buffer[MAXIMUM_STRING_SIZE];
const SDL_Color foreground = to_sdl_color(color_pair.foreground);
const SDL_Color background = to_sdl_color(color_pair.background);
Font *font = global_monospaced_font;
SDL_Surface *surface;
SDL_Texture *texture;
SDL_Rect position;
position.x = x;
position.y = y;
if (string == NULL || string[0] == '\0') {
return CODE_OK;
}
/* Validate that x and y are nonnegative. */
if (x < 0 || y < 0) {
return CODE_ERROR;
}
surface = TTF_RenderText_Shaded(font, string, foreground, background);
if (surface == NULL) {
sprintf(log_buffer, CREATE_SURFACE_FAIL, "print_absolute()");
log_message(log_buffer);
return CODE_ERROR;
}
texture = SDL_CreateTextureFromSurface(renderer, surface);
if (texture == NULL) {
sprintf(log_buffer, CREATE_TEXTURE_FAIL, "print_absolute()");
log_message(log_buffer);
return CODE_ERROR;
}
/* Copy destination width and height from the texture. */
SDL_QueryTexture(texture, NULL, NULL, &position.w, &position.h);
SDL_RenderCopy(renderer, texture, NULL, &position);
SDL_DestroyTexture(texture);
SDL_FreeSurface(surface);
return CODE_OK;
}
示例9: SDL_DestroyTexture
bool ActorBase::loadTexture(const std::string& imgPath, const SDL_Rect& _clip/* = { 0,0,0,0 }*/)
{
if (texture)
{
SDL_DestroyTexture(texture);
texture = nullptr;
position = { 0, 0, 0, 0 };
}
texture = engine->loadTexture(imgPath);
if (!texture)
return false;
else
{
if (SDL_QueryTexture(texture, &textureFormat, &textureAccess, &textureWidth, &textureHeight) != static_cast<Uint32>(0))
{
log << warnlvl << full_log << "Error quarying the texture: " << SDL_GetError() << el;
throw;
}
setClip(_clip);
return true;
}
}
示例10: guard
void GraphicsManager::RenderTexture (const std::string& id, int srcLeft, int srcTop, int srcRight, int srcBottom, int dstLeft, int dstTop, int dstRight, int dstBottom)
{
SDL_Rect* srcRect = nullptr;
SDL_Rect* dstRect = nullptr;
ScopeGuard guard([&srcRect, &dstRect] () {
if (srcRect != nullptr) { delete srcRect; srcRect = nullptr; }
if (dstRect != nullptr) { delete dstRect; dstRect = nullptr; }
});
auto texture = Texture(id);
if (srcLeft != -1 || srcTop != -1 || srcRight != -1 || srcBottom != -1) {
srcRect = new SDL_Rect;
srcRect->x = srcLeft;
srcRect->y = srcTop;
srcRect->w = srcRight - srcLeft;
srcRect->h = srcBottom - srcTop;
}
if (dstLeft != -1 || dstTop != -1 || dstRight != -1 || dstBottom != -1) {
dstRect = new SDL_Rect;
dstRect->x = dstLeft;
dstRect->y = dstTop;
if (dstRight != -1 || dstBottom != -1) {
dstRect->w = dstRight - dstLeft;
dstRect->h = dstBottom - dstTop;
}
else {
SDL_QueryTexture(texture, nullptr, nullptr, &dstRect->w, &dstRect->h);
}
}
SDL_RenderCopy(device, Texture(id), srcRect, dstRect);
}
示例11: Mix_LoadWAV
// Tank creation Method
Tank::Tank(SDL_Renderer *renderer, int pNum, string filePath, string audioPath, float x, float y)
{
// activate the player
active = true;
// set the player number 0 or 1
playerNum = pNum;
// set float for player speed
speed = 200.0f;
fire = Mix_LoadWAV((audioPath + "fire.wav").c_str());
// see if this is player 1, or player 2, and create the correct file path
if(playerNum == 0){
//Create the red Tank texture
playerPath = filePath + "redTank.png";
}else{
//Create the blue Tank texture
playerPath = filePath + "blueTank.png";
}
// load the surface into the texture
texture = IMG_LoadTexture(renderer, playerPath.c_str());
// set the SDL_Rect X and Y for the player
posRect.x = x;
posRect.y = y;
// Use SDL_QueryTexture to get the W and H of the player's texture
int w, h;
SDL_QueryTexture(texture, NULL, NULL, &w, &h);
posRect.w = w;
posRect.h = h;
// Set the movement floats to the players original X and Y
pos_X = x;
pos_Y = y;
// set the xDir and yDir for the joysticks
xDir = 0;
yDir = 0;
// set initial values so the tank can shoot
xDirOld = 1;
yDirOld = 0;
// find the center of the texture
center.x = posRect.w/2;
center.y = posRect.h/2;
// String to create the path to the player's bullet image
string bulletPath;
// see if this is player 1, or player 2, and create the correct file path
if(playerNum == 0){
//Create the bullet 1 texture
bulletPath = filePath + "redBullet.png";
}else{
//Create the bullet 2 texture
bulletPath = filePath + "blueBullet.png";
}
//Create the player's bullet pool
for (int i = 0; i < 10; i++)
{
// create the bullet and move offscreen, out of the game play area
TankBullet tmpBullet(renderer, bulletPath, -1000, -1000, 0, 0);
// add to bulletlist
bulletList.push_back(tmpBullet);
}
}
示例12: main
//.........这里部分代码省略.........
window = SDL_CreateShapedWindow("SDL_Shape test",
SHAPED_WINDOW_X, SHAPED_WINDOW_Y,
SHAPED_WINDOW_DIMENSION,SHAPED_WINDOW_DIMENSION,
0);
SDL_SetWindowPosition(window, SHAPED_WINDOW_X, SHAPED_WINDOW_Y);
if(window == NULL) {
for(i=0;i<num_pictures;i++)
SDL_FreeSurface(pictures[i].surface);
SDL_free(pictures);
SDL_VideoQuit();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape.");
exit(-4);
}
renderer = SDL_CreateRenderer(window,-1,0);
if (!renderer) {
SDL_DestroyWindow(window);
for(i=0;i<num_pictures;i++)
SDL_FreeSurface(pictures[i].surface);
SDL_free(pictures);
SDL_VideoQuit();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window.");
exit(-5);
}
for(i=0;i<num_pictures;i++)
pictures[i].texture = NULL;
for(i=0;i<num_pictures;i++) {
pictures[i].texture = SDL_CreateTextureFromSurface(renderer,pictures[i].surface);
if(pictures[i].texture == NULL) {
for(i=0;i<num_pictures;i++)
if(pictures[i].texture != NULL)
SDL_DestroyTexture(pictures[i].texture);
for(i=0;i<num_pictures;i++)
SDL_FreeSurface(pictures[i].surface);
SDL_free(pictures);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_VideoQuit();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape.");
exit(-6);
}
}
event_pending = 0;
should_exit = 0;
event_pending = SDL_PollEvent(&event);
current_picture = 0;
button_down = 0;
texture_dimensions.h = 0;
texture_dimensions.w = 0;
texture_dimensions.x = 0;
texture_dimensions.y = 0;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Changing to shaped bmp: %s", pictures[current_picture].name);
SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h);
SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
while(should_exit == 0) {
event_pending = SDL_PollEvent(&event);
if(event_pending == 1) {
if(event.type == SDL_KEYDOWN) {
button_down = 1;
if(event.key.keysym.sym == SDLK_ESCAPE) {
should_exit = 1;
break;
}
}
if(button_down && event.type == SDL_KEYUP) {
button_down = 0;
current_picture += 1;
if(current_picture >= num_pictures)
current_picture = 0;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Changing to shaped bmp: %s", pictures[current_picture].name);
SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h);
SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
}
if(event.type == SDL_QUIT)
should_exit = 1;
event_pending = 0;
}
render(renderer,pictures[current_picture].texture,texture_dimensions);
SDL_Delay(10);
}
/* Free the textures. */
for(i=0;i<num_pictures;i++)
SDL_DestroyTexture(pictures[i].texture);
SDL_DestroyRenderer(renderer);
/* Destroy the window. */
SDL_DestroyWindow(window);
/* Free the original surfaces backing the textures. */
for(i=0;i<num_pictures;i++)
SDL_FreeSurface(pictures[i].surface);
SDL_free(pictures);
/* Call SDL_VideoQuit() before quitting. */
SDL_VideoQuit();
return 0;
}
示例13: main
int
main(int argc, char *argv[])
{
int i, done;
const char *driver;
SDL_Window *window;
SDL_Texture *sprite;
int window_w, window_h;
int sprite_w, sprite_h;
SDL_Event event;
if (SDL_VideoInit(NULL, 0) < 0) {
fprintf(stderr, "Couldn't initialize SDL video: %s\n",
SDL_GetError());
exit(1);
}
driver = SDL_GetCurrentVideoDriver();
/* Find a native window driver and create a native window */
for (i = 0; factories[i]; ++i) {
if (SDL_strcmp(driver, factories[i]->tag) == 0) {
factory = factories[i];
break;
}
}
if (!factory) {
fprintf(stderr, "Couldn't find native window code for %s driver\n",
driver);
quit(2);
}
printf("Creating native window for %s driver\n", driver);
native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H);
if (!native_window) {
fprintf(stderr, "Couldn't create native window\n");
quit(3);
}
window = SDL_CreateWindowFrom(native_window);
if (!window) {
fprintf(stderr, "Couldn't create SDL window: %s\n", SDL_GetError());
quit(4);
}
SDL_SetWindowTitle(window, "SDL Native Window Test");
/* Create the renderer */
if (SDL_CreateRenderer(window, -1, 0) < 0) {
fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
quit(5);
}
/* Clear the window, load the sprite and go! */
SDL_SelectRenderer(window);
SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear();
sprite = LoadSprite(window, "icon.bmp");
if (!sprite) {
quit(6);
}
/* Allocate memory for the sprite info */
SDL_GetWindowSize(window, &window_w, &window_h);
SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h);
positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
if (!positions || !velocities) {
fprintf(stderr, "Out of memory!\n");
quit(2);
}
srand(time(NULL));
for (i = 0; i < NUM_SPRITES; ++i) {
positions[i].x = rand() % (window_w - sprite_w);
positions[i].y = rand() % (window_h - sprite_h);
positions[i].w = sprite_w;
positions[i].h = sprite_h;
velocities[i].x = 0;
velocities[i].y = 0;
while (!velocities[i].x && !velocities[i].y) {
velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
}
}
/* Main render loop */
done = 0;
while (!done) {
/* Check for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_EXPOSED:
SDL_SelectRenderer(event.window.windowID);
SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear();
break;
}
break;
case SDL_QUIT:
done = 1;
break;
//.........这里部分代码省略.........
示例14: glGenVertexArrays
int BEE::Background::load_from_surface(SDL_Surface* tmp_surface) {
if (!is_loaded) {
if (game->options->renderer_type != BEE_RENDERER_SDL) {
width = tmp_surface->w;
height = tmp_surface->h;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
GLfloat texcoords[] = {
0.0, 0.0,
1.0, 0.0,
1.0, 1.0,
0.0, 1.0,
};
glGenBuffers(1, &vbo_texcoords);
glBindBuffer(GL_ARRAY_BUFFER, vbo_texcoords);
glBufferData(GL_ARRAY_BUFFER, sizeof(texcoords), texcoords, GL_STATIC_DRAW);
GLfloat vertices[] = {
0.0, 0.0,
(GLfloat)width, 0.0,
(GLfloat)width, (GLfloat)height,
0.0, (GLfloat)height,
};
glGenBuffers(1, &vbo_vertices);
glBindBuffer(GL_ARRAY_BUFFER, vbo_vertices);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
GLushort elements[] = {
0, 1, 2,
2, 3, 0,
};
glGenBuffers(1, &ibo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW);
glEnableVertexAttribArray(game->vertex_location);
glBindBuffer(GL_ARRAY_BUFFER, vbo_vertices);
glVertexAttribPointer(
game->vertex_location,
2,
GL_FLOAT,
GL_FALSE,
0,
0
);
glGenTextures(1, &gl_texture);
glBindTexture(GL_TEXTURE_2D, gl_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_RGBA,
width,
height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
tmp_surface->pixels
);
glBindVertexArray(0);
is_loaded = true;
has_draw_failed = false;
} else {
texture = SDL_CreateTextureFromSurface(game->renderer, tmp_surface);
if (texture == nullptr) {
game->messenger_send({"engine", "background"}, BEE_MESSAGE_WARNING, "Failed to create texture from surface: " + get_sdl_error());
return 1;
}
SDL_QueryTexture(texture, nullptr, nullptr, &width, &height);
is_loaded = true;
has_draw_failed = false;
}
} else {
game->messenger_send({"engine", "background"}, BEE_MESSAGE_WARNING, "Failed to load background from surface because it has already been loaded");
return 1;
}
return 0;
}
示例15: main
int main(int argc, const char * argv[])
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
std::cout << "SDL init error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Window *win = SDL_CreateWindow("SpaceThing", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
if (win == nullptr) {
std::cout << "SDL create window error: " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}
SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == nullptr) {
SDL_DestroyWindow(win);
std::cout << "SDL create renderer error: " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}
char * basePath = SDL_GetBasePath();
std::string imagePath = std::string(basePath) + "Assets/farback.gif";
std::cout << "Image path is: " << imagePath << std::endl;
SDL_Surface *bg = IMG_Load(imagePath.c_str());
if (bg == nullptr) {
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
std::cout << "SDL load bmp error loading background: " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}
SDL_free(basePath);
SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, bg);
SDL_FreeSurface(bg);
if (tex == nullptr) {
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
std::cout << "SDL create background texture error: " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}
int w, h;
SDL_QueryTexture(tex, nullptr, nullptr, &w, &h);
SDL_Event e;
bool quit = false;
while (!quit) {
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
quit = true;
}
}
// Render the scene
SDL_RenderClear(ren);
SDL_Rect dst;
dst.x = 0;
dst.y = 0;
dst.w = w;
dst.h = h;
SDL_RenderCopy(ren, tex, nullptr, &dst);
SDL_RenderPresent(ren);
}
SDL_DestroyTexture(tex);
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
std::cout << "SDL Sample Exiting\n";
return 0;
}