OGRE1.8 crashes when using custom RenderQueueListner

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Hi,
thanks masterfalcon for giving me pointers in fixing my last issue. Really helps me a lot. I am now trying to implement GLES2.0 onto my current project as my studio wants to achieve better graphics (shaders and such). Currently as it stands, 1.8 works well with GLES1.1. However, when I switched to GLES2.0, my app crashes when my custom RenderQueueListener for our UI system tries to render. The RenderQueueListener is modified from the SpriteManager2d from the wiki. Here's what I did:

Code: Select all


Gui::Gui()
{
	sprWatermark_=0;
	wmFont_=0;
	wmText_=0;
	
	init(Graphics::GetSingleton()->getSceneManager(),Ogre::RENDER_QUEUE_OVERLAY, true);
	
}

void Gui::init(Ogre::SceneManager* sceneMan, Ogre::uint8 targetQueue, bool afterQueue)
{
	Gui::sceneMan=sceneMan;
	Gui::afterQueue=afterQueue;
	Gui::targetQueue=targetQueue;
	
	hardwareBuffer.setNull();
	
	sceneMan->addRenderQueueListener(this);
}

Gui::~Gui()
{	
	Clear();
	end();
}

Gui* Gui::GetSingleton()
{
    static Gui* gui = 0;
	
    if (gui == 0)
        gui = new Gui();
	
    return gui;
}


void Gui::end()
{
	if (!hardwareBuffer.isNull())
		destroyHardwareBuffer();
	
	sceneMan->removeRenderQueueListener(this);
}
void Gui::destroyHardwareBuffer()
{
	delete renderOp.vertexData;
	renderOp.vertexData=0;
	hardwareBuffer.setNull();
}

