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


C++ texture::Sampler类代码示例

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


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

示例1: lua_TextureSampler_addRef

int lua_TextureSampler_addRef(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 1:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA))
            {
                Texture::Sampler* instance = getInstance(state);
                instance->addRef();
                
                return 0;
            }

            lua_pushstring(state, "lua_TextureSampler_addRef - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 1).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:faustgames-ru,项目名称:AndroidWallpapers,代码行数:31,代码来源:lua_TextureSampler.cpp

示例2: setNode

void Form::setNode(Node* node)
{
    // If the user wants a custom node then we need to create a 3D quad
    if (node && node != _node)
    {
        // Set this Form up to be 3D by initializing a quad.
        float x2 = _bounds.width;
        float y2 = _bounds.height;
        float vertices[] =
        {
            0, y2, 0,   0, _v1,
            0, 0, 0,    0, 0,
            x2, y2, 0,  _u2, _v1,
            x2, 0, 0,   _u2, 0
        };
        VertexFormat::Element elements[] =
        {
            VertexFormat::Element(VertexFormat::POSITION, 3),
            VertexFormat::Element(VertexFormat::TEXCOORD0, 2)
        };
        Mesh* mesh = Mesh::createMesh(VertexFormat(elements, 2), 4, false);
        GP_ASSERT(mesh);
        mesh->setPrimitiveType(Mesh::TRIANGLE_STRIP);
        mesh->setVertexData(vertices, 0, 4);

        _nodeQuad = Model::create(mesh);
        SAFE_RELEASE(mesh);
        GP_ASSERT(_nodeQuad);

        // Create the effect and material
        Effect* effect = createEffect();
        GP_ASSERT(effect);
        _nodeMaterial = Material::create(effect);

        GP_ASSERT(_nodeMaterial);
        _nodeQuad->setMaterial(_nodeMaterial);
        _nodeMaterial->release();
        node->setModel(_nodeQuad);
        _nodeQuad->release();

        // Bind the WorldViewProjection matrix.
        _nodeMaterial->setParameterAutoBinding("u_worldViewProjectionMatrix", RenderState::WORLD_VIEW_PROJECTION_MATRIX);

        // Bind the texture from the framebuffer and set the texture to clamp
        Texture::Sampler* sampler = Texture::Sampler::create(_frameBuffer->getRenderTarget()->getTexture());
        GP_ASSERT(sampler);
        sampler->setWrapMode(Texture::CLAMP, Texture::CLAMP);
        _nodeMaterial->getParameter("u_texture")->setValue(sampler);
        sampler->release();

        RenderState::StateBlock* rsBlock = _nodeMaterial->getStateBlock();
        rsBlock->setDepthWrite(true);
        rsBlock->setBlend(true);
        rsBlock->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
        rsBlock->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
    }
    _node = node;
}
开发者ID:5guo,项目名称:GamePlay,代码行数:58,代码来源:Form.cpp

示例3: lua_TextureSampler_getTexture

int lua_TextureSampler_getTexture(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 1:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA))
            {
                Texture::Sampler* instance = getInstance(state);
                void* returnPtr = (void*)instance->getTexture();
                if (returnPtr)
                {
                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
                    object->instance = returnPtr;
                    object->owns = false;
                    luaL_getmetatable(state, "Texture");
                    lua_setmetatable(state, -2);
                }
                else
                {
                    lua_pushnil(state);
                }

                return 1;
            }
            else
            {
                lua_pushstring(state, "lua_TextureSampler_getTexture - Failed to match the given parameters to a valid function signature.");
                lua_error(state);
            }
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 1).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:Brashworks,项目名称:GamePlay,代码行数:45,代码来源:lua_TextureSampler.cpp

示例4: initializeQuad

    void Form::initializeQuad(Mesh* mesh)
    {
        // Release current model.
        SAFE_RELEASE(_quad);

        // Create the model
        _quad = Model::create(mesh);

        // Create the material
        Material* material = _quad->setMaterial("res/shaders/textured.vsh", "res/shaders/textured.fsh");

        // Set the common render state block for the material
        RenderState::StateBlock* stateBlock = _theme->getSpriteBatch()->getStateBlock();
        stateBlock->setDepthWrite(true);
        material->setStateBlock(stateBlock);

        // Bind the WorldViewProjection matrix
        material->setParameterAutoBinding("u_worldViewProjectionMatrix", RenderState::WORLD_VIEW_PROJECTION_MATRIX);

        // Create a FrameBuffer if necessary.
        if (!_frameBuffer)
        {
            _frameBuffer = FrameBuffer::create(_id.c_str());
        }

        // Use the FrameBuffer to texture the quad.
        if (!_frameBuffer->getRenderTarget())
        {
            RenderTarget* rt = RenderTarget::create(_id.c_str(), _bounds.width, _bounds.height);
            _frameBuffer->setRenderTarget(rt);
            SAFE_RELEASE(rt);
        }

        Texture::Sampler* sampler = Texture::Sampler::create(_frameBuffer->getRenderTarget()->getTexture());
        sampler->setWrapMode(Texture::CLAMP, Texture::CLAMP);
        material->getParameter("u_texture")->setValue(sampler);
        material->getParameter("u_textureRepeat")->setValue(Vector2::one());
        material->getParameter("u_textureTransform")->setValue(Vector2::zero());

        SAFE_RELEASE(sampler);
    }
开发者ID:Jaegermeiste,项目名称:GamePlay,代码行数:41,代码来源:Form.cpp

示例5: lua_TextureSampler_setWrapMode

int lua_TextureSampler_setWrapMode(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 3:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
            {
                // Get parameter 1 off the stack.
                Texture::Wrap param1 = (Texture::Wrap)lua_enumFromString_TextureWrap(luaL_checkstring(state, 2));

                // Get parameter 2 off the stack.
                Texture::Wrap param2 = (Texture::Wrap)lua_enumFromString_TextureWrap(luaL_checkstring(state, 3));

                Texture::Sampler* instance = getInstance(state);
                instance->setWrapMode(param1, param2);
                
                return 0;
            }
            else
            {
                lua_pushstring(state, "lua_TextureSampler_setWrapMode - Failed to match the given parameters to a valid function signature.");
                lua_error(state);
            }
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 3).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:Brashworks,项目名称:GamePlay,代码行数:41,代码来源:lua_TextureSampler.cpp

示例6: lua_TextureSampler_setFilterMode

int lua_TextureSampler_setFilterMode(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 3:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                lua_type(state, 2) == LUA_TNUMBER &&
                lua_type(state, 3) == LUA_TNUMBER)
            {
                // Get parameter 1 off the stack.
                Texture::Filter param1 = (Texture::Filter)luaL_checkint(state, 2);

                // Get parameter 2 off the stack.
                Texture::Filter param2 = (Texture::Filter)luaL_checkint(state, 3);

                Texture::Sampler* instance = getInstance(state);
                instance->setFilterMode(param1, param2);
                
                return 0;
            }

            lua_pushstring(state, "lua_TextureSampler_setFilterMode - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 3).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:faustgames-ru,项目名称:AndroidWallpapers,代码行数:39,代码来源:lua_TextureSampler.cpp

示例7: setUnlitMaterialTexture

void LightSample::setUnlitMaterialTexture(Model* model, const char* texturePath, bool mipmap)
{
    Material* material = model->setMaterial("res/shaders/textured.vert", "res/shaders/textured.frag", "DIRECTIONAL_LIGHT_COUNT 1");
    material->setParameterAutoBinding("u_worldViewProjectionMatrix", "WORLD_VIEW_PROJECTION_MATRIX");

    // Load the texture from file.
    Texture::Sampler* sampler = material->getParameter("u_diffuseTexture")->setValue(texturePath, mipmap);
    if (mipmap)
	{
        sampler->setFilterMode(Texture::LINEAR_MIPMAP_LINEAR, Texture::LINEAR);
	}
	else
	{
        sampler->setFilterMode(Texture::LINEAR, Texture::LINEAR);
	}
	sampler->setWrapMode(Texture::CLAMP, Texture::CLAMP);
    material->getStateBlock()->setCullFace(true);
    material->getStateBlock()->setDepthTest(true);
    material->getStateBlock()->setDepthWrite(true);
	material->getStateBlock()->setBlend(true);
	material->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
	material->getStateBlock()->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
}
开发者ID:Divoo,项目名称:GamePlay,代码行数:23,代码来源:LightSample.cpp

示例8: loadGround

void BillboardSample::loadGround()
{
	// Just a basic plane for this sample
	Mesh* mesh = Mesh::createQuad(-(GROUND_WIDTH / 2.0f), -(GROUND_HEIGHT / 2.0f), GROUND_WIDTH, GROUND_HEIGHT);
	Node* node = Node::create();
	_ground = Model::create(mesh);
	SAFE_RELEASE(mesh);
	node->setDrawable(_ground);
    _scene->addNode(node);
	node->rotateX(MATH_DEG_TO_RAD(90));
	Effect* effect = Effect::createFromFile("res/shaders/textured.vert", "res/shaders/textured.frag", "TEXTURE_REPEAT");    
	Material* material = Material::create(effect); 
	material->getStateBlock()->setDepthTest(true);
	material->getStateBlock()->setBlend(false);
	Texture::Sampler* sampler = material->getParameter("u_diffuseTexture")->setValue("res/png/dirt.png", true);
	sampler->setFilterMode(Texture::LINEAR_MIPMAP_LINEAR, Texture::LINEAR);
	material->getParameter("u_textureRepeat")->setValue(Vector2(GROUND_REPEAT_TEXTURE, GROUND_REPEAT_TEXTURE));
	material->setParameterAutoBinding("u_worldViewProjectionMatrix", RenderState::WORLD_VIEW_PROJECTION_MATRIX);
	_ground->setMaterial(material);
	SAFE_RELEASE(material);
	SAFE_RELEASE(effect)
    SAFE_RELEASE(node);
}
开发者ID:03050903,项目名称:GamePlay,代码行数:23,代码来源:BillboardSample.cpp

示例9: lua_TextureSampler_getRefCount

int lua_TextureSampler_getRefCount(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 1:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA))
            {
                Texture::Sampler* instance = getInstance(state);
                unsigned int result = instance->getRefCount();

                // Push the return value onto the stack.
                lua_pushunsigned(state, result);

                return 1;
            }
            else
            {
                lua_pushstring(state, "lua_TextureSampler_getRefCount - Failed to match the given parameters to a valid function signature.");
                lua_error(state);
            }
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 1).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:Brashworks,项目名称:GamePlay,代码行数:36,代码来源:lua_TextureSampler.cpp

