Quote:Original post by phantom
Quote:Original post by MARS_999
I went back to using glCopyTexImage2D and it works fine, but kicker is when I use glCopyTexSubImage2D instead of glCopyTexImage2D I see the same results as I do when I am using FBO's? What gives...
Without seeing how[/b[ you are doing it it is just impossible to tell whats wrong, you've given basically NO infomation...
reflection
void CTerrain::RenderReflection(float move_y){ const double plane[4] = {0.0f, 1.0f, 0.0f, 0.0f}; waterReflection.BindBuffer(); glViewport(0, 0, mapData.waterTextureSizeWidth, mapData.waterTextureSizeHeight); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glLoadIdentity(); g_Camera.LookAt(); glPushMatrix(); glTranslatef(0.0f, -move_y + mapData.waterHeight + .1f, 0.0f); glScalef(1.0, -1.0, 1.0); glEnable(GL_CLIP_PLANE0); glClipPlane(GL_CLIP_PLANE0, plane); DrawTerrainVBO(0.0f, true); glDisable(GL_CLIP_PLANE0); glPopMatrix(); waterReflection.unBindBuffer(); //glBindTexture(GL_TEXTURE_2D, textureObjectWater[WATER_REFLECTION]); //glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, mapData.waterTextureSizeWidth, mapData.waterTextureSizeHeight, 0);}
refraction
void CTerrain::RenderRefractionAndDepth(float move_y){ const double plane[4] = {0.0f, -1.0f, 0.0f, 0.0f}; waterRefraction.BindBuffer(); waterDepth.BindBuffer(); glViewport(0, 0, mapData.waterTextureSizeWidth, mapData.waterTextureSizeHeight); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glLoadIdentity(); g_Camera.LookAt(); glPushMatrix(); glTranslatef(0.0f, -move_y + mapData.waterHeight + .1f, 0.0f); glEnable(GL_CLIP_PLANE0); glClipPlane(GL_CLIP_PLANE0, plane); DrawTerrainVBO(0.0f, true); glDisable(GL_CLIP_PLANE0); glPopMatrix(); waterRefraction.unBindBuffer(); waterDepth.unBindBuffer(); //glBindTexture(GL_TEXTURE_2D, textureObjectWater[WATER_REFRACTION]); //glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, mapData.waterTextureSizeWidth, mapData.waterTextureSizeHeight, 0); //render depth to texture //glBindTexture(GL_TEXTURE_2D, textureObjectWater[WATER_DEPTHMAP]); //glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, 0, 0, mapData.waterTextureSizeWidth, mapData.waterTextureSizeHeight, 0); }
here is the texture binding function
void CTerrain::SetupTexturesWater(void){ glActiveTextureARB(GL_TEXTURE0_ARB); waterReflection.RenderTexture(); //glBindTexture(GL_TEXTURE_2D, textureObjectWater[WATER_REFLECTION]); glActiveTextureARB(GL_TEXTURE1_ARB); waterRefraction.RenderTexture(); //glBindTexture(GL_TEXTURE_2D, textureObjectWater[WATER_REFRACTION]); glActiveTextureARB(GL_TEXTURE2_ARB); glBindTexture(GL_TEXTURE_2D, textureObject[WATER_NORMALMAP]); glActiveTextureARB(GL_TEXTURE3_ARB); glBindTexture(GL_TEXTURE_2D, textureObject[WATER_DUDVMAP]); glActiveTextureARB(GL_TEXTURE4_ARB); waterDepth.RenderTexture(); //glBindTexture(GL_TEXTURE_2D, textureObjectWater[WATER_DEPTHMAP]);}
FBO class
#include "main.h"FBO::FBO(){ fb = 0; depth_rb = 0; texture = 0; texture_target = 0; texWidth = 0; texHeight = 0; filterMode = 0; texInternalFormat = 0; texFormat = 0; depthTexture = false;}FBO::~FBO(){ glDeleteRenderbuffersEXT(1, &depth_rb); glDeleteTextures(1, &texture); glDeleteFramebuffersEXT(1, &fb);}void FBO::SetupFBO(unsigned int textureTarget, unsigned int tex_Width, unsigned int tex_Height, unsigned int filter_Mode, unsigned int tex_InternalFormat, unsigned int tex_Format, bool depth_Texture){ texture_target = textureTarget; texWidth = tex_Width; texHeight = tex_Height; filterMode = filter_Mode; texInternalFormat = tex_InternalFormat; texFormat = tex_Format; depthTexture = depth_Texture;}void FBO::Init(void){ glGenFramebuffersEXT(1, &fb); glGenRenderbuffersEXT(1, &depth_rb); glGenTextures(1, &texture); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glBindTexture(texture_target, texture); // init texture glTexParameterf(texture_target, GL_TEXTURE_MIN_FILTER, filterMode); glTexParameterf(texture_target, GL_TEXTURE_MAG_FILTER, filterMode); glTexParameterf(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); if(texture_target == GL_TEXTURE_3D) glTexParameterf(texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexImage2D(texture_target, 0, texInternalFormat, texWidth, texHeight, 0, texFormat, GL_FLOAT, NULL); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, texture_target, texture, 0); // initialize depth renderbuffer glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, texWidth, texHeight); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);}void FBO::BindBuffer(void){ glBindTexture(texture_target, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); if(depthTexture) { glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); }}void FBO::unBindBuffer(void){ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);}void FBO::RenderTexture(void){ glBindTexture(texture_target, texture);}