c++ - SDL Window Not Appearing -


i'm trying sdl window appear, doesn't seem working. program run, , function show window run no errors, nothing shows on screen. have icon in dock says program not responding. here's code:

int main(int argc, const char * argv[]) {      maincomponent maincomponent;     maincomponent.init();      char myvar;      cout << "enter key quit...";     cin >> myvar;      return 0; }  void maincomponent::init() {     //initialize sdl     sdl_init(sdl_init_everything);      window = sdl_createwindow("my game window", 100, 100, 100, 100, sdl_window_shown);      cout << screenwidth << " " << screenheight << endl;      if(window == nullptr) {         cout << "error not create window" << sdl_geterror() << endl;     }      sdl_delay(5000);  } 

here's screenshot of icon on dock https://www.dropbox.com/s/vc01iqp0z07zs25/screenshot%202016-02-02%2017.26.44.png?dl=0 let me know if there's i'm doing wrong, thanks!

sdl_renderer should initialized handle rendering. explained in detailed here what sdl renderer?.

here's modified code above initialized renderer;

#include <sdl2/sdl.h> #include <iostream>  using namespace std;  class maincomponent {  public:     void init();     ~maincomponent();   private:     sdl_window *window;     sdl_renderer* renderer; };  maincomponent::~maincomponent() {   sdl_destroyrenderer(renderer);   sdl_destroywindow(window); }  void maincomponent::init() {     //initialize sdl     sdl_init(sdl_init_everything);      int screenwidth = 400;     int screenheight = 300;      window = sdl_createwindow("my game window", 100, 100, screenwidth, screenheight, sdl_window_shown);     renderer = sdl_createrenderer(window, -1, 0);      cout << screenwidth << " " << screenheight << endl;      if(window == nullptr) {         cout << "error not create window" << sdl_geterror() << endl;     }      //change background color     sdl_setrenderdrawcolor(renderer, 255, 0, 0, 255);      // clear entire screen our selected color.     sdl_renderclear(renderer);      // until drawn behind scenes.     // show new, red contents of window.     sdl_renderpresent(renderer);       sdl_delay(5000);  }   int main(int argc, const char * argv[]) {      maincomponent maincomponent;     maincomponent.init();      char myvar;      cout << "enter key quit...";     cin >> myvar;      sdl_quit();     return 0; } 

this should compile , run properly. hope helps.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -