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 4 of 4

Thread: Bad redrawing on GeForce 7300

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

    Bad redrawing on GeForce 7300

    I have app, that opens image and redraws it with opengl as textured quad. This app works fine on iMac with AMD Radeon HD 6750M but when I launch this app on iMac with nVidia GeForce 7300 some images is not correctly redrawn. For example some images with 3200x2000 dimensions it redraws as a quad with identical edges (top and bottom is equal to right and left). Could it be problem with OpenGL code? Or my mistake should be in Objective-C code where image is being processed before sending it to OpenGL?


    P.S. I have no ability to test it on macs with other graphics card but as I see this problem is on almost all older macs.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,095
    I don't know anything about 7300 but what is the maximum texture size for the card?

  3. #3
    Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    302
    The maximum 2D texture size is 4096, according to Apple's chart: https://developer.apple.com/graphics...Info_1075.html . However, that doesn't mean you'll always be able to allocate a texture with dimensions smaller than that. Without code, it's difficult to diagnose the problem.

  4. #4
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41
    It works like that:

    • Read image (create NSImage from image url)
    • Create NSBitmapImageRep from NSImage
    • Copy NSBitmapImageRep, and create CIImage from that
    • Apply CIFilter on CIImage to get grayscale image version
    • Create NSBitmapImageRep from CIImage
    • Create 2 textures
    • Add texture's image (texture1 - normal image bitmap, texture2 - grayscale image bitmap)
    • Create 3 framebuffers (mainframebuffer, normalframebuffer, grayscaleframebuffer)
    • Draw normal image texture to normalframebuffer and gray scale image texture to grayscaleframebuffer
    • Draw both framebuffers to mainframebuffer (1st normalframebuffer and then grayscaleframebuffer on top of it)
    • Draw main framebuffer to screen

    Code :
        glPushMatrix();
        glLoadIdentity();
        glViewport(0, 0, _fullWidth, _fullHeight);
        glMatrixMode(GL_PROJECTION);
        glFrustum(0, _fullWidth, 0, _fullHeight, 0.1, 100);
        glTranslatef(0.0,0.0,-0.5);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, normalframebuffer);
        glClearColor(0.93, 0.93, 0.93, 1.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glViewport(0, 0, _fullWidth, _fullHeight);
        glDisable(GL_DEPTH_TEST);
        glDepthMask(GL_FALSE);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
     
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glBindTexture(GL_TEXTURE_2D, normalimagetextur);
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0, _fullHeight);
        glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0, 0.0);
        glTexCoord2f(1.0f, 0.0f); glVertex2f(_fullWidth, 0.0);
        glTexCoord2f(1.0f, 1.0f); glVertex2f(_fullWidth, _fullHeight);
        glEnd();
        glBindTexture(GL_TEXTURE_2D, 0);
     
        glDisable(GL_BLEND);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
        glPopMatrix();
     
        glPushMatrix();
        glLoadIdentity();
        glViewport(0, 0, _fullWidth, _fullHeight);
        glMatrixMode(GL_PROJECTION);
        glFrustum(0, _fullWidth, 0, _fullHeight, 0.1, 100);
        glTranslatef(0.0,0.0,-0.5);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frontframebuffer);
        glClearColor(0.93, 0.93, 0.93, 1.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glViewport(0, 0, _fullWidth, _fullHeight);
        glDisable(GL_DEPTH_TEST);
        glDepthMask(GL_FALSE);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
     
        glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
        glBindTexture(GL_TEXTURE_2D, grayscaleimagetexture);
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0, _fullHeight);
        glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0, 0.0);
        glTexCoord2f(1.0f, 1.0f); glVertex2f(_fullWidth, 0.0);
        glTexCoord2f(1.0f, 0.0f); glVertex2f(_fullWidth, _fullHeight);
        glEnd();
        glDisable(GL_BLEND);
        glBindTexture(GL_TEXTURE_2D, 0);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
        glPopMatrix();

    _fullWidth is 5*image width (everything is drawn 5 times bigger than it realy is, to achieve zoom-in effect with glTranslatef


    Everything is drawn to main framebuffer like that:

    Code :
     
        glPushMatrix();
        glLoadIdentity();
        glViewport(0, 0, _fullWidth, _fullHeight);
        glMatrixMode(GL_PROJECTION);
        glFrustum(0, _fullWidth, 0, _fullHeight, 0.1, 100);
        glTranslatef(0.0,0.0,-0.5);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mainframebuffer);
        glClearColor(0.93, 0.93, 0.93, 1.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glViewport(0, 0, _fullWidth, _fullHeight);
        glDisable(GL_DEPTH_TEST);
        glDepthMask(GL_FALSE);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
     
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glBindTexture(GL_TEXTURE_2D, normalframebuffertexture);
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0, _fullHeight);
        glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0, 0.0);
        glTexCoord2f(1.0f, 1.0f); glVertex2f(_fullWidth, 0.0);
        glTexCoord2f(1.0f, 0.0f); glVertex2f(_fullWidth, _fullHeight);
        glEnd();
        glBindTexture(GL_TEXTURE_2D, 0);
     
        glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
        glBindTexture(GL_TEXTURE_2D, grayscaleframebuffertexture);
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0, _fullHeight);
        glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0, 0.0);
        glTexCoord2f(1.0f, 1.0f); glVertex2f(_fullWidth, 0.0);
        glTexCoord2f(1.0f, 0.0f); glVertex2f(_fullWidth, _fullHeight);
        glEnd();
        glBindTexture(GL_TEXTURE_2D, 0);
        glDisable(GL_BLEND);
     
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
        glPopMatrix();


    And then drawn to screen like that:

    Code :
        float zoom = [zoomSlider floatValue];
        glLoadIdentity();
        visibleRect = [self visibleRect];
        glViewport(0, 0, NSWidth(visibleRect), NSHeight(visibleRect));
        glMatrixMode(GL_PROJECTION);
        glFrustum(NSMinX(visibleRect), NSMaxX(visibleRect), NSMinY(visibleRect), NSMaxY(visibleRect), 0.1, 100);
        glTranslatef(0,0,zoom);
        glClearColor(0.93, 0.93, 0.93, 1.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, texture);
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0, _fullHeight);
        glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0, 0.0);
        glTexCoord2f(1.0f, 1.0f); glVertex2f(_fullWidth, 0.0);
        glTexCoord2f(1.0f, 0.0f); glVertex2f(_fullWidth, _fullHeight);
        glEnd();
        glBindTexture(GL_TEXTURE_2D, 0);


    Texture's and framebuffers size is equal to original image size. So it doesn't exceeds size limits.

    Example:
    Images from OS->Library->Desktop Pictures:
    Floating Leaves.jpg -> redraws not correctly. Dimensions: 3200x2000.
    Forest in Mist.jpg -> redraws not correctly. Dimensions: 3200x2000.

    Other images from desktop pictures gets redrawed correctly but app gets bad image size (not 3200x2000)

    Other images:
    mirage-2000.jpg -> redraws not correctly. Dimensions 1024x768.

    So it looks like the problem is not only in image size.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Floating Leaves.jpg 
Views:	78 
Size:	87.1 KB 
ID:	886   Click image for larger version. 

Name:	Forest in Mist.jpg 
Views:	74 
Size:	90.7 KB 
ID:	887   Click image for larger version. 

Name:	mirage-2000-wallpaper_1024x768_19147.jpg 
Views:	80 
Size:	81.2 KB 
ID:	889  
    Last edited by hockeyman; 10-18-2012 at 07:02 AM.

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
  •