Jump to content
  • Advertisement
Sign in to follow this  
subi

small texture matrix prob

This topic is 4800 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I am having a few problems getting reflections to work, i am pretty close and just need a little hand
void UpdateTextReflection()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, M_SIZE, M_SIZE);

glMatrixMode(GL_TEXTURE);
  glLoadIdentity();
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glGetFloatv(GL_MODELVIEW_MATRIX, View);
  glGetFloatv(GL_PROJECTION_MATRIX, Proj);
  glLoadMatrixf(Proj);
  glMultMatrixf(View);  
  glScalef(1, -1, 1);
  glPopMatrix();
 
  glEnable(GL_CLIP_PLANE0);
  glClipPlane(GL_CLIP_PLANE0, CP);
  RenderWall();
  glDisable(GL_CLIP_PLANE0);

  glBindTexture(GL_TEXTURE_2D, mirror);
  glCopyTexSubImage2D(GL_TEXTURE_2D, 0,0,0,0,0,M_SIZE, M_SIZE);

  glViewport(0, 0, Width, Height);

   glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glTranslatef(0.5, 0.5, 0.0); //centre the texture
    glScalef(0.5, 0.5, 0);
    gluPerspective(video.GetFOV(),(GLfloat)Width/(GLfloat)Height, video.GetZNear(),video.GetZFar());
	  glLoadMatrixf(View);
	
  glMatrixMode(GL_MODELVIEW);
}

void RenderScene()
{
	UpdateTextReflection();
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(0.2f, 0.5f, 1.0f, 1.0f);
	glLoadIdentity();
	camera.Look();
	
	glMatrixMode(GL_TEXTURE);
  glPushMatrix();
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
 	RenderWall(); //render brick wall
	glMatrixMode(GL_TEXTURE);
  glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	

	glDisable(GL_LIGHTING);
	glColor4fv(WATERCOLOR);

	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,water.TextureID);
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);

	glActiveTextureARB(GL_TEXTURE0_ARB);
	glBindTexture(GL_TEXTURE_2D,mirror);

	RenderWater(); //render water plane

	glColor4f(1, 1, 1, 1);
    glEnable(GL_LIGHTING);
  glActiveTextureARB(GL_TEXTURE1_ARB);
    glDisable(GL_TEXTURE_2D);
  glActiveTextureARB(GL_TEXTURE0_ARB);

	SwapBuffers();
}

as u can see i am rendering my brick wall to a texture in order to reflect it onto the water. The water and the brick wall render just perfect, the reflection shows up but moves around with the mouse and looks really wrong, so i know i am stuffing something up around the texture matrix. Thanks for any help

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!