Rastar Posted February 13, 2016 Share Posted February 13, 2016 When I try to get the pixels of a Buffer's color texture, I get an exception. The texture is fine and can e.g. be set to a texture slot, so I guess the data isn't actually retrieved from the GPU? Is there a way to do this? Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 14, 2016 Share Posted February 14, 2016 Does the example for GetPixels() work for you? Perhaps showing example code of what you are trying will result in help. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rastar Posted February 14, 2016 Author Share Posted February 14, 2016 Yes, that works. But I am trying to get the content of a render buffer Texture* tex = Texture::Create(width, height); Buffer* buffer = Buffer::Create(width, height, 1, 0); buffer->SetColorTexture(tex); buffer->Enable(); buffer->Clear(); world->Render(); buffer->Disable(); Context::SetCurrent(context); tex = buffer->GetColorTexture(); const char* pixelBuf = new char[tex->GetMipmapSize(0)]; tex->GetPixels(pixelBuf); A call to mat->SetTexture(tex) works, probably because the texture handle is being passed, but the above call to GetPixels() doesn't. As I said, I assume the texture isn't actually retrieved from the GPU to the main memory. Quote Link to comment Share on other sites More sharing options...
NightQuest Posted February 14, 2016 Share Posted February 14, 2016 Forgive me if I'm wrong, but I think your problem may be the const const char* pixelBuf = new char[tex->GetMipmapSize(0)]; tex->GetPixels(pixelBuf); When I did this, I had to cast it GLubyte* tPixels = new GLubyte[tex->GetMipmapSize(0)]; tex->GetPixels(reinterpret_cast<const char*>(tPixels)); I have no idea why it's passed as a const char* since it's obviously modified; if anything, it should be passed as a char* const. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.