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
//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 #3
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;
	}
}