Hi

I am trying write a little program that displays a constant number of object in the view area at all times (currently point objects). I am using a frustum class that gives me the important view coordinates (it

is mostly from the Lighthouse View Frustum Culling Tutorial). It seems like it should be easy but the view remains splotchy with objects constantly blinking (being added to random positions) on screen.

Does anyone have any ideas?

Below is the function I use to redraw the objects. I can attach the rest of the application if it would help.

void cstarfield::weMove()

{

camera.MoveForward(g_speed);//forward is -z

```
camera.Render();//needs to be here for frustum
lftl = camera.ftl; lfbl=camera.fbl; lfbr=camera.fbr; lftr=camera.ftr;
lntl = camera.ntl; lnbl=camera.nbl; lnbr=camera.fbr; lntr=camera.ftr;
for ( int i = 0; i < NUM_STARS; i++ )
{
glPushMatrix();
glTranslatef( g_xyz[i][0], g_xyz[i][1], g_xyz[i][2] );
if (g_color==GL_TRUE)
glColor3fv( g_colors[i] );
else
glColor3f( 255,255,255);
glPointSize(g_pointsize); //sets the pixel size of the points
glBegin(GL_POINTS); // render with points
glVertex2i(0,0); //display a point at current x,y,z
glEnd();
glPopMatrix();
GLfloat lowest, highest, range;
GLfloat tmp;
Vec3 a( g_xyz[i][0], g_xyz[i][1], g_xyz[i][2] );
enum {TOP=0, BOTTOM,LEFT,RIGHT,NEARP,FARP};
if (camera.pointInFrustum(a) == CCamera::OUTSIDE)
//if star is outside of frustum then recalc to somewhere inside ...
{
GLfloat dn,df,dl,dr,dt,db, td;
dn=camera.pl[NEARP].distance(a);
df=camera.pl[FARP].distance(a);
dl=camera.pl[LEFT].distance(a);
dr=camera.pl[RIGHT].distance(a);
dt=camera.pl[TOP].distance(a);
db=camera.pl[BOTTOM].distance(a);
if (dl<0)
if (camera.ftl.x<camera.ftr.x)
g_xyz[i][0] = g_xyz[i][0]-dr;
else
g_xyz[i][0] = g_xyz[i][0]+dr;
if (dr<0)
if (camera.ftl.x<camera.ftr.x)
g_xyz[i][0] = g_xyz[i][0]+dl;
else
g_xyz[i][0] = g_xyz[i][0]-dl;
if (dt<0)
if (camera.ftl.y>camera.fbl.y)
g_xyz[i][1] = g_xyz[i][1]-db;
else
g_xyz[i][1] = g_xyz[i][1]+db;
if (db<0)
if (camera.ftl.y>camera.fbl.y)
g_xyz[i][1] = g_xyz[i][1]+dt;
else
g_xyz[i][1] = g_xyz[i][1]-dt;
if (df<0)
if (camera.ftl.z>camera.ntl.z)
g_xyz[i][2] = g_xyz[i][2]-dn;
else
g_xyz[i][2] = g_xyz[i][2]+dn;
if (dn<0)
if (camera.ftl.z>camera.ntl.z)
g_xyz[i][2] = g_xyz[i][2]-df;
else
g_xyz[i][2] = g_xyz[i][2]+df;
Vec3 d(g_xyz[i][0], g_xyz[i][1], g_xyz[i][2]);
if (camera.pointInFrustum(d) == CCamera::OUTSIDE)
{
lowest=dl; highest=dr;
if (lowest> highest){tmp=lowest;lowest=highest;highest=tmp; }
range=(highest-lowest)+1;
g_xyz[i][0] = lowest+int(range*rand()/(RAND_MAX + 1.0));
lowest=db; highest=dt;
if (lowest> highest){tmp=lowest;lowest=highest;highest=tmp; }
range=(highest-lowest)+1;
g_xyz[i][1] = lowest+int(range*rand()/(RAND_MAX + 1.0));
lowest=dn; highest=df;
if (lowest> highest){tmp=lowest;lowest=highest;highest=tmp; }
range=(highest-lowest)+1;
g_xyz[i][2] = lowest+int(range*rand()/(RAND_MAX + 1.0));
}
```

}