当前位置: 首页>>代码示例>>C++>>正文


C++ GetAspectRatio函数代码示例

本文整理汇总了C++中GetAspectRatio函数的典型用法代码示例。如果您正苦于以下问题:C++ GetAspectRatio函数的具体用法?C++ GetAspectRatio怎么用?C++ GetAspectRatio使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetAspectRatio函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: glClearColor

void VimridViewer::Render()
{
	this->GlutApplication::Render();

	// Use dark gray which is good for stereo.
	glClearColor(0.2, 0.2, 0.2, 1.0);

	if (IsStereoEnabled())
	{
		RenderStereoBuffer(GL_BACK_LEFT);
		RenderStereoBuffer(GL_BACK_RIGHT);
	}
	else
	{
		glDrawBuffer(GL_BACK);

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();

		// Set a normal frustum for non-stereo viewers.
		glFrustum(
			-1.0, 1.0,
			-GetAspectRatio(),
			GetAspectRatio(),
			GetFrustumNearClip(),
			GetFrustumFarClip());

		RenderDelegate();
	}

	FinishRender();
}
开发者ID:nbolton,项目名称:vimrid,代码行数:32,代码来源:VimridViewer.cpp

示例2: Window3

GeometryShadersWindow::GeometryShadersWindow(Parameters& parameters)
    :
    Window3(parameters)
{
    if (!SetEnvironment() || !CreateScene())
    {
        parameters.created = false;
        return;
    }

    mEngine->SetClearColor({ 1.0f, 1.0f, 1.0f, 1.0f });
    InitializeCamera();

    mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f);
    Vector4<float> camPosition{ 2.8f, 0.0f, 0.0f, 1.0f };
    Vector4<float> camDVector{ -1.0f, 0.0f, 0.0f, 0.0f };
    Vector4<float> camUVector{ 0.0f, 0.0f, 1.0f, 0.0f };
    Vector4<float> camRVector = Cross(camDVector, camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

#if defined(SAVE_RENDERING_TO_DISK)
    mTarget = std::make_shared<DrawTarget>(1, DF_R8G8B8A8_UNORM, mXSize,
        mYSize);
    mTarget->GetRTTexture(0)->SetCopyType(Resource::COPY_STAGING_TO_CPU);
#endif
}
开发者ID:yimogod,项目名称:gt_learn,代码行数:26,代码来源:GeometryShadersWindow.cpp

示例3: CreateScene

//----------------------------------------------------------------------------
bool GelatinCube::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    CreateScene();

    // Center-and-fit for camera viewing.
    mScene->Update();
    mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f);
    AVector camDVector(0.0f, 1.0f, 0.0f);
    AVector camUVector(0.0f, 0.0f, 1.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    APoint camPosition = APoint::ORIGIN -
        2.0f*mScene->WorldBound.GetRadius()*camDVector;
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    // Initial update of objects.
    mScene->Update();

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);

    // Sort the box faces based on current camera parameters.
    mBox->SortFaces(mCamera->GetDVector());

    InitializeCameraMotion(0.01f, 0.001f);
    InitializeObjectMotion(mScene);
    return true;
}
开发者ID:vijaynerella,项目名称:GeometricTools,代码行数:35,代码来源:GelatinCube.cpp

示例4: XMMatrixPerspectiveFovLH

void WavesApp::OnResize()
{
	D3DApp::OnResize();
	// The window resized, so update the aspect ratio and recompute the projection matrix.
	XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::PI/* 90度视角 */, GetAspectRatio(), 1.0f, 1000.0f);
	XMStoreFloat4x4(&m_projMaxtrix, P);
}
开发者ID:wjingzhe,项目名称:DX11,代码行数:7,代码来源:WavesDemo.cpp

示例5: GetAspectRatio

//----------------------------------------------------------------------------
bool Terrains::OnInitialize ()
{
	if (!WindowApplication3::OnInitialize())
	{
		return false;
	}

	// Set up the camera.  Position the camera in the middle of page[0][0].
	// Orient it to look diagonally across the terrain pages.
	mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1500.0f);
	APoint camPosition(64.0f, 64.0f, mHeightAboveTerrain);
	AVector camDVector(Mathf::INV_SQRT_2, Mathf::INV_SQRT_2, 0.0f);
	AVector camUVector(0.0f, 0.0f, 1.0f);
	AVector camRVector = camDVector.Cross(camUVector);
	mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

	CreateScene();

	// Initial update of objects.
	mScene->Update();

	// Initial culling of scene.
	mCuller.SetCamera(mCamera);
	mCuller.ComputeVisibleSet(mScene);

	InitializeCameraMotion(1.0f, 0.01f);
	MoveForward();
	return true;
}
开发者ID:bhlzlx,项目名称:WildMagic,代码行数:30,代码来源:Terrains.cpp

示例6: GetAspectRatio

//----------------------------------------------------------------------------
bool NonuniformScale::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    // Set up the camera.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 100.0f);
    float cs = 0.866025f, sn = 0.5f;
    APoint camPosition(0.0f, -4.0f, 2.0f);
    AVector camDVector(0.0f, cs, -sn);
    AVector camUVector(0.0f, sn, cs);
    AVector camRVector = camDVector.Cross(camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    CreateScene();

    // Initial update of objects.
    mScene->Update();

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);

    InitializeCameraMotion(0.01f, 0.001f);
    InitializeObjectMotion(mScene);
    return true;
}
开发者ID:rasslingcats,项目名称:calico,代码行数:30,代码来源:NonuniformScale.cpp

示例7: GetAspectRatio

void TopicApp::OnResize()
{
	DXApp::OnResize();

    // The window resized, so update the aspect ratio and recompute the projection matrix.
    m_cam.setLens(0.25f*MathHelper::Pi, GetAspectRatio(), 1.0f, 1000.0f);
}
开发者ID:madmaurice,项目名称:sandbox,代码行数:7,代码来源:topicApp.cpp

示例8: GetAspectRatio

//----------------------------------------------------------------------------
bool ReflectionsAndShadows::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    // Set up the camera.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
    APoint camPosition(180.0f, 0.0f, 23.0f);
    AVector camDVector(-1.0f, 0.0f, 0.0f);
    AVector camUVector(0.0f, 0.0f, 1.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    CreateScene ();

    // Initial update of objects.
    mScene->Update();
    mBiped->Update(mUpdateTime);

    // Initial culling of scene,
    mSceneCuller.SetCamera(mCamera);
    mSceneCuller.ComputeVisibleSet(mScene);
    mBipedCuller.SetCamera(mCamera);
    mBipedCuller.ComputeVisibleSet(mBiped);

    InitializeCameraMotion(0.1f, 0.01f);
    InitializeObjectMotion(mScene);
    return true;
}
开发者ID:rasslingcats,项目名称:calico,代码行数:32,代码来源:ReflectionsAndShadows.cpp

示例9: CreateScene

//----------------------------------------------------------------------------
bool BlendedAnimations::OnInitialize ()
{
	if (!WindowApplication3::OnInitialize())
	{
		return false;
	}

	CreateScene();

	// Center-and-fit for camera viewing.
	mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
	APoint camPosition(-60.0f, -60.0f, 90.0f);
	AVector camDVector(1.0f, 1.0f, -1.0f);
	camDVector.Normalize();
	AVector camUVector(0.5f, 0.5f, 1.0f);
	camUVector.Normalize();
	AVector camRVector = camDVector.Cross(camUVector);
	mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

	// Initial update of objects.
	mScene->Update(mAnimTime);

	InitializeCameraMotion(0.01f, 0.01f);
	InitializeObjectMotion(mScene);
	return true;
}
开发者ID:bhlzlx,项目名称:WildMagic,代码行数:27,代码来源:BlendedAnimations.cpp

示例10: CreateScene

//----------------------------------------------------------------------------
bool SphereMaps::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    CreateScene();

    // Center-and-fit for camera viewing.
    mScene->Update();
    mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
    AVector camDVector(0.0f, 1.0f, 0.0f);
    AVector camUVector(0.0f, 0.0f, 1.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    APoint camPosition = APoint::ORIGIN -
        3.0f*mScene->WorldBound.GetRadius()*camDVector;
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    // Initial update of objects.
    mScene->Update();
    CopyNormalToTCoord1(mScene);

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);

    InitializeCameraMotion(0.001f, 0.001f);
    InitializeObjectMotion(mScene);
    return true;
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:33,代码来源:SphereMaps.cpp

示例11: CreateScene

//----------------------------------------------------------------------------
bool FreeFormDeformation::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    // Set up the scene graph.
    CreateScene();

    // Center-and-fit mesh for viewing by camera
    mMesh->Update();
    mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f);
    AVector camDVector(0.0f, 0.0f, 1.0f);
    AVector camUVector(0.0f, 1.0f, 0.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    APoint camPosition = APoint::ORIGIN -
        2.5f*mScene->WorldBound.GetRadius()*camDVector;
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    // Initial update of objects.
    mScene->Update();

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);

    InitializeCameraMotion(0.01f, 0.02f);
    InitializeObjectMotion(mScene);
    return true;
}
开发者ID:vijaynerella,项目名称:GeometricTools,代码行数:33,代码来源:FreeFormDeformation.cpp

示例12: CreateScene

//----------------------------------------------------------------------------
bool WaterDropFormation::OnInitialize ()
{
	if (!WindowApplication3::OnInitialize())
	{
		return false;
	}

	CreateScene();

	// Center-and-fit for camera viewing.
	mScene->Update();
	mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
	mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 1000.0f);
	float angle = 0.01f*Mathf::PI;
	float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle);
	AVector camDVector(-cs, 0.0f, -sn);
	AVector camUVector(sn, 0.0f, -cs);
	AVector camRVector = camDVector.Cross(camUVector);
	APoint camPosition = APoint::ORIGIN -
	                     0.9f*mScene->WorldBound.GetRadius()*camDVector;
	mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

	// Initial update of objects.
	mScene->Update();

	// Initial culling of scene.
	mCuller.SetCamera(mCamera);
	mCuller.ComputeVisibleSet(mScene);

	InitializeCameraMotion(0.01f, 0.001f);
	InitializeObjectMotion(mScene);

	mLastSeconds = (float)GetTimeInSeconds();
	return true;
}
开发者ID:dodong471520,项目名称:WildMagic,代码行数:36,代码来源:WaterDropFormation.cpp

示例13: GetAspectRatio

//----------------------------------------------------------------------------
bool BouncingSpheres::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    // Set up the camera.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
    float angle = 0.02f*Mathf::PI;
    float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle);
    APoint camPosition(27.5f, 8.0f, 8.9f);
    AVector camDVector(-cs, 0.0f, -sn);
    AVector camUVector(-sn, 0.0f, cs);
    AVector camRVector = camDVector.Cross(camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    CreateScene();

    // Initial update of objects.
    mScene->Update();

    // Initialize balls with correct transformations.
    PhysicsTick();

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);
    return true;
}
开发者ID:rasslingcats,项目名称:calico,代码行数:31,代码来源:BouncingSpheres.cpp

示例14: GetAspectRatio

//----------------------------------------------------------------------------
bool RoughPlaneSolidBox::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    // Set up the camera.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 100.0f);
    float angle = 0.1f*Mathf::PI;
    float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle);
    APoint camPosition(17.695415f, 0.0f, 6.4494629f);
    AVector camDVector(-cs, 0.0f, -sn);
    AVector camUVector(-sn, 0.0f, cs);
    AVector camRVector = camDVector.Cross(camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    InitializeModule();
    CreateScene();

    // Initial update of objects.
    mScene->Update();

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);

    InitializeCameraMotion(0.001f, 0.001f);
    InitializeObjectMotion(mScene);
    return true;
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:32,代码来源:RoughPlaneSolidBox.cpp

示例15: pos

	bool Camera::ObjectFrustumCulling( const RenderObject& obj )
	{
		const AABB& aabb = obj.m_worldAABB;

		//物体坐标转换到相机空间进行裁减
		VEC4 pos(aabb.GetCenter(), 1.0f);
		Common::Transform_Vec4_By_Mat44(pos, pos, GetViewMatrix());

		float n = GetNearClip();
		float f = GetFarClip();
		float fov = GetFov();
		float half_w = n * std::tan(fov/2);
		float half_h = half_w / GetAspectRatio();

		//检测前后面
		if(-pos.z+aabb.m_boundingRadius <= n || -pos.z-aabb.m_boundingRadius >= f)
			return true;

		//检测左右面
		float planeX = half_w * pos.z / -n;
		if(pos.x - planeX >= aabb.m_boundingRadius ||
			pos.x + aabb.m_boundingRadius <= -planeX)
			return true;

		//检测上下面
		float planeY = half_h * pos.z / -n;
		if(pos.y - planeY >= aabb.m_boundingRadius ||
			pos.y + aabb.m_boundingRadius <= -planeY)
			return true;

		return false;
	}
开发者ID:lai3d,项目名称:ThisIsASoftRenderer,代码行数:32,代码来源:Camera.cpp


注:本文中的GetAspectRatio函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。