Cartoon Shader (Basic) C++ sample program

Greetings!

You’ll find the Cartoon Shader (Basic) C++ sample program, filed in directory `cartoon_shader’, here:
github.com/drivird/drunken-octo-robot.git

I’ve also fully implemented the following Python classes in C++:
FilterManager --> CFilterManager
CommonFilters --> CCommonFilters

I hope you find it useful and of course, constructive critics are always welcome :slight_smile:

Cheers!

Fantastic work, thanks!

:slight_smile:

hi, your c++ samples are fantastic and mostly working fine.

this one crashes on me though on startup.

 	libpanda_d.dll!LVecBase3f::operator[](int i=2)  Line 137 + 0xc bytes	C++
>	Cartoon_Shader.exe!CFilterManager::resize_buffers()  Line 520 + 0xd bytes	C++
 	Cartoon_Shader.exe!CFilterManager::call_resize_buffers(const Event * eventPtr=0x035dfff4, void * dataPtr=0x002aee64)  Line 557	C++
 	libpanda_d.dll!EventHandler::dispatch_event(const Event * event=0x035dfff4)  Line 90 + 0x24 bytes	C++
 	libpanda_d.dll!EventHandler::process_events()  Line 44 + 0x37 bytes	C++
 	libp3framework_d.dll!PandaFramework::task_event(GenericAsyncTask * task=0x00c2f010, void * data=0x002afb68)  Line 1564 + 0xe bytes	C++
 	libpanda_d.dll!GenericAsyncTask::do_task()  Line 76 + 0x1b bytes	C++
 	libpanda_d.dll!AsyncTask::unlock_and_do_task()  Line 455 + 0xf bytes	C++
 	libpanda_d.dll!AsyncTaskChain::service_one_task(AsyncTaskChain::AsyncTaskChainThread * thread=0x00000000)  Line 770 + 0xf bytes	C++
 	libpanda_d.dll!AsyncTaskChain::do_poll()  Line 1306	C++
 	libpanda_d.dll!AsyncTaskManager::poll()  Line 547	C++
 	libp3framework_d.dll!PandaFramework::do_frame(Thread * current_thread=0x0352a3fc)  Line 844 + 0xe bytes	C++
 	libp3framework_d.dll!PandaFramework::main_loop()  Line 859 + 0x13 bytes	C++
 	Cartoon_Shader.exe!main(int argc=1, char * * argv=0x035cd508)  Line 49 + 0xe bytes	C++
 	Cartoon_Shader.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes	C
 	Cartoon_Shader.exe!mainCRTStartup()  Line 403	C
 	kernel32.dll!74d133aa() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!771f9ef2() 	
 	ntdll.dll!771f9ec5() 	

in particular in

// Resize all buffers to match the size of the window.
void CFilterManager::resize_buffers()
   {
   for(unsigned int i = 0; i < m_buffers.size(); ++i)
      {
      const LVecBase3f& size = m_sizes[i];
      LVecBase2n xysize = get_scaled_size(size[0], size[1], size[2]);
      // Note: python is set_size()!?
      m_buffers[i]->set_size_and_recalc(xysize.x, xysize.y);
      }
   }

the content of m_buffers seems to be garbage.
(I am running a debug version of panda)

Thanks for reporting this bug. I could only reproduce it with binaries built using MSVC. Nevertheless, it is fixed.

cool :slight_smile:

I’ll try download your example again

odd I have cleaned my solution and made a complete rebuild but I keep getting

1>Linking...
1>cFilterManager.obj : error LNK2005: "public: __thiscall CCommonFilters::CCommonFilters(class GraphicsOutput *,class NodePath)" (??0CCommonFilters@@QAE@PAVGraphicsOutput@@VNodePath@@@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "private: class Shader const * __thiscall CCommonFilters::load_shader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?load_shader@CCommonFilters@@ABEPBVShader@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: void __thiscall CCommonFilters::cleanup(void)" (?cleanup@CCommonFilters@@QAEXXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::reconfigure(bool,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reconfigure@CCommonFilters@@QAE_N_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "private: void __thiscall CCommonFilters::update(void)" (?update@CCommonFilters@@AAEXXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_cartoon_ink(float)" (?set_cartoon_ink@CCommonFilters@@QAE_NM@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_cartoon_ink(void)" (?del_cartoon_ink@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: __thiscall CCommonFilters::SetBloomParameters::SetBloomParameters(void)" (??0SetBloomParameters@CCommonFilters@@QAE@XZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_bloom(struct CCommonFilters::SetBloomParameters const &)" (?set_bloom@CCommonFilters@@QAE_NABUSetBloomParameters@1@@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_bloom(void)" (?del_bloom@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_half_pixel_shift(void)" (?set_half_pixel_shift@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_half_pixel_shift(void)" (?del_half_pixel_shift@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_view_glow(void)" (?set_view_glow@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_view_glow(void)" (?del_view_glow@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_inverted(void)" (?set_inverted@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_inverted(void)" (?del_inverted@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: __thiscall CCommonFilters::SetVolumetricLightingParameters::SetVolumetricLightingParameters(class NodePath)" (??0SetVolumetricLightingParameters@CCommonFilters@@QAE@VNodePath@@@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_volumetric_lighting(struct CCommonFilters::SetVolumetricLightingParameters const &)" (?set_volumetric_lighting@CCommonFilters@@QAE_NABUSetVolumetricLightingParameters@1@@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_volumetric_lighting(void)" (?del_volumetric_lighting@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_blur_sharpen(float)" (?set_blur_sharpen@CCommonFilters@@QAE_NM@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_blur_sharpen(void)" (?del_blur_sharpen@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: __thiscall CCommonFilters::SetAmbientOcclusionParameters::SetAmbientOcclusionParameters(void)" (??0SetAmbientOcclusionParameters@CCommonFilters@@QAE@XZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::set_ambient_occlusion(struct CCommonFilters::SetAmbientOcclusionParameters const &)" (?set_ambient_occlusion@CCommonFilters@@QAE_NABUSetAmbientOcclusionParameters@1@@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: bool __thiscall CCommonFilters::del_ambient_occlusion(void)" (?del_ambient_occlusion@CCommonFilters@@QAE_NXZ) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "private: static enum AsyncTask::DoneStatus __cdecl CCommonFilters::call_update(class GenericAsyncTask *,void *)" (?call_update@CCommonFilters@@CA?AW4DoneStatus@AsyncTask@@PAVGenericAsyncTask@@PAX@Z) already defined in cCommonFilters.obj
1>cFilterManager.obj : error LNK2005: "public: static char const * const CCommonFilters::CARTOON_BODY" (?CARTOON_BODY@CCommonFilters@@2PBDB) already defined in cCommonFilters.obj
1>cCommonFilters.obj : error LNK2019: unresolved external symbol "public: __thiscall CFilterManager::CFilterManager(class GraphicsOutput *,class NodePath,int,int)" (??0CFilterManager@@QAE@PAVGraphicsOutput@@VNodePath@@HH@Z) referenced in function "public: __thiscall CCommonFilters::CCommonFilters(class GraphicsOutput *,class NodePath)" (??0CCommonFilters@@QAE@PAVGraphicsOutput@@VNodePath@@@Z)
1>cFilterManager.obj : error LNK2001: unresolved external symbol "public: __thiscall CFilterManager::CFilterManager(class GraphicsOutput *,class NodePath,int,int)" (??0CFilterManager@@QAE@PAVGraphicsOutput@@VNodePath@@HH@Z)
1>cCommonFilters.obj : error LNK2019: unresolved external symbol "public: void __thiscall CFilterManager::cleanup(void)" (?cleanup@CFilterManager@@QAEXXZ) referenced in function "public: void __thiscall CCommonFilters::cleanup(void)" (?cleanup@CCommonFilters@@QAEXXZ)
1>cFilterManager.obj : error LNK2001: unresolved external symbol "public: void __thiscall CFilterManager::cleanup(void)" (?cleanup@CFilterManager@@QAEXXZ)
1>cCommonFilters.obj : error LNK2019: unresolved external symbol "public: class NodePath __thiscall CFilterManager::render_quad_into(struct CFilterManager::RenderQuadIntoParameters const &)" (?render_quad_into@CFilterManager@@QAE?AVNodePath@@ABURenderQuadIntoParameters@1@@Z) referenced in function "public: bool __thiscall CCommonFilters::reconfigure(bool,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reconfigure@CCommonFilters@@QAE_N_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>cFilterManager.obj : error LNK2001: unresolved external symbol "public: class NodePath __thiscall CFilterManager::render_quad_into(struct CFilterManager::RenderQuadIntoParameters const &)" (?render_quad_into@CFilterManager@@QAE?AVNodePath@@ABURenderQuadIntoParameters@1@@Z)
1>cCommonFilters.obj : error LNK2019: unresolved external symbol "public: __thiscall CFilterManager::RenderQuadIntoParameters::RenderQuadIntoParameters(void)" (??0RenderQuadIntoParameters@CFilterManager@@QAE@XZ) referenced in function "public: bool __thiscall CCommonFilters::reconfigure(bool,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reconfigure@CCommonFilters@@QAE_N_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>cFilterManager.obj : error LNK2001: unresolved external symbol "public: __thiscall CFilterManager::RenderQuadIntoParameters::RenderQuadIntoParameters(void)" (??0RenderQuadIntoParameters@CFilterManager@@QAE@XZ)
1>cCommonFilters.obj : error LNK2019: unresolved external symbol "public: class NodePath __thiscall CFilterManager::render_scene_into(struct CFilterManager::RenderSceneIntoParameters const &)" (?render_scene_into@CFilterManager@@QAE?AVNodePath@@ABURenderSceneIntoParameters@1@@Z) referenced in function "public: bool __thiscall CCommonFilters::reconfigure(bool,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reconfigure@CCommonFilters@@QAE_N_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>cFilterManager.obj : error LNK2001: unresolved external symbol "public: class NodePath __thiscall CFilterManager::render_scene_into(struct CFilterManager::RenderSceneIntoParameters const &)" (?render_scene_into@CFilterManager@@QAE?AVNodePath@@ABURenderSceneIntoParameters@1@@Z)
1>cCommonFilters.obj : error LNK2019: unresolved external symbol "public: __thiscall CFilterManager::RenderSceneIntoParameters::RenderSceneIntoParameters(void)" (??0RenderSceneIntoParameters@CFilterManager@@QAE@XZ) referenced in function "public: bool __thiscall CCommonFilters::reconfigure(bool,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?reconfigure@CCommonFilters@@QAE_N_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>cFilterManager.obj : error LNK2001: unresolved external symbol "public: __thiscall CFilterManager::RenderSceneIntoParameters::RenderSceneIntoParameters(void)" (??0RenderSceneIntoParameters@CFilterManager@@QAE@XZ)
1>toonMakerBasic.obj : error LNK2019: unresolved external symbol "public: void __thiscall CFilterManager::resize_buffers(void)" (?resize_buffers@CFilterManager@@QAEXXZ) referenced in function "private: static void __cdecl ToonMakerBasic::call_filters_manager_resize_buffers(class Event const *,void *)" (?call_filters_manager_resize_buffers@ToonMakerBasic@@CAXPBVEvent@@PAX@Z)
1>C:\Users\Chrys\Desktop\drunken-octo-robot-master\cartoon_shader\Debug\Cartoon_Shader.exe : fatal error LNK1120: 7 unresolved externals
1>Build log was saved at "file://c:\Users\Chrys\Desktop\drunken-octo-robot-master\cartoon_shader\Debug\BuildLog.htm"
1>Cartoon_Shader - 40 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I’ll see if I can figure out what’s going on when I get time.