Beispiel #1
0
//Perform per frame updates
void UpdateFrame()
{
	window.Update();
	camera.Update();

	//Change object type
	if(window.isKeyPressed(' '))
	{
		++objectType;
		if(objectType==3)
			objectType=0;

		window.SetKeyReleased(' ');
	}

	//Change render path
	if(window.isKeyPressed('1') && renderPath!=CHROMATIC_SINGLE && pathOneSupported)
	{
		renderPath=CHROMATIC_SINGLE;
		InitChromaticSingleStates();
	}
	
	if(window.isKeyPressed('2') && renderPath!=SIMPLE_SINGLE)
	{
		renderPath=SIMPLE_SINGLE;
		InitSimpleSingleStates();
	}

	if(window.isKeyPressed('3') && renderPath!=CHROMATIC_TWIN)
	{
		renderPath=CHROMATIC_TWIN;
		//Set States every pass, as it is a 2 pass algorithm
	}
}
Beispiel #2
0
//Set up variables
bool DemoInit()
{
    if(!window.Init("Project Template", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
        return 0;											//quit if not created

    SetUpARB_multitexture();
    SetUpEXT_texture3D();
    SetUpEXT_texture_edge_clamp();
    SetUpNV_register_combiners();
    SetUpNV_texture_shader();
    SetUpNV_vertex_program();

    if(	!EXT_texture_edge_clamp_supported || !ARB_multitexture_supported ||
            !NV_vertex_program_supported || !NV_register_combiners_supported)
        return false;

    //Check we have at least 3 texture units
    GLint maxTextureUnitsARB;
    glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnitsARB);

    if(maxTextureUnitsARB<3)
    {
        errorLog.OutputError("I require at least 3 texture units");
        return false;
    }

    //Set light colors
    lightColors[0].Set(1.0f, 1.0f, 1.0f, 1.0f);
    lightColors[1].Set((float)47/255, (float)206/255, (float)240/255, 1.0f);
    lightColors[2].Set((float)254/255, (float)48/255, (float)18/255, 1.0f);
    lightColors[3].Set((float)83/255, (float)243/255, (float)29/255, 1.0f);



    //Load textures
    //Decal image
    decalImage.Load("decal.tga");
    glGenTextures(1, &decalTexture);
    glBindTexture(GL_TEXTURE_2D, decalTexture);
    glTexImage2D(	GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height,
                    0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


    //Create light textures
    if(!InitLightTextures(	atten1DTexture, atten2DTexture, atten3DTexture,
                            gaussian1DTexture, gaussian2DTexture))
        return false;


    camera.Init(VECTOR3D(0.0f, 0.0f, 3.5f));

    //reset timer for start
    timer.Reset();

    return true;
}
Beispiel #3
0
//Perform per frame updates
void UpdateFrame()
{
    window.Update();
    camera.Update();

    //Update the light's position
    lightPosition+=lightMovement;

    //reflect the velocity if necessary
    if(lightPosition.x>0.9f || lightPosition.x<-0.9f)
        lightMovement.x=-lightMovement.x;

    if(lightPosition.y>0.9f || lightPosition.y<-0.9f)
        lightMovement.y=-lightMovement.y;

    if(lightPosition.z>0.9f || lightPosition.z<-0.9f)
        lightMovement.z=-lightMovement.z;

    if(window.isKeyPressed('1') && codePath!=TEXTURE_ATTEN)
    {
        codePath=TEXTURE_ATTEN;
        SetTextureAttenStates();
    }

    if(	window.isKeyPressed('2') && codePath!=PASS_THROUGH_ATTEN &&
            NV_texture_shader_supported)
    {
        codePath=PASS_THROUGH_ATTEN;
        SetPassThroughAttenStates();
    }

    if(	window.isKeyPressed('3') && codePath!=TEXTURE_3D_ATTEN &&
            EXT_texture3D_supported)
    {
        codePath=TEXTURE_3D_ATTEN;
        SetTexture3DAttenStates();
    }

    if( window.isKeyPressed('4') && codePath!=GAUSSIAN_ATTEN)
    {
        codePath=GAUSSIAN_ATTEN;
        SetGaussianAttenStates();
    }

    if(	window.isKeyPressed(' '))
    {
        currentLightColor++;
        if(currentLightColor==4)
            currentLightColor=0;

        window.SetKeyReleased(' ');
    }
}
Beispiel #4
0
//Set up variables
bool DemoInit()
{
	if(!window.Init("Render To Texture", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
		return 0;											//quit if not created

	camera.Init(VECTOR3D(0.0f, 0.0f, -2.5f), 2.0f, 100.0f);

	//Set up extensions
	if(	!SetUpWGL_ARB_extensions_string())
		return false;

	SetUpEXT_texture_filter_anisotropic();
	SetUpSGIS_generate_mipmap();
		
	//Get the WGL extensions string
	const char * wglExtensions;
	wglExtensions=wglGetExtensionsStringARB(window.hDC);

	//Set up wgl extensions
	if(	!SetUpWGL_ARB_pbuffer(wglExtensions) || !SetUpWGL_ARB_pixel_format(wglExtensions) ||
		!SetUpWGL_ARB_render_texture(wglExtensions))
		return false;


	//Init the pbuffer
	int pbufferExtraIAttribs[]={WGL_BIND_TO_TEXTURE_RGBA_ARB, true,
								0};

	int pbufferFlags[]={WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
						WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,
						
						//request mipmap space if mipmaps are to be used
						SGIS_generate_mipmap_supported ? WGL_MIPMAP_TEXTURE_ARB : 0,
						SGIS_generate_mipmap_supported ? true : 0,

						0};

	if(!pbuffer.Init(pbufferSize, pbufferSize, 32, 24, 8, 1, pbufferExtraIAttribs, pbufferFlags))
		return false;
	

	//Create the texture object to relate to the pbuffer
	glGenTextures(1, &pbufferTexture);
	glBindTexture(GL_TEXTURE_2D, pbufferTexture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	//Use generated mipmaps if supported
	if(SGIS_generate_mipmap_supported)
	{
		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
		useMipmapFilter=true;
	}

	//Use maximum anisotropy if supported
	if(EXT_texture_filter_anisotropic_supported)
	{
		glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
		currentAnisotropy=maxAnisotropy;
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
	}



	//Load the decal texture
	//Note: This MUST be done when the pbuffer is the current context
	pbuffer.MakeCurrent();
	
	IMAGE decalImage;
	decalImage.Load("decal.bmp");

	glGenTextures(1, &decalTexture);
	glBindTexture(GL_TEXTURE_2D, decalTexture);
	glTexImage2D(	GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height,
					0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


	
	//reset timer for start
	timer.Reset();
	
	return true;
}
Beispiel #5
0
//draw a frame
void RenderFrame()
{
	//Draw to pbuffer
	pbuffer.MakeCurrent();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();										//reset modelview matrix

	gluLookAt(	0.0f, 0.0f, 4.0f,
				0.0f, 0.0f, 0.0f,
				0.0f, 1.0f, 0.0f);

	//Draw scene
	if(drawTextured)
	{
		glBindTexture(GL_TEXTURE_2D, decalTexture);
		glEnable(GL_TEXTURE_2D);
		
		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);

		glutSolidTeapot(0.8f);
		
		glPopMatrix();

		glDisable(GL_TEXTURE_2D);
	}
	else
	{
		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
		glRotatef(55.0f, 1.0f, 0.0f, 0.0f);
		glutWireTorus(0.3f, 1.0f, 12, 24);
		glPopMatrix();

		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
		glRotatef(-55.0f, 1.0f, 0.0f, 0.0f);
		glutWireTorus(0.3f, 1.0f, 12, 24);
		glPopMatrix();
	}


	
	//Draw to window
	window.MakeCurrent();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	camera.SetupViewMatrix();
	glLoadMatrixf(camera.viewMatrix);


	glBindTexture(GL_TEXTURE_2D, pbufferTexture);
	//use the pbuffer as the texture
	wglBindTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);


	//Draw simple rectangle
	glBegin(GL_TRIANGLE_STRIP);
	{
		glTexCoord2f(0.0f, 0.0f);
		glVertex3f(-1.0f, -1.0f, 0.0f);
		glTexCoord2f(0.0f, 1.0f);
		glVertex3f(-1.0f,  1.0f, 0.0f);
		glTexCoord2f(1.0f, 0.0f);
		glVertex3f( 1.0f, -1.0f, 0.0f);
		glTexCoord2f(1.0f, 1.0f);
		glVertex3f( 1.0f,  1.0f, 0.0f);
	}
	glEnd();

	//release the pbuffer for further rendering
	wglReleaseTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);



	fpsCounter.Update();											//update frames per second counter
	glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
	window.StartTextMode();
	window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
	glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
	window.Print(0, 48, "%dx Anisotropy", currentAnisotropy);
	glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
	window.Print(0, 68, "%s", useMipmapFilter ?	"LINEAR_MIPMAP_LINEAR filtering" :
												"LINEAR filtering");
	window.EndTextMode();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	if(window.isKeyPressed(VK_F1))
	{
		window.SaveScreenshot();
		window.SetKeyReleased(VK_F1);
	}

	window.SwapBuffers();									//swap buffers

	//check for any opengl errors
	window.CheckGLError();

	//quit if necessary
	if(window.isKeyPressed(VK_ESCAPE))
		PostQuitMessage(0);
}
Beispiel #6
0
//Perform per frame updates
void UpdateFrame()
{
	window.Update();
	camera.Update();

	//Change anisotropy level
	if(	window.isKeyPressed(VK_UP) && EXT_texture_filter_anisotropic_supported &&
		currentAnisotropy<maxAnisotropy)
	{
		window.MakeCurrent();
		currentAnisotropy*=2;
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
		window.SetKeyReleased(VK_UP);
	}
	
	if(	window.isKeyPressed(VK_DOWN) && EXT_texture_filter_anisotropic_supported &&
		currentAnisotropy>1)
	{
		window.MakeCurrent();
		currentAnisotropy/=2;
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
		window.SetKeyReleased(VK_DOWN);
	}

	//toggle mipmaps
	if( window.isKeyPressed('M') && useMipmapFilter==false && SGIS_generate_mipmap_supported)
	{
		window.MakeCurrent();
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
		useMipmapFilter=true;
	}

	if( window.isKeyPressed('L') && useMipmapFilter==true && SGIS_generate_mipmap_supported)
	{
		window.MakeCurrent();
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, false);
		useMipmapFilter=false;
	}

	//Pause/unpause
	if(window.isKeyPressed('P'))
		timer.Pause();

	if(window.isKeyPressed('U'))
		timer.Unpause();

	//Swap between scenes in the pbuffer
	if(window.isKeyPressed('1') && drawTextured)
	{
		//Draw wire tori
		drawTextured=false;
	}

	if(window.isKeyPressed('2') && !drawTextured)
	{
		//draw textured sphere
		drawTextured=true;
	}
}
Beispiel #7
0
//Set up variables
bool DemoInit()
{
	if(!window.Init("Project Template", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
		return 0;											//quit if not created

	SetUpARB_multitexture();
	SetUpARB_texture_cube_map();
	SetUpEXT_texture_edge_clamp();
	SetUpNV_register_combiners();
	SetUpNV_register_combiners2();
	SetUpNV_vertex_program();

	//Check for necessary extensions
	if(	!ARB_multitexture_supported || !ARB_texture_cube_map_supported ||
		!EXT_texture_edge_clamp_supported || !NV_register_combiners_supported ||
		!NV_vertex_program_supported)
		return false;

	//Check for single-pass chromatic aberration states
	GLint maxTextureUnits;
	glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnits);
	if( NV_register_combiners2_supported && maxTextureUnits>=4)
	{
		errorLog.OutputSuccess("Single Pass Chromatic Aberration Supported!");
		pathOneSupported=true;
		renderPath=CHROMATIC_SINGLE;
	}

	camera.Init(VECTOR3D(0.0f, 0.0f, 4.0f), 2.5f, 10.0f);

	if(	!cubeMapPosX.Load("cube_face_posx.tga") ||
		!cubeMapNegX.Load("cube_face_negx.tga") ||
		!cubeMapPosY.Load("cube_face_posy.tga") ||
		!cubeMapNegY.Load("cube_face_negy.tga") ||
		!cubeMapPosZ.Load("cube_face_posz.tga") ||
		!cubeMapNegZ.Load("cube_face_negz.tga"))
		return false;

	//Build a texture from the data
	glGenTextures(1, &cubeMapTexture);								//Generate Texture ID
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);					//Bind texture
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
					0, GL_RGBA8, cubeMapPosX.width, cubeMapPosX.height, 0,
					cubeMapPosX.format, GL_UNSIGNED_BYTE, cubeMapPosX.data);
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
					0, GL_RGBA8, cubeMapNegX.width, cubeMapNegX.height, 0,
					cubeMapNegX.format, GL_UNSIGNED_BYTE, cubeMapNegX.data);

	glTexImage2D(	GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
					0, GL_RGBA8, cubeMapPosY.width, cubeMapPosY.height, 0,
					cubeMapPosY.format, GL_UNSIGNED_BYTE, cubeMapPosY.data);
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
					0, GL_RGBA8, cubeMapNegY.width, cubeMapNegY.height, 0,
					cubeMapNegY.format, GL_UNSIGNED_BYTE, cubeMapNegY.data);

	glTexImage2D(	GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
					0, GL_RGBA8, cubeMapPosZ.width, cubeMapPosZ.height, 0,
					cubeMapPosZ.format, GL_UNSIGNED_BYTE, cubeMapPosZ.data);
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
					0, GL_RGBA8, cubeMapNegZ.width, cubeMapNegZ.height, 0,
					cubeMapNegZ.format, GL_UNSIGNED_BYTE, cubeMapNegZ.data);

	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

	
	//reset timer for start
	timer.Reset();
	
	return true;
}
Beispiel #8
0
//draw a frame
void RenderFrame()
{
	//Clear buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();										//reset modelview matrix


	camera.SetupViewMatrix();
	glMultMatrixf(camera.viewMatrix);

	DrawBackground();


	glPushAttrib(GL_ALL_ATTRIB_BITS);
	
	//Enable vertex program
	glEnable(GL_VERTEX_PROGRAM_NV);

	//Enable register combiners
	glEnable(GL_REGISTER_COMBINERS_NV);

	//Enable textures
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);

	//Set up CHROMATIC_SINGLE tex units
	if(renderPath==CHROMATIC_SINGLE)
	{
		glActiveTextureARB(GL_TEXTURE2_ARB);
		glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
		glEnable(GL_TEXTURE_CUBE_MAP_ARB);

		glActiveTextureARB(GL_TEXTURE3_ARB);
		glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
		glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	}
	
	glActiveTextureARB(GL_TEXTURE0_ARB);

	//Set the texture Matrix to be the inverse view matrix
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMultMatrixf(camera.viewMatrix.GetInverse());
	glMatrixMode(GL_MODELVIEW);

	//Create object display lists
	static GLuint objectLists;
	if(!objectLists)
	{
		objectLists=glGenLists(3);
		
		glNewList(objectLists, GL_COMPILE);
		{
			glutSolidSphere(1.0, 120, 60);
		}
		glEndList();

		glNewList(objectLists+1, GL_COMPILE);
		{
			glutSolidTorus(0.3, 0.7, 120, 60);
		}
		glEndList();

		glNewList(objectLists+2, GL_COMPILE);
		{
			glutSolidTeapot(1.0f);
		}
		glEndList();
	}

	//If using CHROMATIC_TWIN, need to do two passes, so set states every frame
	if(renderPath==CHROMATIC_TWIN)
		InitChromaticTwin1States();

	//draw object
	glCallList(objectLists+objectType);

	//Do the second path if necessary
	if(renderPath==CHROMATIC_TWIN)
	{
		InitChromaticTwin2States();
		glCallList(objectLists+objectType);
	}

	//Reset texture matrix
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glPopAttrib();

	


	fpsCounter.Update();											//update frames per second counter
	glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
	window.StartTextMode();
	window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
	glColor4f(0.5f, 0.0f, 1.0f, 1.0f);
	if(renderPath==CHROMATIC_SINGLE)
		window.Print(0, 48, "Single Pass Chromatic Aberration");
	if(renderPath==SIMPLE_SINGLE)
		window.Print(0, 48, "Single Pass Simple Refraction");
	if(renderPath==CHROMATIC_TWIN)
		window.Print(0, 48, "Two Pass Chromatic Aberration");
	window.EndTextMode();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	if(window.isKeyPressed(VK_F1))
	{
		window.SaveScreenshot();
		window.SetKeyReleased(VK_F1);
	}

	window.SwapBuffers();									//swap buffers

	//check for any opengl errors
	window.CheckGLError();

	//quit if necessary
	if(window.isKeyPressed(VK_ESCAPE))
		PostQuitMessage(0);
}
Beispiel #9
0
//draw a frame
void RenderFrame()
{
    //Clear buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();										//reset modelview matrix

    camera.SetupViewMatrix();
    glLoadMatrixf(camera.viewMatrix);

    //Enable box texture
    glEnable(GL_TEXTURE_2D);

    //Enable attenuation textures
    if(codePath==TEXTURE_ATTEN || codePath==GAUSSIAN_ATTEN)
    {
        //2D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glEnable(GL_TEXTURE_2D);
        //1D atten
        glActiveTextureARB(GL_TEXTURE2_ARB);
        glEnable(GL_TEXTURE_1D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }
    else if(codePath==PASS_THROUGH_ATTEN)	//set up pass through states
    {
        //enable texture shaders
        glEnable(GL_TEXTURE_SHADER_NV);
    }
    else if(codePath==TEXTURE_3D_ATTEN)
    {
        //3D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glEnable(GL_TEXTURE_3D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }



    //Enable vertex program
    glEnable(GL_VERTEX_PROGRAM_NV);
    glBindProgramNV(GL_VERTEX_PROGRAM_NV, vertexProgram);

    //Send the light's color to primary color
    glColor4fv(lightColors[currentLightColor]);

    //set the texture matrix
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glTranslatef(0.5f, 0.5f, 0.5f);
    glScalef(0.5f, 0.5f, 0.5f);
    glScalef(1/lightRadius, 1/lightRadius, 1/lightRadius);
    glTranslatef(-lightPosition.x, -lightPosition.y, -lightPosition.z);
    glMatrixMode(GL_MODELVIEW);

    //Enable register combiners
    glEnable(GL_REGISTER_COMBINERS_NV);

    //Draw Cube
    glDrawArrays(GL_QUADS, 0, 24);

    //Disable box texture
    glDisable(GL_TEXTURE_2D);

    //Disable attenuation textures
    if(codePath==TEXTURE_ATTEN || codePath==GAUSSIAN_ATTEN)
    {
        //2D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glDisable(GL_TEXTURE_2D);
        //1D atten
        glActiveTextureARB(GL_TEXTURE2_ARB);
        glDisable(GL_TEXTURE_1D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }
    else if(codePath==PASS_THROUGH_ATTEN)	//set up pass through states
    {
        //disable texture shaders
        glDisable(GL_TEXTURE_SHADER_NV);
    }
    else if(codePath==TEXTURE_3D_ATTEN)
    {
        //3D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glDisable(GL_TEXTURE_3D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }

    //Disable vertex program
    glDisable(GL_VERTEX_PROGRAM_NV);

    //reset the texture matrix
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);

    //Disable register combiners
    glDisable(GL_REGISTER_COMBINERS_NV);


    //Draw light in a display list
    glColor4fv(lightColors[currentLightColor]);
    glTranslatef(lightPosition.x, lightPosition.y, lightPosition.z);
    static GLuint sphereList=0;
    if(!sphereList)
    {
        sphereList=glGenLists(1);
        glNewList(sphereList, GL_COMPILE);
        {
            gluSphere(sphere, 0.1f, 24, 12);
        }
        glEndList();
    }
    glCallList(sphereList);
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);



    fpsCounter.Update();											//update frames per second counter
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    window.StartTextMode();
    window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
    glColor4f(1.0f, 1.0f, 0.0f, 0.0f);
    if(codePath==TEXTURE_ATTEN)
        window.Print(0, 48, "Using Texture Attenuation");
    if(codePath==PASS_THROUGH_ATTEN)
        window.Print(0, 48, "Using Pass Through Attenuation");
    if(codePath==TEXTURE_3D_ATTEN)
        window.Print(0, 48, "Using 3D Texture Attenuation");
    if(codePath==GAUSSIAN_ATTEN)
        window.Print(0, 48, "Using Gaussian Texture Attenuation");
    window.EndTextMode();
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    if(window.isKeyPressed(VK_F1))
    {
        window.SaveScreenshot();
        window.SetKeyReleased(VK_F1);
    }

    window.SwapBuffers();									//swap buffers

    //check for any opengl errors
    window.CheckGLError();

    //quit if necessary
    if(window.isKeyPressed(VK_ESCAPE))
        PostQuitMessage(0);
}