Hi community,
I am totally new to the field of OpenGL. Just read the lighthouse3d tutorials and program the samples. Till this moment everything worked fine.
For me, the actual factor to deal with OpenGL is to display and rotate a point cloud. So, I tried to customize the samples to my benefit. At that time my problems began.
I declared two arrays:
- float imgdata[480][640][3]; //contains the three-dimensional coordinates
- float texture[480][640][3]; //contains the color values for each point
The points from these array should be converted into glVertex3f, set by the renderScene() function. If anything will be changed the function reshape() should just redraw the window.
After running my program I just got a white screen. Receive no useful results =(
Hope You understand my problem. So, can you please help me?
I am very grateful for any support.
Cheers
Thats my actual code:
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (60, (GLfloat)w / (GLfloat)h, 1.0, 500.0);
glMatrixMode (GL_MODELVIEW);
}
void renderScene(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glRotatef(ry, 0.0, 1.0, 0.0); //rotate about the z axis
glRotatef(rx-180, 1.0, 0.0, 0.0); //rotate about the y axis
float x,y,z;
glPointSize(1.0);
glBegin(GL_POINTS);
for (int i=0;i<480;i++)
{
for (int j=0;j<640;j++)
{
glColor3f(texture[i][j][0]/255, texture[i][j][1]/255, texture[i][j][2]/255);
x=imgdata[i][j][0];
y=imgdata[i][j][1];
z=imgdata[i][j][2];
glVertex3f(x,y,z);
}
}
glEnd();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(10,10);
glutInitWindowSize(640, 480);
glutCreateWindow("3D disparity image");
glutDisplayFunc(renderScene);
glutReshapeFunc(reshape);
glutIdleFunc(renderScene);
glutMainLoop();
}