Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Spiral Thing
- // By: Chdata
- #include "stdafx.h"
- #include <iostream>
- #include <Windows.h>
- #include <glut.h>
- #include <WinBase.h>
- #include <cstdlib>
- #include <ctime>
- const int XSize = 640, YSize = XSize/4*3, winsize = XSize * YSize;
- void circul(float xcenter, float ycenter, float a, float b, float r)
- {
- float pi = 3.1415926f;
- float dtr = pi/180.0f;
- glBegin(GL_LINES);
- glColor3f(rand()&1,rand()&1,rand()&1); //glColor3f(0.0f,0.0f,1.0f
- float x = xcenter + r * cos(a); //* pi/180.0f
- float y = ycenter + r * -sin(a);
- for(a; a < b; a+=dtr)
- {
- glVertex2f(x,y);
- x = xcenter + r * cos(a);
- y = ycenter + r * -sin(a);
- glVertex2f(x,y);
- }
- glEnd();
- glutSwapBuffers();
- }
- void display(void)
- {
- float a = 0.0f;
- float b = 0.03125f;
- float e = 0.5f;
- float f = e + b;
- float g = 1.0f;
- float h = g + b;
- float j = 1.5f;
- float k = j + b;
- float step = b;
- float pi = 3.1415926f;
- float x = XSize/2;
- float y = YSize/2;
- float d = 0.0f;
- float r = 191.0f;
- while (true)
- {
- while (d<r)
- {
- circul(x, y, a * pi, b * pi, d * 2);
- circul(x, y, e * pi, f * pi, d * 2);
- circul(x, y, g * pi, h * pi, d * 2);
- circul(x, y, j * pi, k * pi, d * 2);
- a += step;
- b += step;
- e += step;
- f += step;
- g += step;
- h += step;
- j += step;
- k += step;
- if (a>=2) a-=2;
- if (b> 2) b-=2;
- if (e>=2) e-=2;
- if (f> 2) f-=2;
- if (g>=2) g-=2;
- if (h> 2) h-=2;
- if (j>=2) j-=2;
- if (k> 2) k-=2;
- d++;
- Sleep(182);
- }
- if (d=r) d=0;
- //Sleep(182);
- //if (!d) glClear(GL_COLOR_BUFFER_BIT);
- }
- /*
- float a = 0.0f, b = 0.0f; //, r = 0.0f;
- float x = XSize/2, y = YSize/2;
- float pi = 3.1415926f;
- float dtr = pi/180.0f;
- for(float r = 0.0f; r < 192.0f; r++)
- {
- b += 1.875f;
- circul(x, y, a, b * dtr, r);
- glClear(GL_COLOR_BUFFER_BIT);
- }
- */
- }
- void init(void)
- {
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- glOrtho (0, XSize, YSize, 0, 0, 1);
- glMatrixMode (GL_MODELVIEW);
- }
- int _tmain(int argc, char **argv )
- {
- srand((unsigned int)time(NULL));
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(XSize, YSize);
- glutCreateWindow("Brought to you by:");
- glutDisplayFunc(display);
- init();
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement