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


C++ Texture::Apply方法代码示例

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


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

示例1: Setup

//----------------------------------------------------------------------------
bool EnvironmentMaps::Setup ()
{
    // load model
    m_spkScene = new Node(1);
    m_spkTrnNode = new Node(1);
    m_spkScene->AttachChild(m_spkTrnNode);

    Stream kStream;
    bool bLoaded = kStream.Load("Face.mgc");
    if ( !bLoaded )
        return false;
    m_spkModel = (Node*) kStream.GetObjectAt(0);

    m_spkTrnNode->AttachChild(m_spkModel);

    // attach environment map
    Image* pkImage = Image::Load("SphereMap.mif");
    if ( !pkImage )
        return false;

    Texture* pkTexture = new Texture;
    pkTexture->SetImage(pkImage);
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_NONE;
    pkTexture->Apply() = Texture::AM_DECAL;
    pkTexture->Envmap() = Texture::EM_SPHERE;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkTexture);
    m_spkModel->SetRenderState(pkTS);

    return true;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:33,代码来源:EnvironmentMaps.cpp

示例2: CreateCloth

//----------------------------------------------------------------------------
void Cloth::CreateCloth ()
{
    // create quadratic spline using particles as control points
    m_pkSpline = new BSplineRectanglef(m_pkModule->GetRows(),
        m_pkModule->GetCols(),m_pkModule->Positions2D(),2,2,false,false,
        true,true);

    // generate a rectangle surface
    int iUSamples = 16;
    int iVSamples = 32;
    bool bWantNormals = false;
    bool bWantColors = false;
    bool bDoubleSided = true;
    Vector2f kTextureMin(0.0f,0.0f), kTextureMax(1.0f,1.0f);
    m_spkCloth = new RectangleSurface(m_pkSpline,iUSamples,iVSamples,
        bWantNormals,bWantColors,bDoubleSided,&kTextureMin,&kTextureMax);

    // attach a texture for the surface
    Texture* pkTexture = new Texture;
    pkTexture->SetImage(Image::Load("purplecloth.mif"));
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkTexture->Apply() = Texture::AM_REPLACE;
    pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkTexture);
    m_spkCloth->SetRenderState(pkTS);

    m_spkTrnNode->AttachChild(m_spkCloth);
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:31,代码来源:Cloth.cpp

示例3: CreateGround

//----------------------------------------------------------------------------
TriMesh* BallHill::CreateGround ()
{
    TriMesh* pkGround = NULL;
    CreateRectangleMesh(pkGround,Vector3f::ZERO,Vector3f::UNIT_X,
        Vector3f::UNIT_Y,Vector3f::UNIT_Z,32.0f,32.0f,false,false,true);
    m_spkGround = pkGround;

    // change the texture repeat
    int iVQuantity = m_spkGround->GetVertexQuantity();
    Vector2f* akUV = m_spkGround->Textures();
    for (int i = 0; i < iVQuantity; i++)
        akUV[i] *= 8.0f;

    Texture* pkTexture = new Texture;
    pkTexture->SetImage(Image::Load("grass.mif"));
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkTexture->Apply() = Texture::AM_REPLACE;
    pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkTexture);
    m_spkGround->SetRenderState(pkTS);

    return pkGround;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:26,代码来源:BallHill.cpp

示例4: brushSize

