Xcode 10 and macOS 10.14

  • Sack TV
    Likes 0

    Problem Description

    I updated my mac today and a project with OpenGL isn’t working, the window is opening but it shows nothing, i use SDL2 ad my window library, but also GLFW doesn't work.

    I don't get any errors in the console or the program. Do you know how to fix it?

  • Sonar Systems admin
    Likes 0

    Anything else get updated?

  • Sack TV
    Likes 0

    Only commandline tools, but it updated automaticly. Also Xcode was released befor macOS 10.14 and it was working at that time.

  • Sonar Systems admin
    Likes 0

    Is xcode updated?

  • Sack TV
    Likes 0

    Yes

     

  • Sonar Systems admin
    Likes 0

    Did you try setting it up again?

  • Sack TV
    Likes 0

    I made a completly new project just using SDL2 to calculate the Mandelbrot set which was working with macOS 10.13 and it is not working, i even reinstalled SDL and it is still not working.

    Have you installed macOS 10.14? 

  • Sack TV
    Likes 0

    I found out, that if i move the window everything is rendering, I now use the SDL_SetWindowPosition command to move the window.

    Is there a good way to do that?


  • Sonar Systems admin
    Likes 0

    Can you show me a video of it please.

  • Sack TV
    Likes 0

    Here:

    https://youtu.be/MrbWuthlbx0

  • Sonar Systems admin
    Likes 0

    Can you show me the code please.

  • Sack TV
    Likes 0

    (the window-class is copied from a tutorial)

     

    main: 

    #include <stdio.h>

    #include <stdlib.h>

    #include "window.h"

    #include <complex.h>

    #include <math.h>

     

    using namespace std;

     

    int height = 720;

    int width = 1280;

     

    double zoom = 1.0;

    double shiftX = 2.0;

    double shiftY = 2.0;

     

    double stepSizeX = 0.01;

    double stepSizeY = 0.01;

    double stepSizeZoom = 0.01;

     

    float escapeSize = 2.0;

    int maxIterations = 50;

     

    char input;

     

    Window window("Mandelbrot Set", width, height);

     

     

    double map(double min, double max, double minI, double maxI, double input) {

        return (input * (max / maxI));

    }

     

     

    void calculate() {

        for (int y = 0; y < height; y++) {

            for (int x = 0; x < width; x++) {

                complex<double> c(zoom * (x - (width - height) /2) / height * 4.0 - shiftX, zoom * y / height * 4.0 - shiftY);

                complex<double> z(0.0, 0.0);

                int iteration = 0;

                while(iteration < maxIterations) {

                    z = pow(z, 2) + c;

                    if (abs(z) > escapeSize) {

                        break;

                    }

                    iteration++;

                }

                if(iteration == maxIterations) {

                     window.drawPoint(x, y, 0, 0, 0, 255);

                }

                else {

                  window.drawPoint(x, y, (short)(map(0, 255, 0, maxIterations, iteration * 0.4)), (short)(map(0, 255, 0, maxIterations, iteration * 0.4)), (short)(map(0, 255, 0, maxIterations, iteration * 1.0)), 255);

                }

            }

        }

    }

     

     

    int main() {

        printf("Starting window...\n");

        

        window.clear();

        SDL_RenderPresent(window.renderer);

        

        calculate();

        

        SDL_RenderPresent(window.renderer);

        while(!window.isClosed()) {

            window.pollEvents();

            

            if(window.controls[0] == true) {

                shiftY -= stepSizeY;

                calculate();

            }

            if(window.controls[1] == true) {

                shiftY += stepSizeY;

                calculate();

            }

            if(window.controls[2] == true) {

                shiftX -= stepSizeX;

                calculate();

            }

            if(window.controls[3] == true) {

                shiftX += stepSizeX;

                calculate();

            }

            if(window.controls[4] == true) {

                zoom -= stepSizeZoom;

                calculate();

            }

            if(window.controls[5] == true) {

                zoom += stepSizeZoom;

                calculate();

            }

            if(window.controls[6] == true) {

                maxIterations = 1000;

                calculate();

            }

            if(window.controls[7] == true) {

                maxIterations = 50;

                calculate();

            }

            if(window.controls[8] == true) {

                SDL_Delay(1000);

                printf("Zoom: %f, Shift X: %f, Shift Y: %f\n", zoom, shiftX, shiftY);

            }

            SDL_RenderPresent(window.renderer);

        }

        

        printf("Window closed\n");

        return 0;

    }

     

    window.cpp :

     

    #include "window.h"

    #include <stdio.h>

    #include <string>

     

    Window::Window(const std::string &title, int width, int height):

    title(title), width(width), height(height) {

        closed = !init();

    }

     

    Window::~Window() {

        SDL_DestroyRenderer(renderer);

        SDL_DestroyWindow(window);

        SDL_Quit();

    }

     

    bool Window::init() {

        if(SDL_Init(SDL_INIT_VIDEO) != 0) {

            printf("Error: Failed to initalize SDL\n");

            return false;

        }

        

        window = SDL_CreateWindow

        (

         title.c_str(),

         SDL_WINDOWPOS_CENTERED,

         SDL_WINDOWPOS_CENTERED,

         width, height,

         SDL_WINDOW_OPENGL

         );

        

        if(window == nullptr) {

            printf("Error: Window creaton failed\n");

            return false;

        }

        

        renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);

        

        if(renderer == nullptr) {

            printf("Error: Window creaton failed\n");

            return false;

        }

        

        return true;

    }

     

    void Window::pollEvents() {

        SDL_Event event;

        

        if(SDL_PollEvent(&event)) {

            switch(event.type) {

                case SDL_QUIT:

                    closed = true;

                    break;

                    

                case SDL_KEYDOWN:

                    switch (event.key.keysym.sym) {

                        case SDLK_UP:

                            controls[0] = true;

                            break;

                            

                        case SDLK_DOWN:

                            controls[1] = true;

                            break;

                            

                        case SDLK_LEFT:

                            controls[2] = true;

                            break;

                            

                        case SDLK_RIGHT:

                            controls[3] = true;

                            break;

                            

                        case SDLK_PLUS:

                            controls[4] = true;

                            break;

                            

                        case SDLK_MINUS:

                            controls[5] = true;

                            break;

                            

                  &nbs

  • Sonar Systems admin
    Likes 0

    Which tutorial?

  • Sack TV
    Likes 0

    It doesn’t matter, because that the problem isn't just limited to SDL, also a project with GLFW and OpenGL (using your OpenGL tutorial) and the same project with SDL is affected. Do you have the same problem or do you now a better solution?

  • Sonar Systems admin
    Likes 0

    Could you please provide the tutorial you used.

  • Sonar Systems admin
    Likes 0

    The tutorials from the first link are mine, how many did you follow?

  • Sack TV
    Likes 0

    All 

  • Sonar Systems admin
    Likes 0

    Have you tried it all in the main to see if that works?

  • Sack TV
    Likes 0

    What do you mean? Putting all the code for the window in the main? I have done that, same problem. Do you know a solution?

  • Sonar Systems admin
    Likes 0

    Did you try the code from GitHub?

  • Sack TV
    Likes 0

    Yes, do you have a solution or not??

  • Sack TV
    Likes 0

    But i’m not using GLUT, the only command i could copy was glFlush(); but it doesn't do anything.

  • Sonar Systems admin
    Likes 0

    What about the order of the code?

Login to reply