I'm new here. I have written a screensaver using OpenGL and was hoping you guys could help figure out how to make it display a preview in the preview window when the user selects my screensaver. The screensaver is a simple lens effect that applies itself to the entire desktop. Its a fisheye lens effect. You've probably seen other screensavers that do the exact same thing. The problem I'm having is when my screensaver is selected the preview window remains black. I know that the command line argument /p is passed to my program when in preview mode and I'm detecting that just fine. I just don't understand why I can't grab the entire desktop and apply the effect inside the preview window. Here's some code showing how I'm going about grabbing the the desktop:
Code :if(previewMode) hDC = GetDC(GetDesktopWindow()); else hDC = GetDC( hWnd ); int pf = ChoosePixelFormat( hDC, &pfd ); SetPixelFormat( hDC, pf, &pfd ); hRC = wglCreateContext( hDC ); wglMakeCurrent( hDC, hRC ); pixelBuffer = new GLubyte[sizeof(GLubyte) * Width * Height * 4]; glReadBuffer(GL_FRONT); GLint ReadBuffer; glGetIntegerv(GL_READ_BUFFER, &ReadBuffer); glPixelStorei(GL_READ_BUFFER, GL_RGBA); GLint PackAlignment; glGetIntegerv(GL_PACK_ALIGNMENT, &PackAlignment); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, pixelBuffer);
Now, pixelBuffer should have the image data for the desktop, but in preview mode it doesn't work. Have any idea as to where I'm going wrong? If you need to see all my code I'll post it but its kinda long. Thanks in advance.