Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5986519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:40:59+00:00 2026-05-22T22:40:59+00:00

in this code i’m try to draw simple olympic ring and rotate it… the

  • 0

in this code i’m try to draw simple olympic ring and rotate it… the below work fine but i can’t rotate the rings.. help me to solve this problme…

void myReshape (int width, int height)
{
  glViewport (0, 0, width, height);    
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D (-5, 105, -5, 105);
  glMatrixMode (GL_MODELVIEW);
  glLoadIdentity ();
  glTranslatef (0.375, 0.375, 0.0);
}


int main (int argc, char **argv)
{
  glutInit(&argc, argv);
  glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 
  glutInitWindowPosition(100,100); 
  glutInitWindowSize(110*PIXEL_SIZE, 110*PIXEL_SIZE);
  glutCreateWindow ("Olymipc Rings  ||  rotation  "); 
  glClearColor(1.0, 1.0, 1.0, 0.0);  
  glPointSize(PIXEL_SIZE);          
  glShadeModel (GL_FLAT);       
  glutDisplayFunc(display);
  glutReshapeFunc(myReshape);
  glutMainLoop(); 
  return 0; 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:41:00+00:00Added an answer on May 22, 2026 at 10:41 pm

    Try this:

    #include <stdlib.h>
    #include <stdio.h>
    #include <GL/glut.h>
    #include <GL/gl.h>
    #include <math.h>
    
    #define PIXEL_SIZE 3 
    #define MESSAGE     "hello world !"
    
    void draw_circle(int x, int y, int r);
    
    int ring_radius = 19; 
    int color[5][3]={{0,0,1}, {0,0,0},{1,0,0}, {1,1,0},{0,1,0}};
    int center[5][2]={{15,60},{50,60},{85,60},{33,45},{68,45}};
    //=========================================================
    
    void drawText(const char * message)
    {
        glRasterPos2f((GLfloat)0, (GLfloat)-400);
        while (*message) 
        {
            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *message);
            glutStrokeCharacter(GLUT_STROKE_ROMAN,*message++);
        }
    }
    
    void display (void) 
    {
        int ms = glutGet(GLUT_ELAPSED_TIME);
    
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D (-5, 105, -5, 105);
        glMatrixMode (GL_MODELVIEW);
        glLoadIdentity ();
        glTranslatef (0.375, 0.375, 0.0);
    
        glClear(GL_COLOR_BUFFER_BIT); 
        glBegin(GL_LINE_LOOP);
        glVertex2i(-1,-1);
        glVertex2i(100,-1);
        glVertex2i(100,100);
        glVertex2i(-1,100);
        glEnd();
    
        const float deg_per_sec = 60.0f;
        float angle = deg_per_sec * ( (float)ms / 1000.0f );
    
        for(int i = 0 ; i <5; i++)
        {
            glColor3f(color[i][0],color[i][1],color[i][2]);
    
            glPushMatrix();
            glTranslatef( center[i][0], center[i][1], 0 );
            glRotatef(angle, 0, 0, 1);
            glTranslatef( -center[i][0], -center[i][1], 0 );
            draw_circle(center[i][0],center[i][1],ring_radius);
            glPopMatrix();
        }
        glScalef(0.001, 0.001, 0.001);
        drawText(MESSAGE);
        glFlush();             
    
        glutSwapBuffers();
    }
    
    void draw_circle(int center_x, int center_y , int radius)
    {
        int r = radius;
        int h = 1 - r ;    /*initialization */
        int x = 0;
        int y = r;
        int dU=3;
        int dD = 5 - 2*r;
        int i = center_x;
        int j = center_y;
    
        glPointSize(6);
        glBegin(GL_POINTS);
    
        while( y > x )
        {
            if (h<0)
            {
                dU= dU + 2;
                h = h + dU;
                x = x + 1;
                dD = dD + 2;
            }
            else
            {
                dD = 2*(x-y) + 5;
                h = h + dD;
                x = x + 1;
                y = y - 1;
                dU = dU + 2;
                dD = dD + 4;
            }
    
            glVertex2i(x+i, y+j);
            glVertex2i(-x+i, y+j);
            glVertex2i(x+i, -y+j);
            glVertex2i(-x+i,-y+j);
            glVertex2i(y+i, x+j);
            glVertex2i(y+i, -x+j);
            glVertex2i(-y+i, x+j);
            glVertex2i(-y+i, -x+j);
    
        }
    
        glEnd();
    } 
    
    void myReshape (int width, int height)
    {
        glViewport (0, 0, width, height);    
    }
    
    void idle()
    {
        glutPostRedisplay();
    }
    
    
    int main (int argc, char **argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); 
        glutInitWindowPosition(100,100); 
        glutInitWindowSize(110*PIXEL_SIZE, 110*PIXEL_SIZE);
        glutCreateWindow ("Olymipc Rings  ||  rotation  "); 
        glClearColor(1.0, 1.0, 1.0, 0.0);  
        glPointSize(PIXEL_SIZE);          
        glShadeModel (GL_FLAT);       
        glutDisplayFunc(display);
        glutReshapeFunc(myReshape);
        glutIdleFunc(idle);
        glutMainLoop(); 
        return 0; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code here does not work when I try to find a single parent
this code was just working! but for some reason it stopped to work now.
this code does not work? When i try to click on the radiobutton, nothing
This code compiles but looks very strange. I have a typical and simple parent/child
This code compiles fine without warnings but the substring does not appear in the
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
This code compiles in CodeGear 2009 and Visual Studio 2010 but not gcc. Why?
This code works well in Mac/Linux, but not in Windows. import mmap import os
This code is ment to download the source code of an html file but
This code is reading from mysql db tables and should return few names. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.