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


C++ Texture2D::GenerateMipmaps方法代码示例

本文整理汇总了C++中Texture2D::GenerateMipmaps方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture2D::GenerateMipmaps方法的具体用法?C++ Texture2D::GenerateMipmaps怎么用?C++ Texture2D::GenerateMipmaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture2D的用法示例。


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

示例1: CreateScene

//----------------------------------------------------------------------------
void BlendedAnimations::CreateScene ()
{
	mWireState = new0 WireState();
	mRenderer->SetOverrideWireState(mWireState);

	mScene = new0 Node();
	mScene->AttachChild(mManager.GetRoot());

	// Create a floor to walk on.
	VertexFormat* vformat = VertexFormat::Create(3,
	                        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
	                        VertexFormat::AU_NORMAL, VertexFormat::AT_FLOAT3, 0,
	                        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

	mFloor = StandardMesh(vformat).Rectangle(2, 2, 1024.0f, 2048.0f);
	VertexBufferAccessor vba(mFloor);
	for (int i = 0; i < vba.GetNumVertices(); ++i)
	{
		Float2& tcoord = vba.TCoord<Float2>(0, i);
		tcoord[0] *= 64.0f;
		tcoord[1] *= 256.0f;
	}

	std::string textureName = Environment::GetPathR("Grating.wmtf");
	Texture2D* texture = Texture2D::LoadWMTF(textureName);
	texture->GenerateMipmaps();
	mFloor->SetEffectInstance(Texture2DEffect::CreateUniqueInstance(texture,
	                          Shader::SF_LINEAR_LINEAR, Shader::SC_REPEAT, Shader::SC_REPEAT));

	mScene->AttachChild(mFloor);

	ComputeVisibleSet(mScene);
}
开发者ID:bhlzlx,项目名称:WildMagic,代码行数:34,代码来源:BlendedAnimations.cpp

示例2: CreateScene

//----------------------------------------------------------------------------
void SphereMaps::CreateScene ()
{
    mScene = new0 Node();
    mTrnNode = new0 Node();
    mScene->AttachChild(mTrnNode);

    VertexFormat* vformat = VertexFormat::Create(3,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_NORMAL, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT3, 1);

    TriMesh* mesh = StandardMesh(vformat).Torus(64, 64, 1.0f, 0.5f);
    mTrnNode->AttachChild(mesh);

    std::string effectFile = Environment::GetPathR("SphereMap.wmfx");
    SphereMapEffect* effect = new0 SphereMapEffect(effectFile);
    std::string environmentName = Environment::GetPathR("SphereMap.wmtf");
    Texture2D* environmentTexture = Texture2D::LoadWMTF(environmentName);
    environmentTexture->GenerateMipmaps();
    mesh->SetEffectInstance(effect->CreateInstance(environmentTexture));
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:22,代码来源:SphereMaps.cpp

示例3: OnInitialize

//----------------------------------------------------------------------------
bool NonlocalBlowup::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }
#ifdef RUN_CONSOLE
    RunConsole();
    return false;
#endif

    mScene = new0 Node();
    mScene->LocalTransform.SetRotate(HMatrix(
        0.80475128f, 0.59107417f, -0.054833174f, 0.0f,
        -0.17529237f, 0.32487807f, 0.92936903f, 0.0f,
        0.56714010f, -0.73829913f, 0.36505684f, 0.0f,
        0.0f, 0.0f, 0.0f, 1.0f));
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

    TriMesh* mesh = StandardMesh(vformat).Rectangle(256, 256, 16.0f, 16.0f);
    mScene->AttachChild(mesh);

    std::string gridName = Environment::GetPathR("Grid.wmtf");
    Texture2D* gridTexture = Texture2D::LoadWMTF(gridName);
    gridTexture->GenerateMipmaps();

    Texture1D* colorTexture = new0 Texture1D(Texture::TF_A8R8G8B8, 8, 1);
    unsigned char* color = (unsigned char*)colorTexture->GetData(0);
    color[ 0] = 128;  color[ 1] = 128;  color[ 2] = 128;  color[ 3] = 255;
    color[ 4] = 255;  color[ 5] =   0;  color[ 6] = 128;  color[ 7] = 255;
    color[ 8] = 255;  color[ 9] =   0;  color[10] =   0;  color[11] = 255;
    color[12] =   0;  color[13] = 255;  color[14] =   0;  color[15] = 255;
    color[16] =   0;  color[17] = 255;  color[18] = 255;  color[19] = 255;
    color[20] =   0;  color[21] = 128;  color[22] = 255;  color[23] = 255;
    color[24] =   0;  color[25] =   0;  color[26] = 255;  color[27] = 255;
    color[28] = 255;  color[29] = 255;  color[30] = 255;  color[31] = 255;

    float dt = 0.01f, dx = 1.0f, dy = 1.0f;
    // Uncomment only one of these at a time.
    NonconvexDomain0p50(dt, dx, dy);
    //SquareSymmetric0p01(dt, dx, dy);
    //SquareSymmetric0p50(dt, dx, dy);
    //SquareSymmetric0p99(dt, dx, dy);
    //SquareGaussX0p50(dt, dx, dy);
    //SquareGaussXY0p50(dt, dx, dy);
    //SquareGaussFour0p50(dt, dx, dy);

    DisplacementEffect* effect = new0 DisplacementEffect();
    mesh->SetEffectInstance(effect->CreateInstance(mHeightTexture,
        gridTexture, colorTexture, mDomainTexture));

    // Set up the camera so that it looks at the graph from slightly above
    // the xy-plane and at a skewed angle/direction of view.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 10000.0f);
    APoint camPosition(0.0f, 3.46f, 42.97f);
    AVector camDVector(0.0f, 0.0f, -1.0f);
    AVector camUVector(0.0f, 1.0f, 0.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    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.01f);
    InitializeObjectMotion(mScene);
    return true;
}
开发者ID:vijaynerella,项目名称:GeometricTools,代码行数:77,代码来源:NonlocalBlowup.cpp

示例4: CreateScene

//----------------------------------------------------------------------------
void Terrains::CreateScene ()
{
	// Create the root of the scene.
	mScene = new0 Node();

	// Load and initialize the sky dome.  It follows the camera.
	std::string skyMeshName = Environment::GetPathR("SkyDomePNT2.wmvf");
	Visual::PrimitiveType type;
	VertexFormat* vformat;
	VertexBuffer* vbuffer;
	IndexBuffer* ibuffer;
	Visual::LoadWMVF(skyMeshName, type, vformat, vbuffer, ibuffer);
	mSkyDome = new0 TriMesh(vformat, vbuffer, ibuffer);
	mScene->AttachChild(mSkyDome);

	APoint skyPosition = mCamera->GetPosition();
	skyPosition[2] = 0.0f;
	mSkyDome->LocalTransform.SetTranslate(skyPosition);
	mSkyDome->LocalTransform.SetUniformScale(mCamera->GetDMax());

	Texture2DEffect* skyEffect = new0 Texture2DEffect(
	                                 Shader::SF_LINEAR_LINEAR, Shader::SC_REPEAT, Shader::SC_REPEAT);
	std::string skyTextureName = Environment::GetPathR("SkyDome.wmtf");
	Texture2D* skyTexture = Texture2D::LoadWMTF(skyTextureName);
	skyTexture->GenerateMipmaps();
	mSkyDome->SetEffectInstance(skyEffect->CreateInstance(skyTexture));

	// Load the height field and create the terrain.
	vformat = VertexFormat::Create(3,
	                               VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
	                               VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0,
	                               VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 1);

	// For lower-resolution terrain, change the paths to Height64/Color64 or
	// Height32/Color32.
	std::string heightName = ThePath + "Data/Height128/height";
	std::string colorName = ThePath + "Data/Color128/color";

	mTerrain = new0 Terrain(heightName, vformat, mCamera);
	mScene->AttachChild(mTerrain);

	// The effect that is shared across all pages.
	std::string effectFile =
	    Environment::GetPathR("BaseMulDetailFogExpSqr.wmfx");
	TerrainEffect* terrainEffect = new0 TerrainEffect(effectFile);

	std::string detailName = Environment::GetPathR("Detail.wmtf");
	Texture2D* detailTexture = Texture2D::LoadWMTF(detailName);
	detailTexture->GenerateMipmaps();

	ShaderFloat* fogColorDensity = new0 ShaderFloat(1);
	(*fogColorDensity)[0] = 0.5686f;
	(*fogColorDensity)[1] = 0.7255f;
	(*fogColorDensity)[2] = 0.8353f;
	(*fogColorDensity)[3] = 0.0015f;

	// Attach an effect to each page.  Preload all resources to video memory.
	// This will avoid frame rate stalls when new terrain pages are
	// encountered as the camera moves.
	const int numRows = mTerrain->GetRowQuantity();
	const int numCols = mTerrain->GetColQuantity();
	for (int r = 0; r < numRows; ++r)
	{
		for (int c = 0; c < numCols; ++c)
		{
			TerrainPage* page = mTerrain->GetPage(r, c);

			char suffix[32];
			sprintf(suffix, ".%d.%d.wmtf", r, c);
			std::string colorTextureName = colorName + std::string(suffix);
			Texture2D* colorTexture = Texture2D::LoadWMTF(colorTextureName);
			colorTexture->GenerateMipmaps();

			VisualEffectInstance* instance = terrainEffect->CreateInstance(
			                                     colorTexture, detailTexture, fogColorDensity);

			page->SetEffectInstance(instance);

			mRenderer->Bind(page->GetVertexBuffer());
			mRenderer->Bind(page->GetVertexFormat());
			mRenderer->Bind(page->GetIndexBuffer());
			mRenderer->Bind(colorTexture);
		}
	}
}
开发者ID:bhlzlx,项目名称:WildMagic,代码行数:86,代码来源:Terrains.cpp


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