mdl_submesh submesh;
};
-#if 0
-GLuint tex_dual_noise;
-#endif
-
static void scene_init( scene *pscene )
{
pscene->verts = NULL;
v3_fill( pscene->bbx[0], 999999.9f );
v3_fill( pscene->bbx[1], -999999.9f );
-
-#if 0
- static int noise_ready = 0;
- if( !noise_ready )
- {
- noise_ready = 1;
-
- u8 *buf = malloc( 256*256*2 );
-
- for( int i=0; i<256*256; i++ )
- {
- u8 val = rand()&0xff;
- buf[i*2] = val;
- }
-
- for( int y=0; y<256; y++ )
- {
- for( int x=0; x<256; x++ )
- {
- u8 *pr = &buf[(y*256+x)*2],
- *pg = &buf[(((y+17)&0xff)*256+((x+37)&0xff))*2+1];
- *pg = *pr;
- }
- }
-
- /* TODO: This texture should be delted somewhere */
- glGenTextures( 1, &tex_dual_noise );
- glBindTexture( GL_TEXTURE_2D, tex_dual_noise );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RG, 256, 256, 0, GL_RG,
- GL_UNSIGNED_BYTE, buf );
-
- vg_tex2d_linear();
- vg_tex2d_repeat();
-
- free( buf );
- }
-#endif
}
/*
* Append a model into the scene with a given transform
*/
static void scene_add_submesh( scene *pscene, mdl_header *mdl,
- mdl_submesh *sm, m4x3f transform )
+ mdl_submesh *sm, m4x3f transform )
{
- pscene->verts = buffer_reserve( pscene->verts, pscene->vertex_count,
- &pscene->vertex_cap, sm->vertex_count, sizeof(mdl_vert) );
+ pscene->verts = buffer_reserve( pscene->verts, pscene->vertex_count,
+ &pscene->vertex_cap, sm->vertex_count, sizeof(mdl_vert) );
+
pscene->indices = buffer_reserve( pscene->indices, pscene->indice_count,
- &pscene->indice_cap, sm->indice_count, sizeof(u32) );
+ &pscene->indice_cap, sm->indice_count, sizeof(u32) );
m3x3f normal_matrix;
m3x3_copy( transform, normal_matrix );
static void scene_push_tri( scene *pscene, u32 tri[3] )
{
pscene->indices = buffer_reserve( pscene->indices, pscene->indice_count,
- &pscene->indice_cap, 3, sizeof(u32) );
+ &pscene->indice_cap, 3, sizeof(u32) );
u32 *dst = &pscene->indices[pscene->indice_count];
dst[0] = tri[0];
static void scene_push_vert( scene *pscene, mdl_vert *v )
{
pscene->verts = buffer_reserve( pscene->verts, pscene->vertex_count,
- &pscene->vertex_cap, 1, sizeof(mdl_vert) );
-
+ &pscene->vertex_cap, 1, sizeof(mdl_vert) );
pscene->verts[pscene->vertex_count ++] = *v;
}
&pscene->indice_cap, sizeof( mdl_vert ));
}
-__attribute__((warn_unused_result))
-static int scene_upload( scene *pscene )
+static void scene_upload( scene *pscene )
{
- if( ! mesh_upload( &pscene->mesh,
- pscene->verts, pscene->vertex_count,
- pscene->indices, pscene->indice_count ) )
- {
- return 0;
- }
+ mesh_upload( &pscene->mesh,
+ pscene->verts, pscene->vertex_count,
+ pscene->indices, pscene->indice_count );
vg_info( "Scene upload\n" );
vg_info( " indices:%u\n", pscene->indice_count );
vg_info( " verts:%u\n", pscene->vertex_count );
-
- return 1;
}
static void scene_bind( scene *pscene )
static void scene_free_offline_buffers( scene *pscene )
{
- free( pscene->verts );
- free( pscene->indices );
+ vg_free( pscene->verts );
+ vg_free( pscene->indices );
}
static void scene_free( scene *pscene )
{
scene_free_offline_buffers( pscene );
- /* TODO: bvh */
}
/*