//------------------------------OGRE SPRITES RENDER QUEUE--------------------------------------
#pragma mark Sprites functions
void Gui::renderQueueStarted(
							 Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
{
	
	if (!afterQueue && queueGroupId==targetQueue)
	{
		renderBuffer();
	}
}

void Gui::renderQueueEnded(
						   Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
{
	
	if (afterQueue && queueGroupId==targetQueue)
	{
		renderBuffer();
	}
}

void Gui::renderBuffer()
{
	Ogre::RenderSystem* rs=Ogre::Root::getSingleton().getRenderSystem();
	std::list<Sprite*>::iterator currSpr, endSpr;
	
	VertexChunk thisChunk;
	std::list<VertexChunk> chunks;
	
	unsigned int newSize;
	
	std::list<Sprite*> rsprites;
	for (std::list<Sprite*>::iterator currSpr = sprites.begin(); currSpr != sprites.end(); currSpr++)
	{
		Sprite* tmp = *currSpr;
		if(!tmp->IsHidden())
		{
			rsprites.push_back(tmp);
		}
	}
	
	newSize=rsprites.size()*6;
	if (newSize<OGRE2D_MINIMAL_HARDWARE_BUFFER_SIZE)
		newSize=OGRE2D_MINIMAL_HARDWARE_BUFFER_SIZE;
	
	// grow hardware buffer if needed
	if (hardwareBuffer.isNull() || hardwareBuffer->getNumVertices()<newSize)
	{
		if (!hardwareBuffer.isNull())
			destroyHardwareBuffer();
		
		createHardwareBuffer(newSize);
	}
	
	if (rsprites.empty()) return;
	
	// write quads to the hardware buffer, and remember chunks
	float* buffer;
	float z=-1;
	
	buffer=(float*)hardwareBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
	
	endSpr=rsprites.end();
	currSpr=rsprites.begin();
	thisChunk.texHandle=(*currSpr)->texHandle;
	thisChunk.vertexCount=0;
	thisChunk.alphaVal = (*currSpr)->alpha_;
	thisChunk.colourVal = (*currSpr)->colour_;
	thisChunk.rotAngle = (*currSpr)->rotAngle_;
	
	while (currSpr!=endSpr)
	{
		if((*currSpr)->rotAngle_==0)
			//if(true)
		{
			// 1st point (left bottom)
			*buffer=(*currSpr)->relx1; buffer++;
			*buffer=(*currSpr)->rely1; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx1; buffer++;
			*buffer=(*currSpr)->ty1; buffer++;
			// 2st point (right top)
			*buffer=(*currSpr)->relx2; buffer++;
			*buffer=(*currSpr)->rely2; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx2; buffer++;
			*buffer=(*currSpr)->ty2; buffer++;
			// 3rd point (left top)
			*buffer=(*currSpr)->relx2; buffer++;
			*buffer=(*currSpr)->rely1; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx1; buffer++;
			*buffer=(*currSpr)->ty2; buffer++;
			
			// 4th point (left bottom)
			*buffer=(*currSpr)->relx1; buffer++;
			*buffer=(*currSpr)->rely1; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx1; buffer++;
			*buffer=(*currSpr)->ty1; buffer++;
			// 5th point (right bottom)
			*buffer=(*currSpr)->relx1; buffer++;
			*buffer=(*currSpr)->rely2; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx2; buffer++;
			*buffer=(*currSpr)->ty1; buffer++;
			// 6th point (right top)
			*buffer=(*currSpr)->relx2; buffer++;
			*buffer=(*currSpr)->rely2; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx2; buffer++;
			*buffer=(*currSpr)->ty2; buffer++;
		}else {
			// 1st point (left bottom)
			*buffer=(*currSpr)->bl.x; buffer++;
			*buffer=(*currSpr)->bl.y; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx1; buffer++;
			*buffer=(*currSpr)->ty1; buffer++;
			// 2st point (right top)
			*buffer=(*currSpr)->tr.x; buffer++;
			*buffer=(*currSpr)->tr.y; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx2; buffer++;
			*buffer=(*currSpr)->ty2; buffer++;
			// 3rd point (left top)
			*buffer=(*currSpr)->tl.x; buffer++;
			*buffer=(*currSpr)->tl.y; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx1; buffer++;
			*buffer=(*currSpr)->ty2; buffer++;
			
			// 4th point (left bottom)
			*buffer=(*currSpr)->bl.x; buffer++;
			*buffer=(*currSpr)->bl.y; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx1; buffer++;
			*buffer=(*currSpr)->ty1; buffer++;
			// 5th point (right bottom)
			*buffer=(*currSpr)->br.x; buffer++;
			*buffer=(*currSpr)->br.y; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx2; buffer++;
			*buffer=(*currSpr)->ty1; buffer++;
			// 6th point (right top)
			*buffer=(*currSpr)->tr.x; buffer++;
			*buffer=(*currSpr)->tr.y; buffer++;
			*buffer=z; buffer++;
			*buffer=(*currSpr)->tx2; buffer++;
			*buffer=(*currSpr)->ty2; buffer++;
		}
		
		// remember this chunk
		thisChunk.vertexCount+=6;
		//}
		currSpr++;
		
		if (currSpr==endSpr || thisChunk.texHandle!=(*currSpr)->texHandle || thisChunk.alphaVal!=(*currSpr)->alpha_ || thisChunk.colourVal!=(*currSpr)->colour_)
		{
			
			chunks.push_back(thisChunk);
			if (currSpr!=endSpr)
			{
				thisChunk.texHandle=(*currSpr)->texHandle;
				thisChunk.vertexCount=0;
				thisChunk.colourVal = (*currSpr)->colour_;
				thisChunk.alphaVal = (*currSpr)->alpha_;
				thisChunk.rotAngle = (*currSpr)->rotAngle_;
				thisChunk.relativex1 = (*currSpr)->relx1;
				thisChunk.relativey1 = (*currSpr)->rely1;
				thisChunk.relativex2 = (*currSpr)->relx2;
				thisChunk.relativey2 = (*currSpr)->rely2;
			}
		}
		
	}
	
	hardwareBuffer->unlock();
	
	
	
	// set up...
	prepareForRender();
	
	// do the real render!
	Ogre::TexturePtr tp;
	std::list<VertexChunk>::iterator currChunk, endChunk;
	
	endChunk=chunks.end();
	renderOp.vertexData->vertexStart=0;
	for (currChunk=chunks.begin(); currChunk!=endChunk; currChunk++)
	{
		prepareAlpha(currChunk->alphaVal);
		prepareColour(currChunk->colourVal);
		//prepareRotation(currChunk->rotAngle,currChunk->relativex1,currChunk->relativey1,currChunk->relativex2,currChunk->relativey2);
		renderOp.vertexData->vertexCount=currChunk->vertexCount;
		tp=Ogre::TextureManager::getSingleton().getByHandle(currChunk->texHandle);
		rs->_setTexture(0, true, tp->getName());
		rs->_render(renderOp);
		renderOp.vertexData->vertexStart+=currChunk->vertexCount;
	}
	rs->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
	// sprites go home!
	rsprites.clear();
}

void Gui::prepareAlpha(double aval)
{
	Ogre::LayerBlendModeEx alphaBlendMode;
	Ogre::RenderSystem* rs=Ogre::Root::getSingleton().getRenderSystem();
	
	
	alphaBlendMode.alphaArg1 = 0;
	alphaBlendMode.alphaArg2 = aval;
	alphaBlendMode.source1 = Ogre::LBS_TEXTURE;
	alphaBlendMode.source2 = Ogre::LBS_MANUAL;
	alphaBlendMode.blendType = Ogre::LBT_COLOUR;
	alphaBlendMode.operation = Ogre::LBX_MODULATE;
	alphaBlendMode.factor = aval;
	rs->_setTextureBlendMode(0, alphaBlendMode);
	rs->_setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL,0,true);
}

void Gui::prepareColour(Ogre::ColourValue cval)
{
	Ogre::LayerBlendModeEx colourBlendMode;
	Ogre::RenderSystem* rs=Ogre::Root::getSingleton().getRenderSystem();
	
	colourBlendMode.colourArg1 = Ogre::ColourValue::ZERO;
	colourBlendMode.colourArg2 = cval;
	colourBlendMode.source1 = Ogre::LBS_TEXTURE;
	colourBlendMode.source2 = Ogre::LBS_MANUAL;
	colourBlendMode.blendType = Ogre::LBT_COLOUR;
	colourBlendMode.operation = Ogre::LBX_MODULATE;
	colourBlendMode.factor = 1.0;
	rs->_setTextureBlendMode(0, colourBlendMode);		
}

void Gui::prepareForRender()
{
	Ogre::LayerBlendModeEx colorBlendMode;
	Ogre::LayerBlendModeEx alphaBlendMode;
	Ogre::TextureUnitState::UVWAddressingMode uvwAddressMode;
	
	Ogre::RenderSystem* rs=Ogre::Root::getSingleton().getRenderSystem();
	
	colorBlendMode.blendType=Ogre::LBT_COLOUR;
	colorBlendMode.source1=Ogre::LBS_TEXTURE;
	colorBlendMode.operation=Ogre::LBX_SOURCE1;
	
	// set alpha
	//LayerBlendModeEx_NativePtr alphaBlendMode = LayerBlendModeEx_NativePtr.Create();
	alphaBlendMode.alphaArg1 = 0;
	alphaBlendMode.alphaArg2 = 0.5;
	alphaBlendMode.source1 = Ogre::LBS_TEXTURE;
	alphaBlendMode.source2 = Ogre::LBS_MANUAL;
	alphaBlendMode.blendType = Ogre::LBT_ALPHA;
	alphaBlendMode.operation = Ogre::LBX_MODULATE;
	alphaBlendMode.factor = 1.0;
	rs->_setTextureBlendMode(0, alphaBlendMode);	
	
	//	alphaBlendMode.blendType=Ogre::LBT_ALPHA;
	//	alphaBlendMode.source1=Ogre::LBS_TEXTURE;
	//	alphaBlendMode.operation=Ogre::LBX_SOURCE1;
	
	uvwAddressMode.u=Ogre::TextureUnitState::TAM_CLAMP;
	uvwAddressMode.v=Ogre::TextureUnitState::TAM_CLAMP;
	uvwAddressMode.w=Ogre::TextureUnitState::TAM_CLAMP;
	
	rs->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS

	Ogre::Matrix3 rotmat;
	rotmat.FromAxisAngle(Ogre::Vector3(0,0,1), Ogre::Radian(Ogre::Degree(90)));
	Ogre::Matrix4 trans1;
	trans1.makeTrans(-1, -1, 0);
	Ogre::Matrix4 trans2;
	trans2.makeTrans(1, 1, 0);
    float ratio1;
    float ratio2;
    if (Graphics::GetSingleton()->GetDeviceMode() == Graphics::IPAD)
    {
        ratio1 = 1.3333333333f;
        ratio2 = 0.75f;
    }
    else if (Graphics::GetSingleton()->GetDeviceMode() == Graphics::IPHONE || Graphics::GetSingleton()->GetDeviceMode() == Graphics::IPHONE4)
    {
        ratio1 = 1.5f;
        ratio2 = 0.6666666666f;
    }
    Ogre::Matrix4 scalemat(ratio1,0,0,0,
                           0,ratio2,0,0,
                           0,0,0,0,
                           0,0,0,1);
	rs->_setViewMatrix(Ogre::Matrix4(rotmat)* trans2 * scalemat * trans1);
#endif
	rs->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
	
	rs->_setTextureMatrix(0, Ogre::Matrix4::IDENTITY);
	rs->_setTextureCoordSet(0, 0);
	rs->_setTextureCoordCalculation(0, Ogre::TEXCALC_NONE);
    std::cout << "Setting Texture unit filtering" << std::endl;
	rs->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT);
    std::cout << "Finish setting texture unit filtering" << std::endl;
	rs->_setTextureBlendMode(0, colorBlendMode);
	rs->_setTextureBlendMode(0, alphaBlendMode);
	rs->_setTextureAddressingMode(0, uvwAddressMode);
	rs->_disableTextureUnitsFrom(1);
	rs->setLightingEnabled(false);
	rs->_setFog(Ogre::FOG_NONE);
	rs->_setCullingMode(Ogre::CULL_NONE);
	rs->_setDepthBufferParams(false, false);
	rs->_setColourBufferWriteEnabled(true, true, true, false);
	rs->setShadingType(Ogre::SO_GOURAUD);
	rs->_setPolygonMode(Ogre::PM_SOLID);
	rs->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM);
	rs->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM);
	rs->_setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);
	rs->_setAlphaRejectSettings(Ogre::CMPF_ALWAYS_PASS, 0, true);
}


