.[ ČeskéHry.cz ].

Laboratoř ČeskýchHer.cz - PasteBin

Vložit nový kód

ČeskéHry.cz - KOMUNITA HERNÍCH VÝVOJÁŘŮ

  1. Morgan Freeman CBD Gummies: Science-Backed Relief for Pain
    1 hod
  2. ASAS
    2 hod
  3. SAS
    3 hod
  4. gg
    3 hod
  5. FDKJJK
    3 hod
  6. vdavdgvrwg
    4 hod
  7. FGGFG
    4 hod
  8. Watch Full 123Movie Streaming Online Free Download
    4 hod
  9. FullCP
    5 hod
  10. FullCP
    5 hod
Link: http://nopaste.ceske-hry.cz/subdom/nopaste223040
Zaslal: frca
Jazyk: C++
Vloženo: 23.5.2010, 15:43
Stáhnout jako soubor
  1. #include <cstdlib>
  2. #include <SDL/SDL.h>
  3.  
  4. /* pokus by frca */
  5.  
  6.  
  7.  
  8. float getdeltaT()
  9.  
  10. {
  11.  
  12. static bool bfirstrun = true;
  13.  
  14. static double tm_prev;
  15.  
  16. if (bfirstrun)
  17.  
  18. {
  19.  
  20. tm_prev = double(SDL_GetTicks())*0.001;
  21.  
  22. bfirstrun = false;
  23.  
  24. return 0.f;
  25.  
  26. }
  27.  
  28. double tm_now = double(SDL_GetTicks())*0.001;
  29.  
  30. double deltaT = tm_now-tm_prev;
  31.  
  32. tm_prev = tm_now;
  33.  
  34. if (deltaT < 0.0)
  35.  
  36. return 0.0;
  37.  
  38. return deltaT;
  39.  
  40. }
  41.  
  42. int main ( int argc, char** argv )
  43. {
  44. // initialize SDL video
  45. if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
  46. {
  47. printf( "Unable to init SDL: %s\n", SDL_GetError() );
  48. return 1;
  49. }
  50.  
  51. // make sure SDL cleans up before exit
  52. atexit(SDL_Quit);
  53.  
  54. // create a new window
  55. SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16,
  56. SDL_HWSURFACE|SDL_DOUBLEBUF);
  57. if ( !screen )
  58. {
  59. printf("Unable to set 640x480 video: %s\n", SDL_GetError());
  60. return 1;
  61. }
  62. SDL_Event event;
  63. bool firstdraw = true;
  64. //SDL_EventState(SDL_VIDEOEXPOSE, SDL_ENABLE);
  65. while (SDL_WaitEvent(&event))
  66. {
  67. bool done = false;
  68. bool exposed = false;
  69. switch (event.type)
  70. {
  71. // exit if the window is closed
  72. case SDL_QUIT:
  73. done = true;
  74. break;
  75. // check for keypresses
  76. case SDL_KEYDOWN:
  77. {
  78. // exit if ESCAPE is pressed
  79. if (event.key.keysym.sym == SDLK_ESCAPE)
  80. done = true;
  81. break;
  82. }
  83. case SDL_VIDEOEXPOSE:
  84. {
  85. exposed = true;
  86. printf("exposed ");
  87. }
  88. break;
  89. } // end switch
  90. if (done)
  91. break;
  92. if (firstdraw) {
  93. // clear screen
  94. SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 255, 0));
  95. firstdraw = false;
  96. // finally, update the screen :)
  97. printf("sdl_flip ");
  98. SDL_Flip(screen);
  99. }
  100.  
  101. // DRAWING ENDS HERE
  102.  
  103. }
  104. // all is well ;)
  105. return 0;
  106. }
  107.