PDA

View Full Version : point program



04-24-2004, 09:42 PM
hi all,
i am learning opengl..i went through online documentation....i just wanted to know if we can draw lines and plot points without declaring any projection before plotting.....i'm confused with the camera analogy...as a beginner i just wanted to practice few programs without considering camera...i would like to know if we can do this..
thanks a lot

plasmonster
04-24-2004, 10:09 PM
Here's the short answer: you need to define a projection to draw anything on the screen, but that's ok, it's easy to do.

Here's a projection setup for simple 2D drawing:

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0, screenWidth, 0, screenHeight, -999, 999 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

... now draw your stuff

Heres a projection setup for 3D drawing:

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( fovy, aspect, znear, zfar
);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

... now draw your stuff

There's really not much to it.

04-24-2004, 10:25 PM
hi,
i am supposed to display a perspective projected 3D object but without using any inbuilt functions... i know how to calculate all the points for the perspective projected image but i'm not getting any image on the screen if i plot them...please help

plasmonster
04-24-2004, 10:31 PM
Why are you using gl if not to use its functionality? I'm not sure I understand your problem.

If you want to bypass the gl projection matrix:
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
...now do it all yourself