void Gui::createHardwareBuffer(unsigned int size)
{
	Ogre::VertexDeclaration* vd;
	
	renderOp.vertexData=new Ogre::VertexData;
	renderOp.vertexData->vertexStart=0;
	
	vd=renderOp.vertexData->vertexDeclaration;
	vd->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
	vd->addElement(0, Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3),
				   Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
	
	hardwareBuffer=Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
																				  vd->getVertexSize(0),
																				  size,// buffer size
																				  Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
																				  false);// use shadow buffer? no
	
	renderOp.vertexData->vertexBufferBinding->setBinding(0, hardwareBuffer);
	
	renderOp.operationType=Ogre::RenderOperation::OT_TRIANGLE_LIST;
	renderOp.useIndexes=false;
}

void Gui::spriteBltFull(Sprite* spr)
{
	Ogre::TexturePtr tp;
	
	tp=Ogre::TextureManager::getSingleton().getByName(spr->texturePath);
	spr->texHandle=tp->getHandle();
	
	sprites.push_back(spr);	
}


Apparently when I was using GLES2.0, it crashes at "rs->_render(renderOp);" under "renderBuffer()". Here's something that was printed in the log which does not occur in ES1.1

Code: Select all

OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureUnitFiltering(size_t, Ogre::FilterType, Ogre::FilterOptions) at line 1439 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureUnitFiltering(size_t, Ogre::FilterType, Ogre::FilterOptions) at line 1450 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureUnitFiltering(size_t, Ogre::FilterType, Ogre::FilterOptions) at line 1476 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureAddressingMode(size_t, const Ogre::TextureUnitState::UVWAddressingMode&) at line 766 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureAddressingMode(size_t, const Ogre::TextureUnitState::UVWAddressingMode&) at line 768 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
These messages bring me to my prepareForRender() function, which is the only place where I called rs->_setTextureUnitFiltering and rs->_setTextureAddressingMode.

Have I done anything which I am not supposed to do in GLES2.0. Any advice would be appreciated.

Thanks a million.
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

Those errors could still be occurring with GL ES 1.1. Logging of GL errors is still enabled for ES 2(you can disable it by setting GL_CHECK_ERROR to 0 in OgreGLES2Prerequisites.h). Do you happen to know where in _render it's crashing? I'm wondering if it's taking too long to render and causing a conflict with the OS for resources.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Hi,
I have managed to trace the 'culprit' for the crash: in GLES2RenderSystem::_render()

Code: Select all

GLSLESLinkProgram* linkProgram = GLSLESLinkProgramManager::getSingleton().getActiveLinkProgram();
apparently, GLSLESLinkProgramManager::getActiveLinkProgram() is returning a null object. Further probing revealed that it did not enter " if (mActiveVertexGpuProgram)" and "if (mActiveFragmentGpuProgram)". This result in an eventual return of a null object.

Any advice would be appreciated. Thanks
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

Take a look through your logs for any GLSL errors. Do you have a material listener set up for the RTSS? Unless you're using a custom shader, you need to make sure that the RTSS is set up with GL ES 2 since there is no fixed function pipeline.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Oh, that figures! Thanks a lot!
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Hi masterfalcon,
I managed to set up RTSS, but it still crashed at the same point, where there is no active link program. Here's how I set up the RTSS:

