I need to create triangle for each vertex in opengl geometry shader. The problem is I do not know how to specify the coordinates for the new triangle.

For eaxmple, i have a vertex glVertex3f(x, y, 0.0f). I would want to create a triangle surrounding the vertex whose world coordinates are (x - 0.5f, y - 0.5f, 0.0f), (x+ 0.5f, y-0.5f,0.0f),(x ,y+0.5f,0.0f);

Using the glPositionIn[0], i get the vertex position in clip space, if i simple use the glPostionIn[0].x - 0.5 or + 0.5f thing, the result is not what I want. How should i specify the position for the triangle vertex so that I could get a traingle surrounding the input vertex? Thanks.

Using the glPositionIn[0], i get the vertex position in clip space

No, you get the vertex position in whatever space your vertex shader outputted the vertex in. If you wrote a clip-space value to the vertex shader, then that’s what the geometry shader gets. If instead you wrote a world-space value, that’s again what the geometry shader gets.

Only the last active shader stage before rasterization needs to output in clip space. So if your geometry shader needs to get world-space coordinates, make sure to pass them world-space coordinates. The geometry shader is perfectly capable of doing the transforms by itself.