コード例 #1
0
ファイル: core_texture.cpp プロジェクト: Armada651/gli
int run()
{
    int Error(0);

    gli::texture Texture(gli::TARGET_1D, gli::FORMAT_RGBA8_UNORM, gli::texture::texelcoord_type(1), 1, 1, 1);
    gli::texture1D Texture1D(Texture);
    gli::texture1DArray Texture1DArray(Texture);
    gli::texture2D Texture2D(Texture);
    gli::texture2DArray Texture2DArray(Texture);
    gli::texture3D Texture3D(Texture);
    gli::textureCube TextureCube(Texture);
    gli::textureCubeArray TextureCubeArray(Texture);

    Error += Texture == Texture1D ? 0 : 1;
    Error += Texture != Texture1DArray ? 0 : 1;
    Error += Texture != Texture2D ? 0 : 1;
    Error += Texture != Texture2DArray ? 0 : 1;
    Error += Texture != Texture3D ? 0 : 1;
    Error += Texture != TextureCube ? 0 : 1;
    Error += Texture != TextureCubeArray ? 0 : 1;

    gli::texture Texture1D_B(Texture1D);
    gli::texture Texture1DArray_B(Texture1DArray);
    gli::texture Texture2D_B(Texture2D);
    gli::texture Texture2DArray_B(Texture2DArray);
    gli::texture Texture3D_B(Texture3D);
    gli::texture TextureCube_B(TextureCube);
    gli::texture TextureCubeArray_B(TextureCubeArray);

    Error += Texture == Texture1D_B ? 0 : 1;
    Error += Texture != Texture1DArray_B ? 0 : 1;
    Error += Texture != Texture2D_B ? 0 : 1;
    Error += Texture != Texture2DArray_B ? 0 : 1;
    Error += Texture != Texture3D_B ? 0 : 1;
    Error += Texture != TextureCube_B ? 0 : 1;
    Error += Texture != TextureCubeArray_B ? 0 : 1;

    Error += Texture1D == Texture1D_B ? 0 : 1;
    Error += Texture1DArray == Texture1DArray_B ? 0 : 1;
    Error += Texture2D == Texture2D_B ? 0 : 1;
    Error += Texture2DArray == Texture2DArray_B ? 0 : 1;
    Error += Texture3D == Texture3D_B ? 0 : 1;
    Error += TextureCube == TextureCube_B ? 0 : 1;
    Error += TextureCubeArray == TextureCubeArray_B ? 0 : 1;

    return Error;
}
コード例 #2
0
ファイル: core_texture.cpp プロジェクト: SCISS-AB/gli
	int run()
	{
		int Error(0);

		gli::texture Texture(gli::TARGET_1D, gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture::extent_type(1), 1, 1, 1);
		gli::texture1d Texture1D(Texture);
		gli::texture1d_array Texture1DArray(Texture);
		gli::texture2d Texture2D(Texture);
		gli::texture2d_array Texture2DArray(Texture);
		gli::texture3d Texture3D(Texture);
		gli::texture_cube TextureCube(Texture);
		gli::texture_cube_array TextureCubeArray(Texture);

		Error += Texture == Texture1D ? 0 : 1;
		Error += Texture != Texture1DArray ? 0 : 1;
		Error += Texture != Texture2D ? 0 : 1;
		Error += Texture != Texture2DArray ? 0 : 1;
		Error += Texture != Texture3D ? 0 : 1;
		Error += Texture != TextureCube ? 0 : 1;
		Error += Texture != TextureCubeArray ? 0 : 1;

		gli::texture Texture1D_B(Texture1D);
		gli::texture Texture1DArray_B(Texture1DArray);
		gli::texture Texture2D_B(Texture2D);
		gli::texture Texture2DArray_B(Texture2DArray);
		gli::texture Texture3D_B(Texture3D);
		gli::texture TextureCube_B(TextureCube);
		gli::texture TextureCubeArray_B(TextureCubeArray);

		Error += Texture == Texture1D_B ? 0 : 1;
		Error += Texture != Texture1DArray_B ? 0 : 1;
		Error += Texture != Texture2D_B ? 0 : 1;
		Error += Texture != Texture2DArray_B ? 0 : 1;
		Error += Texture != Texture3D_B ? 0 : 1;
		Error += Texture != TextureCube_B ? 0 : 1;
		Error += Texture != TextureCubeArray_B ? 0 : 1;

		Error += Texture1D == Texture1D_B ? 0 : 1;
		Error += Texture1DArray == Texture1DArray_B ? 0 : 1;
		Error += Texture2D == Texture2D_B ? 0 : 1;
		Error += Texture2DArray == Texture2DArray_B ? 0 : 1;
		Error += Texture3D == Texture3D_B ? 0 : 1;
		Error += TextureCube == TextureCube_B ? 0 : 1;
		Error += TextureCubeArray == TextureCubeArray_B ? 0 : 1;

		return Error;
	}
コード例 #3
0
ファイル: VolumeTextures.cpp プロジェクト: bhlzlx/WildMagic
//----------------------------------------------------------------------------
void VolumeTextures::CreateScene ()
{
	mScene = new0 Node();
	mAlphaState = new0 AlphaState();
	mAlphaState->BlendEnabled = true;
	mRenderer->SetOverrideAlphaState(mAlphaState);
	mCullState = new0 CullState();
	mCullState->Enabled = false;
	mRenderer->SetOverrideCullState(mCullState);

	// Create the grid of square meshes.
	const int numSlices = 64;
	const int numSamples = 32;

	// The vertex format that is shared by all square meshes.
	VertexFormat* vformat = VertexFormat::Create(2,
	                        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
	                        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT3, 0);
	int vstride = vformat->GetStride();

	// The index buffer that is shared by all square meshes.
	int numIndices = 6*(numSamples-1)*(numSamples-1);
	IndexBuffer* ibuffer = new0 IndexBuffer(numIndices, sizeof(int));
	int* indices = (int*)ibuffer->GetData();
	for (int i1 = 0; i1 < numSamples - 1; ++i1)
	{
		for (int i0 = 0; i0 < numSamples - 1; ++i0)
		{
			int v0 = i0 + numSamples * i1;
			int v1 = v0 + 1;
			int v2 = v1 + numSamples;
			int v3 = v0 + numSamples;
			*indices++ = v0;
			*indices++ = v1;
			*indices++ = v2;
			*indices++ = v0;
			*indices++ = v2;
			*indices++ = v3;
		}
	}

	// Create the volume texture.  Three Gaussian distributions are used for
	// the RGB color channels.  The alpha channel is constant.
	const int bound = 64;
	Texture3D* texture = new0 Texture3D(Texture::TF_A8R8G8B8, bound, bound,
	                                    bound, 1);
	unsigned char* data = (unsigned char*)texture->GetData(0);
	const float mult = 1.0f/(bound - 1.0f);
	const float rParam = 0.01f;
	const float gParam = 0.01f;
	const float bParam = 0.01f;
	const float extreme = 8.0f;
	APoint rCenter( 0.5f*extreme,  0.0f,         0.0f);
	APoint gCenter(-0.5f*extreme, -0.5f*extreme, 0.0f);
	APoint bCenter(-0.5f*extreme, +0.5f*extreme, 0.0f);
	unsigned char commonAlpha = 12;
	APoint point;
	for (int z = 0; z < bound; ++z)
	{
		point[2] = -extreme + 2.0f*extreme*mult*z;
		for (int y = 0; y < bound; ++y)
		{
			point[1] = -extreme + 2.0f*extreme*mult*y;
			for (int x = 0; x < bound; ++x)
			{
				point[0] = -extreme + 2.0f*extreme*mult*x;

				AVector diff = point - rCenter;
				float sqrLength = diff.SquaredLength();
				float rGauss = 1.0f - rParam*sqrLength;
				if (rGauss < 0.0f)
				{
					rGauss = 0.0f;
				}

				diff = point - gCenter;
				sqrLength = diff.SquaredLength();
				float gGauss = 1.0f - gParam*sqrLength;
				if (gGauss < 0.0f)
				{
					gGauss = 0.0f;
				}

				diff = point - bCenter;
				sqrLength = diff.SquaredLength();
				float bGauss = 1.0f - bParam*sqrLength;
				if (bGauss < 0.0f)
				{
					bGauss = 0.0f;
				}

				*data++ = (unsigned char)(255.0f*bGauss);
				*data++ = (unsigned char)(255.0f*gGauss);
				*data++ = (unsigned char)(255.0f*rGauss);
				*data++ = commonAlpha;
			}
		}
	}

	// The volume texture effect that is shared by all square meshes.
	std::string effectFile = Environment::GetPathR("VolumeTextures.wmfx");
	VolumeTextureEffect* effect = new0 VolumeTextureEffect(effectFile);
	VisualEffectInstance* instance = effect->CreateInstance(texture);

	// The grid of squares.
	const int numVertices = numSamples*numSamples;
	float inv = 1.0f/(numSamples - 1.0f);
	VertexBufferAccessor vba;
	for (int slice = 0; slice < numSlices; ++slice)
	{
		VertexBuffer* vbuffer = new0 VertexBuffer(numVertices, vstride);
		vba.ApplyTo(vformat, vbuffer);

		float w = slice/(numSlices - 1.0f);
		float z = 2.0f*w - 1.0f;
		for (int i1 = 0, i = 0; i1 < numSamples; ++i1)
		{
			float v = i1*inv;
			float y = 2.0f*v - 1.0f;
			for (int i0 = 0; i0 < numSamples; ++i0, ++i)
			{
				float u = i0*inv;
				float x = 2.0f*u - 1.0f;
				vba.Position<Float3>(i) = Float3(x, y, z);
				vba.TCoord<Float3>(0, i) = Float3(u, v, w);
			}
		}

		TriMesh* mesh = new0 TriMesh(vformat, vbuffer, ibuffer);
		mesh->SetEffectInstance(instance);
		mScene->AttachChild(mesh);
	}
}
コード例 #4
0
ファイル: texture.cpp プロジェクト: tornadocean/ClanLib
	Texture3D Texture::to_texture_3d() const
	{
		return Texture3D(impl);
	}