OpenGL not working on older mac?

I’m programming for mac os x. And made simple paint program. On my mac its working good but on older mac (macbook 2.1 (Intel GMA 950) and macbook 3.1 (Intel GMA x3100)) opengl part of my app is not working at all. It shows white window at were it should be my painting field (fully opengl).

On my mac it looks like this:
[ATTACH=CONFIG]225[/ATTACH]

And on older macs it looks like this:
[ATTACH=CONFIG]226[/ATTACH]

You aren’t giving much information. Is macbook 2.1 suppose to mean OpenGL 2.1 and macbook 3.1 suppose to mean OpenGL 3.1?
What is that grass thing? Is it a texture you are applying to a quad? What is the size of the texture? Did you create mipmaps? Did you setup your texture object properly?
http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture

Macbook 2.1 and Macbook 3.1 means macbook version. Macbook 2.1 has Intel GMA 950 graphics card and Macbook 3.1 has Intel GMA x3100 graphics card. Grass is texture made from .jpg image. Image size is 3200 × 2000. Texture is being applied to quad with glTexCoord2f.

Image to texture code:


   ftImg = [NSImage imageNamed:@"grass.jpg"];
    CGImageSourceRef src;
    src = CGImageSourceCreateWithData((CFDataRef)[ftImg TIFFRepresentation], NULL);
    CGImageRef ft =  CGImageSourceCreateImageAtIndex(src, 0, NULL);
    
    ftWidth = CGImageGetWidth(ft);
    ftHeight = CGImageGetHeight(ft);
    
    if(ft) {
        ftData = (GLubyte *) calloc(ftWidth * ftHeight * 4, sizeof(GLubyte));
        ftContext = CGBitmapContextCreate(ftData, ftWidth, ftHeight, 8, ftWidth * 4, CGImageGetColorSpace(ft), kCGImageAlphaPremultipliedLast);
        CGContextDrawImage(ftContext, CGRectMake(0.0, 0.0, (CGFloat)ftWidth, (CGFloat)ftHeight), ft);
        CGContextRelease(ftContext);
        glGenTextures(1, &ftTxt);
        glBindTexture(GL_TEXTURE_2D, ftTxt);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ftWidth, ftHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, ftData);
        free(ftData);
    }

Texture to quad code:


    glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ZERO);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, ftTxt);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f);  
    glVertex2f(0.0, 500);
    glTexCoord2f(0.0f, 1.0f);; 
    glVertex2f(0.0, 0.0);
    glTexCoord2f(1.0f, 1.0f); 
    glVertex2f(800, 0.0);
    glTexCoord2f(1.0f, 0.0f);
    glVertex2f(800, 500);
    glEnd();
    glDisable(GL_TEXTURE_2D);
    glFlush();

By fallowing your link I’ll try to change my texture code to:


   ftImg = [NSImage imageNamed:@"grass.jpg"];
    CGImageSourceRef src;
    src = CGImageSourceCreateWithData((CFDataRef)[ftImg TIFFRepresentation], NULL);
    CGImageRef ft =  CGImageSourceCreateImageAtIndex(src, 0, NULL);
    
    ftWidth = CGImageGetWidth(ft);
    ftHeight = CGImageGetHeight(ft);
    
    if(ft) {
        ftData = (GLubyte *) calloc(ftWidth * ftHeight * 4, sizeof(GLubyte));
        ftContext = CGBitmapContextCreate(ftData, ftWidth, ftHeight, 8, ftWidth * 4, CGImageGetColorSpace(ft), kCGImageAlphaPremultipliedLast);
        CGContextDrawImage(ftContext, CGRectMake(0.0, 0.0, (CGFloat)ftWidth, (CGFloat)ftHeight), ft);
        CGContextRelease(ftContext);
        glGenTextures(1, &ftTxt);
        glBindTexture(GL_TEXTURE_2D, ftTxt);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ftWidth, ftHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, ftData);
        glGenerateMipmap(GL_TEXTURE_2D);
        free(ftData);
    }

And see if it works, when I go back home from work.

The GMA 950is capable of OpenGL 1.4, the GMA X3100 can do OpenGL 2.1. Both have a maximal texture size of 2048, so your textures are too big. You can query those limits at run time, https://developer.apple.com/graphicsimaging/opengl/capabilities/index.html gives you an overview of current Mac GPUs.

You should also learn about non power-of-two texture limitations.

Specifically, you are asking for an NPOT size and you are using REPEAT wrapping. That will work on every Mac in 10.6 and later, however if you care about supporting even older GPUs it will not work on many PPC Macs supported in 10.5 (look for the ARB_texture_non_power_of_two extension.)

Also, only on the Radeon X1#00 GPUs, that NPOT texture (with that wrap mode) will be emulated with software rasterization. You could avoid that by using CLAMP_TO_EDGE instead of REPEAT.

Or use RECTANGLE textures instead of 2D, which will work for all Macs in 10.5.
(You’ll still need to be aware of the maximum texture size, as menzel pointed out.)

I don’t need to support 10.5 macs. I only need to support macs that can run at least os x 10.6. And these MacBooks (2.1, and 3.1) are running 1.7 os x. Actually V-Man’s given link was very useful. I found info, and now my textures seems to be working. But I have now some issues with blending (glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO):wink: I guess. I’m using blending to initiate masking process. But that does’t seems to work. I am trying to solve that right now, and I will give a feedback. Thank you guys for helping me.