相关疑难解决方法(0)

将GPU计算结果返回到OpenGL中的CPU程序

有没有办法将运行在GPU上的着色器的结果返回到CPU上运行的程序?

我想基于GPU上的计算成本高的算法从简单的体素数据生成多边形网格,但我需要在CPU上进行物理计算.

opengl cpu shader video-card

17
推荐指数
1
解决办法
8442
查看次数

使用像素缓冲对象(PBO)从帧缓冲对象(FBO)读取像素值

我可以使用像素缓冲区对象(PBO)直接从FBO读取像素值(即使用glReadPixels)(即FBO仍然连接时)?

如是,

  1. 使用PBO和FBO有什么优缺点?
  2. 以下代码有什么问题

{

//DATA_SIZE = WIDTH * HEIGHT * 3 (BECAUSE I AM USING 3 CHANNELS ONLY)
// FBO and PBO status is good
.
.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId);
//Draw the objects
Run Code Online (Sandbox Code Playgroud)

以下glReadPixels工作正常

glReadPixels(0, 0, screenWidth, screenHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE,  (uchar*)cvimg->imageData);
Run Code Online (Sandbox Code Playgroud)

以下glReadPixels不工作:(

glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboId);
//yes glWriteBuffer has also same target and I also checked with every possible values
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); 
glReadPixels(0, 0, screenWidth, screenHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, (uchar*)cvimg->imageData);
.
.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //back to window framebuffer
Run Code Online (Sandbox Code Playgroud)

opengl fbo framebuffer glreadpixels pbo

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

opengl ×2

cpu ×1

fbo ×1

framebuffer ×1

glreadpixels ×1

pbo ×1

shader ×1

video-card ×1