Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub genVBO( byref model as model_struct )
- with model
- redim .vIndex( ubound(.surfaces) )
- redim .vNormal( ubound(.vertices) )
- redim .vUv( ubound(.vertices) )
- redim .vCol( ubound(.vertices) )
- for s as integer = 0 to ubound(.surfaces)
- for t as integer = .surfaces(s).startID to .surfaces(s).endID
- for p as integer = 0 to 2
- with .surfaces(s)
- redim preserve .vertex_index( ubound(.vertex_index)+1 )
- .vertex_index( ubound(.vertex_index) ) = model.triangles(t).point_id(p)
- end with
- .vNormal( .triangles(t).point_id(p) ) = .triangles(t).normal
- .vUv( .triangles(t).point_id(p) ) = .triangles(t).uv(p)
- .vCol( .triangles(t).point_id(p) ) = vec3f( rnd*1, rnd*1, rnd*1 )
- next
- next
- next
- glGenBuffers( 1, @.VBO )
- glBindBuffer( GL_ARRAY_BUFFER, .VBO )
- glBufferData( GL_ARRAY_BUFFER, (ubound(.vertices)+1)*sizeof(nmathf.vec3f), @.vertices(0).x, GL_STATIC_DRAW )
- glGenBuffers( 1, @.normalVBO )
- glBindBuffer( GL_ARRAY_BUFFER, .normalVBO )
- glBufferData( GL_ARRAY_BUFFER, (ubound(.vNormal)+1)*sizeof(nmathf.vec3f), @.vNormal(0).x, GL_STATIC_DRAW )
- glGenBuffers( 1, @.uvVBO )
- glBindBuffer( GL_ARRAY_BUFFER, .uvVBO )
- glBufferData( GL_ARRAY_BUFFER, (ubound(.vUv)+1)*sizeof(nmathf.vec2f), @.vUv(0).x, GL_STATIC_DRAW )
- glGenBuffers( 1, @.colVBO )
- glBindBuffer( GL_ARRAY_BUFFER, .colVBO )
- glBufferData( GL_ARRAY_BUFFER, (ubound(.vCol)+1)*sizeof(nmathf.vec3f), @.vCol(0).x, GL_DYNAMIC_DRAW )
- for s as integer = 0 to ubound(.surfaces)
- glGenBuffers( 1, @.vIndex(s) )
- glBindBuffer( GL_ARRAY_BUFFER, .vIndex(s) )
- glBufferData( GL_ARRAY_BUFFER, (ubound(.surfaces(s).vertex_index)+1) * sizeof(uinteger), @.surfaces(s).vertex_index(0), GL_DYNAMIC_DRAW )
- next
- glBindBuffer( GL_ARRAY_BUFFER, 0 )
- end with
- end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement