Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: OpenGL not working on older mac?

  1. #1
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41

    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:
    Click image for larger version. 

Name:	Screen Shot 2012-07-11 at 8.48.42 AM.jpg 
Views:	146 
Size:	15.0 KB 
ID:	804

    And on older macs it looks like this:
    Click image for larger version. 

Name:	Screen Shot 2012-07-11 at 8.52.06 AM.jpg 
Views:	124 
Size:	7.7 KB 
ID:	805

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    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_Mi...ting_a_Texture
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41
    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:

    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:

    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:

    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_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.
    Last edited by hockeyman; 07-12-2012 at 06:51 AM.

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    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/graphics...ies/index.html gives you an overview of current Mac GPUs.

  5. #5
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    782
    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.)
    Last edited by arekkusu; 07-12-2012 at 12:12 PM.

  6. #6
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41
    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);) 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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •