繁体   English   中英

OPENGL Texture2D直接/间接操纵

[英]OPENGL Texture2D manipulation directly/indirectly

遵循本教程之后 ,我将在3D场景上执行阴影映射。 现在,我想在使用ARB扩展名应用之前,先处理shadowMapTexture的原始纹理元素数据(请参见下面的摘录)。

//Textures
GLuint shadowMapTexture;  
...
...

**CopyTexSubImage2D** is used to copy the contents of the frame buffer into a 
texture. First we bind the shadow map texture, then copy the viewport into the 
texture. Since we have bound a **DEPTH_COMPONENT** texture, the data read will 
automatically come from the depth buffer.

//Read the depth buffer into the shadow map texture
glBindTexture(GL_TEXTURE_2D, shadowMapTexture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, shadowMapSize, shadowMapSize); 
  • 注意:我仅使用OpenGL 2.1。

涂可以通过两种方式做到这一点:

float* texels = ...;
glBindTexture(GL_TEXTURE_2D, shadowMapTexture);
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y,w,h, GL_DEPTH_COMPONENT, GL_FLOAT, texels);

要么

将您的shadowMapTexture附加到(写入)帧缓冲区并调用:

float* pixels = ...;
glRasterPos2i(x,y)
glDrawPixels(w,h, GL_DEPTH_COMPONENT, GL_FLOAT, pixels);

不要忘记在上述方法中先禁用depth_test。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM