capturing a partial screen.
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