How to load shader From File on Xcode

  • AvenousLee
    Likes 0

    Problem Description

    on Window version 

    fragmentShader = LoadShaderFromFile (GL_FRAGEMENT_SHADER,”../fragmentShader1.frag”);

    how do i do it on Xcode ? 

     

  • Sonar Systems admin
    Likes 0

    Are you having any particular issue?

     

  • AvenousLee
    Likes 0

    Hi , thanks for the reply and sorry . Still new to the opengl thing 

    I already solve that issue . 

    I have another question is there away to add GLES2 and EGL lib in to Xcode ?

    cos I’m trying to follow a sample of code that my school gave but is for window platform so I’m trying to get it to work on mac platform . 
     

    Here is a part of the code here I’m having issue currenly 

     glfwSetErrorCallback(error_callback);

     

      // Initialize GLFW library

      if (!glfwInit())

        return -1;

     

      glfwDefaultWindowHints();

      glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);

      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);

      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

     

      // Create and open a window

      window = glfwCreateWindow(WINDOW_WIDTH,

                                WINDOW_HEIGHT,

                                "Hello World",

                                NULL,

                                NULL);

     

      if (!window)

      {

        glfwTerminate();

        printf("glfwCreateWindow Error\n");

        exit(1);

      }

     

      glfwMakeContextCurrent(window);

     

      Init();

     

      // Repeat

      while (!glfwWindowShouldClose(window)) {

     

     

        Draw();

        glfwSwapBuffers(window);

        glfwPollEvents();

      }

     

      glfwDestroyWindow(window);

      glfwTerminate();

      exit(EXIT_SUCCESS);

    }

    The problem is that when I run the code it show the erro message “ glfwCreateWindow Error message ”

    But if I comment out the line  glfwWindowHint(GLFW_CLIENT_API,GLFW_OPENGL_ES_API);

    Then is program is able to run , is there away to over come it ?

  • Sonar Systems admin
    Likes 0

    Are you doing mobile dev?

  • AvenousLee
    Likes 0

    no , not for this one . just opengl 

  • Sonar Systems admin
    Likes 0

    Why are you trying to load GLES then?


Login to reply