OpenGL (GLFW) does not show image on macOS Mojave

499 Views Asked by At

I updated macOS to Mojave, and some parts of my program does not work correctly. I want show coded pattern on GLFW window. However, it does not show anything. Before updating this code works correctly. The code below is my code which does not work. Is there any part which cannot be use anymore? Or does anyone know about changes between High Sierra to Mojave?

void showPattern(float cr, float cg, float cb, int num, int p){
unsigned char *pat;
pat=(unsigned char *)malloc(sizeof(unsigned char)*pxsize*pysize*3);
int i, j, len;
int pt = 0;
len = (_patwidth)<pxsize?(_patwidth):pxsize;
glfwMakeContextCurrent(codewin);
for(i=0;i<pysize;i++){
    for(j=0;j<len;j++){
        if(p==POSITIVE){
            pat[pt+0] = cr * pattern[num].posi[4*j];
            pat[pt+1] = cg * pattern[num].posi[4*j];
            pat[pt+2] = cb * pattern[num].posi[4*j];
        }
        else{
            pat[pt+0] = cr * pattern[num].nega[4*j];
            pat[pt+1] = cg * pattern[num].nega[4*j];
            pat[pt+2] = cb * pattern[num].nega[4*j];
        }
        pt+=3;
    }
}

glfwMakeContextCurrent(codewin);
glColor4d(1.0, 1.0, 1.0, 0.0);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pxsize, pysize, GL_RGB, GL_UNSIGNED_BYTE, pat);


glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(-1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(-1.0f, -1.0f);
glEnd();

glFlush();
glfwSwapBuffers(codewin);
free(pat);
}
  • macOS: 10.14
  • Xcode: 10.1
  • OpenGL: 2.1
  • GLFW: 3.3.0
  • GLEW: 2.1
1

There are 1 best solutions below

1
On

It's a bug in Mojave unfortunately. According to this Stuttering movement and black screen on macOS 10.14 & Xcode 10 it should be fixed in 10.14.2.

Until then a workaround is to build with the macOS 10.13 SDK which you can get here