Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #ifdef __APPLE__
- #include <GLUT/glut.h>
- #else
- #include <GL/glut.h>
- #endif
- #include <stdlib.h>
- using namespace std;
- const double logWidth=100.0;
- const double logHeight=100.0;
- const int rowSize=2, columnSize=8, gridHeight=20, gridWidth=80, initHeight=95, initWidth=10, N_SIZE=100;
- double backgroundColor[3]={0.5,0.5,0.5};
- double lineColor[3]={0.8,0.8,0.8};
- vector <int> numbers(N_SIZE);
- int _16[rowSize][columnSize];
- void init(){
- glClearColor(0.265,0.685,1.0,1.0); /**Background Color**/
- glMatrixMode(GL_PROJECTION); /**2D**/
- gluOrtho2D(0.0,logWidth,0.0,logHeight);/**Sync**/
- }
- void Display(){
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_QUADS);
- glColor3dv(backgroundColor);
- glVertex2i(initWidth,initHeight);
- glVertex2i(initWidth,initHeight-gridHeight);
- glVertex2i(initWidth+gridWidth, initHeight-gridHeight);
- glVertex2i(initWidth+gridWidth, initHeight);
- glEnd();
- glColor3dv(lineColor);
- glBegin(GL_LINES);
- for (int i = 0; i <= rowSize; i++){
- glVertex2i(initWidth,initHeight-gridHeight*i/rowSize);
- glVertex2i(initWidth+gridWidth, initHeight-gridHeight*i/rowSize);
- }
- glEnd();
- glBegin(GL_LINES);
- for(int i = 0;i<=columnSize;i++){
- glVertex2i(initWidth + gridWidth*i/columnSize, initHeight);
- glVertex2i(initWidth+gridWidth*i/columnSize, initHeight-gridHeight);
- }
- glEnd();
- glFlush();
- glutSwapBuffers();
- }
- void pre(){
- for(int i = 0;i < N_SIZE;i++) numbers[i]=i+1;
- for(int i = 0;i < rowSize;i++){
- for(int j = 0;j < columnSize;j++){
- int index = rand()%numbers.size();
- _16[i][j]=numbers[index];
- numbers.erase(numbers.begin()+index);
- }
- }
- }
- int main(int argc, char *argv[])
- {
- glutInit(&argc, argv);
- glutInitWindowSize(640,480);
- glutInitWindowPosition(10,10);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
- glutCreateWindow("primeFactory");
- init();
- pre();
- glutDisplayFunc(Display);
- glutMainLoop();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement