Sign in to follow this  
Dragon_Strike

rendering the clipmaps

Recommended Posts

im trying to make a function that will render the clipmaps (rings) described in geoemtry clipmaps... i want to create a function which renders these rings based on their level and a first level size... but for some reason i cant get it to fit togheter...
int blocksize = (255+1.0f)/4; // 255 = default clipmap size

void CTERRAIN::RenderLevel(float x, float z, int level)
{
        int scale = pow(2, level);
	
	RenderBlock((x+blocksize+2*scale)	, (z+blocksize+2*scale), scale);
	RenderBlock((x+blocksize+2*scale)	, (z+2*scale),			scale);
	RenderBlock((x+2*scale)				, (z+blocksize+2*scale), scale);

	RenderBlock(-(x+2*blocksize+scale)	, (z+blocksize+scale), scale);
	RenderBlock(-(x+2*blocksize+scale)	, (z+scale),			scale);
	RenderBlock(-(x+blocksize+scale)		, (z+blocksize+2*scale), scale);

	RenderBlock(-(x+2*blocksize+scale)	, -(z+2*blocksize+scale), scale);
	RenderBlock(-(x+2*blocksize+scale)	, -(z+blocksize+scale),			scale);
	RenderBlock(-(x+blocksize+scale)	, -(z+2*blocksize+scale), scale);	

	RenderBlock((x+blocksize+scale)		, -(z+2*blocksize+scale), scale);
	RenderBlock((x+blocksize+2*scale)	, -(z+blocksize+scale),			scale);
	RenderBlock((x+scale)				, -(z+2*blocksize+scale), scale);	
}

void CTERRAIN::RenderBlock(float x, float z, float scale)
{
		ShaderProgram->sendUniform("ScaleFactor", scale, scale, x, z);
		glDrawElements(GL_TRIANGLE_STRIP, NumberOfElements, GL_UNSIGNED_INT, 0);
}


the rednerblock function renders a block where the x,z coordinates is the lowerleft part of each block and scaled after the parameter scale... ive not included the fixup blocks because they are not important here... they are jsut empty space..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this