So i want the tiny red circle to orbit the bigger blue circle but i cant get it and i cant find any information on the best way to do this.
Here is pic of the code running
https://gfycat.com/disgustingenlightenedbrahmancow
#define window_width 1080
#define window_height 720
#define PI 3.14159265359
float _angle = 0.0;
float _cameraangle = 30.0;
void Draw1() {
glPushMatrix();
//float theta;
int i;
//float x = 0.5;
//float y = 0.5;
float radius = 0.2;
int num_segments = 1000;
float twicePi = 2 * PI;
//glLoadIdentity();
glBegin(GL_POLYGON);
glColor3ub(43, 78, 88);
for (i = 0; i < 360; i++) {
float theta = i + PI / 180;
float x = 500+ 250 * cos(theta);
float y = 350 + 250 * sin(theta);
glVertex2f(x, y);
}
glEnd();
glEnd();
//glFlush();
glPopMatrix;
}
void Draw2() {
glPushMatrix();
//float theta;
int i;
//float x = 0.5;
//float y = 0.5;
float radius = 0.2;
int num_segments = 1000;
float twicePi = 2 * PI;
glTranslatef(175, 175, 0);
glRotatef(_angle, 0, 0, 0.5);
//glTranslatef(175, 175, 0);
glBegin(GL_POINTS);
glColor3ub(255, 0, 0);
for (i = 0; i < 360; i++) {
float theta = i + PI / 180;
float x = 500 + 10 * cos(theta);
float y = 350 + 10 * sin(theta);
glVertex3f(x, y, 0);
}
glEnd();
glPopMatrix();
}
void Display() {
glClear(GL_COLOR_BUFFER_BIT);
Draw1();
glFlush();
Draw2();
glFlush();
glutSwapBuffers();
}
void update(int value)
{
_angle += 2.0f;
if (_angle > 360.f)
{
_angle -= 360;
}
glutPostRedisplay();
glutTimerFunc(25, update, 0);
}
void LineSegment(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_LOOP);
glVertex2i(20, 120);
glVertex2i(180, 120);
glVertex2i(45, 20);
glVertex2i(100, 190);
glVertex2i(155, 20);
glEnd();
glFlush();
}
void Initialize() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
gluOrtho2D(0.0, window_width, 0.0, window_height);
}
int main(int iArgc, char** cppArgv) {
glutInit(&iArgc, cppArgv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(950, 500);
glutInitWindowPosition(200, 200);
glutCreateWindow("test");
Initialize();
glutDisplayFunc(Display);
glutTimerFunc(25, update, 0);
glutMainLoop();
return 0;
}