Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CreateTextureFromView probs



Hi guys...

I'm trying to hack render2texture into GooBall, using the NSView createTexture:FromView:InternalFormat function, but I keep getting an Invalid enum. I tried hacking around with pixel formats, etc.. to no avail, and would really appreciate it if someone who got it to work has some input. Here is the info:

I'm using a share context, set up like this:
(NSOpenGLPixelFormatAttribute sharedAttributes[] = {
NSOpenGLPFAAccelerated, 0
};
NSOpenGLPixelFormat *pixelFormat;
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes: sharedAttributes];
s_SharedContext = [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];
[pixelFormat release];
NSWindow *shareWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,64,64) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
[s_SharedContext setView: [shareWindow contentView]];
[[shareWindow contentView] display];
[s_SharedContext makeCurrentContext];




I have several visible windows (game view, scene editing views, etc), all set up like this:
NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAStencilSize, 8,
0
};
NSOpenGLPixelFormat *pixelFormat;
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes];
m_Context = [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: MasterOpenGLContext() ];
[pixelFormat release];
id primaryWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect (0,0,256,256) styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO];
[primaryWindow makeKeyAndOrderFront:self];
[[primaryWindow contentView] display];
[m_Context setView: [primaryWindow contentView]];
[m_Context makeCurrentContext];



The surface contexts are set up like this:
SInt32 attributes[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFAColorSize, 24,
0
};
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*)attributes];
NSOpenGLContext* context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: MasterOpenGLContext()];
[pixelFormat release];

id surfaceWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect (0,0,width,height) styleMask:NSBorderlessWindowMask backing:NSBackingStoreNonretained defer:NO];
[surfaceWindow makeKeyAndOrderFront:nil];
[context setView: [surfaceWindow contentView]];
[context makeCurrentContext];
[context update];


	GLAssert ();

// Set up the texture
unsigned long tid;
[MasterOpenGLContext() makeCurrentContext]; // This gets the shared context
glGenTextures(1, &tid);
glBindTexture(kRenderTexTarget, tid);
switch (gR2TMode) {
case kWGLPBuffer:
case kCopyTex:
....
case kNSView:
[MasterOpenGLContext() update];
[MasterOpenGLContext() createTexture: tid fromView: [surfaceWindow contentView] internalFormat: GL_RGBA];
GLAssert ();
break;
}


TIA,


Nicholas Francis www.otee.dk

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.