When you create a brush in a 3D map editor such as Valve’s Hammer Editor, textures of the object are by default repeated and aligned to the world coordinates.
How can i implement this functionality using OpenGL?
Can glTexGen be used to achieve this?
Or do i have to use texture matrix somehow?
If i create 3×3 box, then it’s easy:
Set GL_TEXTURE_WRAP_T to GL_REPEAT
Set texturecoords to 3,3 at the edges.
But if the object is not an axis aligned convexhull it gets, uh, a bit complicated.
Basically i want to create functionality of face edit sheet from Valve Hammer:

Technically you can use texture coordinate generation for this. But I recommend using a vertex shader that generates the texture coordinates from the transformed vertex coordinates. Be a bit more specific (I don’t know Hammer very well).
After seeing the video I understand your confusion. I think you should know, that Hammer/Source probably don’t have the drawing API generate texture coordinates, but produce them internally.
So what you can see there are textures that are projected on either the X, Y or Z plane, depending in which major direction the face is pointing to. It then uses the local vertex coordinates as texture coordinates.
You can implement this in the code loading a model to a Vertex Buffer Object (more efficient, since the computation is done only once), or in a GLSL vertex shader. I’ll give you the pseudocode:
To make this work with glTexGen texture coordinate generation, you’d have to split your models into parts of each major axis. What glTexGen does is just the mapping step
face.texcoord[i] = { s = pos.<>, t = pos.<> }. In a vertex shader you can do the branching directly.