29 //#include "stretchy_buffer.h"
31 int main( int argc
, char *argv
[] )
35 fs_set_gameinfo( "/home/harry/SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo/gameinfo.txt" );
37 printf( "read: %s\n", argv
[1] );
38 //vdf_node *node = vdf_open_file( argv[1] );
40 vmf_map
*map
= vmf_init( argv
[1], 1 );
42 // TODO: Make init/free codes
46 .fragments
= (csr_frag
*)csr_malloc( 1024*1024*sizeof(csr_frag
) ),
47 .bounds
= { -1000.f
, -1000.f
, 1000.f
, 1000.f
}
49 csr_rt_clear( &target
);
51 draw_vmf_group( &target
, map
, map
->root
, "tar_layout", NULL
, NULL
);
53 float *rgba_test
= (float *)csr_malloc( 1024*1024*sizeof(float)*3 );
55 for( int l
= 0; l
< 1024; l
++ )
57 for( int x
= 0; x
< 1024; x
++ )
59 float *dst
= &rgba_test
[ (l
*1024+x
)*3 ];
60 csr_frag
*src
= &target
.fragments
[ ((1023-l
)*1024+x
) ];
68 csr_32f_write( "hello.pfm", 1024, 1024, rgba_test
);
70 free( target
.fragments
);
79 solidgen_ctx_init( &solid_main );
81 vdf_node *world = vdf_next( node, "world", NULL );
83 vdf_foreach( world, "solid", brush )
85 solidgen_push( &solid_main, brush );
90 printf("Timer starts\n");
92 csr_frag *image = (csr_frag *)csr_malloc( 1024*1024*sizeof(csr_frag) );
93 clear_depth( image, 1024, 1024 );
95 for( int i = 0; i < csr_sb_count( solid_main.indices )/3; i ++ )
97 u32 * base = solid_main.indices + i*3;
101 tri[0] = solid_main.verts[ base[0] ];
102 tri[1] = solid_main.verts[ base[1] ];
103 tri[2] = solid_main.verts[ base[2] ];
105 draw_buffers( image, 1024, 1024, (v4f){ -1000.f, -1000.f, 1000.f, 1000.f }, tri, 1 );
108 printf("Timer ends \n");
110 double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
111 printf("Tracing took %f seconds to execute\n", time_taken);
113 float *rgba_test = (float *)csr_malloc( 1024*1024*sizeof(float)*3 );
115 for( int i = 0; i < 1024*1024; i ++ )
117 rgba_test[i*3+0] = image[i].qa;
118 rgba_test[i*3+1] = image[i].qb;
119 rgba_test[i*3+2] = image[i].depth;
122 csr_32f_write( "hello.pfm", 1024, 1024, rgba_test );
127 solidgen_to_obj( &solid_main, "hello.obj" );