Advertisement
ITE_Man

Untitled

Jan 8th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.83 KB | None | 0 0
  1. #include <windows.h> // Header File For Windows
  2. #include <gl.h> // Header File For The OpenGL32 Library
  3. #include <glu.h> // Header File For The GLu32 Library
  4. #include <glaux.h> // Header File For The Glaux Library
  5. #include <cmath>
  6. #include "GLTexture.h"
  7. #include "Model_3DS.h"
  8. #include <texture.h>
  9. #include "Building.h"
  10. #include "wall.h"
  11. #include "camera.h"
  12. #include "FootballField.h"
  13. #include "Ground.h"
  14. #include "Mall.h"
  15. //#include "Sound.h"
  16.  
  17.  
  18. FootballField Store(400, 125, 250);
  19. FootballField Store2(60, 18, 30);
  20. FootballField Build1(275, 175, 500);
  21. FootballField Build2(275, 170, 500);
  22. FootballField Build3(600, 150, 300);
  23. FootballField Build4(350, 175, 550);
  24. FootballField Build5(800, 150, 200);
  25. FootballField Build5Floor2(800, 150, 200);
  26. FootballField Build6(275, 170, 500);
  27. FootballField KShop1(800, 325, 250);
  28. FootballField KShop2(400, 325, 250);
  29. FootballField KShop3(800, 325, 250);
  30. FootballField KShop4(380, 325, 250);
  31. FootballField KShop5(400, 325, 250);
  32. FootballField KShop6(380, 325, 250);
  33. FootballField KShop7(380, 325, 250);
  34. FootballField KShopWall(400, 20, 250);
  35. FootballField Floor2(380, 50, 75);
  36. //first WIDTH second IS LENGTH THIRD HIEGHT 845is height of the second floor
  37. Mall MyMall(3720, 2500, 1350);
  38. wall MallWall;
  39. wall MallWall2;
  40. Mall GunStore(500, 300, 320);
  41. Mall BedStore(850, 600, 320);
  42. wall ModelToMall;
  43. wall GroundRoad;
  44. wall WallToStore;
  45. int HondaBlack;
  46. Model_3DS Mosc;
  47. FootballField ii(20, 20, 50);
  48.  
  49.  
  50.  
  51. Camera camera;
  52.  
  53. HDC hDC = NULL; // Private GDI Device Context
  54. HGLRC hRC = NULL; // Permanent Rendering Cntext
  55. HWND hWnd = NULL; // Holds Our Window Handle
  56. HINSTANCE hInstance; // Holds The Instance Of The Application
  57.  
  58. bool keys[256]; // Array Used For The Keyboard Routine
  59. bool active = TRUE; // Window Active Flag Set To TRUE By Default
  60. bool fullscreen = FALSE; // Fullscreen Flag Set To Fullscreen Mode By Default
  61.  
  62. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
  63.  
  64.  
  65. GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
  66. {
  67. if (height == 0) // Prevent A Divide By Zero By
  68. {
  69. height = 1; // Making Height Equal One
  70. }
  71.  
  72. glViewport(0, 0, width, height); // Reset The Current Viewport
  73.  
  74. glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
  75. glLoadIdentity(); // Reset The Projection Matrix
  76.  
  77. // Calculate The Aspect Ratio Of The Window
  78. gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 7500.0f);
  79.  
  80. glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
  81. glLoadIdentity(); // Reset The Modelview Matrix
  82. }
  83.  
  84. Model_3DS Model1, Model2, Model3, Model4, Model5, Model13, Laptop, Model6, Model12, Model11, Model7, Model8,
  85. Model10, M16, AWP, Sword, PP19, M4, glock, Honda, Honda1, Honda2, RPG, Pistol, Ch1,Conne,Bed1,Bed2,sofa1,Beroo, Sport1,Sport2,Sport3;
  86.  
  87. int elevatorH = 0, back, front, left, right, top, down;
  88. int MallFace2, Store1, SideStore, Window;
  89. int Build1Tex, SideOfBuild1, WallBack, Build2Tex;
  90. int SideOfBuild2, Store2Tex, SideOfStore2;
  91. int Build3Tex, SideOfBuild3, BackOfBuild3;
  92. int SideOfMall, Floor2Tex;
  93. int RoadTex, Cone, Shop1, Shop2, Shop3, Shop4, SecondFloor;
  94. int Raod2, Road3, Build5Floor2Tex;
  95. int Build4Tex, SideOfBuild4, Build5Tex;
  96. bool EnableSound = true;
  97. int WallSide, KshopWall, Kshop1, Kshop2, Kshop3, Kshop4, Kshop5, Kshop6, Kshop7, Kshop8; float DeafultX = 0;
  98. float xx = 0, yy = 5, zz = 0, xxx = 0, yyy = 0, zzz = 0, teta = 90, mousexx = 0, mouseyy = 0, mouseSensitivity = 0.009;
  99. float mousexxDiff = 0, mousexxCurrent = 0, mousexxPrev = 0, speed = 1.8;
  100. int mouseX = 0, mouseY = 0; bool isClicked = false, isRClicked = false;
  101.  
  102. //INIT initialize = INIT();
  103. //Sound sound;
  104. int Build6Tex, Build6Side, Baloor;
  105.  
  106. void CameraKeyBoard()
  107. {
  108. if (keys['P']) {
  109. if (EnableSound) {
  110. //sound.Stop();
  111. EnableSound = false;
  112. }
  113.  
  114. else
  115. {
  116. //sound.Play();
  117. EnableSound = true;
  118. }
  119. }
  120. /*if (keys['W']) {
  121. camera.MoveForward(2);
  122. }
  123. if (keys['D'])
  124. camera.MoveRight(2);
  125.  
  126. if (keys['A'])
  127. camera.MoveRight(-2);
  128.  
  129. if (keys['S'])
  130. camera.MoveForward(-2);*/
  131.  
  132. if (keys['E'])
  133. camera.RotateY(-1);
  134.  
  135. if (keys['Q'])
  136. camera.RotateY(1);
  137.  
  138. if (keys['U'])
  139. camera.RotateX(1);
  140.  
  141. if (keys['O'])
  142. camera.RotateX(-1);
  143.  
  144. }
  145.  
  146.  
  147.  
  148. int InitGL(GLvoid) // All Setup For OpenGL Goes Here
  149. {
  150. glShadeModel(GL_SMOOTH); // Enable Smooth Shading
  151. glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
  152. glClearDepth(1.0f); // Depth Buffer Setup
  153. glEnable(GL_DEPTH_TEST); // Enables Depth Testing
  154. glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
  155. glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
  156. //initialize.InitOpenAL();
  157. //sound = Sound("cello.wav");
  158. glEnable(GL_BLEND);
  159. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  160.  
  161. glEnable(GL_TEXTURE_2D);
  162. Shop1 = LoadTexture("Shop1.bmp");
  163. Shop2 = LoadTexture("Shop2.bmp");
  164. Shop3 = LoadTexture("Shop3.bmp");
  165. Shop4 = LoadTexture("Shop4.bmp");
  166. Cone = LoadTexture("Cone.bmp");
  167. SecondFloor = LoadTexture("SecondFloor.bmp");
  168. Build1Tex = LoadTexture("21.bmp");
  169. SideOfBuild1 = LoadTexture("SideOfBuild1.bmp");
  170. WallBack = LoadTexture("WallBack.bmp");
  171. Build2Tex = LoadTexture("FreeBuild.bmp");
  172. SideOfBuild2 = LoadTexture("SideOfBuild2.bmp");
  173. Store2Tex = LoadTexture("Store2.bmp");
  174. SideOfStore2 = LoadTexture("SideOfStore2.bmp");
  175. Build3Tex = LoadTexture("Build3.bmp");
  176. SideOfBuild3 = LoadTexture("SideOfBuild3.bmp");
  177. BackOfBuild3 = LoadTexture("BackOfBuild3.bmp");
  178. Build4Tex = LoadTexture("Build4.bmp");
  179. SideOfBuild4 = LoadTexture("SideOfBuild.bmp");
  180. Build5Tex = LoadTexture("Build6.bmp");
  181. Build5Floor2Tex = LoadTexture("Build5Floor2.bmp");
  182. SideOfMall = LoadTexture("SideOfMall1.bmp");
  183. Build6Tex = LoadTexture("SideOfBuild4.bmp");
  184. Build6Side = LoadTexture("Cone.bmp");
  185. Baloor = LoadTexture("Baloor.bmp");
  186. ////////////////////////////////////////////////
  187. Kshop1 = LoadTexture("resturant.bmp");
  188. Kshop2 = LoadTexture("Shop2.bmp");
  189. Kshop3 = LoadTexture("dress.bmp");
  190. Kshop4 = LoadTexture("shoos.bmp");
  191. Kshop5 = LoadTexture("Shop1.bmp");
  192. Kshop6 = LoadTexture("shoos3.bmp");
  193. Kshop7 = LoadTexture("resturant1.bmp");
  194. KshopWall = LoadTexture("Cone.bmp");
  195. WallSide = LoadTexture("Cone.bmp");
  196.  
  197. Floor2Tex = LoadTexture("Floor2.bmp");
  198. back = LoadTexture("back.bmp");
  199. left = LoadTexture("left.bmp");
  200. right = LoadTexture("right.bmp");
  201. top = LoadTexture("top.bmp");
  202. down = LoadTexture("down.bmp");
  203. RoadTex = LoadTexture("Road.bmp");
  204. front = LoadTexture("front.bmp");
  205. Store1 = LoadTexture("Store1.bmp");
  206. SideStore = LoadTexture("SideStore.bmp");
  207. Window = LoadTexture("Window.bmp");
  208. Cone = LoadTexture("Cone.bmp");
  209. Raod2 = LoadTexture("Road2.bmp");
  210. Road3 = LoadTexture("Road3.bmp");
  211. HondaBlack = LoadTexture("Honda7.bmp");
  212.  
  213. Store.Ws.SetTexture(Store1);
  214. Store.We.SetTexture(SideStore);
  215. Store.Ww.SetTexture(SideStore);
  216. Store.Wn.SetTexture(Baloor);
  217.  
  218. Store2.Ws.SetTexture(Store2Tex);
  219. Store2.We.SetTexture(SideOfStore2);
  220. Store2.Ww.SetTexture(SideOfStore2);
  221. Store2.Wn.SetTexture(WallBack);
  222.  
  223. Build1.Ws.SetTexture(Build1Tex);
  224. Build1.We.SetTexture(SideOfBuild1);
  225. Build1.Ww.SetTexture(SideOfBuild1);
  226. Build1.Wn.SetTexture(WallBack);
  227.  
  228. Build2.Wn.SetTexture(WallBack);
  229. Build2.Ws.SetTexture(Build2Tex);
  230. Build2.We.SetTexture(SideOfBuild2);
  231. Build2.Ww.SetTexture(SideOfBuild2);
  232.  
  233. Build3.Ws.SetTexture(Build3Tex);
  234. Build3.Ww.SetTexture(SideOfBuild3);
  235. Build3.We.SetTexture(SideOfBuild3);
  236. Build3.Wn.SetTexture(BackOfBuild3);
  237.  
  238. Build4.Ws.SetTexture(Build4Tex);
  239. Build4.We.SetTexture(SideOfBuild4);
  240. Build4.Ww.SetTexture(SideOfBuild4);
  241.  
  242. Build5.Ws.SetTexture(Build5Tex);
  243. Build5.We.SetTexture(SideOfMall);
  244. Build5.Ww.SetTexture(SideOfMall);
  245.  
  246. Build5Floor2.Ws.SetTexture(Build5Floor2Tex);
  247. Build5Floor2.We.SetTexture(SideOfMall);
  248. Build5Floor2.Ww.SetTexture(SideOfMall);
  249.  
  250. Build6.Ws.SetTexture(Build6Tex);
  251. Build6.We.SetTexture(Build6Side);
  252. Build6.Ww.SetTexture(Build6Side);
  253.  
  254.  
  255.  
  256. Floor2.Ws.SetTexture(Floor2Tex);
  257.  
  258. KShop1.Ws.SetTexture(Kshop1);
  259. KShop1.We.SetTexture(WallSide);
  260. KShop1.Ww.SetTexture(WallSide);
  261. KShop1.Wn.SetTexture(Kshop1);
  262.  
  263. KShop2.Ws.SetTexture(Kshop2);
  264. KShop2.We.SetTexture(WallSide);
  265. KShop2.Ww.SetTexture(WallSide);
  266. KShop2.Wn.SetTexture(Kshop2);
  267.  
  268. KShop3.Ws.SetTexture(Kshop3);
  269. KShop3.We.SetTexture(WallSide);
  270. KShop3.Ww.SetTexture(WallSide);
  271. KShop3.Wn.SetTexture(Kshop3);
  272.  
  273. KShop4.Ws.SetTexture(Kshop4);
  274. KShop4.We.SetTexture(WallSide);
  275. KShop4.Ww.SetTexture(WallSide);
  276. KShop4.Wn.SetTexture(Kshop4);
  277.  
  278. KShop5.Ws.SetTexture(Kshop5);
  279. KShop5.We.SetTexture(WallSide);
  280. KShop5.Ww.SetTexture(WallSide);
  281. KShop5.Wn.SetTexture(Kshop5);
  282.  
  283. KShop6.Ws.SetTexture(Kshop6);
  284. KShop6.We.SetTexture(Kshop6);
  285. KShop6.Ww.SetTexture(Kshop6);
  286. KShop6.Wn.SetTexture(Kshop6);
  287.  
  288. KShop7.Ws.SetTexture(Kshop7);
  289. KShop7.We.SetTexture(Kshop7);
  290. KShop7.Ww.SetTexture(Kshop7);
  291. KShop7.Wn.SetTexture(Kshop7);
  292.  
  293. KShopWall.Ws.SetTexture(KshopWall);
  294. KShopWall.We.SetTexture(KshopWall);
  295. KShopWall.Ww.SetTexture(KshopWall);
  296. KShopWall.Wn.SetTexture(KshopWall);
  297.  
  298.  
  299.  
  300. Bed1.Load("Bed1.3ds");
  301. Bed1.Materials[0].tex.Load("Bed1.bmp");
  302. Bed1.Materials[1].tex.Load("Bed1.bmp");
  303. Bed1.Materials[2].tex.Load("Bed2.bmp");
  304. Bed1.Materials[3].tex.Load("Bed2.bmp");
  305. Bed1.Materials[4].tex.Load("Bed3.bmp");
  306. Bed1.Materials[5].tex.Load("Bed2.bmp");
  307.  
  308. Bed2.Load("Bed2.3ds");
  309. Bed2.Materials[0].tex.Load("Bed21.bmp");
  310. Bed2.Materials[1].tex.Load("Bed21.bmp");
  311. Bed2.Materials[2].tex.Load("wood.bmp");
  312. Bed2.Materials[3].tex.Load("Doo.bmp");
  313.  
  314. sofa1.Load("sofa.3ds");
  315. sofa1.Materials[0].tex.Load("sofa3.bmp");
  316. sofa1.Materials[1].tex.Load("Mall_craq.bmp");
  317. sofa1.Materials[2].tex.Load("sofa3.bmp");
  318. sofa1.Materials[3].tex.Load("wood.bmp");
  319.  
  320. Beroo.Load("Beroo.3ds");
  321. Beroo.Materials[0].tex.Load("Wood.bmp");
  322. Beroo.Materials[1].tex.Load("Bed2.bmp");
  323. Beroo.Materials[2].tex.Load("Bed2.bmp");
  324. Beroo.Materials[3].tex.Load("Bed2.bmp");
  325.  
  326.  
  327. Mosc.Load("Es46.3ds");
  328. Mosc.Materials[0].tex.Load("Glasss.bmp");//koba || glass
  329. Mosc.Materials[1].tex.Load("Doolab.bmp"); //k7le
  330. Mosc.Materials[2].tex.Load("Doolab.bmp"); //door //k7le
  331. Mosc.Materials[3].tex.Load("Mall_whites.bmp"); //mskat al bab //white
  332. Mosc.Materials[4].tex.Load("yellow.bmp"); //soor fo6 //k7le
  333. Mosc.Materials[5].tex.Load("Mall_whites.bmp"); //l 3'laf //withe
  334. Mosc.Materials[6].tex.Load("SideOfBuild1.bmp"); // mn joa //k7le
  335. Mosc.Materials[7].tex.Load("Baloor.bmp"); //windows //bne
  336. Mosc.Materials[8].tex.Load("Doolab.bmp"); // cover of windows //k7le || aswd
  337. Mosc.Materials[9].tex.Load("Road2.bmp"); //ground // fde
  338. Mosc.Materials[10].tex.Load("Cone.bmp"); // قاعدة الجامع مثل الرصيف
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345. Sport1.Load("Sport.3ds");
  346. Sport1.Materials[0].tex.Load("Wood.bmp");
  347. Sport1.Materials[1].tex.Load("Bed2.bmp");
  348. Sport1.Materials[2].tex.Load("Honda2.bmp");
  349. Sport1.Materials[3].tex.Load("Bed2.bmp");
  350. Sport1.Materials[4].tex.Load("Honda7.bmp");
  351. Sport1.Materials[5].tex.Load("Honda7.bmp");
  352. Sport1.Materials[6].tex.Load("Honda7.bmp");
  353. Sport1.Materials[7].tex.Load("Honda7.bmp");
  354.  
  355. Sport2.Load("Sport2.3ds");
  356. Sport2.Materials[0].tex.Load("Wood.bmp");
  357. Sport2.Materials[1].tex.Load("Bed2.bmp");
  358. Sport2.Materials[2].tex.Load("Bed2.bmp");
  359. Sport2.Materials[3].tex.Load("Bed2.bmp");
  360.  
  361.  
  362. Sport3.Load("Sport3.3ds");
  363. Sport3.Materials[0].tex.Load("Wood.bmp");
  364. Sport3.Materials[1].tex.Load("Bed2.bmp");
  365. Sport3.Materials[2].tex.Load("Bed2.bmp");
  366. Sport3.Materials[3].tex.Load("Bed2.bmp");
  367. Sport3.Materials[4].tex.Load("Honda2.bmp");
  368. Sport3.Materials[5].tex.Load("Honda2.bmp");
  369. Sport3.Materials[6].tex.Load("Honda2.bmp");
  370. Sport3.Materials[7].tex.Load("Honda2.bmp");
  371.  
  372.  
  373. Model1.Load("ModelPark.3ds");
  374. Model1.Materials[0].tex.Load("1.bmp");
  375. Model1.Materials[1].tex.Load("7.bmp");
  376. Model1.Materials[2].tex.Load("2.bmp");
  377. Model1.Materials[3].tex.Load("4.bmp");
  378. Model1.Materials[4].tex.Load("5.bmp");
  379. Model1.Materials[5].tex.Load("6.bmp");
  380. Model1.Materials[6].tex.Load("7.bmp");
  381. Model1.Materials[7].tex.Load("5.bmp");
  382. Model1.Materials[10].tex.Load("3.bmp");
  383.  
  384.  
  385. Model3.Load("D:\\Residence.3ds");
  386. ///nto2
  387. Model3.Materials[6].tex.LoadBMP("Wood.bmp");
  388. Model3.Materials[2].tex.LoadBMP("Doolab.bmp");
  389. ///mrb3at
  390. Model3.Materials[1].tex.LoadBMP("Wood.bmp");
  391. ////nto2
  392. Model3.Materials[3].tex.LoadBMP("3.bmp");
  393. ///shbak
  394. Model3.Materials[4].tex.LoadBMP("Wood.bmp");
  395. /*الدار */
  396. Model3.Materials[5].tex.LoadBMP("Doolab.bmp");
  397. Model3.Materials[8].tex.LoadBMP("SideOfBuild1.bmp");
  398. Model3.Materials[9].tex.LoadBMP("Car.bmp");
  399. Model3.Materials[10].tex.LoadBMP("Grass.bmp");
  400. Model3.Materials[11].tex.LoadBMP("SideOfMall1.bmp");
  401. Model3.Materials[12].tex.LoadBMP("Wood.bmp"); //windows right side
  402. Model3.Materials[13].tex.LoadBMP("SideOfBuild.bmp"); //all windows and door
  403.  
  404. Model10.Load("D:\\Residence.3ds");
  405. ///nto2
  406. Model10.Materials[6].tex.LoadBMP("Wood.bmp");
  407. Model10.Materials[2].tex.LoadBMP("Doolab.bmp");
  408. ////mrb3at
  409. Model10.Materials[1].tex.LoadBMP("Wood.bmp");
  410. ////nto2
  411. Model10.Materials[3].tex.LoadBMP("5.bmp");
  412. ///shbak
  413. Model10.Materials[4].tex.LoadBMP("Doo.bmp");
  414. ////الدار
  415. Model10.Materials[5].tex.LoadBMP("Car.bmp");
  416. Model10.Materials[8].tex.LoadBMP("SideOfBuild1.bmp");
  417. Model10.Materials[9].tex.LoadBMP("Mall_grey.bmp");
  418. Model10.Materials[10].tex.LoadBMP("SideOfBuild.bmp");
  419. Model10.Materials[11].tex.LoadBMP("Mall_grey.bmp");
  420. Model10.Materials[12].tex.LoadBMP("Mall_grey.bmp"); //windows right side
  421. Model10.Materials[13].tex.LoadBMP("SecondFloor.bmp"); //all windows and door
  422.  
  423. Model6.Load("D:\\Naf.3ds");
  424. Model6.Materials[0].tex.Load("7.bmp");
  425. Model6.Materials[1].tex.Load("1.bmp");
  426. Model6.Materials[2].tex.Load("1.bmp");
  427. Model6.Materials[3].tex.Load("1.bmp");
  428. Model6.Materials[4].tex.Load("1.bmp");
  429.  
  430.  
  431. Model7.Load("Chers.3ds");
  432. Model7.Materials[0].tex.Load("Wood.bmp");
  433. Model7.Materials[1].tex.Load("Wood.bmp");
  434.  
  435. Model8.Load("golf_iv1.3ds");
  436. Model8.Materials[0].tex.Load("Doo.bmp");
  437. Model8.Materials[1].tex.Load("Doo.bmp");
  438. Model8.Materials[2].tex.Load("Car.bmp");
  439. Model8.Materials[3].tex.Load("Car.bmp");
  440. Model8.Materials[6].tex.Load("Baloor.bmp");
  441. Model8.Materials[7].tex.Load("Baloor.bmp");
  442. Model8.Materials[11].tex.Load("down.bmp");
  443. Model8.Materials[12].tex.Load("Doolab.bmp");
  444. Model8.Materials[13].tex.Load("Doolab.bmp");
  445. Model8.Materials[14].tex.Load("Jn6.bmp");
  446. Model8.Materials[15].tex.Load("Jn6.bmp");
  447. Model8.Materials[4].tex.Load("down.bmp");
  448. Model8.Materials[5].tex.Load("down.bmp");
  449.  
  450.  
  451.  
  452. Model11.Load("Tabble.3ds");
  453. ///balck
  454. Model11.Materials[0].tex.Load("Doolab.bmp");
  455. Model11.Materials[1].tex.Load("Doolab.bmp");
  456. ///mn t7t kaml red
  457. Model11.Materials[2].tex.Load("Mall_red.bmp");
  458.  
  459. ///white
  460. Model11.Materials[3].tex.Load("Mall_whites.bmp");
  461. ///red
  462. Model11.Materials[4].tex.Load("Mall_red.bmp");
  463. ///gray
  464. Model11.Materials[5].tex.Load("Mall_red.bmp");
  465. Model11.Materials[6].tex.Load("Mall_red.bmp");
  466. Model11.Materials[7].tex.Load("Mall_red.bmp");
  467. Model11.Materials[8].tex.Load("Mall_red.bmp");
  468. Model11.Materials[9].tex.Load("Mall_red.bmp");
  469. Model11.Materials[10].tex.Load("Mall_red.bmp");
  470. Model11.Materials[11].tex.Load("Mall_red.bmp");
  471. Model11.Materials[12].tex.Load("Mall_red.bmp");
  472.  
  473.  
  474.  
  475. M16.Load("M16.3ds");
  476. M16.Materials[0].tex.Load("GFX.bmp");
  477.  
  478.  
  479.  
  480. AWP.Load("AWP.3ds");
  481. AWP.Materials[0].tex.Load("AWP.bmp");
  482. AWP.Materials[1].tex.Load("AWP1.bmp");
  483.  
  484.  
  485. Sword.Load("Sword.3ds");
  486. Sword.Materials[0].tex.Load("MetalBare.bmp");
  487. Sword.Materials[1].tex.Load("Viking-sword.bmp");
  488. Sword.Materials[2].tex.Load("CHROMIC.bmp");
  489.  
  490.  
  491.  
  492. PP19.Load("PP19.3ds");
  493. PP19.Materials[0].tex.Load("PP19.bmp");
  494. PP19.Materials[1].tex.Load("PP191.bmp");
  495.  
  496. M4.Load("M4.3ds");
  497. M4.Materials[0].tex.Load("AWP.bmp");
  498.  
  499.  
  500. glock.Load("glock.3ds");
  501. glock.Materials[0].tex.Load("9mm.bmp");
  502. glock.Materials[1].tex.Load("glock.bmp");
  503.  
  504. RPG.Load("RPG.3ds");
  505. RPG.Materials[0].tex.Load("RPG.bmp");
  506.  
  507.  
  508. Honda.Load("Honda.3ds");
  509. Honda.Materials[0].tex.Load("Honda1.bmp");
  510. Honda.Materials[1].tex.Load("down.bmp");
  511. Honda.Materials[2].tex.Load("Honda1.bmp");
  512. Honda.Materials[3].tex.Load("Honda1.bmp");
  513. Honda.Materials[4].tex.Load("Honda2.bmp");
  514. Honda.Materials[5].tex.Load("Honda1.bmp");
  515. Honda.Materials[6].tex.Load("Honda1.bmp");
  516. Honda.Materials[7].tex.Load("Honda1.bmp");
  517. Honda.Materials[8].tex.Load("Honda1.bmp");
  518. Honda.Materials[9].tex.Load("Honda6.bmp");
  519. Honda.Materials[10].tex.Load("Honda2.bmp");
  520. Honda.Materials[11].tex.Load("Honda1.bmp");
  521. Honda.Materials[12].tex.Load("Honda1.bmp");
  522. Honda.Materials[13].tex.Load("Honda3.bmp");
  523. Honda.Materials[14].tex.Load("Honda3.bmp");
  524. Honda.Materials[15].tex.Load("Honda3.bmp");
  525. Honda.Materials[16].tex.Load("Honda1.bmp");
  526. Honda.Materials[17].tex.Load("Honda1.bmp");
  527. Honda.Materials[18].tex.Load("Honda3.bmp");
  528. Honda.Materials[19].tex.Load("Honda3.bmp");
  529. Honda.Materials[20].tex.Load("Honda3.bmp");
  530. Honda.Materials[21].tex.Load("Honda3.bmp");
  531. Honda.Materials[22].tex.Load("Honda3.bmp");
  532. Honda.Materials[23].tex.Load("Honda3.bmp");
  533. Honda.Materials[24].tex.Load("Honda3.bmp");
  534. Honda.Materials[25].tex.Load("Honda2.bmp");
  535. Honda.Materials[26].tex.Load("Honda2.bmp");
  536. Honda.Materials[27].tex.Load("Honda3.bmp");
  537. Honda.Materials[28].tex.Load("Honda3.bmp");
  538. Honda.Materials[29].tex.Load("Honda3.bmp");
  539. Honda.Materials[30].tex.Load("Honda3.bmp");
  540. Honda.Materials[31].tex.Load("Honda7.bmp");
  541. Honda.Materials[32].tex.Load("Honda7.bmp");
  542. Honda.Materials[33].tex.Load("Honda7.bmp");
  543. Honda.Materials[34].tex.Load("Honda7.bmp");
  544. Honda.Materials[35].tex.Load("Honda7.bmp");
  545. Honda.Materials[36].tex.Load("Honda2.bmp");
  546. Honda.Materials[37].tex.Load("Honda8.bmp");
  547. Honda.Materials[38].tex.Load("Honda2.bmp");
  548. Honda.Materials[39].tex.Load("Honda2.bmp");
  549.  
  550. Honda1.Load("Honda.3ds");
  551. Honda1.Materials[0].tex.Load("Honda6.bmp");
  552. Honda1.Materials[1].tex.Load("down.bmp");
  553. Honda1.Materials[2].tex.Load("Honda6.bmp");
  554. Honda1.Materials[3].tex.Load("Honda6.bmp");
  555. Honda1.Materials[4].tex.Load("Honda2.bmp");
  556. Honda1.Materials[5].tex.Load("Honda6.bmp");
  557. Honda1.Materials[6].tex.Load("Honda6.bmp");
  558. Honda1.Materials[7].tex.Load("Honda6.bmp");
  559. Honda1.Materials[8].tex.Load("Honda6.bmp");
  560. Honda1.Materials[9].tex.Load("Honda6.bmp");
  561. Honda1.Materials[10].tex.Load("Honda2.bmp");
  562. Honda1.Materials[11].tex.Load("Honda6.bmp");
  563. Honda1.Materials[12].tex.Load("Honda6.bmp");
  564. Honda1.Materials[13].tex.Load("Honda3.bmp");
  565. Honda1.Materials[14].tex.Load("Honda3.bmp");
  566. Honda1.Materials[15].tex.Load("Honda3.bmp");
  567. Honda1.Materials[16].tex.Load("Honda6.bmp");
  568. Honda1.Materials[17].tex.Load("Honda6.bmp");
  569. Honda1.Materials[18].tex.Load("Honda3.bmp");
  570. Honda1.Materials[19].tex.Load("Honda3.bmp");
  571. Honda1.Materials[20].tex.Load("Honda3.bmp");
  572. Honda1.Materials[21].tex.Load("Honda3.bmp");
  573. Honda1.Materials[22].tex.Load("Honda3.bmp");
  574. Honda1.Materials[23].tex.Load("Honda3.bmp");
  575. Honda1.Materials[24].tex.Load("Honda3.bmp");
  576. Honda1.Materials[25].tex.Load("Honda2.bmp");
  577. Honda1.Materials[26].tex.Load("Honda2.bmp");
  578. Honda1.Materials[27].tex.Load("Honda3.bmp");
  579. Honda1.Materials[28].tex.Load("Honda3.bmp");
  580. Honda1.Materials[29].tex.Load("Honda3.bmp");
  581. Honda1.Materials[30].tex.Load("Honda3.bmp");
  582. Honda1.Materials[31].tex.Load("Honda7.bmp");
  583. Honda1.Materials[32].tex.Load("Honda7.bmp");
  584. Honda1.Materials[33].tex.Load("Honda7.bmp");
  585. Honda1.Materials[34].tex.Load("Honda7.bmp");
  586. Honda1.Materials[35].tex.Load("Honda7.bmp");
  587. Honda1.Materials[36].tex.Load("Honda2.bmp");
  588. Honda1.Materials[37].tex.Load("Honda8.bmp");
  589. Honda1.Materials[38].tex.Load("Honda2.bmp");
  590. Honda1.Materials[39].tex.Load("Honda2.bmp");
  591.  
  592.  
  593.  
  594. Honda2.Load("Honda.3ds");
  595. Honda2.Materials[0].tex.Load("Honda9.bmp");
  596. Honda2.Materials[1].tex.Load("down.bmp");
  597. Honda2.Materials[2].tex.Load("Honda9.bmp");
  598. Honda2.Materials[3].tex.Load("Honda9.bmp");
  599. Honda2.Materials[4].tex.Load("Honda2.bmp");
  600. Honda2.Materials[5].tex.Load("Honda6.bmp");
  601. Honda2.Materials[6].tex.Load("Honda9.bmp");
  602. Honda2.Materials[7].tex.Load("Honda9.bmp");
  603. Honda2.Materials[8].tex.Load("Honda9.bmp");
  604. Honda2.Materials[9].tex.Load("Honda9.bmp");
  605. Honda2.Materials[10].tex.Load("Honda2.bmp");
  606. Honda2.Materials[11].tex.Load("Honda9.bmp");
  607. Honda2.Materials[12].tex.Load("Honda9.bmp");
  608. Honda2.Materials[13].tex.Load("Honda3.bmp");
  609. Honda2.Materials[14].tex.Load("Honda3.bmp");
  610. Honda2.Materials[15].tex.Load("Honda3.bmp");
  611. Honda2.Materials[16].tex.Load("Honda9.bmp");
  612. Honda2.Materials[17].tex.Load("Honda9.bmp");
  613. Honda2.Materials[18].tex.Load("Honda3.bmp");
  614. Honda2.Materials[19].tex.Load("Honda3.bmp");
  615. Honda2.Materials[20].tex.Load("Honda3.bmp");
  616. Honda2.Materials[21].tex.Load("Honda3.bmp");
  617. Honda2.Materials[22].tex.Load("Honda3.bmp");
  618. Honda2.Materials[23].tex.Load("Honda3.bmp");
  619. Honda2.Materials[24].tex.Load("Honda3.bmp");
  620. Honda2.Materials[25].tex.Load("Honda2.bmp");
  621. Honda2.Materials[26].tex.Load("Honda2.bmp");
  622. Honda2.Materials[27].tex.Load("Honda3.bmp");
  623. Honda2.Materials[28].tex.Load("Honda3.bmp");
  624. Honda2.Materials[29].tex.Load("Honda3.bmp");
  625. Honda2.Materials[30].tex.Load("Honda3.bmp");
  626. Honda2.Materials[31].tex.Load("Honda7.bmp");
  627. Honda2.Materials[32].tex.Load("Honda7.bmp");
  628. Honda2.Materials[33].tex.Load("Honda7.bmp");
  629. Honda2.Materials[34].tex.Load("Honda7.bmp");
  630. Honda2.Materials[35].tex.Load("Honda7.bmp");
  631. Honda2.Materials[36].tex.Load("Honda2.bmp");
  632. Honda2.Materials[37].tex.Load("Honda8.bmp");
  633. Honda2.Materials[38].tex.Load("Honda2.bmp");
  634. Honda2.Materials[39].tex.Load("Honda2.bmp");
  635.  
  636.  
  637. Laptop.Load("Laptop.3ds");
  638. Laptop.Materials[0].tex.Load("Honda6.bmp");
  639. Laptop.Materials[1].tex.Load("down.bmp");
  640.  
  641. Model13.Load("Counter.3ds");
  642. Model13.Materials[0].tex.Load("Honda2.bmp");
  643. Model13.Materials[1].tex.Load("st-2.bmp");
  644. Model13.Materials[2].tex.Load("st-2.bmp");
  645. Model13.Materials[3].tex.Load("st-1.bmp");
  646. Model13.Materials[4].tex.Load("st-1.bmp");
  647. Model13.Materials[5].tex.Load("Honda2.bmp");
  648. Model13.Materials[6].tex.Load("Honda2.bmp");
  649. Model13.Materials[7].tex.Load("Honda2.bmp");
  650. Model13.Materials[8].tex.Load("Honda2.bmp");
  651. Model13.Materials[9].tex.Load("Honda2.bmp");
  652. Model13.Materials[10].tex.Load("Honda2.bmp");
  653. Model13.Materials[11].tex.Load("Honda2.bmp");
  654. Model13.Materials[12].tex.Load("Honda2.bmp");
  655.  
  656.  
  657. camera.Position.x = 5;
  658. camera.Position.y = 120;
  659. camera.Position.z = 1000;
  660.  
  661. return TRUE; // Initialization Went OK
  662. }
  663.  
  664.  
  665. float radian(float h)
  666. {
  667. return h*3.14 - 180;
  668. }
  669.  
  670.  
  671. void KeyBoardWithMouse()
  672. {
  673. mousexx = mouseSensitivity * (mouseX - 500);
  674. mouseyy = mouseSensitivity * -1 * (mouseY - 300);
  675.  
  676. mousexxPrev = mousexxCurrent;
  677. mousexxCurrent = mousexx;
  678. mousexxDiff = mousexxCurrent - mousexxPrev;
  679.  
  680. xxx = xx + cos(radian(teta));
  681. zzz = zz - sin(radian(teta));
  682. yyy = yy;
  683.  
  684. gluLookAt(xx, yy, zz, xxx, yyy, zzz, 0, 1, 0);
  685.  
  686. teta = mouseX >= 990 ? teta - 5 : mouseX <= 10 ? teta + 5 : teta - mousexxDiff;
  687. if (keys['W']) zz -= sin(radian(teta))*speed, xx += cos(radian(teta))*speed;
  688. if (keys['S']) zz += sin(radian(teta))*speed, xx -= cos(radian(teta))*speed;
  689. if (keys['A']) xx -= sin(radian(teta))*(speed - 0.3), zz -= cos(radian(teta))*(speed - 0.3);
  690. if (keys['D']) xx += sin(radian(teta))*(speed - 0.3), zz += cos(radian(teta))*(speed - 0.3);
  691. if (keys[VK_UP]) yy += 0.8;
  692. if (keys[VK_DOWN]) yy -= 0.8;
  693. if (keys['1']) { float cach = 10; if (yy < cach) { yy -= 2; elevatorH -= 2; } }
  694. if (keys['2']) { float cach = 550; if (yy < cach) { yy += 2; elevatorH += 2; } }
  695. }
  696.  
  697. void skybox()
  698. {
  699. glBindTexture(GL_TEXTURE_2D, back);
  700. glBegin(GL_QUADS);
  701. glTexCoord2d(0, 0);
  702. glVertex3d(-500, -500, -500);
  703. glTexCoord2d(1, 0);
  704. glVertex3d(500, -500, -500);
  705. glTexCoord2d(1, 1);
  706. glVertex3d(500, 500, -500);
  707. glTexCoord2d(0, 1);
  708. glVertex3d(-500, 500, -500);
  709. glEnd();
  710.  
  711. glBindTexture(GL_TEXTURE_2D, front);
  712. glBegin(GL_QUADS);
  713. glTexCoord2d(1, 0);
  714. glVertex3d(-500, -500, 500);
  715. glTexCoord2d(0, 0);
  716. glVertex3d(500, -500, 500);
  717. glTexCoord2d(0, 1);
  718. glVertex3d(500, 500, 500);
  719. glTexCoord2d(1, 1);
  720. glVertex3d(-500, 500, 500);
  721. glEnd();
  722.  
  723. glBindTexture(GL_TEXTURE_2D, left);
  724. glBegin(GL_QUADS);
  725. glTexCoord2d(0, 0);
  726. glVertex3d(-500, -500, 500);
  727. glTexCoord2d(1, 0);
  728. glVertex3d(-500, -500, -500);
  729. glTexCoord2d(1, 1);
  730. glVertex3d(-500, 500, -500);
  731. glTexCoord2d(0, 1);
  732. glVertex3d(-500, 500, 500);
  733. glEnd();
  734.  
  735. glBindTexture(GL_TEXTURE_2D, right);
  736. glBegin(GL_QUADS);
  737. glTexCoord2d(1, 0);
  738. glVertex3d(500, -500, 500);
  739. glTexCoord2d(0, 0);
  740. glVertex3d(500, -500, -500);
  741. glTexCoord2d(0, 1);
  742. glVertex3d(500, 500, -500);
  743. glTexCoord2d(1, 1);
  744. glVertex3d(500, 500, 500);
  745. glEnd();
  746.  
  747. glBindTexture(GL_TEXTURE_2D, top);
  748. glBegin(GL_QUADS);
  749. glTexCoord2d(0, 1);
  750. glVertex3d(-500, 500, -500);
  751. glTexCoord2d(0, 0);
  752. glVertex3d(500, 500, -500);
  753. glTexCoord2d(1, 0);
  754. glVertex3d(500, 500, 500);
  755. glTexCoord2d(1, 1);
  756. glVertex3d(-500, 500, 500);
  757. glEnd();
  758.  
  759. //glBindTexture(GL_TEXTURE_2D, down);
  760. //glBegin(GL_QUADS);
  761. ////glColor3f(1, 0, 0);
  762. //glTexCoord2d(0, 0);
  763. //glVertex3d(-500, 0, 500);
  764. //glTexCoord2d(0, 1);
  765. //glVertex3d(-500, 0, -500);
  766. //glTexCoord2d(1, 1);
  767. //glVertex3d(500, 0, -500);
  768. //glTexCoord2d(0, 0);
  769. //glVertex3d(500, 0, 500);
  770. //glEnd();
  771.  
  772. //glBindTexture(GL_TEXTURE_2D, RoadTex);
  773. //glBegin(GL_QUADS);
  774. ////glColor3f(1, 0, 0);
  775. //glTexCoord2d(0, 0);
  776. //glVertex3d(-500, -0.5, 500);
  777. //glTexCoord2d(0, 1);
  778. //glVertex3d(-500, -0.5, -500);
  779. //glTexCoord2d(1, 1);
  780. //glVertex3d(500, -0.5, -500);
  781. //glTexCoord2d(0, 0);
  782. //glVertex3d(500, -0.5, 500);
  783. //glEnd();
  784. }
  785. void Connne(float x, float y, float z, float h, float r, int texture)
  786. {
  787. glBindTexture(GL_TEXTURE_2D, texture);
  788. for (float i = 0; i < 2 * 3.14; i += 0.3)
  789. {
  790. glNormal3d(sin(i), atan(r / h), cos(i));
  791. float xx = r*cos(i);
  792. float zz = r*sin(i);
  793. float xxx = r*cos(i + 0.3);
  794. float zzz = r*sin(i + 0.3);
  795. glBegin(GL_QUADS);
  796. glTexCoord2d(0, 0);
  797. glVertex3f(x + xx, y, z - zz);
  798. glTexCoord2d(1, 0);
  799. glVertex3f(x + xxx, y, z - zzz);
  800. glTexCoord2d(1, 2);
  801. glVertex3f(x + xxx, y + h, z - zzz);
  802. glTexCoord2d(0, 2);
  803. glVertex3f(x + xx, y + h, z - zz);
  804. glEnd();
  805.  
  806. }
  807. }
  808. bool Cam = false;
  809. double eyeX, eyeY = 5, eyeZ;
  810. double lllX, lllY, lllZ;
  811. double angle = 0;
  812. void ThirdCamera() {
  813. if (Cam == false) {
  814. gluLookAt(eyeX, eyeY, eyeZ, lllX, lllY, lllZ, 0, 1, 0);
  815. }
  816. if (keys['D']) eyeZ -= 0.005; eyeY = 0.3*fabs(cos(angle));
  817. if (keys['A']) eyeZ += 0.005; eyeY = 0.3*fabs(cos(angle));
  818. if (keys['W']) eyeX -= 0.005; eyeY = 0.3*fabs(cos(angle));;
  819. if (keys['S']) eyeX += 0.005; eyeY = 0.3*fabs(cos(angle));
  820. if (keys['Z']) lllX -= 0.01*cos(0.1); lllZ -= 0.01*sin(0.1);
  821. if (keys['X']) lllX += 0.01*cos(0.1); lllZ += 0.01*sin(0.1);
  822. }
  823. bool checkNearDoor(float leftX, float rightX, float doorZ) {
  824.  
  825. float vision = 200;
  826.  
  827. if (camera.Position.x >= leftX && camera.Position.x <= rightX && abs(camera.Position.z - doorZ) <= vision)
  828. return true;
  829.  
  830. else
  831. return false;
  832. }
  833. void Ligth() {
  834. // (0 , 30) (0,170) (0 30)
  835. //glTranslated(0, -400, );
  836. glColor3f(0, 0, 0);
  837. glBegin(GL_POLYGON);
  838. glTexCoord2d(0, 0);
  839. glVertex3f(0, -155, 155);
  840. glTexCoord2d(0, 1);
  841. glVertex3f(20, -155, 155);
  842. glTexCoord2d(1, 1);
  843. glVertex3f(0, -155, 0);
  844. glTexCoord2d(1, 0);
  845. glVertex3f(20, -155, 0);
  846. glEnd();
  847.  
  848. glBegin(GL_POLYGON);
  849. glBindTexture(GL_TEXTURE_2D, HondaBlack);
  850. glTexCoord2d(0, 0);
  851. glVertex3f(30, -155, 155);
  852. glTexCoord2d(0, 0);
  853. glVertex3f(-10, -155, 155);
  854. glTexCoord2d(0, 0);
  855. glVertex3f(30, -155, 130);
  856. glTexCoord2d(0, 0);
  857. glVertex3f(-10, -155, 130);
  858. glEnd();
  859.  
  860. /**/
  861.  
  862. glColor3f(0, 0, 0);
  863. //glScaled(1.4, 1, 1.4);
  864. //glTranslated(0, 155, 0);
  865. //ii.Draw();
  866. //ii.Ws.SetTexture(HondaBlack);
  867. }
  868.  
  869. void Ligth3d() {
  870. // (0 , 30) (0,170) (0 30)
  871. glTranslated(400, 0, 1500);
  872. glColor3f(0.2, 0.2, 0.2);
  873. glBegin(GL_POLYGON);
  874. glVertex3f(0, 0, 20);
  875. glVertex3f(20, 0, 0);
  876. glVertex3f(0, 155, 0);
  877. glVertex3f(20, 155, 20);
  878. glEnd();
  879.  
  880. glBegin(GL_POLYGON);
  881. glVertex3f(0, 0, 20);
  882. glVertex3f(0, 0, 0);
  883. glVertex3f(0, 155, 20);
  884. glVertex3f(0, 155, 0);
  885. glEnd();
  886.  
  887. glBegin(GL_POLYGON);
  888. glVertex3f(20, 0, 20);
  889. glVertex3f(20, 0, 0);
  890. glVertex3f(20, 155, 20);
  891. glVertex3f(20, 155, 0);
  892. glEnd();
  893.  
  894. glBegin(GL_POLYGON);
  895. glVertex3f(0, 0, 20);
  896. glVertex3f(20, 0, 20);
  897. glVertex3f(0, 155, 0);
  898. glVertex3f(20, 155, 0);
  899. glEnd();
  900.  
  901. /**/
  902.  
  903. glColor3f(0, 0, 0);
  904. glScaled(1.4, 1, 1.4);
  905. glTranslated(0, 155, 0);
  906. ii.Draw();
  907. }
  908. int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
  909. {
  910. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  911. glLoadIdentity();
  912. KeyBoardWithMouse();
  913.  
  914. //camera.Render();
  915. //CameraKeyBoard();
  916. //Ccamera();
  917. if (keys['B']) ThirdCamera();
  918.  
  919. glPushMatrix();
  920. glScaled(7, 7, 7);
  921. skybox();
  922. glPopMatrix();
  923.  
  924.  
  925. glPushMatrix();
  926. glScaled(7, 7, 7);
  927. skybox();
  928. glPopMatrix();
  929.  
  930. glPushMatrix();
  931. glTranslated(1065, 430, -650);
  932. KShop1.Draw();
  933. glPopMatrix();
  934.  
  935. glPushMatrix();
  936. glTranslated(1065, 430, 830);
  937. KShop3.Draw();
  938. glPopMatrix();
  939.  
  940. //first to the door of the mall second raise to up last more to the right
  941. glPushMatrix();
  942. glRotated(90, 0, 1, 0);
  943. glTranslated(-70, 425, 1885);
  944. KShop5.Draw();
  945. glPopMatrix();
  946.  
  947. glPushMatrix();
  948. glRotated(90, 0, 1, 0);
  949. glTranslated(-855, 425, 1865);
  950. KShop2.Draw();
  951. glPopMatrix();
  952. //first left and right of the door second up and down third go front to the door
  953. glPushMatrix();
  954. glRotated(90, 0, 1, 0);
  955. glTranslated(-455, 425, 2135);
  956. KShopWall.Draw();
  957. glPopMatrix();
  958.  
  959. //the side of the door
  960. glPushMatrix();
  961. glRotated(90, 0, 1, 0);
  962. glTranslated(-70, 425, 1085);
  963. KShop4.Draw();
  964. glPopMatrix();
  965.  
  966. glPushMatrix();
  967. glRotated(90, 0, 1, 0);
  968. glTranslated(-835, 425, 1065);
  969. KShop6.Draw();
  970. glPopMatrix();
  971.  
  972. glPushMatrix();
  973. glRotated(90, 0, 1, 0);
  974. glTranslated(-450, 425, 1065);
  975. KShop7.Draw();
  976. glPopMatrix();
  977.  
  978. glPushMatrix();
  979. glRotated(90, 1, 0, 0);
  980. MallWall.SetPosition(1600, -600, -405);
  981. MallWall.SetDimntion(1800, 1150);
  982. MallWall.Draw();
  983. glPopMatrix();
  984.  
  985. glPushMatrix();
  986. glRotated(90, 1, 0, 0);
  987. MallWall2.SetPosition(1600,-600, -20);
  988. MallWall2.SetDimntion(1800, 1150);
  989. MallWall2.Draw();
  990. glPopMatrix();
  991.  
  992.  
  993. glPushMatrix();
  994. //first go back and front second height third positive to right
  995. glTranslated(2270, 5, -660);
  996. glScaled(0.5, 0.5, 0.5);
  997. glRotated(-90, 0, 1, 0);
  998. MyMall.Draw();
  999. glPopMatrix();
  1000.  
  1001.  
  1002.  
  1003. /*glPushMatrix();
  1004. glTranslated(90, 112.6, -75);
  1005. glScaled(0.5, 0.5, 0.5);
  1006. Floor2.Draw();
  1007. glPopMatrix();*/
  1008.  
  1009. glPushMatrix();
  1010. glTranslated(2200, 10, 400);
  1011. glRotatef(-90, 0, 1, 0);
  1012. glScaled(35, 35, 35);
  1013. Model12.pos.x = 0;
  1014. Model12.pos.y = 0;
  1015. Model12.pos.z = 0;//درج
  1016. Model12.Draw();
  1017. glPopMatrix();
  1018.  
  1019. glPushMatrix();
  1020. glTranslated(2000, 10, -420);
  1021. glScaled(0.07, 0.07, 0.07);
  1022. Model13.pos.x = 0;
  1023. Model13.pos.y = 0;
  1024. Model13.pos.z = 0;
  1025. Model13.Draw();
  1026. glPopMatrix();
  1027.  
  1028.  
  1029.  
  1030. //////////////////////////////////
  1031. glPushMatrix();
  1032. glTranslated(2000, 70, 1100);
  1033. glScaled(2.5, 2.5, 2.5);
  1034. Sport1.pos.x = 0;
  1035. Sport1.pos.y = 0;
  1036. Sport1.pos.z = 0;
  1037. Sport1.Draw();
  1038. glPopMatrix();
  1039. ///////////////////////////////////////
  1040.  
  1041.  
  1042. //////////////////////////////////
  1043. glPushMatrix();
  1044. glTranslated(2200, 70, 1100);
  1045. glScaled(2.5, 2.5, 2.5);
  1046. glRotatef(180, 0, 1, 0);
  1047. Sport2.pos.x = 0;
  1048. Sport2.pos.y = 0;
  1049. Sport2.pos.z = 0;
  1050. Sport2.Draw();
  1051. glPopMatrix();
  1052. ///////////////////////////////////////
  1053. //////////////////////////////////
  1054. glPushMatrix();
  1055. glTranslated(2200, 40, 900);
  1056. glScaled(40, 40, 40);
  1057. Sport3.pos.x = 0;
  1058. Sport3.pos.y = 0;
  1059. Sport3.pos.z = 0;
  1060. Sport3.Draw();
  1061. glPopMatrix();
  1062. ///////////////////////////////////////
  1063.  
  1064.  
  1065. glPushMatrix();
  1066. glTranslated(1050, 0, -640);
  1067. GunStore.Draw();
  1068. glPopMatrix();
  1069.  
  1070. ///////////////////////////
  1071. glPushMatrix();
  1072. glTranslated(1905, 0, 1120);
  1073. glRotatef(180, 0, 1, 0);
  1074. BedStore.Draw();
  1075. glPopMatrix();
  1076. ///////////////////////////////
  1077.  
  1078.  
  1079.  
  1080.  
  1081. glPushMatrix();
  1082. glTranslated(-240, 0, 0);
  1083. Store.Draw();
  1084. glPopMatrix();
  1085.  
  1086.  
  1087. ////glPushMatrix();
  1088. ////glTranslated(-290, 0, 0);
  1089. ////glRotated(90, 0, 1, 0); ///////////////////////////////////////////////////////////
  1090. ////Store2.Draw();
  1091. ////glPopMatrix();
  1092. //
  1093.  
  1094. glPushMatrix();
  1095. glTranslated(1117, 45, -405);
  1096. glScaled(80, 80, 80);
  1097. Laptop.pos.x = 0;
  1098. Laptop.pos.y = 0;
  1099. Laptop.pos.z = 0;
  1100. Laptop.Draw();
  1101. glPopMatrix();
  1102.  
  1103. glPushMatrix();
  1104. glTranslated(1150, 0, -405);
  1105. glScaled(1.4, 1.4, 1.4);
  1106. Model11.pos.x = 0;
  1107. Model11.pos.y = 0;
  1108. Model11.pos.z = 0;
  1109. Model11.Draw();
  1110. glPopMatrix();
  1111.  
  1112. ///////////////////////////
  1113. glPushMatrix();
  1114. glTranslated(1680, 32, 1060);
  1115. glScaled(1.8, 1.8, 1.8);
  1116. glRotatef(180, 0, 1, 0);
  1117. Bed1.pos.x = 0;
  1118. Bed1.pos.y = 0;
  1119. Bed1.pos.z = 0;
  1120. Bed1.Draw();
  1121. glPopMatrix();
  1122.  
  1123. ////////////////////////////////
  1124.  
  1125. //////////////////////////////
  1126. glPushMatrix();
  1127. glTranslated(1100, 15, 820);
  1128. glScaled(0.07, 0.07, 0.07);
  1129. glRotatef(90, 0, 1, 0);
  1130. Bed2.pos.x = 0;
  1131. Bed2.pos.y = 0;
  1132. Bed2.pos.z = 0;
  1133. Bed2.Draw();
  1134. glPopMatrix();
  1135.  
  1136. ////////////////////
  1137.  
  1138. ////////////////////////
  1139. glPushMatrix();
  1140. glTranslated(1850, 15, 720);
  1141. glScaled(0.09, 0.09, 0.09);
  1142. glRotatef(-90, 0, 1, 0);
  1143. sofa1.pos.x = 0;
  1144. sofa1.pos.y = 0;
  1145. sofa1.pos.z = 0;
  1146. sofa1.Draw();
  1147. glPopMatrix();
  1148.  
  1149. ////////////////////////////
  1150.  
  1151. glPushMatrix();
  1152. glTranslated(1520, 100, 890);
  1153. glScaled(0.6, 0.6, 0.6);
  1154. glRotatef(180, 0, 1, 0);
  1155. Beroo.pos.x = 0;
  1156. Beroo.pos.y = 0;
  1157. Beroo.pos.z = 0;
  1158. Beroo.Draw();
  1159. glPopMatrix();
  1160.  
  1161. ///////////////////////////////////
  1162.  
  1163.  
  1164. glPushMatrix();
  1165. glTranslated(0, 3, 650);
  1166. glScaled(30, 30, 30);
  1167. Model3.pos.x = 0;
  1168. Model3.pos.y = 0;
  1169. Model3.pos.z = 0;
  1170. Model3.Draw();
  1171. glPopMatrix();
  1172.  
  1173. glPushMatrix();
  1174. glTranslated(-450, 3, 1300);
  1175. glScaled(30, 30, 30);
  1176. Model10.pos.x = 0;
  1177. Model10.pos.y = 0;
  1178. Model10.pos.z = 0;
  1179. Model10.Draw();
  1180. glPopMatrix();
  1181.  
  1182. glPushMatrix();
  1183. glTranslated(-600, 3, 500);
  1184. glRotated(90, 0, 1, 0);
  1185. glScaled(2, 2, 2);
  1186. Model7.pos.x = 0;
  1187. Model7.pos.y = 0;
  1188. Model7.pos.z = 0;
  1189. Model7.Draw();
  1190. glPopMatrix();
  1191.  
  1192. glPushMatrix();
  1193. glTranslated(1530, 60, -560);
  1194. glScalef(0.8, 0.8, 0.8);
  1195. M16.pos.x = 0;
  1196. M16.pos.y = 60;
  1197. M16.pos.z = 0;
  1198. M16.Draw();
  1199. glPopMatrix();
  1200.  
  1201.  
  1202. glPushMatrix();
  1203. glTranslated(1530, 60, -420);
  1204. glScalef(0.8, 0.8, 0.8);
  1205. M16.pos.x = 0;
  1206. M16.pos.y = 60;
  1207. M16.pos.z = 0;
  1208. M16.Draw();
  1209. glPopMatrix();
  1210.  
  1211. glPushMatrix();
  1212. glTranslated(1070, 40, -630);
  1213. glScalef(2, 2, 2);
  1214. AWP.pos.x = 0;
  1215. AWP.pos.y = 40;
  1216. AWP.pos.z = 0;
  1217. AWP.Draw();
  1218. glPopMatrix();
  1219.  
  1220. glPushMatrix();
  1221. glTranslated(1070, 40, -510);
  1222. glScalef(2, 2, 2);
  1223. AWP.pos.x = 0;
  1224. AWP.pos.y = 40;
  1225. AWP.pos.z = 0;
  1226. AWP.Draw();
  1227. glPopMatrix();
  1228.  
  1229.  
  1230. glPushMatrix();
  1231. glTranslated(1300, 30, -600);
  1232. glScaled(0.3, 0.3, 0.3);
  1233. Sword.pos.x = 0;
  1234. Sword.pos.y = 30;
  1235. Sword.pos.z = 0;
  1236. Sword.Draw();
  1237. glPopMatrix();
  1238.  
  1239. glPushMatrix();
  1240. glTranslated(1520, 20, -500);
  1241. glScaled(2.5, 2.5, 2.5);
  1242. PP19.pos.x = 0;
  1243. PP19.pos.y = 20;
  1244. PP19.pos.z = 0;
  1245. PP19.Draw();
  1246. glPopMatrix();
  1247.  
  1248. glPushMatrix();
  1249. glTranslated(1070, 35, -500);
  1250. glScaled(1.5, 1.5, 1.5);
  1251. M4.pos.x = 0;
  1252. M4.pos.y = 35;
  1253. M4.pos.z = 0;
  1254. M4.Draw();
  1255. glPopMatrix();
  1256.  
  1257. glPushMatrix();
  1258. glTranslated(1520, 140, -600);
  1259. glScaled(0.05, 0.05, 0.05);
  1260. glock.pos.x = 0;
  1261. glock.pos.y = 140;
  1262. glock.pos.z = 0;
  1263. glock.Draw();
  1264. glPopMatrix();
  1265.  
  1266. glPushMatrix();
  1267. glTranslated(1520, 140, -500);
  1268. glScaled(0.05, 0.05, 0.05);
  1269. glock.pos.x = 0;
  1270. glock.pos.y = 140;
  1271. glock.pos.z = 0;
  1272. glock.Draw();
  1273. glPopMatrix();
  1274.  
  1275. glPushMatrix();
  1276. glTranslated(1520, 140, -400);
  1277. glScaled(0.05, 0.05, 0.05);
  1278. glock.pos.x = 0;
  1279. glock.pos.y = 140;
  1280. glock.pos.z = 0;
  1281. glock.Draw();
  1282. glPopMatrix();
  1283.  
  1284.  
  1285.  
  1286. glPushMatrix();
  1287. glTranslated(1130, 150, -620);
  1288. glScaled(0.05, 0.05, 0.05);
  1289. RPG.pos.x = 0;
  1290. RPG.pos.y = 50;
  1291. RPG.pos.z = 0;
  1292. RPG.Draw();
  1293. glPopMatrix();
  1294.  
  1295. glPushMatrix();
  1296. glTranslated(1240, 150, -620);
  1297. glScaled(0.05, 0.05, 0.05);
  1298. RPG.pos.x = 0;
  1299. RPG.pos.y = 50;
  1300. RPG.pos.z = 0;
  1301. RPG.Draw();
  1302. glPopMatrix();
  1303.  
  1304.  
  1305. glPushMatrix();
  1306. glTranslated(1350, 150, -620);
  1307. glScaled(0.05, 0.05, 0.05);
  1308. RPG.pos.x = 0;
  1309. RPG.pos.y = 50;
  1310. RPG.pos.z = 0;
  1311. RPG.Draw();
  1312. glPopMatrix();
  1313.  
  1314.  
  1315. glPushMatrix();
  1316. glTranslated(1450, 150, -620);
  1317. glScaled(0.05, 0.05, 0.05);
  1318. RPG.pos.x = 0;
  1319. RPG.pos.y = 50;
  1320. RPG.pos.z = 0;
  1321. RPG.Draw();
  1322. glPopMatrix();
  1323.  
  1324.  
  1325. glPushMatrix();
  1326. glTranslated(2000, 45, -400);
  1327. glScaled(0.2, 0.2, 0.2);
  1328. Ch1.pos.x = -65;
  1329. Ch1.pos.y = 45;
  1330. Ch1.pos.z = 0;
  1331. Ch1.Draw();
  1332. glPopMatrix();
  1333.  
  1334.  
  1335. Connne(700, 15, 140, 300, 30, 1);
  1336. Connne(700, 15, 380, 300, 30, 1);
  1337.  
  1338. bool open = checkNearDoor(700, 155, 170);
  1339.  
  1340. if (open) {
  1341.  
  1342. if (DeafultX < 300) {
  1343. DeafultX += 50;
  1344. }
  1345. }
  1346. else // closed
  1347. {
  1348. if (DeafultX > 0)
  1349. DeafultX -= 50;
  1350.  
  1351. }
  1352.  
  1353. glPushMatrix();
  1354. glTranslated(1200, 30, 170); // translation for updating the door postion (Opening).
  1355. glBegin(GL_QUADS);
  1356. glColor3d(1, 0.3, 0.3);
  1357. glVertex3d(-2, 5, 2);
  1358. glVertex3d(-6, 5, 35);
  1359. glVertex3d(-6, -70, 35);
  1360. glVertex3d(-2, -70, 2);
  1361. glEnd();
  1362. glPopMatrix();
  1363.  
  1364. glPushMatrix();
  1365. glTranslated(1200, 30, 190); // translation for updating the door postion (Opening).
  1366. glBegin(GL_QUADS);
  1367. glColor3d(1, 0, 0.3);
  1368. glVertex3d(-2, 5, 2);
  1369. glVertex3d(-6, 5, 35);
  1370. glVertex3d(-6, -70, 35);
  1371. glVertex3d(-2, -70, 2);
  1372. glEnd();
  1373. glPopMatrix();
  1374.  
  1375.  
  1376. glPushMatrix();
  1377. glTranslated(-900, 5, 600);
  1378. glScaled(2, 2, 2);
  1379. Model8.pos.x = 0;
  1380. Model8.pos.y = 0;
  1381. Model8.pos.z = 0;
  1382. Model8.Draw();
  1383. glPopMatrix();
  1384.  
  1385. glPushMatrix();
  1386. glTranslated(-920, 30, 250);
  1387. glScaled(50, 50, 50);
  1388. Honda.pos.x = 0;
  1389. Honda.pos.y = 0;
  1390. Honda.pos.z = 0;
  1391. Honda.Draw();
  1392. glPopMatrix();
  1393.  
  1394. glPushMatrix();
  1395. glTranslated(-920, 40, 800);
  1396. glScaled(50, 50, 50);
  1397. Honda1.pos.x = 0;
  1398. Honda1.pos.y = 0;
  1399. Honda1.pos.z = 0;
  1400. Honda1.Draw();
  1401. glPopMatrix();
  1402.  
  1403. glPushMatrix();
  1404. glTranslated(100, 32, 1250);
  1405. glScaled(50, 50, 50);
  1406. Honda2.pos.x = 0;
  1407. Honda2.pos.y = 0;
  1408. Honda2.pos.z = 0;
  1409. Honda2.Draw();
  1410. glPopMatrix();
  1411.  
  1412. glPushMatrix();
  1413. glTranslated(-10, 32, 1250);
  1414. glScaled(50, 50, 50);
  1415. Honda1.pos.x = 0;
  1416. Honda1.pos.y = 0;
  1417. Honda1.pos.z = 0;
  1418. Honda1.Draw();
  1419. glPopMatrix();
  1420.  
  1421.  
  1422. glPushMatrix();
  1423. glTranslated(200, 125, 1100);
  1424. glScaled(3, 3, 3);
  1425. Model6.pos.x = 0;
  1426. Model6.pos.y = 0;
  1427. Model6.pos.z = 0;
  1428. Model6.Draw();
  1429. glPopMatrix();
  1430.  
  1431.  
  1432. glPushMatrix();
  1433. glTranslated(185, 0, 125);
  1434. glScaled(5, 5, 5);
  1435. Model5.pos.x = 0;
  1436. Model5.pos.y = 0;
  1437. Model5.pos.z = 0;
  1438. Model5.Draw();
  1439. glPopMatrix();
  1440.  
  1441. glPushMatrix();
  1442. glTranslated(185, 0, -80);
  1443. glScaled(5, 5, 5);
  1444. Model5.pos.x = 0;
  1445. Model5.pos.y = 0;
  1446. Model5.pos.z = 0;
  1447. Model5.Draw();
  1448. glPopMatrix();
  1449.  
  1450.  
  1451. glPushMatrix();
  1452. glTranslated(0, 0, -400);
  1453. Build1.Draw();
  1454. glPopMatrix();
  1455.  
  1456. glTranslated(-240, 0, -400);
  1457. Build2.Draw();
  1458. glTranslated(-625, 0, 0);
  1459. Build3.Draw();
  1460. glPushMatrix();
  1461. glRotated(90, 0, 1, 0);
  1462. glTranslated(-500, 0, -375);
  1463. Build4.Draw();
  1464. glPopMatrix();
  1465. glPushMatrix();
  1466. glRotated(90, 0, 1, 0);
  1467. glTranslated(-1400, 0, -375);
  1468. Build5.Draw();
  1469. glPopMatrix();
  1470. glPushMatrix();
  1471. glRotated(90, 0, 1, 0);
  1472. glTranslated(-1400, 210, -375);
  1473. Build5Floor2.Draw();
  1474. glPopMatrix();
  1475.  
  1476. //glPushMatrix();
  1477. //glRotated(180, 0, 1, 0);
  1478. //glTranslated(0, 0, 1400);
  1479. //Build6.Draw();
  1480. //glPopMatrix();
  1481.  
  1482.  
  1483. glPushMatrix();
  1484.  
  1485. glRotated(90, 0, 1, 0);
  1486. glRotated(90, 1, 0, 0);
  1487. GroundRoad.SetPosition(-300, 0, -0.5);
  1488. GroundRoad.SetDimntion(2500, 6000);
  1489. GroundRoad.SetTexture(Raod2);
  1490. GroundRoad.Draw();
  1491. glPopMatrix();
  1492.  
  1493. glPushMatrix();
  1494. glRotated(90, 1, 0, 0);
  1495. GroundRoad.SetPosition(-95, 0, -0.5);
  1496. GroundRoad.SetDimntion(2500, 205);
  1497. GroundRoad.SetTexture(Road3);
  1498. GroundRoad.Draw();
  1499. glPopMatrix();
  1500.  
  1501.  
  1502. glPushMatrix();
  1503. glTranslated(250, 3, 500);
  1504. glScaled(0.2, 0.2, 0.2);
  1505. Model1.pos.x = 0;
  1506. Model1.pos.y = 0;
  1507. Model1.pos.z = 0;
  1508. Model1.Draw();
  1509. glPopMatrix();
  1510.  
  1511. glPushMatrix();
  1512. glTranslated(1300, 615, 2000);
  1513. glScaled(35, 35, 35);
  1514. Mosc.pos.x = 0;
  1515. Mosc.pos.y = 0;
  1516. Mosc.pos.z = 0;
  1517. Mosc.Draw();
  1518. glPopMatrix();
  1519. glPushMatrix();
  1520. glTranslatef(370, 0, 0);
  1521. Ligth3d();
  1522. Ligth();
  1523. glPopMatrix();
  1524.  
  1525.  
  1526. glFlush();
  1527. Sleep(1);
  1528. return TRUE;
  1529. }
  1530.  
  1531.  
  1532. GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
  1533. {
  1534. if (fullscreen) // Are We In Fullscreen Mode?
  1535. {
  1536. ChangeDisplaySettings(NULL, 0); // If So Switch Back To The Desktop
  1537. ShowCursor(TRUE); // Show Mouse Pointer
  1538. }
  1539.  
  1540. if (hRC) // Do We Have A Rendering Context?
  1541. {
  1542. if (!wglMakeCurrent(NULL, NULL)) // Are We Able To Release The DC And RC Contexts?
  1543. {
  1544. MessageBox(NULL, "Release Of DC And RC Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
  1545. }
  1546.  
  1547. if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
  1548. {
  1549. MessageBox(NULL, "Release Rendering Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
  1550. }
  1551. hRC = NULL; // Set RC To NULL
  1552. }
  1553.  
  1554. if (hDC && !ReleaseDC(hWnd, hDC)) // Are We Able To Release The DC
  1555. {
  1556. MessageBox(NULL, "Release Device Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
  1557. hDC = NULL; // Set DC To NULL
  1558. }
  1559.  
  1560. if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
  1561. {
  1562. MessageBox(NULL, "Could Not Release hWnd.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
  1563. hWnd = NULL; // Set hWnd To NULL
  1564. }
  1565.  
  1566. if (!UnregisterClass("OpenGL", hInstance)) // Are We Able To Unregister Class
  1567. {
  1568. MessageBox(NULL, "Could Not Unregister Class.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
  1569. hInstance = NULL; // Set hInstance To NULL
  1570. }
  1571. }
  1572.  
  1573. /* This Code Creates Our OpenGL Window. Parameters Are: *
  1574. * title - Title To Appear At The Top Of The Window *
  1575. * width - Width Of The GL Window Or Fullscreen Mode *
  1576. * height - Height Of The GL Window Or Fullscreen Mode *
  1577. * bits - Number Of Bits To Use For Color (8/16/24/32) *
  1578. * fullscreenflag - Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE) */
  1579.  
  1580. BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
  1581. {
  1582. GLuint PixelFormat; // Holds The Results After Searching For A Match
  1583. WNDCLASS wc; // Windows Class Structure
  1584. DWORD dwExStyle; // Window Extended Style
  1585. DWORD dwStyle; // Window Style
  1586. RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
  1587. WindowRect.left = (long)0; // Set Left Value To 0
  1588. WindowRect.right = (long)width; // Set Right Value To Requested Width
  1589. WindowRect.top = (long)0; // Set Top Value To 0
  1590. WindowRect.bottom = (long)height; // Set Bottom Value To Requested Height
  1591.  
  1592. fullscreen = fullscreenflag; // Set The Global Fullscreen Flag
  1593.  
  1594. hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
  1595. wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
  1596. wc.lpfnWndProc = (WNDPROC)WndProc; // WndProc Handles Messages
  1597. wc.cbClsExtra = 0; // No Extra Window Data
  1598. wc.cbWndExtra = 0; // No Extra Window Data
  1599. wc.hInstance = hInstance; // Set The Instance
  1600. wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
  1601. wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
  1602. wc.hbrBackground = NULL; // No Background Required For GL
  1603. wc.lpszMenuName = NULL; // We Don't Want A Menu
  1604. wc.lpszClassName = "OpenGL"; // Set The Class Name
  1605.  
  1606. if (!RegisterClass(&wc)) // Attempt To Register The Window Class
  1607. {
  1608. MessageBox(NULL, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1609. return FALSE; // Return FALSE
  1610. }
  1611.  
  1612. if (fullscreen) // Attempt Fullscreen Mode?
  1613. {
  1614. DEVMODE dmScreenSettings; // Device Mode
  1615. memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
  1616. dmScreenSettings.dmSize = sizeof(dmScreenSettings); // Size Of The Devmode Structure
  1617. dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
  1618. dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
  1619. dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
  1620. dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
  1621.  
  1622. // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
  1623. if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
  1624. {
  1625. // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
  1626. if (MessageBox(NULL, "The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?", "GL template", MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
  1627. {
  1628. fullscreen = FALSE; // Windowed Mode Selected. Fullscreen = FALSE
  1629. }
  1630. else
  1631. {
  1632. // Pop Up A Message Box Letting User Know The Program Is Closing.
  1633. MessageBox(NULL, "Program Will Now Close.", "ERROR", MB_OK | MB_ICONSTOP);
  1634. return FALSE; // Return FALSE
  1635. }
  1636. }
  1637. }
  1638.  
  1639. if (fullscreen) // Are We Still In Fullscreen Mode?
  1640. {
  1641. dwExStyle = WS_EX_APPWINDOW; // Window Extended Style
  1642. dwStyle = WS_POPUP; // Windows Style
  1643. ShowCursor(FALSE); // Hide Mouse Pointer
  1644. }
  1645. else
  1646. {
  1647. dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
  1648. dwStyle = WS_OVERLAPPEDWINDOW; // Windows Style
  1649. }
  1650.  
  1651. AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
  1652.  
  1653. // Create The Window
  1654. if (!(hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window
  1655. "OpenGL", // Class Name
  1656. title, // Window Title
  1657. dwStyle | // Defined Window Style
  1658. WS_CLIPSIBLINGS | // Required Window Style
  1659. WS_CLIPCHILDREN, // Required Window Style
  1660. 0, 0, // Window Position
  1661. WindowRect.right - WindowRect.left, // Calculate Window Width
  1662. WindowRect.bottom - WindowRect.top, // Calculate Window Height
  1663. NULL, // No Parent Window
  1664. NULL, // No Menu
  1665. hInstance, // Instance
  1666. NULL))) // Dont Pass Anything To WM_CREATE
  1667. {
  1668. KillGLWindow(); // Reset The Display
  1669. MessageBox(NULL, "Window Creation Error.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1670. return FALSE; // Return FALSE
  1671. }
  1672.  
  1673. static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
  1674. {
  1675. sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
  1676. 1, // Version Number
  1677. PFD_DRAW_TO_WINDOW | // Format Must Support Window
  1678. PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
  1679. PFD_DOUBLEBUFFER, // Must Support Double Buffering
  1680. PFD_TYPE_RGBA, // Request An RGBA Format
  1681. bits, // Select Our Color Depth
  1682. 0, 0, 0, 0, 0, 0, // Color Bits Ignored
  1683. 0, // No Alpha Buffer
  1684. 0, // Shift Bit Ignored
  1685. 0, // No Accumulation Buffer
  1686. 0, 0, 0, 0, // Accumulation Bits Ignored
  1687. 16, // 16Bit Z-Buffer (Depth Buffer)
  1688. 0, // No Stencil Buffer
  1689. 0, // No Auxiliary Buffer
  1690. PFD_MAIN_PLANE, // Main Drawing Layer
  1691. 0, // Reserved
  1692. 0, 0, 0 // Layer Masks Ignored
  1693. };
  1694.  
  1695. if (!(hDC = GetDC(hWnd))) // Did We Get A Device Context?
  1696. {
  1697. KillGLWindow(); // Reset The Display
  1698. MessageBox(NULL, "Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1699. return FALSE; // Return FALSE
  1700. }
  1701.  
  1702. if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) // Did Windows Find A Matching Pixel Format?
  1703. {
  1704. KillGLWindow(); // Reset The Display
  1705. MessageBox(NULL, "Can't Find A Suitable PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1706. return FALSE; // Return FALSE
  1707. }
  1708.  
  1709. if (!SetPixelFormat(hDC, PixelFormat, &pfd)) // Are We Able To Set The Pixel Format?
  1710. {
  1711. KillGLWindow(); // Reset The Display
  1712. MessageBox(NULL, "Can't Set The PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1713. return FALSE; // Return FALSE
  1714. }
  1715.  
  1716. if (!(hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
  1717. {
  1718. KillGLWindow(); // Reset The Display
  1719. MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1720. return FALSE; // Return FALSE
  1721. }
  1722.  
  1723. if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context
  1724. {
  1725. KillGLWindow(); // Reset The Display
  1726. MessageBox(NULL, "Can't Activate The GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1727. return FALSE; // Return FALSE
  1728. }
  1729.  
  1730. ShowWindow(hWnd, SW_SHOW); // Show The Window
  1731. SetForegroundWindow(hWnd); // Slightly Higher Priority
  1732. SetFocus(hWnd); // Sets Keyboard Focus To The Window
  1733. ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
  1734.  
  1735. if (!InitGL()) // Initialize Our Newly Created GL Window
  1736. {
  1737. KillGLWindow(); // Reset The Display
  1738. MessageBox(NULL, "Initialization Failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
  1739. return FALSE; // Return FALSE
  1740. }
  1741.  
  1742. return TRUE; // Success
  1743. }
  1744.  
  1745. LRESULT CALLBACK WndProc(HWND hWnd, // Handle For This Window
  1746. UINT uMsg, // Message For This Window
  1747. WPARAM wParam, // Additional Message Information
  1748. LPARAM lParam) // Additional Message Information
  1749. {
  1750. switch (uMsg) // Check For Windows Messages
  1751. {
  1752. case WM_MOUSEMOVE: { mouseX = (int)LOWORD(lParam); mouseY = (int)HIWORD(lParam); isClicked = (LOWORD(wParam) & MK_LBUTTON) ? true : false; isRClicked = (LOWORD(wParam) & MK_RBUTTON) ? true : false; break; }
  1753. case WM_LBUTTONUP: isClicked = false; break;
  1754. case WM_RBUTTONUP: isRClicked = false; break;
  1755. case WM_LBUTTONDOWN: isClicked = true; break;
  1756. case WM_RBUTTONDOWN: isRClicked = true; break;
  1757. case WM_ACTIVATE: // Watch For Window Activate Message
  1758. {
  1759. if (!HIWORD(wParam)) // Check Minimization State
  1760. {
  1761. active = TRUE; // Program Is Active
  1762. }
  1763. else
  1764. {
  1765. active = FALSE; // Program Is No Longer Active
  1766. }
  1767.  
  1768. return 0; // Return To The Message Loop
  1769. }
  1770.  
  1771. case WM_SYSCOMMAND: // Intercept System Commands
  1772. {
  1773. switch (wParam) // Check System Calls
  1774. {
  1775. case SC_SCREENSAVE: // Screensaver Trying To Start?
  1776. case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
  1777. return 0; // Prevent From Happening
  1778. }
  1779. break; // Exit
  1780. }
  1781.  
  1782. case WM_CLOSE: // Did We Receive A Close Message?
  1783. {
  1784. PostQuitMessage(0); // Send A Quit Message
  1785. return 0; // Jump Back
  1786. }
  1787.  
  1788. case WM_KEYDOWN: // Is A Key Being Held Down?
  1789. {
  1790. keys[wParam] = TRUE; // If So, Mark It As TRUE
  1791. return 0; // Jump Back
  1792. }
  1793.  
  1794. case WM_KEYUP: // Has A Key Been Released?
  1795. {
  1796. keys[wParam] = FALSE; // If So, Mark It As FALSE
  1797. return 0; // Jump Back
  1798. }
  1799.  
  1800. case WM_SIZE: // Resize The OpenGL Window
  1801. {
  1802. ReSizeGLScene(LOWORD(lParam), HIWORD(lParam)); // LoWord=Width, HiWord=Height
  1803. return 0; // Jump Back
  1804. }
  1805. }
  1806.  
  1807. // Pass All Unhandled Messages To DefWindowProc
  1808. return DefWindowProc(hWnd, uMsg, wParam, lParam);
  1809. }
  1810.  
  1811. int WINAPI WinMain(HINSTANCE hInstance, // Instance
  1812. HINSTANCE hPrevInstance, // Previous Instance
  1813. LPSTR lpCmdLine, // Command Line Parameters
  1814. int nCmdShow) // Window Show State
  1815. {
  1816. MSG msg; // Windows Message Structure
  1817. BOOL done = FALSE; // Bool Variable To Exit Loop
  1818.  
  1819. // Ask The User Which Screen Mode They Prefer
  1820. //if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
  1821. {
  1822. fullscreen = FALSE; // Windowed Mode
  1823. }
  1824.  
  1825. // Create Our OpenGL Window
  1826. if (!CreateGLWindow("OpenGL template", 640, 480, 16, fullscreen))
  1827. {
  1828. return 0; // Quit If Window Was Not Created
  1829. }
  1830.  
  1831. while (!done) // Loop That Runs While done=FALSE
  1832. {
  1833. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // Is There A Message Waiting?
  1834. {
  1835. if (msg.message == WM_QUIT) // Have We Received A Quit Message?
  1836. {
  1837. done = TRUE; // If So done=TRUE
  1838. }
  1839. else // If Not, Deal With Window Messages
  1840. {
  1841. TranslateMessage(&msg); // Translate The Message
  1842. DispatchMessage(&msg); // Dispatch The Message
  1843. }
  1844. }
  1845. else // If There Are No Messages
  1846. {
  1847. // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
  1848. if (active) // Program Active?
  1849. {
  1850. if (keys[VK_ESCAPE]) // Was ESC Pressed?
  1851. {
  1852. done = TRUE; // ESC Signalled A Quit
  1853. }
  1854. else // Not Time To Quit, Update Screen
  1855. {
  1856. DrawGLScene(); // Draw The Scene
  1857. SwapBuffers(hDC); // Swap Buffers (Double Buffering)
  1858. }
  1859. }
  1860.  
  1861. if (keys[VK_F1]) // Is F1 Being Pressed?
  1862. {
  1863. keys[VK_F1] = FALSE; // If So Make Key FALSE
  1864. KillGLWindow(); // Kill Our Current Window
  1865. fullscreen = !fullscreen; // Toggle Fullscreen / Windowed Mode
  1866. // Recreate Our OpenGL Window
  1867. if (!CreateGLWindow("OpenGL template", 640, 480, 16, fullscreen))
  1868. {
  1869. return 0; // Quit If Window Was Not Created
  1870. }
  1871. }
  1872. }
  1873. }
  1874.  
  1875. // Shutdown
  1876. KillGLWindow(); // Kill The Window
  1877. return (msg.wParam); // Exit The Program
  1878. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement