PDA

View Full Version : Nothing is visible



10-06-2005, 11:16 PM
Here is code which is not displaying I would like to render the vertices described below.

Where is the problem



#include <GL/glut.h>
#include <GL/gl.h>

static float v[6][3] = { {-1.0f,0.0f,2.0f},
{1.0f,0.0f,2.0f},
{-1.0f,0.0f,-2.0f},
{0.0f,2.0f,1.0f},
{0.0f,3.0f,-1.0f},
{0.0f,3.0f,2.0f},
};


void init()
{
glShadeModel(GL_FLAT);
glClearColor(1.0f,1.0f,1.0f,1.0f);
}

void reshape(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//gluPerspective(45, 1, 1, 10000);
gluOrtho2D(0.0,(GLdouble)w,0,0,(GLdouble)h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
//gluLookAt(0.0f,0.0f,5.0f,0.0f,0.0f,0.0f,0.0f,1.0f, 0.0f);
glBegin(GL_POINTS);
for(int i=0;i<6;i++)
{
glVertex3dv(&amp;v[i]);
}
glEnd();
glFlush();

}


int main(int argc,char **argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(700, 700);
glutInitWindowPosition(0, 0);
glutCreateWindow("glCloth");
init();
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMainLoop();

return (0);


}

mikael_aronsson
10-06-2005, 11:31 PM
Hi !

Two problems.

You use gluOrtho2D, this will set the clipping planes to -1 and 1, and as you are using 2 and -2 for most of your vertices a lot will be clipped away.

The second thing is that you map the view to the width and height of the window, this means that your vertices span is 2-4 pixels, this is very small so there is a bug change that you will not see much at all just because of that.

Mikael