c++xcodemacosopenglglut

macOS Catalina 10.15 xcode openGL not running window?


I am working on a c++ project with openGL on Xcode, my code is build successful. But there is no display window?

My Xcode settings here;

My first post - > Here

I need help, and my codes;

#include"GL/glew.h"
#include"GL/freeglut.h"
#include<iostream>
#define GLEW_STATIC

void display(void) {
    
}
int main(int argc, char *argv[]) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(500, 200); //glut penceresinin ekran konumu
    glutInitWindowSize(500, 350); //glut penceresinin boyutları
    glutCreateWindow("OpenGL Merhaba Dunya");
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

And Xcode print its terminal this error message;

freeglut (/Users/ismailyavuz/Library/Developer/Xcode/DerivedData/ornek-acjymofglobglnbdyttjfdcvjwya/Build/Products/Debug/ornek): failed to open display ''
Program ended with exit code: 1

Solution

  • I research and find it. You need the XQuartz for running windows.

    Visit this web site : https://www.xquartz.org

    Download and install it.

    It's working for me.