示例10: initialize

void CreateSceneSample::initialize()
{
    // Create the font for drawing the framerate.
    _font = Font::create("res/ui/arial.gpb");

    // Create a new empty scene.
    _scene = Scene::create();

    // Create the camera.
    Camera* camera = Camera::createPerspective(45.0f, getAspectRatio(), 1.0f, 10.0f);
    Node* cameraNode = _scene->addNode("camera");

    // Attach the camera to a node. This determines the position of the camera.
    cameraNode->setCamera(camera);

    // Make this the active camera of the scene.
    _scene->setActiveCamera(camera);
    SAFE_RELEASE(camera);

    // Move the camera to look at the origin.
    cameraNode->translate(0, 1, 5);
    cameraNode->rotateX(MATH_DEG_TO_RAD(-11.25f));

    // Create a white light.
    Light* light = Light::createDirectional(0.75f, 0.75f, 0.75f);
    Node* lightNode = _scene->addNode("light");
    lightNode->setLight(light);
    // Release the light because the node now holds a reference to it.
    SAFE_RELEASE(light);
    lightNode->rotateX(MATH_DEG_TO_RAD(-45.0f));

    // Create the cube mesh and model.
    Mesh* cubeMesh = createCubeMesh();
    Model* cubeModel = Model::create(cubeMesh);
    // Release the mesh because the model now holds a reference to it.
    SAFE_RELEASE(cubeMesh);

    // Create the material for the cube model and assign it to the first mesh part.
    Material* material = cubeModel->setMaterial("res/shaders/textured.vert", "res/shaders/textured.frag", "DIRECTIONAL_LIGHT_COUNT 1");

    // These parameters are normally set in a .material file but this example sets them programmatically.
    // Bind the uniform "u_worldViewProjectionMatrix" to use the WORLD_VIEW_PROJECTION_MATRIX from the scene's active camera and the node that the model belongs to.
    material->setParameterAutoBinding("u_worldViewProjectionMatrix", "WORLD_VIEW_PROJECTION_MATRIX");
    material->setParameterAutoBinding("u_inverseTransposeWorldViewMatrix", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX");
    // Set the ambient color of the material.
    material->getParameter("u_ambientColor")->setValue(Vector3(0.2f, 0.2f, 0.2f));

    // Bind the light's color and direction to the material.
    material->getParameter("u_directionalLightColor[0]")->setValue(lightNode->getLight()->getColor());
    material->getParameter("u_directionalLightDirection[0]")->bindValue(lightNode, &Node::getForwardVectorWorld);

    // Load the texture from file.
    Texture::Sampler* sampler = material->getParameter("u_diffuseTexture")->setValue("res/png/crate.png", true);
    sampler->setFilterMode(Texture::LINEAR_MIPMAP_LINEAR, Texture::LINEAR);
    material->getStateBlock()->setCullFace(true);
    material->getStateBlock()->setDepthTest(true);
    material->getStateBlock()->setDepthWrite(true);

    _cubeNode = _scene->addNode("cube");
    _cubeNode->setModel(cubeModel);
    _cubeNode->rotateY(MATH_PIOVER4);
    SAFE_RELEASE(cubeModel);
}
开发者ID:1timmy,项目名称:GamePlay,代码行数:63,代码来源:CreateSceneSample.cpp

示例11: ActiveObject

ActiveTexture::ActiveTexture(const GLuint u, Texture::Sampler& s)
	: ActiveObject(*s.GetTexture()), unit(u), samplerObject(&s), ownsSampler(false)
{
	samplerObject->Bind(unit);
}
开发者ID:Nadrin,项目名称:CUBE,代码行数:5,代码来源:texture.cpp

示例12: loadRenderState


//.........这里部分代码省略.........
            GP_ASSERT(renderState->getParameter(name));
            renderState->getParameter(name)->setValue(properties->getFloat());
            break;
        case Properties::VECTOR2:
            {
                Vector2 vector2;
                if (properties->getVector2(NULL, &vector2))
                {
                    GP_ASSERT(renderState->getParameter(name));
                    renderState->getParameter(name)->setValue(vector2);
                }
            }
            break;
        case Properties::VECTOR3:
            {
                Vector3 vector3;
                if (properties->getVector3(NULL, &vector3))
                {
                    GP_ASSERT(renderState->getParameter(name));
                    renderState->getParameter(name)->setValue(vector3);
                }
            }
            break;
        case Properties::VECTOR4:
            {
                Vector4 vector4;
                if (properties->getVector4(NULL, &vector4))
                {
                    GP_ASSERT(renderState->getParameter(name));
                    renderState->getParameter(name)->setValue(vector4);
                }
            }
            break;
        case Properties::MATRIX:
            {
                Matrix matrix;
                if (properties->getMatrix(NULL, &matrix))
                {
                    GP_ASSERT(renderState->getParameter(name));
                    renderState->getParameter(name)->setValue(matrix);
                }
            }
            break;
        default:
            {
                // Assume this is a parameter auto-binding.
                renderState->setParameterAutoBinding(name, properties->getString());
            }
            break;
        }
    }

    // Iterate through all child namespaces searching for samplers and render state blocks.
    Properties* ns;
    while ((ns = properties->getNextNamespace()))
    {
        if (strcmp(ns->getNamespace(), "sampler") == 0)
        {
            // Read the texture uniform name.
            name = ns->getId();
            if (strlen(name) == 0)
            {
                GP_ERROR("Texture sampler is missing required uniform name.");
                continue;
            }

            // Get the texture path.
            const char* path = ns->getString("path");
            if (path == NULL || strlen(path) == 0)
            {
                GP_ERROR("Texture sampler '%s' is missing required image file path.", name);
                continue;
            }

            // Read texture state (booleans default to 'false' if not present).
            bool mipmap = ns->getBool("mipmap");
            Texture::Wrap wrapS = parseTextureWrapMode(ns->getString("wrapS"), Texture::REPEAT);
            Texture::Wrap wrapT = parseTextureWrapMode(ns->getString("wrapT"), Texture::REPEAT);
            Texture::Filter minFilter = parseTextureFilterMode(ns->getString("minFilter"), mipmap ? Texture::NEAREST_MIPMAP_LINEAR : Texture::LINEAR);
            Texture::Filter magFilter = parseTextureFilterMode(ns->getString("magFilter"), Texture::LINEAR);

            // Set the sampler parameter.
            GP_ASSERT(renderState->getParameter(name));
            Texture::Sampler* sampler = renderState->getParameter(name)->setValue(path, mipmap);
            if (sampler)
            {
                sampler->setWrapMode(wrapS, wrapT);
                sampler->setFilterMode(minFilter, magFilter);
            }
        }
        else if (strcmp(ns->getNamespace(), "renderState") == 0)
        {
            while ((name = ns->getNextProperty()))
            {
                GP_ASSERT(renderState->getStateBlock());
                renderState->getStateBlock()->setState(name, ns->getString());
            }
        }
    }
}
开发者ID:AllenPestaluky,项目名称:GamePlay,代码行数:101,代码来源:Material.cpp

示例13: getTexture

Texture* ParticleEmitter::getTexture() const
{
    Texture::Sampler* sampler = _spriteBatch ? _spriteBatch->getSampler() : NULL;
    return sampler? sampler->getTexture() : NULL;
}
开发者ID:hgl888,项目名称:RuntimeCanvas,代码行数:5,代码来源:ParticleEmitter.cpp


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