How To Make A Moving car In OpenGL C++









                                      Download Books to Get More OpneGl C++ Project Code 
 
 
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include <stdlib.h>
#include <math.h>

GLint b=300;
float  counter=600.0;
void initOpenGl()
{
    glClearColor(0.5,0.5,0.5,1); //Background Color
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0,700,0,500);
    glMatrixMode(GL_MODELVIEW);
}

void wheel(int x,int y)
{
   float th;
   glBegin(GL_POLYGON);
   glColor3f(0,0,0);
   for(int i=0;i<360;i++)
   {
       th=i*(3.1416/180);
       glVertex2f(x+20*cos(th),y+20*sin(th));
   }

   glEnd();

}

void car()
{


   //Bottom Part
   glLoadIdentity();
   counter=counter-0.05;
   glTranslated(counter,100,0.0);
   //glScaled(0.1,0.1,0.0);
   glBegin(GL_POLYGON);
   glVertex2f(100,100);
   glVertex2f(100,160);
   glVertex2f(450,160);
   glVertex2f(450,100);

   //Top Part
   glBegin(GL_POLYGON);
   glVertex2f(150,160);
   glVertex2f(200,200);
   glVertex2f(400,200);
   glVertex2f(450,160);

   glEnd();

   wheel(200,100);
   wheel(380,100);

}

void display()
{

  glClear(GL_COLOR_BUFFER_BIT);
  //Push and pop matrix for separating circle object from Background
  glColor3f(0.0,1.0,0.0);
  car();
  glutSwapBuffers();
  glFlush();


}

int main(int argc, char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
    glutInitWindowSize(700,500);
    glutInitWindowPosition(0,0);
    glutCreateWindow("Car Moving");
    initOpenGl();
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMainLoop();
    return 0;
}
                            Download Books to Get More OpneGl C++ Project Code 

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

19 comments:

  1. man and van dublin See whether the workers are prepared, ensured, authorized and reinforced. You need to realize that your hardware is in proficient hands. This will improve the probability of your things being maneuvered carefully and showing up free from any danger to their new area. It doesn't make any difference how proficient and gifted the staff are at moving your things, it is a smart thought for you to consider buying movers protection for your gear.

    ReplyDelete
  2. Autoankauf Oberhausen ohne Lockangebote – ihr kompetenter Gebrauchtwagen Ankauf! Versprechen hält man! Wir haben keinen Onlinerechner und locken nicht mit hohen Onlinepreisen bei der Autobewertung. Sie erhalten eine Erste Bewertung am Telefon und müssen Ihr Fahrzeug nicht vorführen, um einen Preis erhalten zu können. Hierauf haben wir uns spezialisiert. Autoankauf Oberhausen

    ReplyDelete
  3. Different advantages incorporate exceptions from the blockage charge and parking spot charges in the UK's significant urban communities. In the event that an organization utilizes electric vehicles as organization cars, the advantages for the business will be in worth of two or three thousand pounds each year, because of different expense reserve funds. home ev charging point

    ReplyDelete
  4. Full Service Deluxe Moving Companies-These are the huge and notable moving organizations. They offer full assistance moving bundles. Europa-Road túlméretes szállítás

    ReplyDelete
  5. On the Craigslist page, navigate to your location's web page, then click Cars and Trucks by Owner. In the search settings, set the range from $0 - (Your Max Limit). fuel burn calculator

    ReplyDelete
  6. Acting thusly, will help you a ton in managing and choosing the assistance which satisfies all your moving prerequisites other than being sensibly appraised. Flyttebyrå Oslo

    ReplyDelete
  7. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. vinfast Fadil Vinh

    ReplyDelete
  8. shippingsolutionsworldwide Worldwide Inc. is an international & local moving company that provides secure and reliable services to embassies, companies, and individuals from the Washington D.C. Metropolitan area to anywhere around the globe. Although we specialize primarily in international moves, we also have extensive experience in import and destination services. Your belongings or commercial products are custom-packed by our experienced team, and shipped door-to-door, by land, sea or air.

    ReplyDelete
  9. Getting the best one is just a matter of selecting the right one. A good limousine service takes pride in its full commitment to meet and exceed your expectations. Luxury Car Rental Near Me

    ReplyDelete
  10. Open your 'chute ahead of schedule to fly across the guide: If you're out of the airplane and you can see masses of individuals previously falling underneath you, maybe you need to be somewhere else. Clicks Test

    ReplyDelete
  11. An evaporative cooler enjoys a great deal of upper hands over a standard air conditoner in light of the fact that it has a lower cost of establishment, requires less support and works with less energy. Since they are more uncommon in certain pieces of the country, it appears as though a many individuals don't have a clue how an evaporative cooler functions.HVAC Services
    hydronic heating system

    ReplyDelete
  12. The article looks magnificent, but it would be beneficial if you can share more about the suchlike subjects in the future. Keep posting. moving company

    ReplyDelete
  13. Thanks for the informative article. It is important that you need to hire moving company to provide a comprehensive range of seamless door-to-door packing, removalist and valet unpacking services to save you time, and let you get on with the rest of your move. I suggest also that Removalist Adelaide

    ReplyDelete
  14. You don't have to be a trainspotter to notice how far the experience of travelling by rail has come. Long gone is the smoky jerky world of Victorian steam trains, and pretty much long gone are the diesel powered monsters roaring around the country belching fumes and causing endless pollution. These days trains are smooth, fast (though still late), electric and comfortable, and have become the best way to travel, even over long distances. Airport Taxis Weybridge

    ReplyDelete
  15. For the unprepared traveler; however, car rental costs and services can be a rude shock and a blow to that vacation budget.check

    ReplyDelete
  16. https://hostinglelo.in The world of gaming has really undergone a phenomenal change. There was a time when developers sold computer games for a price and made sure that it had enough value to make the player buy the second game in line.

    ReplyDelete
  17. Prior to endeavoring to fabricate your own carport we firmly suggest that you counsel a structure proficient. Its not difficult to commit a mix-up and development errors can be expensive and tedious.www.brisbanecarportbuilders.com/

    ReplyDelete
  18. Clearly there are two different ways of paying, it is possible that you pay in real money or you finance the car.
    a great business leader

    ReplyDelete
  19. I loved your blog post. Really thank you! Will read on... best custom car decal

    ReplyDelete