Archived

This topic is now archived and is closed to further replies.

duhroach

Dynamic Cube Maps

Recommended Posts

I''m trying to pull off dynamic cube mapping, however using the function below, i''m getting horrible results, infact, nothing is textured correctly. can anyone see what''s the matter?
  

bool RenderCubeMap(int texID, float x, float y, float z)
{

	int size=128;
	glViewport(0,0,size,size);
	


	for(int i=0; i < 6;i++)
	{
		glClear( GL_DEPTH_BUFFER_BIT);
		glLoadIdentity();

		glRotatef(dirs[i].x, 1.0, 0.0, 0.0);
		glRotatef(dirs[i].y, 0.0, 1.0, 0.0);
		gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,-1.0, 0.0);
                           
		RenderWorld();


		glEnable(GL_TEXTURE_CUBE_MAP_ARB);
		glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, texID);

		glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
		glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

		glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT + i, 0, GL_RGB, 0, 0, size,size, 0);
	}

	glDisable(GL_TEXTURE_CUBE_MAP_ARB);

	ReSizeGLScene(800,600);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();


	return true;
}
  
~Main == Colt "MainRoach" McAnlis Programmer www.badheat.com/sinewave

Share this post


Link to post
Share on other sites
Nutty has a (working)dynamic cube map demo on his site so you could compare this code with his to se what''s wrong.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
I've implimented his method, although he uses his HELIOS lib so it's hard to figure out the inner workings of things.

Anyone else have an idea? i'm still getting horribly wrong results


~Main

==
Colt "MainRoach" McAnlis
Programmer
www.badheat.com/sinewave

[edited by - duhroach on May 4, 2003 3:50:57 PM]

Share this post


Link to post
Share on other sites
From the second iteration of the loop onwards, you are rendering your world with cubemapping enabled, which will override any 2D texture target. Call glDisable(GL_TEXTURE_CUBE_MAP_ARB) after glCopyTexImage2D() inside of the loop.

Share this post


Link to post
Share on other sites