void gfx::GraphicsEngine::RenderToTexture(RenderQueue* drawQueue){
	TextureHandle target = drawQueue->GetTargetTexture();
	m_FrameBuffer.SetTexture(target);
	m_FrameBuffer.Apply();

	ShaderProgram* spriteProg = g_ShaderBank.GetProgramFromHandle(m_SpriteShader);
	spriteProg->Apply();
	glBindVertexArray(0);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	static bool additive = false; 
	ImGui::Checkbox("Additive", &additive);
	if (additive){
		glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	}
	else {
		glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	}
	//static glm::vec4 color = glm::vec4(1);
	//ImGui::ColorEdit4("BrushColor", &color[0], true);

	for (auto& brush : drawQueue->GetBrushQueue()){
		Texture* brushTex = g_MaterialBank.GetTexture(brush.Texture);
		glm::vec2 brushSize(brush.Size / (m_Width * 0.5f), brush.Size / m_Height);

		spriteProg->SetUniformVec4("g_Pos", glm::vec4(glm::vec2(brush.Position.x - brushSize.x * 0.5f, 1.0f - brush.Position.y + brushSize.y * 0.5f), 0, 0));
		spriteProg->SetUniformVec4("g_Size", glm::vec4(brushSize.x, brushSize.y, 1, 1));
		spriteProg->SetUniformVec4("g_Color", ColorPicker::m_color);
		brushTex->Apply(spriteProg->FetchUniform("g_Texture"), 0);
		spriteProg->SetUniformBool("g_GreyScale", false);
		glDrawArrays(GL_POINTS, 0, 1);
	}
	glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
开发者ID:exnotime,项目名称:DV1508AssetTool,代码行数:34,代码来源:GraphicsEngine.cpp

示例5: CreateBall

//----------------------------------------------------------------------------
TriMesh* BallHill::CreateBall ()
{
    TriMesh* pkBall = NULL;
    m_fRadius = (float)m_kModule.Radius;
    CreateSphereMesh(pkBall,16,16,Vector3f::ZERO,m_fRadius,Vector3f::UNIT_X,
        Vector3f::UNIT_Y,Vector3f::UNIT_Z,false,false,true,true);
    m_spkBall = pkBall;
    m_spkBall->Translate().Z() = (float)m_kModule.A3 + m_fRadius;

    Texture* pkTexture = new Texture;
    pkTexture->SetImage(Image::Load("BallTexture.mif"));
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkTexture->Apply() = Texture::AM_REPLACE;
    pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkTexture);
    m_spkBall->SetRenderState(pkTS);

    UpdateBall();

    return m_spkBall;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:24,代码来源:BallHill.cpp

示例6: CreateRope

//----------------------------------------------------------------------------
void Rope::CreateRope ()
{
    // create quadratic spline using particles as control points
    int iNumCtrlPoints = m_pkModule->GetNumParticles();
    Vector3f* akCtrlPoint = m_pkModule->Positions();
    int iDegree = 2;
    m_pkSpline = new BSplineCurve3f(iNumCtrlPoints,akCtrlPoint,iDegree,
        false,true);

    // generate a tube surface whose medial axis is the spline
    bool bClosed = false;
    Vector3f kUpVector = Vector3f::UNIT_Z;
    int iMedialSamples = 64;
    int iSliceSamples = 8;
    bool bWantNormals = false;
    bool bWantColors = false;
    bool bSampleByArcLength = false;
    bool bInsideView = false;
    Vector2f kTextureMin(0.0f,0.0f), kTextureMax(1.0f,1.0f);

    m_spkRope = new TubeSurface(m_pkSpline,Radial,bClosed,kUpVector,
        iMedialSamples,iSliceSamples,bWantNormals,bWantColors,
        bSampleByArcLength,bInsideView,&kTextureMin,&kTextureMax);

    // attach a texture for the rope
    Texture* pkTexture = new Texture;
    pkTexture->SetImage(Image::Load("rope.mif"));
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkTexture->Apply() = Texture::AM_REPLACE;
    pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkTexture);
    m_spkRope->SetRenderState(pkTS);

    m_spkTrnNode->AttachChild(m_spkRope);
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:38,代码来源:Rope.cpp

示例7: CreateHill

//----------------------------------------------------------------------------
TriMesh* BallHill::CreateHill ()
{
    TriMesh* pkHill = NULL;
    CreateDiskMesh(pkHill,32,32,Vector3f::ZERO,2.0f,Vector3f::UNIT_X,
        Vector3f::UNIT_Y,Vector3f::UNIT_Z,false,false,true);
    m_spkHill = pkHill;

    // change the texture repeat
    int iVQuantity = m_spkHill->GetVertexQuantity();
    Vector2f* akUV = m_spkHill->Textures();
    int i;
    for (i = 0; i < iVQuantity; i++)
        akUV[i] *= 8.0f;

    Texture* pkTexture = new Texture;
    pkTexture->SetImage(Image::Load("gravel.mif"));
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkTexture->Apply() = Texture::AM_REPLACE;
    pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkTexture);
    m_spkHill->SetRenderState(pkTS);

    // adjust disk vertices to form elliptical paraboloid for the hill
    Vector3f* akVertex = m_spkHill->Vertices();
    for (i = 0; i < iVQuantity; i++)
    {
        akVertex[i].Z() = m_kModule.GetHeight(akVertex[i].X(),
            akVertex[i].Y());
    }
    m_spkHill->UpdateModelBound();
    m_spkHill->UpdateModelNormals();

    return m_spkHill;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:37,代码来源:BallHill.cpp

示例8:

void gfx::GraphicsEngine::RenderActiveTarget(){
	glViewport((GLint)(m_Width * 0.5f), BUTTON_SIZE, (GLint)(m_Width * 0.5f), m_Height - BUTTON_SIZE * 2);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	ShaderProgram* spriteProg = g_ShaderBank.GetProgramFromHandle(m_SpriteShader);
	spriteProg->Apply();
	glBindVertexArray(0);
	Texture* tex = g_MaterialBank.GetTexture(m_FrameBuffer.GetTexture());
	float sizeH;
	sizeH = tex->GetHeight() / tex->GetWidth();
	tex->Apply(spriteProg->FetchUniform("g_Texture"), 0);
	spriteProg->SetUniformVec4("g_Color", glm::vec4(1));
	spriteProg->SetUniformVec4("g_Pos", glm::vec4(0.0f, 0.5f + sizeH * 0.5f, 0.0f,0.0f));
	spriteProg->SetUniformVec4("g_Size", glm::vec4(1.0f, sizeH, 1.0f, 1.0f));
	if (tex->GetChannels() == 1){
		spriteProg->SetUniformBool("g_GreyScale", true);
	}
	else{
		spriteProg->SetUniformBool("g_GreyScale", false);
	}
	glDrawArrays(GL_POINTS, 0, 1);

}
开发者ID:exnotime,项目名称:DV1508AssetTool,代码行数:24,代码来源:GraphicsEngine.cpp

示例9: Setup

//----------------------------------------------------------------------------
bool RipplingOcean::Setup ()
{
    m_bStopped = false;
    m_fStopTime = GetTimeInSeconds();

    m_spkScene = new Node(1);
    m_spkTrnNode = new Node(1);
    m_spkScene->AttachChild(m_spkTrnNode);

    // Root node for a scene graph that contains a bump-mapped triangle mesh
    // square.
    m_spkModel = new Node(1);

    // create the triangle mesh surface
    TriMesh* pkMesh = NULL;
    CreateRectangleMesh(pkMesh, Vector3f::ZERO,
        Vector3f::UNIT_X, Vector3f::UNIT_Y, -Vector3f::UNIT_Z,
        1400.0f, 1200.0f, 50, 50, true, true, true);

    m_spkTriMesh = pkMesh;

    m_spkTriMesh->SetVertexShader(m_spkVertShader);
    m_spkTriMesh->SetPixelShader(m_spkPixShader);
    SetupShaders();

    Image* pkNormal = Image::Load("plasma.mif");
    if ( !pkNormal )
        return false;

    HeightToNormalMap( pkNormal );

    Texture* pkNormalTex = new Texture;
    pkNormalTex->SetImage(pkNormal);
    pkNormalTex->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkNormalTex->Filter() = Texture::FM_LINEAR;
    pkNormalTex->Apply() = Texture::AM_DECAL;
    pkNormalTex->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkNormalTex);

    Image* pkWater = Image::Load("watergradient.mif");
    if (!pkWater)
        return false;

    Texture* pkWaterTex = new Texture;
    pkWaterTex->SetImage(pkWater);
    pkWaterTex->Apply() = Texture::AM_DECAL;
    pkWaterTex->Wrap() = Texture::WM_CLAMP_S_CLAMP_T;
    pkTS->Set(1,pkWaterTex);

    Image* pkSkySphere = Image::Load("sky.mif");
    if (!pkSkySphere)
        return false;

    Texture* pkSkySphereTex = new Texture;
    pkSkySphereTex->SetImage(pkSkySphere);
    pkTS->Set(2,pkSkySphereTex);

    m_spkTriMesh->SetRenderState(pkTS);

    m_spkModel->AttachChild(m_spkTriMesh);
    m_spkTrnNode->AttachChild(m_spkModel);

    // I'll admit that this is kind of a hack, but it puts the sun
    // a smidge higher in the sky.  It makes it look nicest to start.  =)
    Matrix3f kIncr;
    kIncr.FromAxisAngle(Vector3f::UNIT_X, -0.08f);
    m_spkTrnNode->Rotate() = kIncr; 

    return true;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:72,代码来源:RipplingOcean.cpp

示例10: gpMultiDraw

void gfx::BasicRenderProgram::Draw(DrawData* data)
{
	//draw
	int flag = data->ShaderFlags;
	g_ModelBank.ApplyBuffers( POS_NORMAL_TEX_TANGENT );
	ShaderProgram* prog = g_ShaderBank.GetProgramFromHandle(m_ProgramHandle);
	
	prog->Apply();
	m_RenderJobManager->BindBuffers(prog);
	GLint loc = -1;
	if(flag & FRAGMENT_DIFFUSEMAP)
	{
		Texture* diffuse = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Diffuse);
		loc = prog->FetchUniform("g_DiffuseTex");
		diffuse->Apply(loc, 0);
		prog->SetUniformBool("useDiffuse",true);
	}
	else
	{
		prog->SetUniformBool("useDiffuse",false);
	}
	if(flag & FRAGMENT_NORMALMAP)
	{
		Texture* normal = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Normal);
		loc = prog->FetchUniform("g_NormalTex");
		normal->Apply(loc, 1);
		prog->SetUniformBool("useNormal",true);
	}
	else
	{
		prog->SetUniformBool("useNormal",false);
	}
	if(flag & FRAGMENT_ROUGHNESSMAP)
	{
		Texture* roughness = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Roughness);
		loc = prog->FetchUniform("g_RoughnessTex");
		roughness->Apply(loc, 2);
		prog->SetUniformBool("useRoughness",true);
	}
	else
	{
		prog->SetUniformBool("useRoughness",false);
	}
	if(flag & FRAGMENT_METALMAP)
	{
		Texture* metal = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Metal);
		loc = prog->FetchUniform("g_MetalTex");
		metal->Apply(loc, 3);
		prog->SetUniformBool("useMetal",true);
	}
	else
	{
		prog->SetUniformBool("useMetal",false);
	}
	BasicData* frameData = (BasicData*)(data->ExtraData);
	prog->SetUniformInt("numPLights", frameData->PointLightCount);
	prog->SetUniformInt("numDLights", frameData->DirLightCount);
	prog->SetUniformUInt("BatchCounts",frameData->BatchOffset);
	prog->SetUniformVec2("g_WorldSize", frameData->WorldSize);
	prog->SetUniformMat4("ShadowMat",frameData->ShadowMat);
	loc = prog->FetchUniform("g_LightCubeTex");
	frameData->SkyTex->Apply(loc, 4);
	loc = prog->FetchUniform("g_IrradianceCube");
	frameData->IrradianceTex->Apply(loc, 5);

	//fog tex
	loc = prog->FetchUniform("g_FogOfWarTex");
	glUniform1i(loc,6);
	glActiveTexture(GL_TEXTURE6);
	glBindTexture(GL_TEXTURE_2D, frameData->FogTex);

	//fog tex
	loc = prog->FetchUniform("g_ShadowMap");
	glUniform1i(loc,7);
	glActiveTexture(GL_TEXTURE7);
	glBindTexture(GL_TEXTURE_2D, frameData->ShadowTex);

	
	if (m_HasDrawID)
	{
		GPU_PROFILE( AutoGPUProfiler gpMultiDraw( "BasicRenderProgramMultiDrawElementsIndirect" ); );
		glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, (GLvoid*)(sizeof(IndirectDrawCall) * (frameData->BatchOffset)), frameData->BatchCount, 0);
		GPU_PROFILE( gpMultiDraw.Stop(); );
