How to get shading with out supplying normals using glDrawElements.

:)I am drawing a mesh using glDrawElements.
Recently I heard that, using GL Shading language(GLSL) ,
shading is possible with out supplying normals.
Is it possible. ???
Please help me on this.
If possible, please provide some examplary code.
Thanks in advance.

Normals are always needed in fragment shader, but you can compute them directly in GLSL (additional work done by shaders, for every vertex).
Search on Google how to compute them in the best way in which fits your case.

This strongly depends on the data you are planning to use.

If you have a heightmap, the computation is easy: The shader must simply take additional heights next to the point the normal will be calculated for. Then, a cross-product gives a good approximation of how the actual normal should look like. The more points are taken into account for this calculation, the more accurate the normal is.

However, for arbitrary geometry this may not be possible. As far as I know, the fragment shader cannot know all points of the drawn polygon; only one point can be known (by using the “flat” keyword which leaves the coordinate un-interpolated).

But why not calculate the normals out of the shader once for all faces, and then simply pass them on to the shader to read and draw?

One way is to use a geometry shader; input triangles with adjacency, output a single triangle, and calculate the normal from the vertex data. Adjacency on input is only necessary if you want to average normals for adjacent faces.

Of course that’s going to be slower than just calculating normals in your asset creation pipeline and including them in the models you load and draw. But it can certainly be done.

Thanks tdname, I will use GLSL.

Thanks all of you to help me on this.