Code: Select all
#include <Irrlicht.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// XEffects Includes
#include "XEffects/CScreenQuad.h"
#include "XEffects/CShaderPre.h"
#include "XEffects/effectWrapper.h"
#include "XEffects/effectWrapperCB.h"
#ifdef _MSC_VER
# pragma comment( lib, "Irrlicht.lib" )
#endif // _MSC_VER
#define USE_PUTS 1
#ifdef USE_PUTS
# define debug_out( x ) puts( x )
#else
# define debug_out( x ) fprintf( stderr, x )
#endif // USE_PUTS
using namespace irr;
using namespace irr::core;
using namespace irr::io;
using namespace irr::video;
using namespace irr::scene;
class EventReceiver : public IEventReceiver
{
public:
// This is the one method that we have to implement
virtual bool OnEvent(const SEvent& event)
{
// Remember whether each key is down or up
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
// This is used to check whether a key is being held down
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
EventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
// We use this array to store the current state of each key
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
int main( int argc, char **argv )
{
// Create the device, and get the usual pointers
IrrlichtDevice* device = createDevice( EDT_OPENGL, dimension2di( 800, 600 ), 32 );
if( !device )
{
debug_out( "Device could not be created" );
return( 0 );
}
IVideoDriver* videoDriver = device->getVideoDriver();
ISceneManager* sceneMgr = device->getSceneManager();
// Create the event receiver and add it to the device
EventReceiver* events = new EventReceiver();
device->setEventReceiver( events );
// Seed the random number generator
srand( time( NULL ) );
// Create an FPS camera
ICameraSceneNode* camera = sceneMgr->addCameraSceneNodeFPS(0,100,0.1f);
camera->setPosition( vector3df( 20, 10, -10) );
camera->setFarValue( 100 );
camera->setNearValue( 0.1f );
// Set the RTT size
dimension2d< s32 > screenRTT = !videoDriver->getVendorInfo().equals_ignore_case( "NVIDIA Corporation" ) ?
dimension2d< s32 >( 1204, 1024 ) : videoDriver->getScreenSize();
// Create the effect handler
effectHandler* effect = new effectHandler( device, dimension2di( 1024, 1024 ), "shaders", dimension2di( 0, 0 ) );
// Set the clear color to black
effect->setClearColour( SColor( 0x00FF0000 ) );
effect->enableDepthPass( true );
// Add a crap-load of cube nodes!
for( s32 i = 0; i < 6; ++ i )
{
for( s32 j = 0; j < 6; ++ j )
{
for( s32 k = 0; k < 6; ++ k )
{
ISceneNode* cube = sceneMgr->addCubeSceneNode( 4.0 );
cube->setPosition( vector3df( i * 4.0f + 2.0f , j * 5.0f + 1.0f, k * 6.0f + 3.0f ) );
cube->setRotation( vector3df( rand() % 360, rand() % 360, rand() % 360 ) );
cube->getMaterial( 0 ).setTexture( 0, videoDriver->getTexture( "media/wall.bmp" ) );
cube->getMaterial( 0 ).setFlag( EMF_LIGHTING, false );
effect->addNodeToDepthPass( cube );
}
}
}
// Create the post processing chain!!
s32 ssao, blurv, blurh, lightmod;
ssao = effect->addPostProcessingEffectFromFile( stringc( "shaders/SSAO.glsl" ) );
//blurv = effect->addPostProcessingEffectFromFile( stringc( "shaders/BlurVP.glsl" ) );
//blurh = effect->addPostProcessingEffectFromFile( stringc( "shaders/BlurHP.glsl" ) );
//lightmod = effect->addPostProcessingEffectFromFile( stringc( "shaders/LightModulate.glsl" ) );
// Retrieve the randomized vectors
ITexture* randomVectors = videoDriver->getTexture( "media/SSAORandomVectors.bmp" );
// Add it for the SSAO post-process
effect->setPostProcessingUserTexture( randomVectors );
bool on = true;
while( device->run() )
{
if( device->isWindowActive() )
{
videoDriver->beginScene( true, true, SColor( 0x00FF0000 ) );
effect->update();
//videoDriver->draw2DImage( effect->getDepthMapTexture(), position2di( 0,0 ) );
videoDriver->endScene();
if( events->IsKeyDown( KEY_KEY_O ) && on == false )
{
on = true;
ssao = effect->addPostProcessingEffectFromFile( stringc( "shaders/SSAO.glsl" ) );
//blurv = effect->addPostProcessingEffectFromFile( stringc( "shaders/BlurVP.glsl" ) );
//blurh = effect->addPostProcessingEffectFromFile( stringc( "shaders/BlurHP.glsl" ) );
lightmod = effect->addPostProcessingEffectFromFile( stringc( "shaders/LightModulate.glsl" ) );
}
if( events->IsKeyDown( KEY_KEY_P ) && on == true )
{
on = false;
effect->removePostProcessingEffect( ssao );
effect->removePostProcessingEffect( blurv );
effect->removePostProcessingEffect( blurh );
effect->removePostProcessingEffect( lightmod );
}
}
}
delete effect;
device->drop();
return( 0 );
}
That's the error i get loading .vert and .frag files as you say: