Kazar Posted February 28, 2010 Share Posted February 28, 2010 I saw the thread about the improved SSAO filter and decided to test out the old filter with the code (and assets) from the Post Processing tutorial. Alas, I ran into some errors so I edited the source a bit, like replacing exitapp with the method from 2.28 ProjectWizard and added RegisterAbstractPath to my SDK folder. What it all comes down to is this error: Unhandled exception at 0x00ccc9e8 in PostProcessing_test-Debug.exe: 0xC0000005: Access violation reading location 0x00000068. The app hangs at BindTexture -> CXX0030: Error: expression cannot be evaluated. Here is the source: #include "engine.h" int main(int argc, char** argv) { Initialize(); RegisterAbstractPath("D:/Leadwerks"); //Create a graphics context Graphics(800,600); //Create a world TWorld world=CreateWorld(); if (!world) { MessageBoxA(0,"Error","Failed to create world.",0); return Terminate(); } //Create a camera TCamera cam=CreateCamera(); MoveEntity(cam,Vec3(0,5,-5)); CameraClearMode(cam,BUFFER_DEPTH); //Create a render buffer for lighting TBuffer gbuffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); //Create a render buffer for post-processing effects TBuffer postbuffer=CreateBuffer(800,600,BUFFER_COLOR); //Create a directional light TLight light=CreateDirectionalLight(); RotateEntity(light,Vec3(45,45,0)); LoadScene("Scenes/scene.sbx"); //Create a skybox TWorld background=CreateWorld(); TMesh skybox=CreateCube(); TCamera skycam=CreateCamera(); FlipMesh(skybox); PaintEntity(skybox,LoadMaterial("abstract::skybox.mat")); SetWorld(world); TShader postfilter=LoadShader("abstract::postfilter.vert","abstract::postfilter_ssao.frag"); SetShaderVec2(postfilter,"camerarange",Vec2(0.1,1000)); TTexture noisetexture=LoadTexture("abstract::noise.bmp"); AmbientLight(Vec3(0.5)); EntityColor(light,Vec4(0.15)); TVec3 camrotation=Vec3(0); float mx=0; float my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); //Main loop while(!KeyHit(KEY_ESCAPE)) { //Camera look mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; RotateEntity(cam,camrotation); UpdateAppTime(); UpdateWorld(); SetBuffer(gbuffer); //Render the background RotateEntity(skycam,EntityRotation(cam)); SetWorld(background); RenderWorld(); //Render the world SetWorld(world); RenderWorld(); //Render lighting SetBuffer(postbuffer); RenderLights(gbuffer); //Draw image onscreen with postfilter applied SetBuffer(BackBuffer()); SetShader(postfilter); BindTexture(GetDepthBuffer(gbuffer),1); BindTexture(noisetexture,10); DrawImage(GetColorBuffer(postbuffer),0,GraphicsHeight(),GraphicsWidth(),-GraphicsHeight()); Flip(); } return Terminate(); } Quote Core i5-750 - GTX 460 1GB - 12GB DDR3 - Win 7 x64 Link to comment Share on other sites More sharing options...
Canardia Posted February 28, 2010 Share Posted February 28, 2010 You should use Framework, the tutorials are meant to understand how the engine works internally, but not meant for real games. The texture slot meanings have also changed since the tutorials were written. So your code using Framework would look like: #include "engine.h" int main(int argc, char** argv) { Initialize(); RegisterAbstractPath("D:/Leadwerks"); //Create a graphics context Graphics(800,600); //Create a framework TFramework fw=CreateFramework(); TCamera cam=GetLayerCamera(GetFrameworkLayer(0)); MoveEntity(cam,Vec3(0,5,-5)); //Create a directional light TLight light=CreateDirectionalLight(); RotateEntity(light,Vec3(45,45,0)); LoadScene("Scenes/scene.sbx"); SetSkybox(LoadMaterial("abstract::skybox.mat")); SetSSAO(1); AmbientLight(Vec3(0.5)); EntityColor(light,Vec4(0.15)); TVec3 camrotation=Vec3(0); float mx=0; float my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); //Main loop while(!KeyHit(KEY_ESCAPE)) { //Camera look mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; RotateEntity(cam,camrotation); UpdateFramework(); RenderFramework(); Flip(0); } return Terminate(); } Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Kazar Posted February 28, 2010 Author Share Posted February 28, 2010 Does LE 2.28 include Framework? I'm getting 2.3 as soon as Josh processes my order. Quote Core i5-750 - GTX 460 1GB - 12GB DDR3 - Win 7 x64 Link to comment Share on other sites More sharing options...
Canardia Posted February 28, 2010 Share Posted February 28, 2010 Yes, but it's a bit different than in LE 2.3, since it's made with C++ source files. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.