Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:17

0001 /**
0002 SGLFW_SOPTIX_Scene_test.cc
0003 ============================
0004 
0005 Started from SOPTIX_Scene_test.cc, a pure CUDA ppm render of optix triangles,
0006 added OpenGL interop viz for interactive view and parameter changing.
0007 
0008 Usage and impl::
0009 
0010     ~/o/sysrap/tests/SGLFW_SOPTIX_Scene_test.sh
0011     ~/o/sysrap/tests/SGLFW_SOPTIX_Scene_test.cc
0012 
0013 As this and alias are now installed can just use::
0014 
0015     SGLFW_SOPTIX_Scene_test.sh
0016     ssst.sh
0017 
0018 For a simpler non-encapsulated non-interactive OptiX only ppm render test, see::
0019 
0020     ~/o/sysrap/tests/SOPTIX_Scene_test.sh
0021     ~/o/sysrap/tests/SOPTIX_Scene_test.cc
0022 
0023 DONE: view maths for raytrace and rasterized now match each other quite closely
0024 
0025 **/
0026 
0027 #include "ssys.h"
0028 #include "SGLM.h"
0029 #include "SScene.h"
0030 
0031 #include "SGLFW.h"
0032 #include "SGLFW_Scene.h"
0033 #include "SGLFW_Evt.h"
0034 #include "SGLFW_SOPTIX.h"
0035 
0036 
0037 int main(int argc, char** argv)
0038 {
0039     bool DUMP = ssys::getenvbool("SGLFW_SOPTIX_Scene_test_DUMP");
0040 
0041     stree* tree = stree::Load();
0042     SScene* scene = SScene::Load() ;
0043     // HMM: ELV selection can now reduce what is loaded into SScene
0044     // BUT there is no such functionality for stree ?
0045     // There is potential for the inconsistency to cause issues ?
0046     if( tree == nullptr || scene == nullptr ) std::cerr
0047          << "SGLFW_SOPTIX_Scene_test.main"
0048          << " LOAD FAIL "
0049          << " tree " << ( tree ? "YES" : "NO " )
0050          << " scene " << ( scene ? "YES" : "NO " )
0051          << "\n"
0052          ;
0053 
0054     if( tree == nullptr || scene == nullptr ) return 0;
0055 
0056     if(DUMP) std::cout << scene->desc() ;
0057 
0058     SRecord* ar = SRecord::Load("$AFOLD", "$AFOLD_RECORD_SLICE" ) ;
0059     SRecord* br = SRecord::Load("$BFOLD", "$BFOLD_RECORD_SLICE" ) ;
0060     SGen* gs = SGen::Load("$AFOLD", "$AFOLD_GENSTEP_SLICE" );
0061 
0062     SGLM gm ;
0063     gm.setTreeScene(tree, scene);
0064     gm.setRecord( ar, br );
0065     gm.setGenstep( gs );
0066 
0067 
0068     if(ssys::is_under_ctest())
0069     {
0070         std::cout << argv[0] << " detected ssys::is_under_ctest so skip interactive renderloop popping up a window\n" ;
0071         return 0;
0072     }
0073 
0074 
0075     SGLFW gl(gm);
0076 
0077     SGLFW_Scene  sc(gl);
0078     SGLFW_Evt    ev(gl);
0079 
0080     std::cout << "[SGLFW_SOPTIX \n" ;
0081     SGLFW_SOPTIX ox(gl);
0082     std::cout << "]SGLFW_SOPTIX \n" ;
0083 
0084     while(gl.renderloop_proceed())
0085     {
0086         gl.renderloop_head();
0087         gl.handle_frame_hop();
0088 
0089         if(gm.option.M)
0090         {
0091             if( gm.toggle.cuda ) ox.render();
0092             else                 sc.render();
0093         }
0094         ev.render();
0095 
0096         gl.handle_snap();
0097         gl.renderloop_tail();
0098     }
0099     return 0 ;
0100 }
0101