Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.37 KB | None | 0 0
  1.  
  2. ////////////////////////////////////////////////////////////
  3. // Headers
  4. ////////////////////////////////////////////////////////////
  5. #include <SFML/Graphics.hpp>
  6. #include <X11/Xlib.h>
  7. #include <X11/Xutil.h>
  8. #include <GL/gl.h>
  9. #include <GL/glu.h>
  10. #include <iostream>
  11.  
  12. unsigned long buffer[] = {
  13. 16u, 16,
  14. 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 338034905u, 3657433343u, 0u, 184483840u, 234881279u, 3053453567u, 3221225727u, 1879048447u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1224737023u, 3305111807u, 3875537151u,0u, 0u, 2063597823u, 1291845887u, 0u, 67109119u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 50266112u, 3422552319u, 0u, 0u, 3070230783u, 2063597823u, 2986344703u, 771752191u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 3422552319u, 0u, 0u, 3372220671u, 1509949695u, 704643327u, 3355443455u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 0u, 3422552319u, 0u, 134152192u, 3187671295u, 251658495u, 0u, 3439329535u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 3422552319u, 0u, 0u, 2332033279u, 1342177535u, 167772415u, 3338666239u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 0u, 3422552319u, 0u, 0u, 436207871u, 3322085628u, 3456106751u, 1375731967u, 4278255360u, 4026597120u, 3758161664u, 3489726208u, 3204513536u, 2952855296u, 2684419840u, 2399207168u, 2130771712u, 1845559040u, 1593900800u, 1308688128u, 1040252672u, 755040000u, 486604544u, 234946304u, 4278255360u, 4043374336u, 3774938880u, 3506503424u, 3221290752u, 2952855296u, 2667642624u, 2399207168u, 2130771712u, 1862336256u, 1627453957u, 1359017481u, 1073805064u, 788591627u, 503379721u, 218169088u, 4278255360u, 4043374336u, 3758161664u, 3506503424u, 3221290752u, 2952855296u, 2684419840u, 2415984384u, 2130771712u, 1862336256u, 1577123584u, 1308688128u, 1040252672u, 755040000u, 486604544u, 218169088u, 4278190335u, 4026532095u, 3758096639u, 3489661183u, 3221225727u, 2952790271u, 2667577599u, 2415919359u, 2130706687u, 1862271231u, 1593835775u, 1325400319u, 1056964863u, 771752191u, 520093951u, 234881279u, 4278190335u, 4026532095u, 3758096639u, 3489661183u, 3221225727u, 2952790271u, 2667577599u, 2415919359u, 2130706687u, 1862271231u, 1593835775u, 1325400319u, 1056964863u, 771752191u, 503316735u, 234881279u, 4278190335u, 4026532095u, 3758096639u, 3489661183u, 3221225727u, 2952790271u, 2684354815u, 2399142143u, 2130706687u, 1862271231u, 1593835775u, 1325400319u, 1040187647u, 771752191u, 520093951u, 234881279u, 4294901760u, 4043243520u, 3774808064u, 3506372608u, 3221159936u, 2952724480u, 2684289024u, 2399076352u, 2147418112u, 1862205440u, 1593769984u, 1308557312u, 1040121856u, 771686400u, 503250944u, 234815488u, 4294901760u, 4060020736u, 3758030848u, 3506372608u, 3221159936u, 2952724480u, 2684289024u, 2415853568u, 2130640896u, 1862205440u, 1593769984u, 1308557312u, 1040121856u, 771686400u, 503250944u, 234815488u, 4294901760u, 4043243520u, 3774808064u, 3489595392u, 3237937152u, 2952724480u, 2684289024u, 2415853568u, 2147418112u, 1862205440u, 1593769984u, 1325334528u, 1056899072u, 788463616u, 503250944u, 234815488,
  15.  
  16. 32u, 32,
  17. 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 268369920u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 1509949695u, 3120562431u, 4009754879u, 4194304255u, 3690987775u, 2130706687u, 83886335u, 0u, 50331903u, 1694499071u, 3170894079u, 3992977663u, 4211081471u, 3657433343u, 1879048447u, 16777471u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 3087007999u, 2281701631u, 1191182591u, 1040187647u, 2030043391u, 4127195391u, 2566914303u, 0u, 16777471u, 3254780159u, 2181038335u, 1191182591u, 973078783u, 2030043391u,4177527039u, 2130706687u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 0u, 0u, 0u, 0u, 0u, 2214592767u, 4093640959u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 2298478847u, 3909091583u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 2214592767u, 3607101695u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1946157311u, 4093640959u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 0u, 0u, 536871167u, 1191182591u, 2281701631u,3019899135u, 637534463u, 0u, 0u, 0u, 100597760u, 251592704u, 33488896u, 0u, 3321889023u, 2919235839u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 2550137087u, 4278190335u, 4278190335u, 3405775103u, 570425599u, 0u, 0u, 0u, 0u, 0u, 0u, 2046820607u, 4043309311u, 620757247u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 33488896u, 0u, 0u, 218104063u, 1291845887u, 3841982719u, 3388997887u, 0u, 0u, 0u, 0u, 0u, 1996488959u, 4093640959u, 1073742079u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1761607935u, 4278190335u, 150995199u, 0u, 0u, 67109119u, 2550137087u, 3909091583u, 889192703u, 0u, 0u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 0u, 0u, 0u, 0u, 0u, 2181038335u, 3925868799u, 0u, 0u, 218104063u, 3070230783u, 3623878911u, 570425599u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 805306623u, 3288334591u, 1795162367u, 1040187647u, 1023410431u, 2231369983u, 4211081471u, 1694499071u, 0u, 369099007u, 3456106751u, 3825205503u, 1174405375u, 872415487u, 872415487u, 872415487u, 872415487u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4293984270u, 2046951677u, 3422552319u, 4110418175u, 4177527039u, 3405775103u, 1409286399u, 0u, 0u, 1409286399u, 4278190335u, 4278190335u, 4278190335u, 4278190335u, 4278190335u, 4278190335u, 4278190335u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u,4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 4294901760u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0,0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4278255360u, 4144037632u, 4009819904u, 3875602176u, 3741384448u, 3607166720u, 3472948992u, 3338731264u, 3204513536u, 3053518592u, 2936078080u, 2801860352u, 2650865408u, 2516647680u, 2382429952u, 2264989440u, 2113994496u, 1996553984u, 1862336256u, 1728118528u, 1577123584u, 1459683072u, 1325465344u, 1191247616u, 1040252672u, 922812160u, 771817216u, 637599488u, 503381760u, 385941248u, 234946304u, 100728576u, 4278255360u, 4144037632u, 4009819904u, 3875602176u, 3724607232u, 3607166720u, 3472948992u, 3338731264u, 3204513536u, 3070295808u, 2936078080u, 2801860352u, 2667642624u, 2516647680u, 2399207168u, 2264989440u, 2130771712u, 1996553984u, 1845559040u, 1728118528u, 1593900800u, 1459683072u, 1308688128u, 1191247616u, 1057029888u, 922812160u, 788594432u, 637599488u, 503381760u, 369164032u, 234946304u, 117505792u, 4278255360u, 4144037632u, 4009819904u, 3875602176u, 3741384448u, 3607166720u, 3472948992u, 3338731264u, 3204513536u, 3053518592u, 2919300864u, 2801860352u, 2650865408u, 2533424896u, 2399207168u, 2264989440u, 2113994496u, 1996553984u, 1862336256u, 1728118528,1593900800u, 1459683072u, 1325465344u, 1191247616u, 1040252672u, 906034944u, 771817216u, 654376704u, 503381760u, 369164032u, 234946304u, 117505792u, 4278255360u, 4144037632u, 4009819904u, 3858824960u, 3741384448u, 3607166720u, 3472948992u, 3338731264u, 3204513536u, 3070295808u, 2936078080u, 2801860352u, 2667642624u, 2533424896u, 2382429952u, 2264989440u, 2130771712u, 1979776768u, 1862336256u, 1728118528u, 1577123584u, 1442905856u, 1325465344u, 1191247616u, 1040252672u, 922812160u, 771817216u, 637599488u, 503381760u, 369164032u, 234946304u, 100728576u, 4278255360u, 4144037632u, 4009819904u, 3875602176u, 3741384448u, 3607166720u, 3472948992u, 3338731264u, 3204513536u, 3070295808u, 2919300864u, 2801860352u, 2667642624u, 2533424896u, 2399207168u, 2264989440u, 2113994496u, 1996553984u, 1862336256u, 1728118528u, 1593900800u, 1442905856u, 1342241795u, 1174470400u, 1057029888u, 906034944u, 788594432u, 654376704u, 503381760u, 385941248u, 251723520u, 100728576u, 4278190335u, 4160749823u, 4026532095u, 3892314367u, 3741319423u, 3623878911u, 3472883967u, 3338666239u, 3221225727u, 3070230783u, 2952790271u, 2818572543u, 2667577599u, 2533359871u, 2399142143u, 2264924415u, 2147483903u, 1996488959u, 1862271231u, 1728053503u, 1593835775u, 1459618047u, 1325400319u, 1191182591u, 1056964863u, 922747135u, 788529407u, 654311679u, 520093951,385876223u, 251658495u, 117440767u, 4278190335u, 4160749823u, 4026532095u, 3892314367u, 3741319423u, 3623878911u, 3489661183u, 3355443455u, 3221225727u, 3087007999u, 2936013055u, 2801795327u, 2667577599u, 2533359871u, 2399142143u, 2281701631u, 2130706687u, 1996488959u, 1862271231u, 1728053503u, 1593835775,1459618047u, 1325400319u, 1191182591u, 1056964863u, 922747135u, 788529407u, 654311679u, 520093951u, 385876223u, 234881279u, 100663551u, 4278190335u, 4160749823u, 4026532095u, 3892314367u, 3758096639u, 3623878911u, 3489661183u, 3355443455u, 3221225727u, 3087007999u, 2936013055u, 2801795327u, 2667577599u, 2550137087u, 2415919359u, 2264924415u, 2130706687u, 1996488959u, 1862271231u, 1728053503u, 1593835775u, 1459618047u, 1325400319u, 1191182591u, 1056964863u, 922747135u, 788529407u, 654311679u, 503316735u, 369099007u, 251658495u, 100663551u, 4278190335u, 4160749823u, 4026532095u, 3892314367u, 3758096639u, 3623878911u, 3489661183u, 3355443455u, 3204448511u, 3087007999u, 2936013055u, 2818572543u, 2667577599u, 2533359871u, 2399142143u, 2264924415u, 2130706687u, 1996488959u, 1879048447u, 1728053503u, 1593835775u, 1459618047u, 1325400319u, 1191182591u, 1056964863u, 922747135u, 788529407u, 654311679u, 520093951u, 385876223u, 251658495u, 117440767u, 4278190335u, 4160749823u, 4026532095u, 3892314367u, 3758096639u, 3623878911u, 3489661183u, 3355443455u, 3221225727u, 3087007999u, 2952790271u, 2818572543u, 2667577599u, 2533359871u, 2399142143u, 2264924415u, 2147483903u, 2013266175u, 1862271231u, 1744830719u, 1610612991u, 1476395263u, 1342177535u, 1191182591u, 1056964863u, 922747135u, 788529407u, 654311679u, 520093951u, 385876223u, 251658495u, 100663551u, 4294901760u, 4160684032u, 4026466304u, 3909025792u, 3774808064u, 3623813120u, 3489595392u, 3355377664u, 3237937152u, 3103719424u, 2952724480u, 2818506752u, 2684289024u, 2550071296u, 2415853568u, 2281635840u, 2147418112u, 2013200384u, 1878982656u, 1744764928u, 1593769984u, 1476329472,1325334528u, 1207894016u, 1056899072u, 939458560u, 788463616u, 654245888u, 520028160u, 385810432u, 251592704u, 117374976u, 4294901760u, 4177461248u, 4043243520u, 3909025792u, 3774808064u, 3640590336u, 3506372608u, 3355377664u, 3221159936u, 3086942208u, 2952724480u, 2818506752u, 2701066240u, 2550071296u, 2415853568u, 2281635840u, 2147418112u, 2013200384u, 1878982656u, 1727987712u, 1610547200u, 1476329472u, 1325334528u, 1191116800u, 1073676288u, 922681344u, 788463616u, 654245888u, 520028160u, 385810432u, 251592704u, 100597760u, 4294901760u, 4177461248u, 4043243520u, 3909025792u, 3774808064u, 3640590336u, 3489595392u, 3372154880u, 3237937152u, 3103719424u, 2952724480u, 2818506752u, 2700935170u, 2550071296u, 2415853568u, 2281635840u, 2147418112u, 2013200384u, 1878982656u, 1744764928u, 1610547200u, 1459552256u, 1342111744u, 1191116800u, 1056899072u, 922681344u, 788463616u, 671023104u, 520028160u, 385810432u, 251592704u, 100597760u, 4294901760u, 4177461248u, 4043243520u, 3909025792u, 3774808064u, 3640590336u, 3489595392u, 3372154880u, 3237937152u, 3086942208u, 2969501696u, 2818506752u, 2684289024u, 2550071296u, 2432630784u, 2281635840u, 2147418112u, 2013200384u, 1862205440u, 1744764928u, 1610547200u, 1476329472u, 1342111744u, 1191116800u, 1056899072u, 922681344u, 788463616u, 654245888u, 520028160u, 385810432u, 251592704u, 117374976u, 4294901760u, 4177461248u, 4043243520u, 3909025792u, 3774808064u, 3623813120u, 3506372608u, 3372154880u, 3237937152u, 3103719424u, 2952724480u, 2835283968u, 2684289024u, 2550071296u, 2432630784u, 2281635840u, 2147418112u, 2046492676u, 1862205440u, 1744764928u, 1610547200u, 1476329472u, 1342111744,1207894016u, 1056899072u, 939458560u, 788463616u, 654245888u, 536281096u, 385810432u, 251592704u, 134152192u,
  18.  
  19. };
  20.  
  21.  
  22. ////////////////////////////////////////////////////////////
  23. /// Initialize OpenGL states into the specified view
  24. ///
  25. /// \param Window Target window to initialize
  26. ///
  27. ////////////////////////////////////////////////////////////
  28. void initialize(sf::Window& window)
  29. {
  30. // Activate the window
  31. window.setActive();
  32.  
  33. // Setup OpenGL states
  34. // Set color and depth clear value
  35. glClearDepth(1.f);
  36. glClearColor(0.f, 0.5f, 0.5f, 0.f);
  37.  
  38. // Enable Z-buffer read and write
  39. glEnable(GL_DEPTH_TEST);
  40. glDepthMask(GL_TRUE);
  41.  
  42. // Setup a perspective projection
  43. glMatrixMode(GL_PROJECTION);
  44. glLoadIdentity();
  45. gluPerspective(90.f, 1.f, 1.f, 500.f);
  46. }
  47.  
  48. ////////////////////////////////////////////////////////////
  49. /// Draw the OpenGL scene (a rotating cube) into
  50. /// the specified view
  51. ///
  52. /// \param window Target window for rendering
  53. /// \param elapsedTime Time elapsed since the last draw
  54. ///
  55. ////////////////////////////////////////////////////////////
  56. void draw(sf::Window& window, float elapsedTime)
  57. {
  58. // Activate the window
  59. window.setActive();
  60.  
  61. // Clear color and depth buffers
  62. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  63.  
  64. // Apply some transformations
  65. glMatrixMode(GL_MODELVIEW);
  66. glLoadIdentity();
  67. glTranslatef(0.f, 0.f, -200.f);
  68. glRotatef(elapsedTime * 0.05f, 1.f, 0.f, 0.f);
  69. glRotatef(elapsedTime * 0.03f, 0.f, 1.f, 0.f);
  70. glRotatef(elapsedTime * 0.09f, 0.f, 0.f, 1.f);
  71.  
  72. // Draw a cube
  73. glBegin(GL_QUADS);
  74.  
  75. glColor3f(1.f, 1.f, 0.f);
  76. glVertex3f(-50.f, -50.f, -50.f);
  77. glVertex3f(-50.f, 50.f, -50.f);
  78. glVertex3f( 50.f, 50.f, -50.f);
  79. glVertex3f( 50.f, -50.f, -50.f);
  80.  
  81. glColor3f(1.f, 1.f, 0.f);
  82. glVertex3f(-50.f, -50.f, 50.f);
  83. glVertex3f(-50.f, 50.f, 50.f);
  84. glVertex3f( 50.f, 50.f, 50.f);
  85. glVertex3f( 50.f, -50.f, 50.f);
  86.  
  87. glColor3f(0.f, 1.f, 1.f);
  88. glVertex3f(-50.f, -50.f, -50.f);
  89. glVertex3f(-50.f, 50.f, -50.f);
  90. glVertex3f(-50.f, 50.f, 50.f);
  91. glVertex3f(-50.f, -50.f, 50.f);
  92.  
  93. glColor3f(0.f, 1.f, 1.f);
  94. glVertex3f(50.f, -50.f, -50.f);
  95. glVertex3f(50.f, 50.f, -50.f);
  96. glVertex3f(50.f, 50.f, 50.f);
  97. glVertex3f(50.f, -50.f, 50.f);
  98.  
  99. glColor3f(1.f, 0.f, 1.f);
  100. glVertex3f(-50.f, -50.f, 50.f);
  101. glVertex3f(-50.f, -50.f, -50.f);
  102. glVertex3f( 50.f, -50.f, -50.f);
  103. glVertex3f( 50.f, -50.f, 50.f);
  104.  
  105. glColor3f(1.f, 0.f, 1.f);
  106. glVertex3f(-50.f, 50.f, 50.f);
  107. glVertex3f(-50.f, 50.f, -50.f);
  108. glVertex3f( 50.f, 50.f, -50.f);
  109. glVertex3f( 50.f, 50.f, 50.f);
  110.  
  111. glEnd();
  112. }
  113.  
  114.  
  115. ////////////////////////////////////////////////////////////
  116. /// Entry point of application
  117. ///
  118. /// \return Error code
  119. ///
  120. ////////////////////////////////////////////////////////////
  121. int main()
  122. {
  123. // Open a connection with the X server
  124. Display* display = XOpenDisplay(NULL);
  125. if (!display)
  126. return EXIT_FAILURE;
  127.  
  128. // Get the default screen
  129. int screen = DefaultScreen(display);
  130.  
  131. // Let's create the main window
  132. XSetWindowAttributes attributes;
  133. attributes.background_pixel = BlackPixel(display, screen);
  134. attributes.event_mask = KeyPressMask;
  135. Window window = XCreateWindow(display, RootWindow(display, screen),
  136. 0, 0, 650, 330, 0,
  137. DefaultDepth(display, screen),
  138. InputOutput,
  139. DefaultVisual(display, screen),
  140. CWBackPixel | CWEventMask, &attributes);
  141.  
  142. Atom net_wm_icon = XInternAtom(display, "_NET_WM_ICON", False);
  143. Atom cardinal = XInternAtom(display, "CARDINAL", False);
  144. int length = 2 + 16 * 16 + 2 + 32 * 32;
  145. XChangeProperty(display, window, net_wm_icon, cardinal, 32, PropModeReplace, (const unsigned char*) buffer, length);
  146.  
  147. if (!window)
  148. return EXIT_FAILURE;
  149.  
  150. // Set the window's name
  151. XStoreName(display, window , "SFML Window");
  152.  
  153. // Let's create the windows which will serve as containers for our SFML views
  154. Window view1 = XCreateWindow(display, window,
  155. 10, 10, 310, 310, 0,
  156. DefaultDepth(display, screen),
  157. InputOutput,
  158. DefaultVisual(display, screen),
  159. 0, NULL);
  160. Window view2 = XCreateWindow(display, window,
  161. 330, 10, 310, 310, 0,
  162. DefaultDepth(display, screen),
  163. InputOutput,
  164. DefaultVisual(display, screen),
  165. 0, NULL);
  166.  
  167. // Show our windows
  168. XMapWindow(display, window);
  169. XFlush(display);
  170.  
  171. // Create our SFML views
  172. sf::Window SFMLView1(view1);
  173. sf::Window SFMLView2(view2);
  174.  
  175. // Create a clock for measuring elapsed time
  176. sf::Clock clock;
  177.  
  178. // Initialize our views
  179. initialize(SFMLView1);
  180. initialize(SFMLView2);
  181.  
  182. // Start the event loop
  183. bool running = true;
  184. while (running)
  185. {
  186. while (XPending(display))
  187. {
  188. // Get the next pending event
  189. XEvent event;
  190. XNextEvent(display, &event);
  191.  
  192. // Process it
  193. switch (event.type)
  194. {
  195. case sf::Event::Closed :
  196. running = false;
  197. break;
  198. }
  199. }
  200.  
  201. // Draw something into our views
  202. draw(SFMLView1, clock.getElapsedTime().asSeconds());
  203. draw(SFMLView2, clock.getElapsedTime().asSeconds() * 0.3f);
  204.  
  205. // Display the views on screen
  206. SFMLView1.display();
  207. SFMLView2.display();
  208. }
  209.  
  210. // Close the display
  211. XCloseDisplay(display);
  212.  
  213. return EXIT_SUCCESS;
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement