Advertisement
Insyder01

Untitled

May 12th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include <vector>
  2. #ifdef __APPLE__
  3. #include <GLUT/glut.h>
  4. #else
  5. #include <GL/glut.h>
  6. #endif
  7.  
  8. #include <stdlib.h>
  9. using namespace std;
  10. const double logWidth=100.0;
  11. const double logHeight=100.0;
  12. const int rowSize=2, columnSize=8, gridHeight=20, gridWidth=80, initHeight=95, initWidth=10, N_SIZE=100;
  13. double backgroundColor[3]={0.5,0.5,0.5};
  14. double lineColor[3]={0.8,0.8,0.8};
  15. vector <int> numbers(N_SIZE);
  16. int _16[rowSize][columnSize];
  17. void init(){
  18.     glClearColor(0.265,0.685,1.0,1.0); /**Background Color**/
  19.     glMatrixMode(GL_PROJECTION); /**2D**/
  20.     gluOrtho2D(0.0,logWidth,0.0,logHeight);/**Sync**/
  21.  
  22. }
  23.  
  24. void Display(){
  25.     glClear(GL_COLOR_BUFFER_BIT);
  26.     glBegin(GL_QUADS);
  27.     glColor3dv(backgroundColor);
  28.     glVertex2i(initWidth,initHeight);
  29.     glVertex2i(initWidth,initHeight-gridHeight);
  30.     glVertex2i(initWidth+gridWidth, initHeight-gridHeight);
  31.     glVertex2i(initWidth+gridWidth, initHeight);
  32.     glEnd();
  33.  
  34.     glColor3dv(lineColor);
  35.     glBegin(GL_LINES);
  36.     for (int i = 0; i <= rowSize; i++){
  37.         glVertex2i(initWidth,initHeight-gridHeight*i/rowSize);
  38.         glVertex2i(initWidth+gridWidth, initHeight-gridHeight*i/rowSize);
  39.     }
  40.     glEnd();
  41.  
  42.     glBegin(GL_LINES);
  43.    for(int i = 0;i<=columnSize;i++){
  44.         glVertex2i(initWidth + gridWidth*i/columnSize, initHeight);
  45.         glVertex2i(initWidth+gridWidth*i/columnSize, initHeight-gridHeight);
  46.    }
  47.    glEnd();
  48.  
  49.  
  50.  
  51.  
  52.  
  53.     glFlush();
  54.     glutSwapBuffers();
  55.  
  56. }
  57. void pre(){
  58.     for(int i = 0;i < N_SIZE;i++) numbers[i]=i+1;
  59.     for(int i = 0;i < rowSize;i++){
  60.         for(int j = 0;j < columnSize;j++){
  61.             int index = rand()%numbers.size();
  62.             _16[i][j]=numbers[index];
  63.             numbers.erase(numbers.begin()+index);
  64.         }
  65.     }
  66. }
  67. int main(int argc, char *argv[])
  68. {
  69.     glutInit(&argc, argv);
  70.     glutInitWindowSize(640,480);
  71.     glutInitWindowPosition(10,10);
  72.     glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
  73.  
  74.     glutCreateWindow("primeFactory");
  75.     init();
  76.     pre();
  77.     glutDisplayFunc(Display);
  78.     glutMainLoop();
  79.  
  80.     return EXIT_SUCCESS;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement