Sign in to follow this  
mrrolf810p

pbuffer questions

Recommended Posts

I've been trying to get pbuffering working, but I'm running into many problems, and I have a few questions. I'm implementing a cg raytracer and I need 128-bit textures and pbuffer. I quickly realized that I had to call wglShareLists() to be able to use textures in the pbuffer and regular context. Then I read that if I share contexts, the pixelformat for each must be the same. That means I can't get 128-bit pbuffer, since it must be the same as the frame buffer. Therefore I must create all my 128-bit textures while the pbuffer is the current context, and not use wglShareLists() and I will be limited to only using those textures in the pbuffer. Am I understanding this correctly? After I render something to be pbuffer, I want to store the result in a texture. I know I can bind the pbuffer as a texture and draw with that, but does it actually copy the data from the pbuffer to the texture, or just use the pbuffer data as the texture data? I need to copy the data to a texture, I'm currently using glCopyTexImage2D(). Will this work correctly? My images are GL_TEXTURE_RECTANGLE_NV:GL_FLOAT_RGB(A)32_NV. I assume it does work, but I'm getting all black textures. I haven't found solid answers to these questions anywhere. If anyone could shed some light on these questions, I'd appreciate it.

Share this post


Link to post
Share on other sites
You can use these files taken straight from my own Scenegraph :)
http://www.realityflux.com/abba/C++/Sample/


pixelBuffer.initialize(TCMSize,TCMSize, 24, 0,
PBUFFER_RGBA |
PBUFFER_FORMAT_FLOAT |
PER_CHANNEL_COLOR_BITS_32 |
PBUFFER_RENDER_TO_TEXTURE);


PS: in my scenegraph, I have a class called GLTexture which can be associated with a PBuffer to avoid an expensive glCopy.


void GLTexture::bindAttributes(){

if(!TexturesManager::bindTexture(textureIndex))
{
if(textureID > 0)
{
glEnable(textureType);
glBindTexture(textureType, textureID);
}
else
{
return;
}
}

if(pBuffer)
{
wglBindTexImageARB(pBuffer->getPBufferHandle(), WGL_FRONT_LEFT_ARB);
}

doTransform();

snip...
}




void GLTexture::associateWithPBuffer(GLPBuffer *buffer)
{
pBuffer = buffer;
}

Share this post


Link to post
Share on other sites
Thanks for the link.
In your pbuffer code, you use wglShareLists(). Does that mean the pbuffer can only have the same pixelformat as the framebuffer? You couldn't get a full 128-bit pbuffer that way, can you?

Share this post


Link to post
Share on other sites
I guess not. That's one of that questions I asked above. I wasn't sure because I've read a couple of conflicting posts.

I've got a 128b pbuffer, and 128b texture. I draw to the pbuffer, then copy the data via glCopyTexImage2D() (yes I know it's slow, but I'm just trying to get things working before I speed it up). The resulting texture only has 32b presicion. This is where I'm stuck/confused. any ideas why it is doing this?



Share this post


Link to post
Share on other sites

pixelBuffer.initialize(texWidth, texHeight, 24, 0,
PBUFFER_RGBA |
PBUFFER_FORMAT_FLOAT |
PER_CHANNEL_COLOR_BITS_32 |
PBUFFER_TEXTURE_CUBE_MAP |
PBUFFER_RENDER_TO_TEXTURE);

texture128B.setID(TextureLoader::loadEmptyTexture2D(texWidth, texHeight, GL_FLOAT, GL_RGBA_FLOAT32_ATI));





static int loadEmptyTexture2D(GLint width = 128,
GLint height = 128,
GLint type = GL_UNSIGNED_BYTE,
GLint inFormat = GL_RGBA8,
GLint format = GL_RGBA,
GLint clampS = GL_REPEAT,
GLint clampT = GL_REPEAT,
GLint magFilter = GL_LINEAR,
GLint minFilter = GL_LINEAR){
Logger::writeLogDataList("<+>Loading Empty Texture2D: Width %d, Height %d.\n",
width, height);

GLuint textureId;
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clampS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clampT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
glTexImage2D(GL_TEXTURE_2D,
0,
inFormat,
width,
height,
0,
format,
type,
NULL);
return textureId;
}


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this