• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
capturing a partial screen.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

capturing a partial screen.


  • Subject: capturing a partial screen.
  • From: Development <email@hidden>
  • Date: Fri, 4 Sep 2009 10:25:37 -0700

I am attempting to capture part of the user screen, for instance a window. I'm using the OpenGL screen capture example code to build on so the following is my capture code. When I attempt to capture I get a garbled screen so I know I'm not passing the right value somewhere but I don't know where. Forgive me I'm very new to opengl.

-(void)readScreenRect:(NSRect)rect
{
long w =rect.size.width;
long h =rect.size.height;

[self readPartialScreenToBuffer:w bufferHeight: h origin:NSMakePoint (0, 0) bufferBaseAddress: mData];
}
// Use this routine if you want to read only a portion of the screen pixels
- (void) readPartialScreenToBuffer: (size_t) width bufferHeight: (size_t) height origin:(NSPoint)origin bufferBaseAddress: (void *) baseAddress
{
// select front buffer as our source for pixel data
glReadBuffer(GL_FRONT);


    //Read OpenGL context pixels directly.

    // For extra safety, save & restore OpenGL states that are changed
    glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);

    glPixelStorei(GL_PACK_ALIGNMENT, 4); /* Force 4-byte alignment */
    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
    glPixelStorei(GL_PACK_SKIP_ROWS, 0);
    glPixelStorei(GL_PACK_SKIP_PIXELS, 0);

    //Read a block of pixels from the frame buffer
    glReadPixels(origin.x,
				 origin.y,
				 width,
				 height,
				 GL_BGRA,
				 GL_UNSIGNED_INT_8_8_8_8_REV,
				 baseAddress);

    glPopClientAttrib();

    //Check for OpenGL errors
    GLenum theError = GL_NO_ERROR;
    theError = glGetError();

}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: capturing a partial screen.
      • From: Steven Degutis <email@hidden>
  • Prev by Date: Re: Binding table columns that change at runtime
  • Next by Date: Re: Input Managers in Snow Leopard
  • Previous by thread: NSComboboxCell + setButtonBordered:
  • Next by thread: Re: capturing a partial screen.
  • Index(es):
    • Date
    • Thread