Create texture from NSOpenGLContext image

Wong4
Unregistered
 
Post: #1
Hello!

This drives me nuts:

I have an image in a pixelbuffer with an NSOpenGLContext and I "simply" want to use that image as a texture. I cannote use "[_someContext setTextureImageToPixelBuffer:_myPixelBuffer colorBuffer:GL_FRONT];", because I don't have a seocond NSOpenGLContext to hook it up to. Instead I have a OpenGL image with an CGLContextObj where I finally want to draw the texture from the NSOpenGLContext to.

How can I draw the image from a NSOpenGLContext to a CGLContextObj ?

--
Wong
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
I'm not quite clear on what you're asking. If I understand you right, you have two contexts, but one is an NSOpenGLContext with an NSOpenGLPixelBuffer, and the other is a CGLContext. If that's the case, if you get the CGLPixelBuffer from the NSOpenGLPixelBuffer, then you can use the CGL routines to make a texture from it in your CGLContext.
Quote this message in a reply
Wong4
Unregistered
 
Post: #3
> If I understand you right, you have two contexts, but one is an
> NSOpenGLContext with an NSOpenGLPixelBuffer, and the other is a CGLContext.

Exactly!

> If that's the case, if you get the CGLPixelBuffer from the NSOpenGLPixelBuffer...

Well. That's exactly the problem. The program I am working on is a plugin. The in- and out-imagebuffer has a CGLContextObj and these two already exist from the beginning. So I can't create the CGLContextObj from the NSOpenGLContext.

The NSOpenGLContext comes from QCRenderer. I only want to draw the result from the renderer to my CGLPixelBuffer.

So, what do I do now ? Any thoughts ?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Every NSOpenGLContext has a CGLContext you can get with -CGLContextObj; every NSOpenGLPixelFormat has a CGLPixelFormat you can get with -CGLPixelFormatObj, and every NSOpenGLPixelBuffer has a CGLPixelBuffer you can get with -CGLPixelBufferObj. Just drop down to CGL to do what you need.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Pasting an image with alpha mask on a texture Najdorf 10 5,835 Jun 24, 2008 03:23 PM
Last Post: Najdorf
  NSOpenGLContext sharing question TomorrowPlusX 4 4,446 Oct 19, 2006 09:33 AM
Last Post: akb825