c++ - Image not showing up in SDL -


when run shows black screen, , if put sdl_geterror() @ end prints blank line.....

any ideas on how fix this?

#include <sdl2/sdl.h> #include <sdl2/sdl_image.h> #include <iostream>  class character {  public: sdl_rect src, cur; public: sdl_texture *image;  void setsrc(int x, int y, int w, int h) {      src.x = x;     src.y = y;     src.w = w;     src.h = h;  }  void setcur(int x, int y, int w, int h) {      src.x = x;     src.y = y;     src.w = w;     src.h = h;  }  };    int main(int argc, char* argv[]) {  bool in = true; character p1, p2, ball;  sdl_window *window = 0; sdl_renderer *renderer = 0; sdl_surface *screen, *imageloader;  sdl_init(sdl_init_video);  window = sdl_createwindow("pong",sdl_windowpos_centered,sdl_windowpos_centered, 800, 600, sdl_window_shown);  renderer = sdl_createrenderer(window, -1, 0);  p1.setsrc(0, 0, 100, 500); p1.setcur(0, 0, 100, 500);  imageloader = img_load("/home/donaldo/documents/games/images/player.bmp");  p1.image = sdl_createtexturefromsurface(renderer, imageloader);  sdl_rendercopy(renderer, p1.image, &p1.src, &p1.cur);  sdl_renderpresent(renderer);  sdl_delay(3000);  return 0; 

}

you have typo in setcur() function. assume want setting cur rectangle, not src again.

also, not related it's practice free surface , texture allocated when you're done them.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -