i got 2 view port display separate , if i display single image is fine , but when i put 2 image together , it come out 2 straight lines .
what’s the problem with code
#include <stdlib.h>
#include <windows.h>
#include <iostream>
#include <glut.h>
#define _USE_MATH_DEFINES
#include <math.h>
GLfloat winWidth=800 ,winHeight=400;
void init ()
{
glClearColor(1,1,1,0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(-150,150,-150,150);
glMatrixMode(GL_MODELVIEW);
gluOrtho2D(-150,150,-150,150);
glLoadIdentity();
}
void sqrShape ()
{
glColor3f(0.0,0.0,1.0);
glBegin(GL_LINE_LOOP);
glVertex2f(100,100);
glVertex2f(-100,100);
glVertex2f(-100,-100);
glVertex2f(100,-100);
glEnd();
}
void gyroShape()
{
glColor3f(0.0,0.0,1.0);
glBegin(GL_LINE_LOOP);
glVertex2f(80,10);
glVertex2f(-80,10);
glVertex2f(-80,-10);
glVertex2f(80,-10);
glEnd();
}
void firstPic()
{
for(float i =1; i< 12; i++)
{
glPushMatrix();
gyroShape();
glScalef(0.8,1.2,1);
glColor3f(1,0,0);
}
glPopMatrix();
glFlush();
}
void scalePic()
{
sqrShape();
float i=0;
for (i=0;i<12;i++)
{
glPushMatrix();
glRotatef(5,0,0,1);
glScalef(0.9,0.9,1);
sqrShape();
}
for (i=0;i<12;i++)
{
glPopMatrix();
}
glFlush();
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0.0, 0.0,winWidth/2,winHeight);
firstPic();
glViewport(winWidth/2, 0.0,winWidth/2,winHeight);
scalePic();
glFlush();
}
/*void winReshapeFcn (int newWidth, int newHeight)
{
glMatrixMode (GL_PROJECTION);
glLoadIdentity ( );
gluOrtho2D(-100,100,-100,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluOrtho2D(-100,100,-100,100);
}*/
void main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(200,200);
glutInitWindowSize(winWidth,winHeight);
glutCreateWindow(“Assignment 1 - 2D Image Display”);
init ();
glutDisplayFunc(display);
glutMainLoop();
}