簡體   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