asdf
unknown
plain_text
2 years ago
1.3 kB
15
Indexable
#include<windows.h> #include<bits/stdc++.h> #ifdef __APPLE__ #include <GLUT/glut.h> #else #include <GL/glut.h> #endif #include <stdlib.h> using namespace std; double getY(double x) { double ans = (5.0 - (2 * x) ) / 3.0; return ans; } int cnt; double getCirY(double x) { if(cnt % 2 == 0) return sqrt(sqrt(5.0/7.0) - x * x); if(cnt % 2) return -sqrt(sqrt(5.0/7.0) - x * x); } void init() { glClearColor(0.0, 0.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-3.0,3.0, -3.0, 3.0, -1.0, 1.0); } static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glColor3f(1, 1, 0); for(double i = 0.1; i <= 1; i += 0.001) { glVertex3f(i, getY(i), 0); } for(double i = -1; i <= 1; i += 0.001) { glVertex3f(i, getCirY(i), 0); cnt ++; glVertex3f(i, getCirY(i), 0); cnt ++; } glEnd(); glFlush(); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(640,640); glutInitWindowPosition(10,10); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); glutCreateWindow("GLUT Shapes"); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }
Editor is loading...