Code: Select all


    root_ = OGRE_NEW Ogre::Root;

    staticPluginLoader_->load();
    const Ogre::RenderSystemList& rs = root_->getAvailableRenderers();
    std::cout << "I have " << rs.size() << " render system" << std::endl;
    if (rs.size())
    {
        Ogre::RenderSystem* r = rs.at(0);
        root_->setRenderSystem(r);
        Ogre::ConfigOptionMap& cfg = r->getConfigOptions();
        for (Ogre::ConfigOptionMap::iterator itr = cfg.begin();
			 itr != cfg.end(); ++itr)
        {
        }
		std::ostringstream oss1;
		std::ostringstream oss2;
		oss1 << w << " x " << h;
		oss2 << s;
        r->setConfigOption("Full Screen", "Yes");
        r->setConfigOption("Video Mode", oss1.str());
		r->setConfigOption("Content Scaling Factor", oss2.str());
        r->setConfigOption("Orientation", "Landscape Left");
        r->setConfigOption("RTT Preferred Mode", "Copy");
        r->setConfigOption("FSAA", "4");
	}

	window_ = root_->initialise(true);

    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Ogre::macBundlePath(), "FileSystem", "General");
    sceneManager_ = root_->createSceneManager(Ogre::ST_GENERIC);
    initShader(sceneManager_);
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

and here's my initShader(SceneManager) code which is modified based on the post from http://www.ogre3d.org/forums/viewtopic. ... 83#p417656

Code: Select all

    if (Ogre::RTShader::ShaderGenerator::initialize())
    {
        currVPScene_ = sm;
        mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
        mShaderGenerator->addSceneManager(sm);
        Ogre::StringVector groupVector = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
        Ogre::StringVector::iterator itGroup = groupVector.begin();
        Ogre::StringVector::iterator itGroupEnd = groupVector.end();
        Ogre::String shaderCoreLibsPath;
        Ogre::String shaderCachePath;
        
        for (; itGroup != itGroupEnd; ++itGroup)
        {

            Ogre::ResourceGroupManager::LocationList resLocationsList = Ogre::ResourceGroupManager::getSingleton().getResourceLocationList(*itGroup);
            Ogre::ResourceGroupManager::LocationList::iterator it = resLocationsList.begin();
            Ogre::ResourceGroupManager::LocationList::iterator itEnd = resLocationsList.end();
            bool coreLibsFound = false;
            
            // Try to find the location of the core shader lib functions and use it
            // as shader cache path as well - this will reduce the number of generated files
            // when running from different directories.
            shaderCoreLibsPath = Ogre::macBundlePath() + "/";
            shaderCachePath = shaderCoreLibsPath;
            coreLibsFound = true;
            // Core libs path found in the current group.
            if (coreLibsFound) 
                break; 
        }
        
        // Core shader libs not found -> shader generating will fail.
        if (shaderCoreLibsPath.empty())	
        {
            return false;
        }
        shaderCachePath = Ogre::macCachePath();
        mMaterialMgrListener = new ShaderGeneratorTechniqueResolverListener(mShaderGenerator);				
        Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener);
        shaderInitialized = true;
        return true;
    }
But somehow it is still unable to detect any link program. Any advice would be appreciated.

Thanks!
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

Are there any GL or GLSL errors being reported? If so, what are they?
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

The strange thing is, none. the RTShader material is parsed without any error, which means that the RTSS should have init properly. The only error which I received is the ones in my first post:

Code: Select all

OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureUnitFiltering(size_t, Ogre::FilterType, Ogre::FilterOptions) at line 1439 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureUnitFiltering(size_t, Ogre::FilterType, Ogre::FilterOptions) at line 1450 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureUnitFiltering(size_t, Ogre::FilterType, Ogre::FilterOptions) at line 1476 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureAddressingMode(size_t, const Ogre::TextureUnitState::UVWAddressingMode&) at line 766 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureAddressingMode(size_t, const Ogre::TextureUnitState::UVWAddressingMode&) at line 768 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

Hmm, the only thing coming to mind right now is to maybe try changing your RTT mode from Copy to FBO. It performs much better and is better supported too.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Hmm..... FBO doesn't help either.

Here's what my log said:

Code: Select all

Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
ArchiveFactory for archive type EmbeddedZip registered.
DDS codec registering
FreeImage version: 3.15.0
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Supported formats: jpg,jif,jpeg,jpe,png,tga,targa,tif,tiff
PVRTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
plugins.cfg not found, automatic plugin loading disabled.
*-*-* OGRE Initialising
*-*-* Version 1.8.0unstable (Byatis)
Installing plugin: OpenGL ES 2.0 RenderSystem
OpenGL ES 2.x Rendering Subsystem created.
Plugin successfully installed
Installing plugin: Octree Scene Manager
Plugin successfully installed
Installing plugin: ParticleFX
Particle Emitter Type 'Point' registered
Particle Emitter Type 'Box' registered
Particle Emitter Type 'Ellipsoid' registered
Particle Emitter Type 'Cylinder' registered
Particle Emitter Type 'Ring' registered
Particle Emitter Type 'HollowEllipsoid' registered
Particle Affector Type 'LinearForce' registered
Particle Affector Type 'ColourFader' registered
Particle Affector Type 'ColourFader2' registered
Particle Affector Type 'ColourImage' registered
Particle Affector Type 'ColourInterpolator' registered
Particle Affector Type 'Scaler' registered
Particle Affector Type 'Rotator' registered
Particle Affector Type 'DirectionRandomiser' registered
Particle Affector Type 'DeflectorPlane' registered
Plugin successfully installed
Installing plugin: BSP Scene Manager
Plugin successfully installed
CPU Identifier & Features
-------------------------
 *   CPU ID: 
 *      VFP: no
 *     NEON: yes
-------------------------
GLES2RenderSystem::_createRenderWindow "OGRE Render Window", 768x1024 fullscreen  miscParams: FSAA=4 contentScalingFactor=1 displayFrequency=0 Hz orientation=Landscape Left 
iOS: Window created 768 x 1024 with backing store size 768 x 1024 using content scaling factor 1.0
GL_VERSION = OpenGL ES 2.0 IMGSGX543-58.6
GL_VENDOR = Imagination Technologies
GL_RENDERER = PowerVR SGX 543
GL_EXTENSIONS = GL_OES_depth_texture GL_OES_depth24 GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_EXT_read_format_bgra GL_EXT_shader_texture_lod GL_EXT_texture_filter_anisotropic GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_IMG_read_format GL_IMG_texture_compression_pvrtc 
EXT:GL_OES_depth_texture
EXT:GL_OES_depth24
EXT:GL_OES_fbo_render_mipmap
EXT:GL_OES_mapbuffer
EXT:GL_OES_packed_depth_stencil
EXT:GL_OES_rgb8_rgba8
EXT:GL_OES_standard_derivatives
EXT:GL_OES_texture_float
EXT:GL_OES_texture_half_float
EXT:GL_OES_vertex_array_object
EXT:GL_EXT_blend_minmax
EXT:GL_EXT_discard_framebuffer
EXT:GL_EXT_read_format_bgra
EXT:GL_EXT_shader_texture_lod
EXT:GL_EXT_texture_filter_anisotropic
EXT:GL_APPLE_framebuffer_multisample
EXT:GL_APPLE_rgb_422
EXT:GL_APPLE_texture_format_BGRA8888
EXT:GL_APPLE_texture_max_level
EXT:GL_IMG_read_format
EXT:GL_IMG_texture_compression_pvrtc
**************************************
*** OpenGL ES 2.x Renderer Started ***
**************************************
GLSL ES support detected
Registering ResourceManager for type GpuProgram
GL ES 2: Using FBOs for rendering to textures
FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 Packed-D24S8 
FBO PF_R5G6B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_B5G6R5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A4R4G4B4 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A1R5G5B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A8B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_B8G8R8A8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_X8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_X8B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
[GLES2] : Valid FBO targets PF_UNKNOWN PF_R5G6B5 PF_B5G6R5 PF_A4R4G4B4 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_A8B8G8R8 PF_B8G8R8A8 PF_X8R8G8B8 PF_X8B8G8R8 
RenderSystem capabilities
-------------------------
RenderSystem Name: OpenGL ES 2.x Rendering Subsystem
GPU Vendor: imagination technologies
Device Name: PowerVR SGX 543
Driver Version: 0.0.0.0
 * Fixed function pipeline: no
 * Hardware generation of mipmaps: yes
 * Texture blending: yes
 * Anisotropic texture filtering: yes
 * Dot product texture operation: yes
 * Cube mapping: yes
 * Hardware stencil buffer: no
 * Hardware vertex / index buffers: yes
 * Vertex programs: yes
 * Number of floating-point constants for vertex programs: 128
 * Number of integer constants for vertex programs: 128
 * Number of boolean constants for vertex programs: 128
 * Fragment programs: yes
 * Number of floating-point constants for fragment programs: 64
 * Number of integer constants for fragment programs: 64
 * Number of boolean constants for fragment programs: 64
 * Geometry programs: no
 * Number of floating-point constants for geometry programs: 0
 * Number of integer constants for geometry programs: 0
 * Number of boolean constants for geometry programs: 0
 * Supported Shader Profiles: cg glsles ps_2_0 vs_2_0
 * Texture Compression: yes
   - DXT: no
   - VTC: no
   - PVRTC: yes
 * Scissor Rectangle: yes
 * Hardware Occlusion Query: no
 * User clip planes: no
 * VET_UBYTE4 vertex element type: yes
 * Infinite far plane projection: yes
 * Hardware render-to-texture: yes
 * Floating point textures: no
 * Non-power-of-two textures: no
 * Volume textures: no
 * Multiple Render Targets: 1
   - With different bit depths: no
 * Point Sprites: yes
 * Extended point parameters: yes
 * Max Point Size: 0
 * Vertex texture fetch: no
 * Number of world matrices: 0
 * Number of texture units: 8
 * Stencil buffer depth: 0
 * Number of vertex blend matrices: 0
 * Render to Vertex Buffer : no
 * GL 1.5 without VBO workaround: no
 * Frame Buffer objects: yes
 * Frame Buffer objects (ARB extension): no
 * Frame Buffer objects (ATI extension): no
 * PBuffer support: no
 * GL 1.5 without HW-occlusion workaround: no