开发者ID:Robograde,项目名称:Robograde,代码行数:83,代码来源:BasicRenderProgram.cpp

示例11:

void gfx::ShaderProgram::SetUniformTexture(const rString& name, Texture& tex){
	tex.Apply(FetchUniform(name), m_TextureCount++);
}
开发者ID:Robograde,项目名称:Robograde,代码行数:3,代码来源:ShaderProgram.cpp

示例12: CreateSnakeBody

//----------------------------------------------------------------------------
void WrigglingSnake::CreateSnakeBody ()
{
    // create the B-spline curve for the snake body
    Vector3f* akCtrl = new Vector3f[m_iNumCtrl];
    int i;
    for (i = 0; i < m_iNumCtrl; i++)
    {
        // control points for a snake
        float fRatio = ((float)i)/(float)(m_iNumCtrl-1);
        float fX = -1.0f + 2.0f*fRatio;
        float fXMod = 10.0f*fX - 4.0f;
        akCtrl[i].X() = fX;
        akCtrl[i].Y() = ms_fRadius*(1.5f + Mathf::ATan(fXMod)/Mathf::PI);
        akCtrl[i].Z() = 0.0f;

        // sinusoidal motion for snake
        m_afAmplitude[i] = 0.1f+fRatio*Mathf::Exp(-fRatio);
        m_afPhase[i] = 1.5f*fRatio*Mathf::TWO_PI;
    }

    // the control points are copied by the curve objects
    m_pkCenter = new BSplineCurve3f(m_iNumCtrl,akCtrl,m_iDegree,false,true);
    delete[] akCtrl;

    // generate a tube surface
    bool bClosed = false;
    Vector3f kUpVector = Vector3f::UNIT_Y;
    int iMedialSamples = 128;
    int iSliceSamples = 32;
    bool bWantNormals = true;
    bool bWantColors = false;
    bool bSampleByArcLength = false;
    bool bInsideView = false;
    Vector2f kTextureMin(0.0f,0.0f), kTextureMax(1.0f,16.0f);

    m_spkSnakeBody = new TubeSurface(m_pkCenter,Radial,bClosed,kUpVector,
        iMedialSamples,iSliceSamples,bWantNormals,bWantColors,
        bSampleByArcLength,bInsideView,&kTextureMin,&kTextureMax);

    // attach a texture for the snake body
    Texture* pkTexture = new Texture;
    pkTexture->SetImage(Image::Load("snake.mif"));
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkTexture->Apply() = Texture::AM_REPLACE;
    pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkTexture);
    //m_spkSnakeBody->SetRenderState(pkTS);

    // Set up a light map to add to the current color.
    pkTexture = new Texture;
    pkTexture->SetImage(Image::Load("LightMap.mif"));
    pkTexture->Filter() = Texture::FM_LINEAR;
    pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkTexture->Apply() = Texture::AM_ADD;
    pkTexture->Envmap() = Texture::EM_SPHERE;
    pkTS->Set(1,pkTexture);
    m_spkSnakeBody->SetRenderState(pkTS);


    m_spkSnakeRoot->AttachChild(m_spkSnakeBody);
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:64,代码来源:WrigglingSnake.cpp


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