Pixel Buffers, Cocoa, and Mipmaps

bensta00
Unregistered
 
Post: #1
I am working with PBuffers for the first time, and I have set one up in Cocoa and it seems to be working OK. Anyway, I was just wondering if it were possible to automatically generate mipmaps of the pbuffer?

I MUST have an automatically gen'd mipmap set for the texture, but I really don't know how to go about it.

I do...

pBuffer = [[NSOpenGLPixelBuffer alloc]
initWithTextureTarget:GL_TEXTURE_2D
textureInternalFormat:GL_RGBA
textureMaxMipMapLevel:4
pixelsWide:512
pixelsHigh:512];

so setting max mipmap levels to 4, but this doesn't seem to generate the mipmaps.

Cheers, Ben.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #2
this may have nothing to do with it, because of mipmaps, but shouldn't it be 256x256?

It's not magic, it's Ruby.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
I am not sure how well it works with pbuffers, but look at the SGIS_generate_mipmap extension. It will generate all the mip levels above the level you update.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
SGIS_generate_mipmap doesn't seem to work with CGLTexImagePBuffer and friends, but there is a hack to make it work -- if you share texture objects between the PBuffer context and the normal rendering context, you can use CopyTex(Sub)Image2D in the PBuffer context to write into a SGIS_generate_mipmap-enabled texture accessible from the main.
Quote this message in a reply
bensta00
Unregistered
 
Post: #5
OK thanks, I'll do that. The problem is that I need to do this about 50 times per frame. So it's gonna be sloooow. So if anyone has any other ideas that doesn't involve moving the color buffer, then please say!

Thanks for the responses, I'll get to it!

Ben
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #6
What on earth are you doing that you need to create 50 pbuffers every frame!?

If you need this to run at real-time speeds, you may need to rethink your design...

- Alex Diener
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
That's not excessive at all. 50 pbuffers = 50 dynamic textures. Lots of games use more than 50 textures in a scene. Just animate them all (you could easily use 50 cloud types in just the sky part of the scene. Now add animated foliage... 100's of textures...)

bensta00, if you find that SGIS_generate_mipmap doesn't work automatically with pbuffers, please file a feature request so Apple knows it is important to you. It should work.
Quote this message in a reply
bensta00
Unregistered
 
Post: #8
ThemsAllTook, I am implementing a stereo vision algorithm.

Arekkusu, OK, I will do that right now. I can't get it working, and it's annoying! :-) I'm just about to use the pixel copying technique described earlier. Basically I wanted to eliminate buffer reads totally, as they slowed this algorithm down last time I implemented it, and I redesigned it a little not to use them atall. Ah well...

Thanks,

Ben
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #9
I haven't experimented with this, but if it works the way I think OSC means, you can force the mipmaps to be generated by touching any one texel of the base mip level. You don't have to actually copy the entire content-- try just updating one pixel from a const int.

Of course, that might fail if the drivers are smart enough to regenerate mip levels based on the subportion of the texture that changed...
Quote this message in a reply
bensta00
Unregistered
 
Post: #10
Hello again everyone, could someone please post a request for this feature to Apple for me? The website says I need a developer's username & password, and I ain't got one of those!

Supposedly this feature is available under the evil Windows, so it should be featured on OS X too!

Let me know if you can,

Thanks!
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #11
An ADC Online membership is free. You just have to agree to the NDA.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  MipMaps OptimisticMonkey 4 5,579 Feb 17, 2011 07:17 PM
Last Post: Holmes
  [CoreGraphics] Image manipulation - pixel by pixel g00se 5 9,950 Jul 28, 2010 08:27 AM
Last Post: ThemsAllTook
  Frame buffers, vertex programs and more. 8600m GT m3the01 18 7,886 Nov 18, 2007 07:34 PM
Last Post: m3the01
  Stencil buffers in an FBO... trouble TomorrowPlusX 17 7,594 Mar 23, 2006 08:19 PM
Last Post: kberg
  mipmaps LOD bias bensta00 2 4,012 Feb 2, 2005 10:04 AM
Last Post: bensta00