Ejemplo n.º 1
0
    void begin()
    {
        // set-up matrices
        mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
        mRenderSystem->_setViewMatrix(Ogre::Matrix4::IDENTITY);

#if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0
        Ogre::OrientationMode orient = mWindow->getViewport(mActiveViewport)->getOrientationMode();
        mRenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY * Ogre::Quaternion(Ogre::Degree(orient * 90.f), Ogre::Vector3::UNIT_Z));
#else
        mRenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
#endif

        // initialise render settings
        mRenderSystem->setLightingEnabled(false);
        mRenderSystem->_setDepthBufferParams(false, false);
        mRenderSystem->_setDepthBias(0, 0);
        mRenderSystem->_setCullingMode(Ogre::CULL_NONE);
        mRenderSystem->_setFog(Ogre::FOG_NONE);
        mRenderSystem->_setColourBufferWriteEnabled(true, true, true, true);
        mRenderSystem->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM);
        mRenderSystem->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM);
        mRenderSystem->setShadingType(Ogre::SO_GOURAUD);

        // initialise texture settings
        mRenderSystem->_setTextureCoordCalculation(0, Ogre::TEXCALC_NONE);
        mRenderSystem->_setTextureCoordSet(0, 0);
        mRenderSystem->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
        mRenderSystem->_setTextureAddressingMode(0, mTextureAddressMode);
        mRenderSystem->_setTextureMatrix(0, Ogre::Matrix4::IDENTITY);
#if OGRE_VERSION < MYGUI_DEFINE_VERSION(1, 6, 0)
        mRenderSystem->_setAlphaRejectSettings(Ogre::CMPF_ALWAYS_PASS, 0);
#else
        mRenderSystem->_setAlphaRejectSettings(Ogre::CMPF_ALWAYS_PASS, 0, false);
#endif
        mRenderSystem->_setTextureBlendMode(0, mColorBlendMode);
        mRenderSystem->_setTextureBlendMode(0, mAlphaBlendMode);
        mRenderSystem->_disableTextureUnitsFrom(1);

        // enable alpha blending
        mRenderSystem->_setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);

        // always use wireframe
        // TODO: add option to enable wireframe mode in platform
        mRenderSystem->_setPolygonMode(Ogre::PM_SOLID);
    }
Ejemplo n.º 2
0
    void doRender(IVertexBuffer* _buffer, ITexture* _texture, size_t _count)
    {
        if (getManualRender())
        {
            begin();
            setManualRender(false);
        }

        // ADDED
        if (!mVertexProgramNoTexture)
            initShaders();

        if (_texture)
        {
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mVertexProgramOneTexture);
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mFragmentProgramOneTexture);
        }
        else
        {
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mVertexProgramNoTexture);
            Ogre::Root::getSingleton().getRenderSystem()->bindGpuProgram(mFragmentProgramNoTexture);
        }

        if (_texture)
        {
            OgreTexture* texture = static_cast<OgreTexture*>(_texture);
            Ogre::TexturePtr texture_ptr = texture->getOgreTexture();
            if (!texture_ptr.isNull())
            {
                mRenderSystem->_setTexture(0, true, texture_ptr);
                mRenderSystem->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
            }
        }

        OgreVertexBuffer* buffer = static_cast<OgreVertexBuffer*>(_buffer);
        Ogre::RenderOperation* operation = buffer->getRenderOperation();
        operation->vertexData->vertexCount = _count;

        mRenderSystem->_render(*operation);

        ++ mCountBatch;
    }