I was wondering, is it possible to render a (3D) torus shape entirely in GLSL, i.e. without using vertex/index arrays? Suggestions are welcome, thanks.
You can use distance functions described in here: http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
One can use different approaches, but the best way to my mind is to code your own renderer in the fragment shader. Some ray-tracer or ray-marcher. In both cases you will need function that builds ray for current pixel on the screen. Next you can analytically find intersection of ray with torus (ray-tracer), or iteratively step along your ray until you encounter torus (ray-marching). In the latter case distance field is the best solution. See artificialidiot's answer.
For advanced studying of ray-tracing see this book.
Not really an answer, but I can't post comments yet..
In Directx you can make Draw(x, 0) calls, x being the number of vertices to draw, and should no vertex buffer be bound it will auto-generate x vertices with no attributes except a unique ID. If something similar is possible in openGL...
You could then pass these vertices with just an ID through to a geometry shader, and use the ID*4 to determine the position on the torus, and generate a quad for each ID. Think of the torus' surface flattened out as a simple plane of rows by colums. For example, (int)((ID*4) / number_of_minor_segments) would give you the row offset along the length of the torus' surface, and ((ID*4) % number_of_minor_segments) would give you the column offset in the current row, minor segments beingt the number of segments you want around the minor radius.
You can calculate the offsets of the next 3 vertices by doing the same for (ID*4)+1, +2, and +3.
Map the offsets from "torus coordinates" to object then to world space, then send two triangles (from vertices 0, 1, 2; 2, 3, 0) to the rasterizer.
Of course the geometry would be re-generated every frame. Why do you want to avoid vertex buffers in the first place?
If you're using a wrapper for OpenGL, like GLUT there are often built in methods to render basic shapes. For example there is glutTorus() in the OpenGL wrapper GLUT to draw a torus without having to set anything up.
As for the comment about impostors by Nicol Bolas, I'm not sure if it's helpful in this case. All I could find with a quick search was http://http.developer.nvidia.com/GPUGems3/gpugems3_ch21.html in which case you indeed don't have to set up vertex and index arrays but I think this method might be more advanced than you need.
Anyway, if you can explain us better why you don't want to set-up a vertex and index buffer we can come up with better solutions.