Printing OpenGL View in Window
So I have a window with many icons, and within this window I have an openGL view. Like so:
![[Image: Picture10.png]](http://i24.photobucket.com/albums/c11/skeldi/Picture10.png)
however, when I print it out, I get this:
![[Image: pics10-2.png]](http://i24.photobucket.com/albums/c11/skeldi/pics10-2.png)
My print function is rather simple:
Any help as to get my OpenGL view to print without biting my upper lip off?
![[Image: Picture10.png]](http://i24.photobucket.com/albums/c11/skeldi/Picture10.png)
however, when I print it out, I get this:
![[Image: pics10-2.png]](http://i24.photobucket.com/albums/c11/skeldi/pics10-2.png)
My print function is rather simple:
Code:
-(IBAction)printMyWindow:(id)sender;
{
[[NSApp mainWindow] print:NULL];
}Any help as to get my OpenGL view to print without biting my upper lip off?
Maybe if you do something like this in the OpenGLView before printing?
Code:
- (void) copyGLToBackingStore {
NSSize size;
void * buffer;
[[self openGLContext] makeCurrentContext];
size = [self bounds].size;
buffer = malloc(size.width * size.height * 4);
glReadPixels(0, 0, size.width, size.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
[self lockFocus];
NSDrawBitmap([self bounds], size.width, size.height, 8, 4, 32, (size.width * 4), NO, NO, NSDeviceRGBColorSpace, (const unsigned char **) &buffer);
[self unlockFocus];
free(buffer);
[[self window] flushWindow];
}
I actually tried that, but it didn't change anything sadly.
Code:
- (void)print:(id)sender
{
NSImage * im = [[NSImage alloc] initWithSize:[self bounds].size];
// copy the gl contents to the image via what alex said or other method
NSImageView * imView = [[NSImageView alloc] initWithFrame:[self bounds]];
[imView setImage: im];
[imView print:nil];
}Sir, e^iπ + 1 = 0, hence God exists; reply!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| OpenGL view first frame flickers garbage | mk12 | 8 | 5,519 |
Sep 4, 2010 06:06 PM Last Post: mk12 |
|
| When to create custom OpenGL view instead of subclass NSOpenGL view | Coyote | 37 | 16,869 |
Oct 20, 2009 08:16 PM Last Post: Coyote |
|
| How do I place all of my UI elements to be subviews of another view/window? | xenocide | 2 | 2,384 |
Feb 1, 2009 08:32 PM Last Post: xenocide |
|
| opengl view question | Leroy | 3 | 2,828 |
Jul 23, 2007 11:08 PM Last Post: AnotherJake |
|
| Porting SDL to Cocoa OpenGL view--texture problem | smittyz | 7 | 4,327 |
Jul 21, 2007 07:53 PM Last Post: smittyz |
|