Registering ResourceManager for type Texture
DefaultWorkQueue('Root') initialising on thread 0x108bfb0.
DefaultWorkQueue('Root')::WorkerFunc - thread 0x1096460 starting.
DefaultWorkQueue('Root')::WorkerFunc - thread 0x1096380 starting.
Particle Renderer Type 'billboard' registered
SceneManagerFactory for type 'OctreeSceneManager' registered.
SceneManagerFactory for type 'BspSceneManager' registered.
Registering ResourceManager for type BspLevel
Added resource location '/var/mobile/Applications/DC33702B-FF9E-46A8-82C8-7B982044903F/myproject.app' of type 'FileSystem' to resource group 'General'
Parsing scripts for resource group Autodetect
Finished parsing scripts for resource group Autodetect
Creating resources for group Autodetect
Parsing scripts for resource group General
Parsing script RTShaderSystem.material
...Parsing other material and fontdef scripts...
Finished parsing scripts for resource group General
Creating resources for group General
Parsing scripts for resource group Internal
Finished parsing scripts for resource group Internal
Creating resources for group Internal
2011-03-28 09:52:13.217 myProject[332:707] Ignoring duplicate kGSEventApplicationLaunch GSEvent
[Switching to process 13059 thread 0x0]
[Switching to process 11779 thread 0x0]
[Switching to process 13059 thread 0x0]
End Of Line
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureUnitFiltering(size_t, Ogre::FilterType, Ogre::FilterOptions) at line 1476 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureAddressingMode(size_t, const Ogre::TextureUnitState::UVWAddressingMode&) at line 766 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
OpenGL error 0x0500 in virtual void Ogre::GLES2RenderSystem::_setTextureAddressingMode(size_t, const Ogre::TextureUnitState::UVWAddressingMode&) at line 768 in /Users/developer/projectsHg/be2/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp

[Switching to process 11779 thread 0x0]
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3 (8F191)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
(gdb) 
Strange enough, no GL or GLSL error reported. The initialization codes are still the same as the ones I posted
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

I noticed something in your log that caught my attention. Are you using any Cg programs? If not, perhaps try compiling Ogre with the Cg for GL ES 2 option turned off. It could be buggy and might be interfering with GLSL ES programs.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Oh, I din realize that as well. Will try it out. Thanks
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

while I was rebuilding my OGRE libraries, i was reading this post: http://www.ogre3d.org/forums/viewtopic.php?f=21&t=62795. I was wondering: could it be that I did not specify a fragment and vertex program? For ES2.0, I would need to specify these in the material files, right?
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

It's possible, though if no programs are defined the RTSS will generate them for you.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

If RTSS will automatically generate the programs for me, then that makes me wonder why it is not able to find any active link program in rendersystem::_render(). Even when I build OGRE without Cg support, I still encounter the same problem. With reference to the earlier codes I posted, is there any other thing which I need to do in order for RTSS to generate the vertex and fragment programs automatically???
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

Let's see. Add a material listener to resolve techniques (the sample browser has a fully working class that you can use for this), add your scene manager to the RTSS, and initialize the RTSS. SampleBrowser.h has all the code necessary to do it, just look for USE_RTSHADER_SYSTEM in the code.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

ok, will do~
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

I did a comparison between what I did in my project and what SampleBrowser.h did. Aside from the initalizeShader where I did it slightly different from the SampleBrowser, I realized that there is this segment of code which I do not have in mine:

Code: Select all

			if(mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION) == false)
			{
				//newViewport->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
				
				// creates shaders for base material BaseWhite using the RTSS
				Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);				
				baseWhite->setLightingEnabled(false);
				mShaderGenerator->createShaderBasedTechnique(
					"BaseWhite", 
					Ogre::MaterialManager::DEFAULT_SCHEME_NAME, 
					Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
			    mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
					"BaseWhite");
				baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
				baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
				baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
				baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());

				// creates shaders for base material BaseWhiteNoLighting using the RTSS
				mShaderGenerator->createShaderBasedTechnique(
					"BaseWhiteNoLighting", 
					Ogre::MaterialManager::DEFAULT_SCHEME_NAME, 
					Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
			    mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
					"BaseWhiteNoLighting");
				Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
				baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
				baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
				baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
				baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
			}

is this segment of code necessary???
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by masterfalcon »

I don't think it is necessary, but it couldn't hurt to have it in there for debugging.
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Ok, out of curiosity, I stripped my custom renderQueueListener from the project, everything runs just fine in ES2.0. I managed to render a 3D scene with no crash at all. Which makes me wonder what have gone wrong in my renderQueuelistener. I suspect that it might have something to do with my prepareForRender() method from the code segments in my very first post of the topic.

The renderQueueListener was adapted from the spriteManager2D from the wiki and we have been using it as our UI engine. Any further advice would be appreciated.
elisagroup
Gnoblar
Posts: 9
Joined: Sat May 07, 2011 11:03 pm
x 2

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by elisagroup »

Hi Guys,
I'm also using the similar code adapted from the one posted on wiki for gui rendering and getting the exact same error described above.
DuracellRabbid, did you by chance managed to fix it?
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

Hi,
I have given out trying to find a solution for it. My team has switched to UIKit for that purposes as this makes our UI independent of the rendering engine as well.
elisagroup
Gnoblar
Posts: 9
Joined: Sat May 07, 2011 11:03 pm
x 2

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by elisagroup »

For anyone who might come across this thread... the solution was to remove the following lines from prepareForRender()
rs->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM);
rs->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM);

It was disabling shaders generated by RT Shader system. Now I feel silly it took me so long to figure out this
DuracellRabbid
Kobold
Posts: 36
Joined: Fri Jun 11, 2010 4:23 am

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by DuracellRabbid »

well, I tried to remove them, but it does not work for me anyway
elisagroup
Gnoblar
Posts: 9
Joined: Sat May 07, 2011 11:03 pm
x 2

Re: OGRE1.8 crashes when using custom RenderQueueListner

Post by elisagroup »

The solution i posted above worked well in my previous project. I tried to reuse the same code in my current project( 3d RTS game ) and got a blank screen instead. I then tried to use custom shaders instead of RTSS generated ones and it finally worked for me...

add this to the header file of your sprite manager class:

Code: Select all

    Ogre::HighLevelGpuProgramPtr vertProg;
    Ogre::HighLevelGpuProgramPtr fragProg;
Load shaders in your sprite manager initialization method

Code: Select all

    vertProg = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("SimpleTexturingNoLightsVP",
                                                                              Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                                              "glsles",
                                                                              Ogre::GPT_VERTEX_PROGRAM);
    vertProg->setSourceFile( "SimpleTexturingNoLightsVP.glsles" );
    vertProg->load();
    
    fragProg = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("SimpleTexturingNoLightsFP",
                                                                              Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                                              "glsles",
                                                                              Ogre::GPT_FRAGMENT_PROGRAM);
    fragProg->setSourceFile( "SimpleTexturingNoLightsFP.glsles" );
    fragProg->load();
SimpleTexturingNoLightsVP.glsles

Code: Select all

#version 100

precision mediump int;
precision mediump float;

attribute vec4 position;
attribute vec4 uv0;

varying vec4 outUV0;

/*
  Basic texturing vertex program for GLSL ES
*/
void main()
{
	gl_Position = position;
	outUV0 = uv0;
}

SimpleTexturingNoLightsFP.glsles

Code: Select all

#version 100

precision mediump int;
precision mediump float;

uniform sampler2D sampler;

varying vec4 outUV0;

/*
  Basic texturing fragment program for GLSL ES
*/
void main()
{
	gl_FragColor = texture2D(sampler, outUV0.xy);
}

in prepareForRender() remove(comment out) the following lines

Code: Select all

rs->unbindGpuProgram(Ogre::GPT_FRAGMENT_PROGRAM);
rs->unbindGpuProgram(Ogre::GPT_VERTEX_PROGRAM);
Add the below calls instead:

Code: Select all

 rs->bindGpuProgram( vertProg->_getBindingDelegate() );
 rs->bindGpuProgram( fragProg->_getBindingDelegate() );
That's all I needed to get it working with GLES 2.0 renderer.

Hope it helps someone
Post Reply