Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.71 KB | None | 0 0
  1. // Useful reference: https://docs.microsoft.com/en-us/windows/desktop/opengl/glmatrixmode
  2. // This code is suitable for the following OpenGL primitives:
  3. // GL_POINTS , GL_LINES , GL_LINE_STRIP , GL_LINE_LOOP , GL_POLYGON , GL_TRIANGLES , GL_TRIANGLE_STRIP.
  4. //#include <Windows.h>
  5. //#include <GL\glew.h>
  6. //#include <GL\freeglut.h>
  7. //#include <iostream>
  8. //
  9. //using namespace std;
  10. //
  11. //void display() // Drawing function
  12. //{
  13. //
  14. // //glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
  15. //
  16. // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
  17. // //Indicates the buffers currently enabled for color writing.
  18. //
  19. // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
  20. //
  21. // glLoadIdentity(); //has to be at beg of any prog that has transformations
  22. //
  23. // glLineWidth(2.0); // when we connect line
  24. //
  25. // //glColor3f(1, 0, 0.0); // to color the lines def=white
  26. //
  27. // glBegin(GL_TRIANGLE_STRIP); // the shape you want to draw
  28. //
  29. // glColor3f(1, 0, 0);
  30. // glVertex3f(0.2f, 0.2f, 0.0f); // drawing the points
  31. // glVertex3f(0.4f, 0.2f, 0.0f);
  32. // glVertex3f(0.5f, 0.5f, 0.0f);
  33. //
  34. // glColor3f(1,1,0);
  35. // glVertex3f(0.4f, 0.8f, 0.0f);
  36. //
  37. // glColor3f(1, 1, 1);
  38. // glVertex3f(0.2f, 0.8f, 0.0f);
  39. //
  40. // glColor3f(0, 0, 1);
  41. // glVertex3f(0.1f, 0.5f, 0.0f);
  42. //
  43. // glEnd();
  44. // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
  45. //}
  46. //
  47. //void main(int argc, char* argv[]) {
  48. //
  49. // // Initialize GLUT
  50. // glutInit(&argc, argv);
  51. //
  52. // // Set up some memory buffers for our display
  53. // glutInitDisplayMode(GLUT_SINGLE);
  54. //
  55. // // Set the window size
  56. // glutInitWindowSize(400, 400);
  57. //
  58. // // Create the window with the title "Hello,GL"
  59. // glutCreateWindow("Hello, GL");
  60. // // Bind the two functions (above) to respond when necessary
  61. //
  62. // glutDisplayFunc(display);
  63. // // Very important! This initializes the entry points in the OpenGL driver so we can
  64. // // call all the functions in the API.
  65. //
  66. // glutMainLoop(); // to show the frame
  67. //}
  68.  
  69. // This code is suitable for the following OpenGL primitives:
  70. // GL_QUADS.
  71. //#include <Windows.h>
  72. //#include <GL\glew.h>
  73. //#include <GL\freeglut.h>
  74. //#include <iostream>
  75. //
  76. //using namespace std;
  77. //
  78. //void display() // Drawing function
  79. //{
  80. //
  81. // glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
  82. //
  83. // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
  84. // //Indicates the buffers currently enabled for color writing.
  85. //
  86. // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
  87. //
  88. // glLoadIdentity(); //has to be at beg of any prog that has transformations
  89. //
  90. // glLineWidth(2.0); // when we connect line
  91. //
  92. // glBegin(GL_QUADS); //the shape you want to draw
  93. //
  94. // glColor3f(0, 0, 0); // to color the lines def=white
  95. //
  96. // glVertex3f(-0.5f, 0.5f, 0.0f); // drawing the points
  97. // glVertex3f(-0.5f, 0.3f, 0.0f);
  98. // glVertex3f(-0.2f, 0.1f, 0.0f);
  99. // glVertex3f(-0.2f, 0.8f, 0.0f);
  100. //
  101. // glVertex3f(0.5f, 0.5f, 0.0f);
  102. // glVertex3f(0.5f, 0.3f, 0.0f);
  103. // glVertex3f(0.2f, 0.1f, 0.0f);
  104. // glVertex3f(0.2f, 0.8f, 0.0f);
  105. //
  106. // glEnd();
  107. // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
  108. //}
  109. //
  110. //void main(int argc, char* argv[]) {
  111. //
  112. // // Initialize GLUT
  113. // glutInit(&argc, argv);
  114. //
  115. // // Set up some memory buffers for our display
  116. // glutInitDisplayMode(GLUT_SINGLE);
  117. //
  118. // // Set the window size
  119. // glutInitWindowSize(400, 400);
  120. //
  121. // // Create the window with the title "Hello,GL"
  122. // glutCreateWindow("Hello, GL");
  123. // // Bind the two functions (above) to respond when necessary
  124. //
  125. // glutDisplayFunc(display);
  126. // // Very important! This initializes the entry points in the OpenGL driver so we can
  127. // // call all the functions in the API.
  128. //
  129. // glutMainLoop(); // to show the frame
  130. //}
  131.  
  132. // This code is suitable for the following OpenGL primitives:
  133. // GL_QUAD_STRIP.
  134. //#include <Windows.h>
  135. //#include <GL\glew.h>
  136. //#include <GL\freeglut.h>
  137. //#include <iostream>
  138. //
  139. //using namespace std;
  140. //
  141. //void display() // Drawing function
  142. //{
  143. //
  144. // glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
  145. //
  146. // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
  147. // //Indicates the buffers currently enabled for color writing.
  148. //
  149. // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
  150. //
  151. // glLoadIdentity(); //has to be at beg of any prog that has transformations
  152. //
  153. // glLineWidth(2.0); // when we connect line
  154. //
  155. // glBegin(GL_QUAD_STRIP); //the shape you want to draw
  156. //
  157. // glColor3f(0, 0, 0); // to color the lines def=white
  158. //
  159. // glColor3f(0,0,0);
  160. // glVertex3f(0.1f, -0.2f, 0.0f); // drawing the points
  161. // glVertex3f(0.2f, 0.3f, 0.0f);
  162. // glVertex3f(-0.3f, -0.2f, 0.0f);
  163. // glVertex3f(-0.1f, 0.5f, 0.0f);
  164. //
  165. //
  166. // glColor3f(1,1,1);
  167. // glVertex3f(-0.5f, 0.3f, 0.0f);
  168. // glVertex3f(-0.5f, 0.7f, 0.0f);
  169. //
  170. // glColor3f(1, 0, 0);
  171. // glVertex3f(-0.9f, 0.3f, 0.0f);
  172. // glVertex3f(-0.8f, 0.6f, 0.0f);
  173. //
  174. // glEnd();
  175. // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
  176. //}
  177. //
  178. //void main(int argc, char* argv[]) {
  179. //
  180. // // Initialize GLUT
  181. // glutInit(&argc, argv);
  182. //
  183. // // Set up some memory buffers for our display
  184. // glutInitDisplayMode(GLUT_SINGLE);
  185. //
  186. // // Set the window size
  187. // glutInitWindowSize(400, 400);
  188. //
  189. // // Create the window with the title "Hello,GL"
  190. // glutCreateWindow("Hello, GL");
  191. // // Bind the two functions (above) to respond when necessary
  192. //
  193. // glutDisplayFunc(display);
  194. // // Very important! This initializes the entry points in the OpenGL driver so we can
  195. // // call all the functions in the API.
  196. //
  197. // glutMainLoop(); // to show the frame
  198. //}
  199.  
  200. // Cool Shape for GL_TRIANGLE_STRIP , GL_TRIANGLE
  201. //#include <Windows.h>
  202. //#include <GL\glew.h>
  203. //#include <GL\freeglut.h>
  204. //#include <iostream>
  205. //
  206. //using namespace std;
  207. //
  208. //void display() // Drawing function
  209. //{
  210. //
  211. // glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
  212. //
  213. // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
  214. // //Indicates the buffers currently enabled for color writing.
  215. //
  216. // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
  217. //
  218. // glLoadIdentity(); //has to be at beg of any prog that has transformations
  219. //
  220. // glLineWidth(2.0); // when we connect line
  221. //
  222. // glBegin(GL_TRIANGLES); //the shape you want to draw
  223. //
  224. // glColor3f(0, 0, 0); // to color the lines def=white
  225. // glVertex3f(0.0f, 0.0f, 0.0f); // drawing the points
  226. // glVertex3f(0.5f, 0.0f, 0.0f);
  227. // glVertex3f(0.5f, 0.5f, 0.0f);
  228. //
  229. // glVertex3f(0.0f, 0.0f, 0.0f);
  230. // glVertex3f(0.0f, 0.5f, 0.0f);
  231. // glVertex3f(-0.5f, 0.5f, 0.0f);
  232. //
  233. //
  234. // glVertex3f(0.0f, 0.0f, 0.0f);
  235. // glVertex3f(-0.5f, 0.0f, 0.0f);
  236. // glVertex3f(-0.5f, -0.5f, 0.0f);
  237. //
  238. // glVertex3f(0.0f, 0.0f, 0.0f);
  239. // glVertex3f(0.0f, -0.5f, 0.0f);
  240. // glVertex3f(0.5f, -0.5f, 0.0f);
  241. //
  242. // glEnd();
  243. // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
  244. //}
  245. //
  246. //void main(int argc, char* argv[]) {
  247. //
  248. // // Initialize GLUT
  249. // glutInit(&argc, argv);
  250. //
  251. // // Set up some memory buffers for our display
  252. // glutInitDisplayMode(GLUT_SINGLE);
  253. //
  254. // // Set the window size
  255. // glutInitWindowSize(400, 400);
  256. //
  257. // // Create the window with the title "Hello,GL"
  258. // glutCreateWindow("Hello, GL");
  259. // // Bind the two functions (above) to respond when necessary
  260. //
  261. // glutDisplayFunc(display);
  262. // // Very important! This initializes the entry points in the OpenGL driver so we can
  263. // // call all the functions in the API.
  264. //
  265. // glutMainLoop(); // to show the frame
  266. //}
  267.  
  268. // This code is suitable for the following OpenGL primitives:
  269. // GL_TRIANGLE_FAN
  270. #include <Windows.h>
  271. #include <GL\glew.h>
  272. #include <GL\freeglut.h>
  273. #include <iostream>
  274.  
  275. using namespace std;
  276.  
  277. void display() // Drawing function
  278. {
  279.  
  280. glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
  281.  
  282. glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
  283. //Indicates the buffers currently enabled for color writing.
  284.  
  285. glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
  286.  
  287. glLoadIdentity(); //has to be at beg of any prog that has transformations
  288.  
  289. glLineWidth(2.0); // when we connect line
  290.  
  291. glBegin(GL_TRIANGLE_FAN);
  292.  
  293. glColor3f(0, 0, 0); // to color the lines def=black
  294. glVertex3f(0.0f, 0.0f, 0.0f); // drawing the points
  295. glVertex3f(0.5f, 0.0f, 0.0f);
  296. glVertex3f(0.5f, 0.5f, 0.0f);
  297.  
  298. glColor3f(1, 0, 0);
  299. glVertex3f(0.0f, 0.5f, 0.0f);
  300.  
  301. glColor3f(0, 1, 0);
  302. glVertex3f(-0.5f, 0.5f, 0.0f);
  303.  
  304. glColor3f(0, 0, 1);
  305. glVertex3f(-0.5f, 0.0f, 0.0f);
  306.  
  307. glColor3f(0, 1, 1);
  308. glVertex3f(-0.5f, -0.5f, 0.0f);
  309.  
  310. glColor3f(1, 1, 1);
  311. glVertex3f(0.0f, -0.5f, 0.0f);
  312.  
  313. glColor3f(1, 1, 0);
  314. glVertex3f(0.5f, -0.5f, 0.0f);
  315.  
  316. glColor3f(1,1,1);
  317. glVertex3f(0.5f, 0.0f, 0.0f);
  318.  
  319. glEnd();
  320. glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
  321. }
  322.  
  323. void main(int argc, char* argv[]) {
  324.  
  325. // Initialize GLUT
  326. glutInit(&argc, argv);
  327.  
  328. // Set up some memory buffers for our display
  329. glutInitDisplayMode(GLUT_SINGLE);
  330.  
  331. // Set the window size
  332. glutInitWindowSize(400, 400);
  333.  
  334. // Create the window with the title "Hello,GL"
  335. glutCreateWindow("Hello, GL");
  336. // Bind the two functions (above) to respond when necessary
  337.  
  338. glutDisplayFunc(display);
  339. // Very important! This initializes the entry points in the OpenGL driver so we can
  340. // call all the functions in the API.
  341.  
  342. glutMainLoop(); // to show the frame
  343. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement