Glaucoma is a common eye disease that damages the optic nerve and leads to loss of vision. The disease shows few symptoms in the early stages, making its identification a complex task. To overcome the challenges associated with this task, this study aimed to tackle the localization and segmentation of the optic disc, as well as the classification of glaucoma. For the optic disc segmentation, we propose a novel metaheuristic approach called Grey Wolf Optimization (GWO). Two different approaches are used for glaucoma classification: a one-stage approach, in which the whole image without cropping is used for classification, and a two-stage approach. In the two-stage approach, the optic disc region is detected using the You Only Look Once (YOLO) detection algorithm. Once the optic disc region of interest (ROI) is identified, glaucoma classification is performed using pre-trained convolutional neural networks (CNNs) and vision transformation techniques. In addition, both the one-stage and the two-stage approaches are applied in combination with the pre-trained CNN using the Random Forest algorithm. In segmentation, GWO achieved an average sensitivity of 96.04%, a specificity of 99.58%, an accuracy of 99.39%, a DICE coefficient of 94.15%, and a Jaccard index of 90.4% on the Drishti-GS dataset. For classification, the proposed method achieved remarkable results with a high-test accuracy of 100% and 88.18% for hold-out validation and three-fold cross-validation for the Drishti-GS dataset, and 96.15% and 93.84% for ORIGA with hold-out and five-fold cross-validation, respectively. Comparing the results with previous studies, the proposed CNN model outperforms them. In addition, the use of the Swin transformer shows its effectiveness in classifying glaucoma in different subsets of the data.