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

  • Home
  • SEARCH
  • 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 4609008
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:55:33+00:00 2026-05-22T00:55:33+00:00

In the following program i am trying to draw a simple house. The coordinates

  • 0

In the following program i am trying to draw a simple house. The coordinates are defined in the house array. I need to rotate the house and display both rotated as well as the original house.
But why is the rotated house not being displayed?

    //Program to create a house like figure and rotate ir about a given fixed point using OpenGL functions.
#include <glut.h>
#include <stdio.h>

float house [11][2] = {{100,200},{200,250},{300,200},{100,200},{100,100},{175,100},{175,150},{225,150},{225,100},{300,100},{300,200}};

void init()
{
    glClearColor(1,1,1,0);
    glMatrixMode(GL_PROJECTION);
    gluOrtho2D(0,800,0,800);
    glMatrixMode(GL_MODELVIEW);
}

void display()
{
    glClear(GL_COLOR_BUFFER_BIT);

    //NORMAL HOUSE
    glColor3f(1,0,0);
    glBegin(GL_LINE_LOOP);

    for(int i=0;i<11;i++)
        glVertex2fv(house[i]);
    glEnd();
    glFlush();


    //ROTATED HOUSE
    glPushMatrix();
    glRotatef(60,0,1,0);
    glColor3f(1,1,0);
    glBegin(GL_LINE_LOOP);

    for(int i=0;i<11;i++)
        glVertex2fv(house[i]);
    glEnd();
    glFlush();
    glPopMatrix();
}

void main(int argc,char** argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(800,800);
    glutInitWindowPosition(100,100);
    glutCreateWindow("House rotation");
    init();
    glutDisplayFunc(display);
    glutMainLoop();
}
  • 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-22T00:55:33+00:00Added an answer on May 22, 2026 at 12:55 am

    Try rotating on the Z axis instead of the Y axis:

    //Program to create a house like figure and rotate ir about a given fixed point using OpenGL functions.
    #include <GL/glut.h>
    
    float house [11][2] = {{100,200},{200,250},{300,200},{100,200},{100,100},{175,100},{175,150},{225,150},{225,100},{300,100},{300,200}};
    
    void display()
    {
        glClearColor(1,1,1,0);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D(0,800,0,800);
    
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    
        //NORMAL HOUSE
        glColor3f(1,0,0);
        glBegin(GL_LINE_LOOP);
        for(int i=0;i<11;i++)
            glVertex2fv(house[i]);
        glEnd();
    
    
        //ROTATED HOUSE
        glPushMatrix();
        glTranslatef(100,100,0);
        glRotatef(60,0,0,1);
        glTranslatef(-100,-100,0);
        glColor3f(1,1,0);
        glBegin(GL_LINE_LOOP);
        for(int i=0;i<11;i++)
            glVertex2fv(house[i]);
        glEnd();
        glPopMatrix();
    }
    
    void main(int argc,char** argv)
    {
        glutInit(&argc,argv);
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize(800,800);
        glutInitWindowPosition(100,100);
        glutCreateWindow("House rotation");
        glutDisplayFunc(display);
        glutMainLoop();
    }
    

    EDIT: This one should rotate around the bottom corner.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with
I'm trying to get the following simple C++ program to compile: #include <stdio.h> #include
Hey everyone, I am trying to run the following program, but am getting a
I am trying to do the following: class Program { static void Main(string[] args)
I'm trying to start Microsoft word using QProcess as following: QString program = WINWORD.EXE;
I am trying to write a C++ program that takes the following inputs from
When i am trying to run my program it is giving the following error
Trying to run my program in FreeBSD OS, I have the following results: $
The following program is very simple: it outputs a single dot each half a
I am running into problems when trying to draw a large 2D array of

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.