Turn a function plot in 2D directly into 3D

I have the following opengl app which plots 2d funxtions. I want to turn it into one for plotting 3D surfaces with min. changes that is maintain the drawVertex and just change the projection. I was unable to do that as shown in the code...

Please use [code][/code] around source code. I'm not really sure what you are asking, for example what is drawVertex that you don't want to change? I'd doubt it is possible to avoid making quite substantial changes since surfaces have an additional dimension compared to the lines you are currently drawing. Anyway, can you clarify what you are after?

Please use [code][/code] around source code. I'm not really sure what you are asking, for example what is drawVertex that you don't want to change? I'd doubt it is possible to avoid making quite substantial changes since surfaces have an additional dimension compared to the lines you are currently drawing. Anyway, can you clarify what you are after?

I meant use glVertex3d instead of glVertex2d, that is draw the surface one point at a time. This is shown in the attached code.

I think I found what is wrong, I had nothing appearing because in 3d the camera is aiming at the -ve z axis not the +ve axis which I have been assuming translating by glTranslatef(0.0,0.0,-MAXF) will make something appear although not so good looking, no depth cues....

Here is the code working after adding zooming and rotation to the surface, but what I still don't know how to do is to determine the sides of the surface to be colored by 2 different colors in order to be able to see the folds. I can compute the surface normal at every vertex but don't know how to use it to differentiate the sides?

Well I used lighting and defined it to use both sides of the surface and defined the normal at each vertex but what I get is the front surface and the back surface is invisible, what I want is to display the back surface in a different color or shade from the front surface not to be invisible....any help?

Final Version in case anybody is interested

The code plots a surface with -1<=x<=1, -1<=y<=1< -1<=z<=1 in parametric form.
It allows rotating to see the surface from different viewpoints... Of course this could generalize to any ranges. The only problem is the choice of colors of the surface, probably turning the displayed color into shades of gray would look better....

The code plots a surface with -1<=x<=1, -1<=y<=1< -1<=z<=1 in parametric form.
It allows rotating to see the surface from different viewpoints... Of course this could generalize to any ranges. The only problem is the choice of colors of the surface, probably turning the displayed color into shades of gray would look better....

The colors get much better if you keep track of the ModelView matrix and compute the normal and ray according to it and not have them fixed according to original position.
Here the code that does that: