本文整理汇总了C++中GetAspectRatio函数的典型用法代码示例。如果您正苦于以下问题:C++ GetAspectRatio函数的具体用法?C++ GetAspectRatio怎么用?C++ GetAspectRatio使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetAspectRatio函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetClearColor
void Camera::FillXMLInfo(XMLNode *xmlInfo) const
{
Component::FillXMLInfo(xmlInfo);
xmlInfo->SetTagName("Camera");
xmlInfo->SetColor("ClearColor", GetClearColor());
xmlInfo->SetFloat("ZNear", GetZNear());
xmlInfo->SetFloat("ZFar", GetZFar());
xmlInfo->SetEnum("ProjectionMode",
ProjectionMode_GetNamesVector(),
ProjectionMode_GetIndexFromValue(m_projMode),
{XMLProperty::Readonly});
xmlInfo->SetFloat("AspectRatio", GetAspectRatio());
if (GetProjectionMode() == ProjectionMode::Orthographic)
{
xmlInfo->SetFloat("OrthoHeight", GetOrthoHeight());
xmlInfo->SetFloat("FOVDegrees", GetFovDegrees(), {XMLProperty::Hidden});
}
else
{
xmlInfo->SetFloat("OrthoHeight", GetOrthoHeight(), {XMLProperty::Hidden});
xmlInfo->SetFloat("FOVDegrees", GetFovDegrees());
}
}
开发者ID:sephirot47,项目名称:Bang,代码行数:25,代码来源:Camera.cpp
示例17: GetAspectRatio
//----------------------------------------------------------------------------
bool IntersectConvexPolyhedra::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the camera.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 1000.0f);
APoint camPosition(16.0f, 0.0f, 0.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();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.01f, 0.001f);
InitializeObjectMotion(mScene);
return true;
}
开发者ID:rasslingcats,项目名称:calico,代码行数:29,代码来源:IntersectConvexPolyhedra.cpp
示例18: CreateScene
//----------------------------------------------------------------------------
bool ScreenPolygons::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
CreateScene();
// Set up the camera.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
APoint camPosition(80.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);
// Initial update of objects.
mScene->Update();
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.01f, 0.01f);
InitializeObjectMotion(mScene);
return true;
}
开发者ID:bhlzlx,项目名称:WildMagic,代码行数:27,代码来源:ScreenPolygons.cpp
示例19: GetAspectRatio
void Application::OnResize()
{
DirectXApp::OnResize();
//DirectX::XMMATRIX P = DirectX::XMMatrixOrthographicLH(m_ScreenWidth, m_ScreenHeight, 1.0f, 1000.0f);
DirectX::XMMATRIX P = DirectX::XMMatrixPerspectiveFovLH( 0.25f * DirectX::XM_PI, GetAspectRatio(), 1.0f, 10000.0f);
XMStoreFloat4x4(&m_Proj, P);
}
开发者ID:Shadow864,项目名称:DirectX11,代码行数:9,代码来源:Application.cpp
示例20: CalcNormalDisplayRect
void CComboRenderer::ManageDisplay()
{
const RECT& rv = g_graphicsContext.GetViewWindow();
float fScreenWidth = (float)rv.right - rv.left;
float fScreenHeight = (float)rv.bottom - rv.top;
float fOffsetX1 = (float)rv.left;
float fOffsetY1 = (float)rv.top;
float fPixelRatio = CDisplaySettings::Get().GetPixelRatio();
float fMaxScreenWidth = (float)CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iWidth;
float fMaxScreenHeight = (float)CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()).iHeight;
if (fOffsetX1 < 0) fOffsetX1 = 0;
if (fOffsetY1 < 0) fOffsetY1 = 0;
if (fScreenWidth + fOffsetX1 > fMaxScreenWidth) fScreenWidth = fMaxScreenWidth - fOffsetX1;
if (fScreenHeight + fOffsetY1 > fMaxScreenHeight) fScreenHeight = fMaxScreenHeight - fOffsetY1;
// Correct for HDTV_1080i -> 540p
if (GetResolution() == HDTV_1080i)
{
fOffsetY1 /= 2;
fScreenHeight /= 2;
fPixelRatio *= 2;
}
// source rect
rs.left = CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft;
rs.top = CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop;
rs.right = m_iSourceWidth - CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight;
rs.bottom = m_iSourceHeight - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom;
CalcNormalDisplayRect(fOffsetX1, fOffsetY1, fScreenWidth, fScreenHeight, GetAspectRatio() * fPixelRatio, CDisplaySettings::Get().GetZoomAmount());
// check whether we need to alter our source rect
if (rd.left < fOffsetX1 || rd.right > fOffsetX1 + fScreenWidth)
{
// wants to be wider than we allow, so fix
float fRequiredWidth = (float)rd.right - rd.left;
if (rs.right <= rs.left) rs.right = rs.left+1;
float fHorizScale = fRequiredWidth / (float)(rs.right - rs.left);
float fNewWidth = fScreenWidth / fHorizScale;
rs.left = (rs.right - rs.left - (int)fNewWidth) / 2;
rs.right = rs.left + (int)fNewWidth;
rd.left = (int)fOffsetX1;
rd.right = (int)(fOffsetX1 + fScreenWidth);
}
if (rd.top < fOffsetY1 || rd.bottom > fOffsetY1 + fScreenHeight)
{
// wants to be wider than we allow, so fix
float fRequiredHeight = (float)rd.bottom - rd.top;
if (rs.bottom <= rs.top) rs.bottom = rs.top+1;
float fVertScale = fRequiredHeight / (float)(rs.bottom - rs.top);
float fNewHeight = fScreenHeight / fVertScale;
rs.top = (rs.bottom - rs.top - (int)fNewHeight) / 2;
rs.bottom = rs.top + (int)fNewHeight;
rd.top = (int)fOffsetY1;
rd.bottom = (int)(fOffsetY1 + fScreenHeight);
}
}
开发者ID:DJMatty,项目名称:xbmc,代码行数:57,代码来源:ComboRenderer.cpp
注:本文中的GetAspectRatio函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论