Jump to content
  • Advertisement
Sign in to follow this  
vindy

OpenGL C++, win32, OpenGL screensaver preview mode

This topic is 2180 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:

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.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!