Advertisement
Ladies_Man

justincase

Oct 26th, 2015
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.96 KB | None | 0 0
  1.  
  2. // glfw_30.cpp : Defines the entry point for the console application.
  3. //  http://www.glfw.org/docs/latest/quick.html
  4.  
  5. #include "stdafx.h"
  6. #include <time.h>
  7. #define _USE_MATH_DEFINES
  8. #include <cmath>
  9. #include <stdio.h>
  10. #include <iostream>
  11. #include <string>
  12.  
  13.  
  14. #pragma comment(lib,"glaux.lib")
  15.  
  16.  
  17. #define SCREEN_WIDTH 1000
  18. #define SCREEN_HEIGHT 1000
  19. #define SPLIT_X 10
  20. #define SPLIT_Y 10
  21. #define G_CONST 9.78
  22.  
  23. #define REVD(X) ((SPLIT_Y) - (X))
  24.  
  25. using namespace std;
  26.  
  27. float t;
  28.  
  29. GLdouble A, B, C, D;
  30.  
  31. float delta_pos(float velocity, float acceleration);
  32.  
  33. class map;
  34. class body;
  35. class block;
  36. class cargo;
  37. class pendulum;
  38.  
  39.  
  40.  
  41.  
  42. typedef struct {
  43.     int x, y;
  44. } coord;
  45.  
  46. typedef struct {
  47.     coord botleft, topleft, topright, botright;
  48.     int type;
  49. } cell;
  50.  
  51. class map {
  52. public:
  53.    
  54.  
  55.     void set_map(int, int);
  56.     void clean_map();
  57.     void draw_net();
  58.     void draw_obj();
  59.     void print_map();
  60.  
  61.     void set_cell(int, int, int);
  62.  
  63. private:
  64.     int map_size_y;
  65.     int map_size_x;
  66.  
  67.     cell **map_arr;
  68.     int cell_size_x;
  69.     int cell_size_y;
  70. };
  71.  
  72. void map::set_map(int rows, int cols) {
  73.     this->map_size_y = rows;
  74.     this->map_size_x = cols;
  75.  
  76.     this->cell_size_x = (int)(SCREEN_WIDTH / SPLIT_X);
  77.     this->cell_size_y = (int)(SCREEN_HEIGHT / SPLIT_Y);
  78.  
  79.     this->map_arr = (cell **)malloc(this->map_size_y * sizeof(cell *));
  80.     // a[0]
  81.     // a[1]
  82.     // a[2]
  83.     // a[3]
  84.  
  85.     int i, j;
  86.     for (i = 0; i < this->map_size_y; i++) {
  87.         this->map_arr[i] = (cell *)malloc(this->map_size_x * sizeof(cell)); // a[0][0] a[0][1] a[0][2] a[0][3]
  88.     }
  89.  
  90.     for (i = 0; i < this->map_size_y; i++) {
  91.         for (j = 0; j < this->map_size_x; j++) {
  92.             this->map_arr[i][j].type = 0;
  93.         }
  94.     }
  95. }
  96.  
  97. void map::clean_map() {
  98.     for (int i = 0; i < this->map_size_y; i++) {
  99.         delete[] this->map_arr[i];
  100.     }
  101.     delete[] this->map_arr;
  102. }
  103.  
  104. void map::draw_net() {
  105.     int i, j;
  106.  
  107.     for (i = 0; i < SCREEN_WIDTH; i += SCREEN_WIDTH / this->map_size_x) {
  108.         glColor3f(1, 1, 1);
  109.         for (j = 0; j < SCREEN_HEIGHT; j += SCREEN_HEIGHT / this->map_size_y) {
  110.             glBegin(GL_LINES);
  111.             glVertex2f(i, 0);
  112.             glVertex2f(i, SCREEN_HEIGHT);
  113.             glEnd();
  114.  
  115.             glBegin(GL_LINES);
  116.             glVertex2f(0, j);
  117.             glVertex2f(SCREEN_WIDTH, j);
  118.             glEnd();
  119.         }
  120.     }
  121. }
  122.  
  123. void map::draw_obj() {
  124.     int i, j;
  125.  
  126.     for (j = 0; j < this->map_size_y; j++) {
  127.         for (i = 0; i < this->map_size_x; i++) {
  128.             if (0 != map_arr[i][j].type) {
  129.                 if (1 == map_arr[i][j].type) {
  130.                     glColor3f(1, 0, 0);
  131.                 }
  132.                 if (2 == map_arr[i][j].type) {
  133.                     glColor3f(0, 0, 1);
  134.                 }
  135.  
  136.                 glBegin(GL_POLYGON);
  137.                 glVertex2f(map_arr[i][j].botleft.x, map_arr[i][j].botleft.y);
  138.                 glVertex2f(map_arr[i][j].topleft.x, map_arr[i][j].topleft.y);
  139.                 glVertex2f(map_arr[i][j].topright.x, map_arr[i][j].topright.y);
  140.                 glVertex2f(map_arr[i][j].botright.x, map_arr[i][j].botright.y);
  141.                 glEnd();
  142.             }
  143.         }
  144.     }
  145. }
  146.  
  147. void map::print_map() {
  148.     int i, j;
  149.  
  150.     printf("\ncurrent map:\n");
  151.     for (j = 0; j < this->map_size_y; j++) {
  152.         for (i = 0; i < this->map_size_x; i++) {
  153.             if (0 == this->map_arr[i][j].type) {
  154.                 printf("- ");
  155.             }
  156.             if (1 == this->map_arr[i][j].type) {
  157.                 printf("C ");
  158.             }
  159.             if (2 == this->map_arr[i][j].type) {
  160.                 printf("B ");
  161.             }
  162.         }
  163.         printf("\n");
  164.     }
  165.  
  166. }
  167.  
  168. void map::set_cell(int x, int y, int type) {
  169.     this->map_arr[x][REVD(y)].type = type;
  170.  
  171.     this->map_arr[x][REVD(y)].botleft.x = (int)(x * this->cell_size_x);// -this->cell_size_x / 2);
  172.     this->map_arr[x][REVD(y)].botleft.y = (int)(y * this->cell_size_y);// + this->cell_size_y / 2);
  173.  
  174.     this->map_arr[x][REVD(y)].topleft.x = (int)(x * this->cell_size_x);// - this->cell_size_x / 2);
  175.     this->map_arr[x][REVD(y)].topleft.y = (int)(y * this->cell_size_y + this->cell_size_y);
  176.  
  177.     this->map_arr[x][REVD(y)].topright.x = (int)(x * this->cell_size_x + this->cell_size_x);
  178.     this->map_arr[x][REVD(y)].topright.y = (int)(y * this->cell_size_y + this->cell_size_y);
  179.  
  180.     this->map_arr[x][REVD(y)].botright.x = (int)(x * this->cell_size_x + this->cell_size_x);
  181.     this->map_arr[x][REVD(y)].botright.y = (int)(y * this->cell_size_y);// + this->cell_size_y / 2);
  182. }
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. class body {
  190. public:
  191.     char *name;
  192.     int type, num, mass;    // 1 - cargo, 2 - block
  193.     body *up;
  194.     body *down;
  195.     body *right;
  196.     body *left;
  197.  
  198.     void set(int, int, int, float, float);
  199.     void draw();
  200.  
  201. private:
  202.     float curr_x, curr_y;
  203.     float init_x, init_y;
  204.     float center_x, center_y;
  205.     int h, w;
  206.  
  207.  
  208. };
  209.  
  210. void body::set(int num, int type, int mass, float pos_x, float pos_y) {
  211.     this->init_x = pos_x;
  212.     this->init_y = pos_y;
  213.  
  214.     this->curr_x = pos_x;
  215.     this->curr_y = pos_y;
  216.  
  217.     this->type = type;
  218.     this->num = num;
  219.     this->mass = mass;
  220.  
  221.     this->up = NULL;
  222.     this->down = NULL;
  223.     this->right = NULL;
  224.     this->left = NULL;
  225.  
  226.     this->h = 20;
  227.     this->w = 20;
  228. }
  229.  
  230. void body::draw() {
  231.     float pos_x = this->curr_x;
  232.     float pos_y = this->curr_y;
  233.     // 1 = cargo, 2 = block
  234.  
  235.     glBegin(GL_POLYGON);
  236.         if (1 == this->type) glColor3f(1, 0, 0);
  237.         if (2 == this->type) glColor3f(0, 0, 1);
  238.         glVertex2i(pos_x, pos_y);
  239.         glVertex2i(pos_x + this->w, pos_y);
  240.         glVertex2i(pos_x + this->w, pos_y + this->h);
  241.         glVertex2i(pos_x, pos_y + this->h);
  242.     glEnd();
  243. }
  244.  
  245.  
  246.  
  247.  
  248.  
  249. float delta_pos(float velocity, float acceleration);
  250.  
  251.  
  252.  
  253. class block {
  254. public:
  255.     char *name;
  256.     int mass;
  257.  
  258.     void grav();
  259.     void init();
  260.  
  261.     block(float pos_x, float pos_y) {
  262.         this->init_x = pos_x;
  263.         this->init_y = pos_y;
  264.  
  265.         this->curr_x = pos_x;
  266.         this->curr_y = pos_y;
  267.  
  268.         this->visibility = true;
  269.     }
  270.  
  271. private:
  272.     float init_x, init_y;
  273.     float curr_x, curr_y;
  274.     bool visibility;
  275.  
  276.     void draw(float pos_x, float pos_y);
  277. };
  278.  
  279. void block::draw(float pos_x, float pos_y) {
  280.     glBegin(GL_POLYGON);
  281.     glColor3f(1, 0, 0);
  282.     glVertex2i(pos_x, pos_y);
  283.     glVertex2i(pos_x + 20, pos_y);
  284.     glVertex2i(pos_x + 20, pos_y + 20);
  285.     glVertex2i(pos_x, pos_y + 20);
  286.     glEnd();
  287. }
  288.  
  289. void block::grav() {
  290.     if (this->curr_y > 0) {
  291.  
  292.         float pos_x = this->curr_x + delta_pos(0, 0);
  293.         float pos_y = this->curr_y - delta_pos(-2, G_CONST);
  294.  
  295.         this->curr_x = pos_x;
  296.         this->curr_y = pos_y;
  297.  
  298.     }
  299.     else {
  300.         this->curr_y = 0;
  301.         this->visibility = false;
  302.     }
  303.  
  304.     this->draw(this->curr_x, this->curr_y);
  305.  
  306.     printf("x:%f, y:%f\n", this->curr_x, this->curr_y);
  307. }
  308.  
  309. void block::init() {
  310.     float pos_x = this->init_x;
  311.     float pos_y = this->init_y;
  312.  
  313.     this->draw(pos_x, pos_y);
  314. }
  315.  
  316.  
  317. float delta_pos(float velocity, float acceleration) {
  318.     //s = s0 + v*t + (a*t^2)/2
  319.     float delta = velocity * t + (acceleration * t * t) / 2;
  320.     printf("delta=%f\n", delta);
  321.  
  322.     t += 0.0001;
  323.  
  324.     return delta;
  325. }
  326.  
  327.  
  328.  
  329.  
  330. class cargo {
  331. public:
  332.     char *name;
  333.     int ord_num;
  334.     int mass;
  335.     int move_direction;
  336.     block* left_block;
  337.     block* right_block;
  338.     cargo* above_cargo;
  339.     cargo* below_cargo;
  340.  
  341.     void grav(bool);
  342.     void init();
  343.     void add_right_block(block*);
  344.     void add_left_block(block*);
  345.     void add_above_cargo(cargo*);
  346.     void add_below_cargo(cargo*);
  347.  
  348.     cargo(int n, float pos_x, float pos_y) {
  349.         this->ord_num = n;
  350.  
  351.         this->init_x = pos_x;
  352.         this->init_y = pos_y;
  353.  
  354.         this->curr_x = pos_x;
  355.         this->curr_y = pos_y;
  356.  
  357.         this->velo_x = 0;
  358.         this->velo_y = 0;
  359.  
  360.         if (this->velo_y == 0) {
  361.             this->move_direction = -1;
  362.         }
  363.     }
  364.  
  365. private:
  366.     float init_x, init_y;
  367.     float curr_x, curr_y;
  368.     float velo_x, velo_y;
  369.  
  370.     void draw(float, float);
  371. };
  372.  
  373. void cargo::draw(float pos_x, float pos_y) {
  374.     glBegin(GL_POLYGON);
  375.     glColor3f(0, 1, 0);
  376.     glVertex2i(pos_x, pos_y);
  377.     glVertex2i(pos_x + 25, pos_y);
  378.     glVertex2i(pos_x + 25, pos_y + 25);
  379.     glVertex2i(pos_x, pos_y + 25);
  380.     glEnd();
  381. }
  382.  
  383. void cargo::grav(bool fall) {
  384.     if (fall) {
  385.  
  386.         float pos_y;
  387.  
  388.         if (this->curr_y <= 0) {
  389.  
  390.             this->curr_y = 0;
  391.  
  392.             this->velo_y = sqrt(2 * G_CONST * this->init_y) * 0.8;
  393.  
  394.             this->move_direction = 1;
  395.  
  396.         }
  397.  
  398.         if (this->curr_y >= 0) {
  399.  
  400.             if (this->move_direction < 0) {
  401.  
  402.                 float pos_y = (G_CONST * t * t) / 2;
  403.                 this->curr_y -= pos_y;
  404.  
  405.             }
  406.  
  407.             if (this->move_direction > 0) {
  408.  
  409.                 float pos_y = this->velo_y * t - (G_CONST * t * t) / 2;
  410.                 this->curr_y += pos_y;
  411.  
  412.             }
  413.  
  414.         }
  415.     }
  416.  
  417.     this->draw(this->curr_x, this->curr_y);
  418.  
  419.     t += 0.001;
  420.  
  421.     printf("x:%f, y:%f, v=%f\n", this->curr_x, this->curr_y, this->velo_y);
  422. }
  423.  
  424. void cargo::init() {
  425.     float pos_x = this->init_x;
  426.     float pos_y = this->init_y;
  427.  
  428.     this->draw(pos_x, pos_y);
  429. }
  430.  
  431.  
  432.  
  433.  
  434.  
  435. struct node
  436. {
  437.     int value;
  438.     body obj;
  439.     node *next_r, *prev_l;
  440.  
  441.     node(int y) { value = y; next_r = prev_l = NULL; }
  442. };
  443.  
  444. class dll {
  445. public:
  446.  
  447.     void append_front(int, body);
  448.     void append_back(int, body);
  449.     node* get_front();
  450.     node* get_back();
  451.     void display_forward();
  452.     void display_backward();
  453.     void display_objects();
  454.     void draw_objects();
  455.     void destroy_list();
  456.  
  457.     dll() { front = NULL; back = NULL; }
  458.     ~dll() { destroy_list(); }
  459.  
  460.  
  461. private:
  462.  
  463.     node *front;
  464.     node *back;
  465.  
  466. };
  467.  
  468. void dll::append_front(int x, body b) {
  469.  
  470.     node *n = new node(x);
  471.  
  472.     n->obj = b;
  473.  
  474.     if (front == NULL) {
  475.         front = n;
  476.         back = n;
  477.     } else {
  478.         front->prev_l = n;
  479.         n->next_r = front;
  480.         front = n;
  481.     }
  482.  
  483.     cout << "fornt appended" << endl;
  484. }
  485.  
  486. void dll::append_back(int x, body b) {
  487.  
  488.     node *n = new node(x);
  489.  
  490.     n->obj = b;
  491.  
  492.     if (back == NULL) {
  493.         front = n;
  494.         back = n;
  495.     } else {
  496.         back->next_r = n;
  497.         n->prev_l = back;
  498.         back = n;
  499.     }
  500.  
  501.     cout << "back appended" << endl;
  502. }
  503.  
  504. node* dll::get_front() {
  505.     return this->front;
  506. }
  507.  
  508. node* dll::get_back() {
  509.     return this->back;
  510. }
  511.  
  512. void dll::display_forward() {
  513.     node *temp = front;
  514.  
  515.     cout << "\n\nnodes in forward order:" << endl;
  516.  
  517.     while (temp != NULL) {
  518.         cout << temp->value << "   ";
  519.         temp = temp->next_r;
  520.     }
  521. }
  522.  
  523. void dll::display_backward() {
  524.     node *temp = back;
  525.  
  526.     cout << "\n\nnodes in reverse order:" << endl;
  527.  
  528.     while (temp != NULL) {
  529.         cout << temp->value << "   ";
  530.         temp = temp->prev_l;
  531.     }
  532. }
  533.  
  534. void dll::display_objects() {
  535.     node *temp = front;
  536.  
  537.     cout << "\n\nobjects in forward order:" << endl;
  538.  
  539.     while (NULL != temp) {
  540.         printf("(%d", temp->value);
  541.         if (1 == temp->obj.type) printf("CG ");
  542.         if (2 == temp->obj.type) printf("BK ");
  543.         printf("[m:%d])   ", temp->obj.mass);
  544.         temp = temp->next_r;
  545.     }
  546. }
  547.  
  548. void dll::draw_objects() {
  549.     node *temp = front;
  550.  
  551.     while (NULL != temp) {
  552.         temp->obj.draw();
  553.         if (temp->obj.down != NULL) temp->obj.down->draw();
  554.         temp = temp->next_r;
  555.     }
  556. }
  557.  
  558. void dll::destroy_list() {
  559.     node *T = back;
  560.  
  561.     while (T != NULL) {
  562.         node *T2 = T;
  563.         T = T->prev_l;
  564.         delete T2;
  565.     }
  566.  
  567.     front = NULL;
  568.     back = NULL;
  569. }
  570.  
  571.  
  572.  
  573.  
  574. void count_position(string command) {
  575.  
  576.     int comm_len = command.length();
  577.  
  578.  
  579. }
  580.  
  581.  
  582.  
  583. GLuint texture[1];
  584.  
  585. void load_textures()
  586. {
  587.  
  588.     AUX_RGBImageRec *texture1;
  589.     texture1 = auxDIBImageLoadA("tex_snoop.bmp");
  590.     glGenTextures(1, &texture[0]);
  591.     glBindTexture(GL_TEXTURE_2D, texture[0]);
  592.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  593.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  594.     glTexImage2D(GL_TEXTURE_2D, 0, 3, texture1->sizeX, texture1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, texture1->data);
  595.  
  596.     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  597. }
  598.  
  599.  
  600.  
  601. static void cursor_callback(GLFWwindow* window, double x, double y)
  602. {
  603.  
  604. }
  605.  
  606. static void mouse_callback(GLFWwindow* window, int button, int action, int mods)
  607. {
  608.     if (button == GLFW_MOUSE_BUTTON_RIGHT)
  609.     {
  610.         if (action == GLFW_PRESS) glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
  611.         if (action == GLFW_RELEASE) glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
  612.     }
  613.  
  614.     if (button == GLFW_MOUSE_BUTTON_LEFT)
  615.     {
  616.  
  617.     }
  618. }
  619.  
  620. static void resize_callback(GLFWwindow* window, int width, int height)
  621. {
  622.     //      windowWidth = width;
  623.     //      windowHeight = height;
  624.  
  625.     glViewport(0, 0, width, height);
  626.     glMatrixMode(GL_PROJECTION);
  627.     glLoadIdentity();
  628.     glOrtho(0.0, (GLdouble)width, 0.0, (GLdouble)height, -1, 1);
  629.  
  630.     glMatrixMode(GL_MODELVIEW);
  631.     glLoadIdentity();
  632.  
  633.     A = width / 4.0;
  634.     B = 0.0;
  635.     C = D = height / 2.0;
  636.  
  637.     //printf("Reshape occured\n");
  638. }
  639.  
  640. static void keyboard_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
  641. {
  642.     if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
  643.         glfwSetWindowShouldClose(window, GL_TRUE);
  644.     //if (GLFW_KEY_T == key && action == GLFW_PRESS) { gravity(); }
  645. }
  646.  
  647. static void error_callback(int error, const char* description)
  648. {
  649.     fputs(description, stderr);
  650. }
  651.  
  652.  
  653.  
  654.  
  655. int main(int argc, _TCHAR* argv[])
  656. {
  657.     if (!glfwInit()) {
  658.         printf("glfwInit failed\n");
  659.         return -1;
  660.     }
  661.  
  662.     glfwSetErrorCallback(error_callback);
  663.  
  664.     GLFWwindow* window;
  665.  
  666.     //      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
  667.     //      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
  668.     //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
  669.     window = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Anthony's Porject", NULL, NULL);
  670.     if (window == NULL) {
  671.         printf("glfwOpenWindow failed.\n");
  672.         glfwTerminate();
  673.         return -2;
  674.     }
  675.  
  676.     int i, attrib;
  677.     attrib = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
  678.     attrib = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
  679.     attrib = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);
  680.  
  681.     glfwMakeContextCurrent(window);
  682.  
  683.     glfwSetKeyCallback(window, keyboard_callback);
  684.     glfwSetFramebufferSizeCallback(window, resize_callback);
  685.     glfwSetMouseButtonCallback(window, mouse_callback);
  686.     glfwSetCursorPosCallback(window, cursor_callback);
  687.     resize_callback(window, SCREEN_WIDTH, SCREEN_HEIGHT);
  688.  
  689.  
  690.     dll *list = new dll();
  691.     body c, b;
  692.     int x_pos, c_n, b_n;
  693.  
  694.     c_n = b_n = 0;
  695.  
  696.     printf("insert scheme:\n..........\n");
  697.  
  698.     string command;
  699.     back:
  700.     getline(cin, command);
  701.     if (command.length() > 10) {
  702.         printf("must be no longer than 10\n");
  703.         goto back;
  704.     }
  705.  
  706.     count_position(command);
  707.  
  708.  
  709.     map *m = new map();
  710.     m->set_map(SPLIT_X, SPLIT_Y);
  711.  
  712.     for (i = 0, x_pos = 0; i < command.length(); i++) {
  713.         // 1 = cargo, 2 = block
  714.         if ('c' == command[i]) {
  715.  
  716.             m->set_cell(x_pos++, 4, 1); //======
  717.  
  718.             c.set(c_n, 1, 10, 50 + 70 * i, 150);
  719.             list->append_back(c_n, c);
  720.             c_n++;
  721.             if ('(' == command[i + 1]) {
  722.  
  723.             }
  724.         }
  725.         if ('b' == command[i]) {
  726.  
  727.             m->set_cell(x_pos++, 7, 2); //======
  728.  
  729.             b.set(b_n, 2, 0, 50 + 70 * i, 300);
  730.             list->append_back(b_n, b);
  731.             b_n++;
  732.             if ('b' == command[i + 1]) {
  733.  
  734.                 m->set_cell(x_pos++, 5, 2); //======
  735.  
  736.                 b.set(b_n, 2, 0, 50 + 70 * (i + 1), 200);
  737.                 list->append_back(b_n, b);
  738.                 b_n++;
  739.                 i++;
  740.             }
  741.             if ('(' == command[i + 1]) {
  742.                 if ('c' == command[i + 2] && ')' == command[i+3]) {
  743.  
  744.                     m->set_cell(x_pos++, 1, 1); //======
  745.  
  746.                     body extra_c;
  747.                     extra_c.set(c_n, 1, 10, 50 + 70 * i, 100);
  748.                     b.down = &extra_c;
  749.                     c_n++;
  750.                     i += 3;
  751.                 }
  752.             }
  753.         }
  754.        
  755.     }
  756.  
  757.     list->display_forward();
  758.     list->display_objects();
  759.  
  760.  
  761.     t = 0;
  762.  
  763.     glEnable(GL_TEXTURE_2D);
  764.  
  765.     while (!glfwWindowShouldClose(window))
  766.     {
  767.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  768.  
  769.         if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS) {
  770.             m->print_map();
  771.         }
  772.         if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS) {
  773.             i -= 5;
  774.         }
  775.  
  776.         m->draw_obj();
  777.         m->draw_net();
  778.        
  779.  
  780.  
  781.         list->draw_objects();
  782.  
  783.  
  784.  
  785.         glfwSwapBuffers(window);
  786.         glfwPollEvents();
  787.         //glfwWaitEvents();
  788.     }
  789.  
  790.     glfwDestroyWindow(window);
  791.     glfwTerminate();
  792.  
  793.     return 0;
  794. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement