Results 1 to 4 of 4

Thread: Screen Corruption When Using OpenGL

  1. #1

    Screen Corruption When Using OpenGL

    Hi Everyone,

    Emphatic thanks for any help received regarding this plea.

    I have been using OpenGL to render some scenes using Visual C++ 6.0. I am developing on Windows 2000 using an 32Mb ATI Rage 128 Ultra graphics card.

    Recently, I have noticed that while I have my OpenGL application running, some screen corruption can be seen under certain conditions, specifically where I know the R2_NOT raster operation to be used. Closing my OpenGL application resolves this 'problem' instantly.

    I have only noticed this problem on my machine/setup. I have the latest drivers supplied by Dell for my graphics card and have also tried ATI's reference drivers, but the problem remains.

    However, I have also noticed that I can use other people's OpenGL applications free of this corruption. Hence, I wonder if I am doing something wrong.

    I have stripped out most of my code and have reproduced the problem with skeleton code, which I shall include here and would be appreciative if anybody can point out anything (evrything?) I am doing wrong.

    Originally, it seemed that the problem occurred once I had set up my OpenGL surface and subsequently called glFlush() (or any function that indirectly invoked glFlush()). But, because this code can call these before the dialog is displayed, I am less sure.

    OK, this code creates a small dialog box with two quits, one calls glFlush(), though the corruption tends to occur even before the button is clicked, but when the dialog is displayed.

    The dialog has three private members also:
    HDC m_DAHdc;
    HGLRC m_glRContext;

    COpenGLTestDlg::COpenGLTestDlg(CWnd* pParent /*=NULL*/)
    : CDialog(COpenGLTestDlg::IDD, pParent)
    // NOTE: the ClassWizard will add member initialization here
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

    m_DAHdc = NULL;
    m_glRContext = NULL;

    void COpenGLTestDlg::OnButton()

    int COpenGLTestDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
    if (CDialog::OnCreate(lpCreateStruct) == -1)
    return -1;

    CDC *dc = GetDC();
    m_DAHdc = dc->GetSafeHdc();

    int pfindex;
    BOOL result;

    memset(&m_pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));

    m_pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
    m_pfd.nVersion = 1;

    m_pfd.dwFlags = PFD_DOUBLEBUFFER |

    m_pfd.iPixelType = PFD_TYPE_RGBA;
    m_pfd.cColorBits = 24;

    m_pfd.cDepthBits = 16;
    m_pfd.cRedBits = 0;
    m_pfd.cRedShift = 0;
    m_pfd.cGreenBits = 0;
    m_pfd.cGreenShift = 0;
    m_pfd.cBlueBits = 0;
    m_pfd.cBlueShift = 0;
    m_pfd.cAlphaBits = 0;
    m_pfd.cAlphaShift = 0;

    m_pfd.iLayerType = PFD_MAIN_PLANE;

    pfindex = ChoosePixelFormat(m_DAHdc, &m_pfd);

    if(pfindex == 0)
    TRACE("ChoosePixelFormat Failed %d\r\n", GetLastError());

    result = SetPixelFormat(m_DAHdc, pfindex, &m_pfd);

    TRACE("SetPixelFormat Failed %d\r\n", GetLastError());

    m_glRContext = wglCreateContext(m_DAHdc);

    TRACE("wglCreateContext Failed %d\r\n", GetLastError());

    if(wglMakeCurrent(m_DAHdc, m_glRContext) == FALSE)
    TRACE("Chosen Pixel Format = %d\r\n", pfindex);
    return 0;

    void COpenGLTestDlg::OnDestroy()

    ::ReleaseDC((HWND)this, m_DAHdc);

    Many many thanks,

  2. #2

    Re: Screen Corruption When Using OpenGL

    When do you delete the opengl context? You may be lossing some video memory because of that and probably your drivers arent doing a good job in that case (typical)

    wglMakeCurrent(NULL, NULL);


  3. #3
    Member Contributor
    Join Date
    Nov 2001

    Re: Screen Corruption When Using OpenGL

    I have the same setup (W2K/ATI12 and I have found out that the ATI drivers are not truly W2K compatiable. I have some trouble with both directx and opengl on my computer, whereas it works perfectly on other computers with different graphics cards.

    Have you tried your code on another computer?

  4. #4

    Re: Screen Corruption When Using OpenGL


    Thanks for your help everyone.

    Sorry, I was a bit misleading by not deleting my rendering context in the example code...this is something I usually do, but overlooked in my 'stripped down' example. So, although a valid and acute suggestion, it mustn't be the problem.

    Regarding the drivers, I have now tried my code on 3 other computers. Two have different setups and one the same. Oddly enough, there is corruption on the one but none on the other two. So, although not conclusive, it may look like a driver issue.

    Thanks and Kind Regards,

Similar Threads

  1. FBO Corruption on ATi/Mac
    By OrangyTang in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 05-11-2009, 08:11 PM
  2. VBO corruption
    By zed in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 05-09-2008, 03:58 PM
  3. screen corruption
    By bumby in forum OpenGL: Basic Coding
    Replies: 13
    Last Post: 01-16-2004, 11:37 AM
  4. OpenGL Corruption?
    By LordKronos in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-10-2002, 12:44 PM
  5. NVIDIA GeForce 2 graphics corruption using OpenGL
    By DarthPaul in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 03-02-2001, 07:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean