ogldev1 said:
the z axis isn't visible and the coordinate system doesn't seem to be attached to the object however I drew it right after drawing the object.
This surely is because your mvp matrix was given only to the shader program.
So before drawing the axis, you need to load the projection and modelview by using the legacy glLoadMatrix functions.
Or you write second shader for untextured models, so you could use uniforms as well.
ogldev1 said:
When the object rotates, the axes rotate too but now they seem to be detached from the object.
That's confusing (together with the fact z axis isn't drawn).
Maybe you did not really rotate the model, but just the projection (camera), which you did give to GL elsewhere in the code so it still affects the axis.
To minimize the confusion, you can limit GPU matrix use to having only the camera projection, but no model transform.
To draw the axis this way, you would load the camera projection, set modelview to identity, and transform the axis vertices yourself on C++ side.
To proof correctness, you could first try to draw the object vertices as white points and see if they match.
(Exercise makes sense only if you're familiar with transformations. But if so, you can make sure stuff is drawn at the right space as intended.)