MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / LoadFloors

Method LoadFloors

PanzerChasm/client/map_drawer_gl.cpp:983–1032  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

981}
982
983void MapDrawerGL::LoadFloors( const MapData& map_data )
984{
985 std::vector<FloorVertex> floors_vertices;
986 for( unsigned int floor_or_ceiling= 0u; floor_or_ceiling < 2u; floor_or_ceiling++ )
987 {
988 floors_geometry_info[ floor_or_ceiling ].first_vertex_number= floors_vertices.size();
989
990 const unsigned char* const in_data= floor_or_ceiling == 0u ? map_data.floor_textures : map_data.ceiling_textures;
991
992 for( unsigned int x= 0u; x < MapData::c_map_size; x++ )
993 for( unsigned int y= 0u; y < MapData::c_map_size; y++ )
994 {
995 const unsigned char texture_number= in_data[ x + y * MapData::c_map_size ];
996
997 if( texture_number == MapData::c_empty_floor_texture_id ||
998 texture_number == MapData::c_sky_floor_texture_id )
999 continue;
1000
1001 floors_vertices.resize( floors_vertices.size() + 6u );
1002 FloorVertex* v= floors_vertices.data() + floors_vertices.size() - 6u;
1003
1004 v[0].xy[0]= x ; v[0].xy[1]= y;
1005 v[1].xy[0]= x+1u; v[1].xy[1]= y;
1006 v[2].xy[0]= x+1u; v[2].xy[1]= y+1u;
1007 v[3].xy[0]= x ; v[3].xy[1]= y+1u;
1008
1009 v[0].texture_id= v[1].texture_id= v[2].texture_id= v[3].texture_id= texture_number;
1010 v[4]= v[0];
1011 v[5]= v[2];
1012 } // for xy
1013
1014 floors_geometry_info[ floor_or_ceiling ].vertex_count=
1015 floors_vertices.size() - floors_geometry_info[ floor_or_ceiling ].first_vertex_number;
1016 } // for floor and ceiling
1017
1018 floors_geometry_.VertexData(
1019 floors_vertices.data(),
1020 floors_vertices.size() * sizeof(FloorVertex),
1021 sizeof(FloorVertex) );
1022
1023 FloorVertex v;
1024
1025 floors_geometry_.VertexAttribPointer(
1026 0, 2, GL_UNSIGNED_BYTE, false,
1027 ((char*)v.xy) - ((char*)&v) );
1028
1029 floors_geometry_.VertexAttribPointerInt(
1030 1, 1, GL_UNSIGNED_BYTE,
1031 ((char*)&v.texture_id) - ((char*)&v) );
1032}
1033
1034void MapDrawerGL::LoadWalls( const MapData& map_data )
1035{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected