PDA

View Full Version : flickering problem



prashantgp
12-15-2002, 10:00 PM
Hi all,
i am trying to wrie a program where in i am updating the data using idle function.
but instead of smooth transition , it is giving me some flickering problem.
but when the same code is run in Linux it's doing fine.

below is my code pasted. try to run it on ur m/c and pls do help me out.

code :


#include<stdlib.h>
#include<stdio.h>
#include"GL/glut.h"
#include<math.h>
#include<windows.h>
#include<string.h>

float z;
int n,i,j,k,sw,pw,cw, curx,cury;

float position [7][2] = { -0.75,0.85,-0.40,0.85,-0.05,0.85,
0.30,0.85,0.65,0.85,-0.85,0.55,0.80,0.55};
char label[10][10] = {"ADI","HSI","NAV", "","ELE", "ENG","FUL"};

char airspeed[11][10]={"330","331","332","333","334","335","336","337","338",
"339","340"};

char machcounter[11][10]={"0.20","0.21","0.22","0.23","0.24","0.25","0.26",
"0.27","0.28","0.29","0.30"};

char baltitude[11][10]={"04.990","05.110","05.225","05.555","05.785","06.050",
"06.185","06.678","08.849","09.985","09.987"};
char raltitude[11][10]={"4907","4909","4911","4913","4915","4917","4919","4921",
"4923","4925","4950"};

char navigdtk[11][10]={"020","021","022","023","024","025","026",
"027","028","029","030"};

char navigttg[11][10]={"003:41","003:42","003:45","003:50","003:55","003:60","003:65","003:70",
"003:75","003:80","003:85"};

char navigeta[11][10]={"00:08:10","00:08:11","00:08:12","00:08:13","00:08:14","00:08:15",
"00:08:16","00:08:17","00:08:18","00:08:20","00:08:22"};
char superscript[2]="R";
int aspeed=0, state=0;

int pitch[11]={0,10,20,30,40,50,-10,-20,-30,-40,70};
//int hsiyaw[31]={50,50,50,50,50,50,50,50,50,50,160,160,160,160,16 0,160,160,160,160,160,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100};
int
hsiyaw[31]={-10,-20,-30,-40,-50,-60,-70,-80,-90,100,110,120,130,140,150,160,170,180,190,200,210 ,220,230,240,250,260,270,280,290};

float rotate[10]={0,10,20,30,40,25,0,-30,-45,60};
float lposition[722],Xpos,Ypos, radius;
static char stringlabel[100];


void init(void)
{
glLoadIdentity();
glClearColor(1.0,1.0,1.0,1.0);
glShadeModel(GL_SMOOTH);
}

void idle(void)
{
if(aspeed==9)
aspeed=0;
aspeed++;
if(state==30)
state=0;
state++;
//sleep(4.0);
glutSetWindow(pw);
glutPostRedisplay();
}


void drawstring(char *s)
{
unsigned int i;
for(i=0;i<strlen(s);i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,s[i]);
}

void drawSmall(char *s)
{
unsigned int i;
for(i=0;i<strlen(s);i++)
glutBitmapCharacter(GLUT_BITMAP_9_BY_15,s[i]);
}

void DrawCircle(float Xpos, float Ypos , float radius)
{
int i=0;
float vectorX, vectorX1=Xpos+radius,vectorY,vectorY1=Ypos;
float angle;
glPointSize(2.0);
glEnable(GL_LINE_SMOOTH);
glLineWidth(2.0);
glColor3f(0.0,1.0,0.0);
glBegin(GL_LINE_STRIP);
k=0;
for(angle=0.0;angle<=(2.0*3.14159265358979323846)+(2*0.0175);angle+=0. 0175)

{
vectorX=Xpos+(radius*(float)cos((double)angle));
vectorY=Ypos+(radius*(float)sin((double)angle));
glVertex2f(vectorX1,vectorY1);
lposition[k]=vectorX1;k++;
lposition[k]=vectorY1;k++;
glBegin(GL_LINES);
vectorX1=vectorX;
vectorY1=vectorY;
}
glEnd();
}


void Line (void)
{
int m,n,k;

k=0;
for(m=0;m<=180;m+=2)
{ glColor3f(0.0,1.0,1.0);
glEnable(GL_LINE_SMOOTH);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2f(lposition[m],lposition[m+1]);
glVertex2f(-(lposition[m]),lposition[m+1]);
glEnd();
k++;
}
printf("\n these many lines %d",k);
for(n=360;n<=540;n+=2)
{
glColor3f(0.5,0.3,0.1);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2f(lposition[n],lposition[n+1]);
glVertex2f(-(lposition[n]),lposition[n+1]);
glEnd();
}


m=pitch[aspeed];
m*=2;

if(m>0)
{
for(n=360;n<=360+m;n+=2)
{ glColor3f(0.0,1.0,1.0);
glEnable(GL_LINE_SMOOTH);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2f(lposition[n],lposition[n+1]);
glVertex2f(-(lposition[n]),lposition[n+1]);
glEnd();
}
}
if(m<0)
{
for(n=360;n>=360+m;n-=2)
{
glColor3f(0.5,0.3,0.1);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2f(lposition[n],lposition[n+1]);
glVertex2f(-(lposition[n]),lposition[n+1]);
glEnd();
}
}

glLoadIdentity();
}

void display(void)
{

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glRasterPos2f(-0.2,-0.82);
sprintf(stringlabel,"Attitude Direction Indicator");
drawstring(stringlabel);
DrawCircle(0.0,0.0,0.4);
glRotatef(rotate[aspeed],0.0,0.0,1.0);
Line();
glLoadIdentity();


glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
glVertex2f(0.0,0.5);
glVertex2f(0.0,0.6);
glVertex2f(-0.05,0.55);
glVertex2f(0.0,0.6);
glVertex2f(0.05,0.55);
glEnd();
glFlush();
glutIdleFunc(idle);
glutSwapBuffers();

}

void keyboard(unsigned char key , int x , int y)
{
switch(key)
{


case 's' : exit(0);
break;

case 'f' : exit(0);
break;

case 27: exit(0);
break;

default : break;
}
glutPostRedisplay();

}

void reshape( int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-1.0,1.0,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitWindowSize(800,625);
glutInitWindowPosition(0,0);
pw=glutCreateWindow("Multi Function Display");
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
init();

glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutReshapeFunc(reshape);

glutMainLoop();
return 0;

}

i am using VC++ to run this program.


thanks in advance
bye bye
prashant

M/\dm/\n
12-15-2002, 10:23 PM
Originally posted by prashantgp:
void display(void)
{

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
...
...
glVertex2f(0.05,0.55);
glEnd();
glFlush();
glutIdleFunc(idle);
glutSwapBuffers();

}

What the h.ll glFlush & glutidleFunc is doing there http://www.opengl.org/discussion_boards/ubb/smile.gif glFlush is for single buffer progs & idle func should be under init or some sort of keyb funcs. You could use simple idle f like {glutPostRedisplay();} and do all the comparisions in display, maybe under some f name.
And PLZ use code tags next time http://www.opengl.org/discussion_boards/ubb/smile.gif


[This message has been edited by M/\dm/\n (edited 12-15-2002).]

prashantgp
12-16-2002, 02:49 AM
hey man,
but the same code is running very much fine on Linux.
if i remove glLflush() also it does not make any difference.

M/\dm/\n
12-16-2002, 03:00 AM
The fact it runs on Linux means nothing, I had a program that was runing nice on TNT2 &GeForce2GTS, but in the same time was showing wonders on Intel graphic chipsets http://www.opengl.org/discussion_boards/ubb/biggrin.gif
I have no time to look at your code right now, but I'll try to check it out after 3 hours.

nexusone
12-16-2002, 06:06 AM
Try putting the glutIdleFunc in the init routine.

I don't know why there is a linux run's diffrent the windows.

But glutIdleFunc should only be called once to enable, not over and over as you have.

Only glutTimerFunc has to be called again after being called.

Could be adding to overhead in the windows version of GLUT...


[This message has been edited by nexusone (edited 12-16-2002).]

M/\dm/\n
12-16-2002, 08:04 AM
Here comes little improved version. Problem arises at glutPostRedisplay. I'll try to look through that once more tomorrow. Maybe to much calculations? Something could be moved to lists! Actually it looks like Z fighting, but there's no depth! Maybe I just missed something http://www.opengl.org/discussion_boards/ubb/biggrin.gif



#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>
#include <math.h>
#include <windows.h>
#include <string.h>

//float z; Unused.
int n,i,j,k,sw,cw,curx,cury;

float position [7][2] = { -0.75,0.85,-0.40,0.85,-0.05,0.85,0.30,0.85,0.65,0.85,-0.85,0.55,0.80,0.55};
char label[10][10] = {"ADI","HSI","NAV", "","ELE", "ENG","FUL"};

char airspeed[11][10]={"330","331","332","333","334","335","336","337","338","339","340"};

char machcounter[11][10]={"0.20","0.21","0.22","0.23","0.24","0.25","0.26","0.27","0.28","0.29","0.30"};

char baltitude[11][10]={"04.990","05.110","05.225","05.555","05.785","06.050","06.185","06.678","08.849","09.985","09.987"};
char raltitude[11][10]={"4907","4909","4911","4913","4915","4917","4919","4921","4923","4925","4950"};

char navigdtk[11][10]={"020","021","022","023","024","025","026","027","028","029","030"};

char navigttg[11][10]={"003:41","003:42","003:45","003:50","003:55","003:60","003:65","003:70","003:75","003:80","003:85"};

char navigeta[11][10]={"00:08:10","00:08:11","00:08:12","00:08:13","00:08:14","00:08:15","00:08:16","00:08:17","00:08:18","00:08:20","00:08:22"};
char superscript[2]="R";
int aspeed=0, state=0;

int pitch[11]={0,10,20,30,40,50,-10,-20,-30,-40,70};
//int hsiyaw[31]={50,50,50,50,50,50,50,50,50,50,160,160,160,160,16 0,160,160,160,160,160,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100};
int hsiyaw[31]={-10,-20,-30,-40,-50,-60,-70,-80,-90,100,110,120,130,140,150,160,170,180,190,200,210 ,220,230,240,250,260,270,280,290};

float rotate[10]={0,10,20,30,40,25,0,-30,-45,60};
float lposition[722],Xpos,Ypos, radius;
static char stringlabel[100];

void idle()//you can skip voids
{
aspeed==9?aspeed=0:aspeed++;// ?: operator "A+" you can use - comp?NULL(if true):do if false
state==30?state=0:state++;
//Sleep(500);//Msecs !!!
glutPostRedisplay();
}

void init()//you can skip voids
{
glLoadIdentity();
glClearColor(1.0,1.0,1.0,1.0);
glEnable(GL_LINE_SMOOTH);
glShadeModel(GL_SMOOTH);
}

void drawstring(char *s)
{
//unsigned int i;
for(unsigned int i=0;i<strlen(s);i++)//Easier
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,s[i]);
}

void drawSmall(char *s)
{
//unsigned int i;
for(unsigned int i=0;i<strlen(s);i++)//Same as above
glutBitmapCharacter(GLUT_BITMAP_9_BY_15,s[i]);
}

void DrawCircle(float Xpos, float Ypos , float radius)
{
int i=0;
float vectorX, vectorX1=Xpos+radius, vectorY, vectorY1=Ypos;
float angle;
//glPointSize(2.0); I was looooooking for few hours, but didn't found any points anywayZ
//glEnable(GL_LINE_SMOOTH); Already at init http://www.opengl.org/discussion_boards/ubb/smile.gif)
glLineWidth(2.0);
glColor3f(0.0,1.0,0.0);//This is where it happens (killing)
glBegin(GL_LINE_STRIP);
k=0;
float speedup=2.0*3.14159265358979323846+2*0.0175;//You think that float can be THAT long? And especialy prcision on the display http://www.opengl.org/discussion_boards/ubb/smile.gif))))
for(angle=0.0;angle<=speedup;angle+=0.0175)//You should multiply all this stuff to var doblepi etc. for performance reasons
{
vectorX=Xpos+(radius* (float)cos(/*(double)*/angle));//why double? Wellllll OK I understood "It's military stuff"
vectorY=Ypos+(radius* (float)sin(/*(double)*/angle));
glVertex2f(vectorX1,vectorY1);
lposition[k]=vectorX1;
k++;
lposition[k]=vectorY1;
k++;
//glBegin(GL_LINES); Initeration without end??? & under LineStrip
vectorX1=vectorX;
vectorY1=vectorY;
}
glEnd();
}

void Line ()//you can skip voids
{
int m,n,k=0;//Drop to null at init http://www.opengl.org/discussion_boards/ubb/smile.gif
//k=0;
glColor3f(0.0,1.0,1.0);//Lets call that only once http://www.opengl.org/discussion_boards/ubb/smile.gif
glLineWidth(4.0);
glBegin(GL_LINES);
//glColor3f(0.0,1.0,1.0);
//glEnable(GL_LINE_SMOOTH);
for(m=0;m<=180;m+=2)//You can use for(int m=0;m<=180;m+=2) if you dont want to call 1st line in this func http://www.opengl.org/discussion_boards/ubb/smile.gif
{
glVertex2f(lposition[m],lposition[m+1]);
glVertex2f(-(lposition[m]),lposition[m+1]);
k++;
}
glEnd();
printf("\n these many lines %d",k);//Try to use cout for simpler output cout<<"Hi!"<<x<<"/t"<<endl; And maybe So many lines or cout<<x<<" Lines http://www.opengl.org/discussion_boards/ubb/smile.gif))"; use #include <iostream.h>
glColor3f(0.5,0.3,0.1);//Lets call that only once http://www.opengl.org/discussion_boards/ubb/smile.gif
//glColor3f(0.5,0.3,0.1);
glLineWidth(4.0);
glBegin(GL_LINES);
for(n=360;n<=540;n+=2)
{
glVertex2f(lposition[n],lposition[n+1]);
glVertex2f(-(lposition[n]),lposition[n+1]);
}
glEnd();
m=pitch[aspeed];
m*=2;
if(m>0)
{
glColor3f(0.0,1.0,1.0);//Lets call that only once http://www.opengl.org/discussion_boards/ubb/smile.gif
//glColor3f(0.0,1.0,1.0);
//glEnable(GL_LINE_SMOOTH);
glLineWidth(4.0);
glBegin(GL_LINES);
for(n=360;n<=360+m;n+=2)
{
glVertex2f(lposition[n],lposition[n+1]);
glVertex2f(-(lposition[n]),lposition[n+1]);
}
glEnd();
}
if(m<0)
{
glColor3f(0.5,0.3,0.1);//Lets call that only once http://www.opengl.org/discussion_boards/ubb/smile.gif
//glColor3f(0.5,0.3,0.1);
glLineWidth(4.0);
glBegin(GL_LINES);
for(n=360;n>=360+m;n-=2)
{
glVertex2f(lposition[n],lposition[n+1]);
glVertex2f(-(lposition[n]),lposition[n+1]);
}
glEnd();
}
//glLoadIdentity(); No reason to call
}

void display()//you can skip voids
{
glClear(GL_COLOR_BUFFER_BIT);
//glColor3f(1.0,1.0,1.0); Evry call to DrawCircle kills this line anywayZ
glRasterPos2f(-0.2,-0.82);
sprintf(stringlabel,"Attitude Direction Indicator");
drawstring(stringlabel);
DrawCircle(0.0,0.0,0.4);

glPushMatrix();//You pushed matrix away for later use http://www.opengl.org/discussion_boards/ubb/smile.gif
glRotatef(rotate[aspeed],0.0,0.0,1.0);
Line();
glPopMatrix();//You took it back (less costly than glLoadIdentity)

//glLoadIdentity(); No need anymore http://www.opengl.org/discussion_boards/ubb/smile.gif)
//glLineWidth(2.0); you are calling that before each object anyway http://www.opengl.org/discussion_boards/ubb/smile.gif It was 2 at line call.
glBegin(GL_LINE_STRIP);
glVertex2f(0.0,0.5);
glVertex2f(0.0,0.6);
glVertex2f(-0.05,0.55);
glVertex2f(0.0,0.6);
glVertex2f(0.05,0.55);
glEnd();

glutSwapBuffers();
}

void keyboard(unsigned char key , int x , int y)
{
switch(key)
{
case 27: exit(0);
break;
default :
break;
}
// glutPostRedisplay(); No need while there's no movment
}

void reshape( int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

int main(int argc, char **argv)
{
glutInit(&amp;argc,argv);
glutInitWindowSize(800,625);
glutInitWindowPosition(0,0);
glutCreateWindow("Multi Function Display");//Why you need pw??
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB/* | GLUT_DEPTH*/ );//You don't use depth anywayZ
init();

glutDisplayFunc(display);
glutIdleFunc(idle);
glutKeyboardFunc(keyboard);
glutReshapeFunc(reshape);

glutMainLoop();
return 0;
}

prashantgp
12-16-2002, 09:23 PM
Hey,
thanks for putting so much of time on this.
u've suggested me to use cout and all , why i am sticking to C is, because i want to run the same program both on Linux and Windows.

did u try running it on ur m/c??
hey nexusone,
i included idle call in init,but it didn;t work.
looking forward for the help.
thanks
bye bye

M/\dm/\n
12-17-2002, 12:23 AM
Whooow, that's one cool prog. I havn't seen anything like that so far! And, honestly, I don't know whats wrong http://www.opengl.org/discussion_boards/ubb/biggrin.gif



#include <GL/glut.h>//OK
#include <windows.h>//OK

void idle()
{
glutPostRedisplay();//?Maybe that's the problem, although it should work.
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);//OK
glColor3f(1.0,0.0,0.0);//OK
glBegin(GL_LINES);//OK
glVertex2f(-1,-1);//OK
glVertex2f(1,1);//OK
glEnd();//OK
glutSwapBuffers();//? Flickering could arise because bufers aren't swaped as they should
}

void reshape( int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);//OK
glMatrixMode(GL_PROJECTION);//OK
glLoadIdentity();//OK
gluOrtho2D(1.0,1.0,-1.0,1.0);//OK
glMatrixMode(GL_MODELVIEW);//OK
glLoadIdentity();//OK
}

int main(int argc, char **argv)
{
glutInit(&amp;argc,argv);//OK
glutInitWindowSize(800,625);//OK
glutCreateWindow("Multi Function Display");//OK
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);//? Works like GLUT_SINGLE with glFlush();, Maybe there's some sort of dept problem.

glutDisplayFunc(display);//OK
glutIdleFunc(idle);//? Redisplay causes mess.
glutReshapeFunc(reshape);//OK

glutMainLoop();//OK
return 0;//OK
}

That's the absolute minimum for the program to run & draw somthing, but it still catches gliches. Maybe there is specific inits for Ortho, can't tell you as I havn't worked with it lot http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Gavin
12-17-2002, 04:02 AM
gluOrtho2D(1.0,1.0,-1.0,1.0);//OK

HUH!
left, right, bottom, top

M/\dm/\n
12-17-2002, 04:28 AM
I checked with other values, so ther's no problem http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Yes, checked once more - no problem http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by M/\dm/\n (edited 12-17-2002).]

Deiussum
12-17-2002, 06:26 AM
But if Left is 1.0, and Right is 1.0, wouldn't that make the width of the projection 0? http://www.opengl.org/discussion_boards/ubb/smile.gif

M/\dm/\n
12-17-2002, 07:54 AM
I forgot to write the changes in uploaded code, but I checked with values -1 to 1 on x&y axis, no difference at all.

I'm so qurious, will someone find what's wrong here, THAT'S a question http://www.opengl.org/discussion_boards/ubb/biggrin.gif

bodros
12-17-2002, 11:36 AM
I read that some GL doesn't have it's own swap_buffer because it's not supported on all hardware, hence glutSwap. Maybe there's a problem there?

Could be that the difference in windows & linux is speed, so that display intervals are different, making it flicker on one and not the other. If you change the amount of things you display (making it slower/faster) does it have effect on the flickering?

Just guessing here, the program seems fine to me :P

prashantgp
12-17-2002, 08:08 PM
Originally posted by M/\dm/\n:
I forgot to write the changes in uploaded code, but I checked with values -1 to 1 on x&y axis, no difference at all.
I'm so qurious, will someone find what's wrong here, THAT'S a question http://www.opengl.org/discussion_boards/ubb/biggrin.gif
~~~~~~~~~~~~~~~~~
hi all,
this is not my problem at all.
reshaping is working fine. why i am using glutswapbuffers() is b'coz i am using double buffered mode.
what is worrying me is, when i run it on linux it works very much fine.all datas(yaw,pitch,roll,oil levels) are getting updated properly.
but on Linux m/c color combination is not coming properly.
when i use glColor3f(0.0,0.0,1.0) , it's giving red color instead of intended blue.

so pls look in
and help me out.
bye
prashant

M/\dm/\n
12-18-2002, 12:40 AM
I think I heard that you can set color modes to RGB & BGR, but can't tell you where. It's also possible that it was connected with texturing, don't remember as I havn't used this stuff. Oh, remembered, BMPs are saved in BGR format, that was why BGR format exists in OGL http://www.opengl.org/discussion_boards/ubb/biggrin.gif
About buffs, yes, Linux is whole lot faster for simple proceses, because it works as light as MS-DOS, but that shouldn't be the problem, look at this messy code I wrote long ago



#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdlib.h>

static GLfloat spin = 0.0;
GLfloat b=0,k=0,h=0;
float a[10]={0};

void water(int xk)
{
glPushMatrix();
k=0.08;
h=1;
if (a[xk]+xk>8&amp;&amp;a[xk]+xk<20)
{
k=0.04;
h=1.5;
}
if (a[xk]+xk+2>20&amp;&amp;a[xk]+xk+2<40)
{
k=0.16;
h=0.5;
}
if ((a[xk]+xk+2)>=40) a[xk]=0;
glTranslatef(a[xk],0,0);
glColor3f(0,1,1);
glRectf(0+xk, -8*h, 1+xk, 8*h);
glPopMatrix();
a[xk]+=k;

}

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef(-20,0,-50);
glBegin(GL_LINE_STRIP);
glColor3f(1,1,1);
glVertex3f(0,8,0);
glVertex3f(8,8,0);
glVertex3f(8,12,0);
glVertex3f(20,12,0);
glVertex3f(20,4,0);
glVertex3f(40,4,0);
glEnd();
glBegin(GL_LINE_STRIP);
glColor3f(1,1,1);
glVertex3f(0,-8,0);
glVertex3f(8,-8,0);
glVertex3f(8,-12,0);
glVertex3f(20,-12,0);
glVertex3f(20,-4,0);
glVertex3f(40,-4,0);
glEnd();
water(0);
water(3);
glPopMatrix();
glutSwapBuffers();
}

void spinDisplay(void)
{
spin = spin + 2.0;
if (spin > 360.0)
spin = spin - 360.0;
glutPostRedisplay();
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 100.0);
glMatrixMode (GL_MODELVIEW);
}

void mouse(int button, int state, int x, int y)
{
switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
glutIdleFunc(spinDisplay);
break;
case GLUT_RIGHT_BUTTON:
if (state == GLUT_DOWN)
glutIdleFunc(NULL);
break;
default:
break;
}
}

int main(int argc, char** argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Waterpipe");
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(mouse);
glutMainLoop();
return 0;
}

there's no flickering with same swapbuff, although it could be because of non-ortho mode.

prashantgp
12-18-2002, 02:10 AM
Hi
M/\dm/\n,
u said u forgot to include the changed code of mine.pls do that
why i am facing these problems i dont know.
may be i need to sit and study much.
give me ur mail id. so that i can mail my code to u for review.

M/\dm/\n
12-18-2002, 02:58 AM
ksalitis@hotmail.com

KallDrexx
12-19-2002, 05:20 AM
Originally posted by prashantgp:
Hey,
thanks for putting so much of time on this.
u've suggested me to use cout and all , why i am sticking to C is, because i want to run the same program both on Linux and Windows.

did u try running it on ur m/c??
hey nexusone,
i included idle call in init,but it didn;t work.
looking forward for the help.
thanks
bye bye

Um sicne when does linux not have C++? I use cout all the time on linux (all my programmings done on linux). so uhh yeah don't worry..

--KallDrexx