Involved in the production of glycogen and alpha-glucan via the TreS-Pep2 branch involved in the biosynthesis of maltose-1-phosphate (M1P), and probably in the osmoprotection via the biosynthesis of trehalose (PubMed:12473104, PubMed:27513637). Catalyzes the transfer of glucose from UDP-glucose (UDP-Glc) to D-glucose 6-phosphate (Glc-6-P) to form trehalose-6-phosphate (PubMed:12473104). Is specific for the glucosyl acceptor (Glc-6-P cannot be replaced by either mannose-6-P, fructose-6-P or glucosamine-6-P), but any of the glucose sugar nucleotides can be used as glucosyl donors (PubMed:12473104). It is more active with the purine sugar nucleotides than with the pyrimidine sugar nucleotides (PubMed:12473104). ADP-alpha-D-glucose + D-glucose 6-phosphate = ADP + alpha,alpha-trehalose 6-phosphate + H(+) CDP-alpha-D-glucose + D-glucose 6-phosphate = alpha,alpha-trehalose 6-phosphate + CDP + H(+) D-glucose 6-phosphate + GDP-alpha-D-glucose = alpha,alpha-trehalose 6-phosphate + GDP + H(+) D-glucose 6-phosphate + TDP-alpha-D-glucose = alpha,alpha-trehalose 6-phosphate + H(+) + TDP D-glucose 6-phosphate + UDP-alpha-D-glucose = alpha,alpha-trehalose 6-phosphate + H(+) + UDP Activity is increased about twofold by 10 mM manganese. ADP, at 10 mM concentration, inhibits the formation of trehalose-P by 70% with either UDP-glucose or GDP-glucose as substrate, but GDP, also at 10 mM, only inhibits the reaction with UDP-glucose (50%) but not with GDP-glucose. Glycan biosynthesis; trehalose biosynthesis. Homotetramer. Combined inactivation of both glgM and ostA is lethal, potentially due to accumulation of toxic levels of ADP-glucose. Combined inactivation of otsA and glgC results in a loss of alpha-glucans and maltose-1-phosphate (M1P). Belongs to the glycosyltransferase 20 family.