| 2139 | } |
| 2140 | |
| 2141 | void MapDrawerGL::DrawEffectsSprites( |
| 2142 | const MapState& map_state, |
| 2143 | const m_Mat4& view_matrix, |
| 2144 | const m_Vec3& camera_position ) |
| 2145 | { |
| 2146 | SortEffectsSprites( map_state.GetSpriteEffects(), camera_position, sorted_sprites_ ); |
| 2147 | |
| 2148 | sprites_shader_.Bind(); |
| 2149 | |
| 2150 | for( const MapState::SpriteEffect* const sprite_ptr : sorted_sprites_ ) |
| 2151 | { |
| 2152 | const MapState::SpriteEffect& sprite= *sprite_ptr; |
| 2153 | |
| 2154 | const GameResources::SpriteEffectDescription& sprite_description= game_resources_->sprites_effects_description[ sprite.effect_id ]; |
| 2155 | const ObjSprite& sprite_picture= game_resources_->effects_sprites[ sprite.effect_id ]; |
| 2156 | |
| 2157 | glActiveTexture( GL_TEXTURE0 + 0 ); |
| 2158 | glBindTexture( GL_TEXTURE_2D_ARRAY, sprites_textures_arrays_[ sprite.effect_id ] ); |
| 2159 | |
| 2160 | if( !sprite_description.light_on ) |
| 2161 | map_light_.GetFloorLightmap().Bind(1); |
| 2162 | else |
| 2163 | map_light_.GetFullbrightLightmapDummy().Bind(1); |
| 2164 | |
| 2165 | const m_Vec3 vec_to_sprite= sprite.pos - camera_position; |
| 2166 | float sprite_angles[2]; |
| 2167 | VecToAngles( vec_to_sprite, sprite_angles ); |
| 2168 | |
| 2169 | m_Mat4 rotate_z, rotate_x, shift_mat, scale_mat; |
| 2170 | rotate_z.RotateZ( sprite_angles[0] - Constants::half_pi ); |
| 2171 | rotate_x.RotateX( sprite_angles[1] ); |
| 2172 | shift_mat.Translate( sprite.pos ); |
| 2173 | |
| 2174 | const float additional_scale= ( sprite_description.half_size ? 0.5f : 1.0f ) / 128.0f; |
| 2175 | scale_mat.Scale( |
| 2176 | m_Vec3( |
| 2177 | float(sprite_picture.size[0]) * additional_scale, |
| 2178 | 1.0f, |
| 2179 | float(sprite_picture.size[1]) * additional_scale ) ); |
| 2180 | |
| 2181 | sprites_shader_.Uniform( "view_matrix", scale_mat * rotate_x * rotate_z * shift_mat * view_matrix ); |
| 2182 | sprites_shader_.Uniform( "tex", int(0) ); |
| 2183 | sprites_shader_.Uniform( "lightmap", int(1) ); |
| 2184 | sprites_shader_.Uniform( "frame", sprite.frame ); |
| 2185 | sprites_shader_.Uniform( "lightmap_coord", sprite.pos.xy() / float(MapData::c_map_size) ); |
| 2186 | |
| 2187 | glDrawArrays( GL_TRIANGLES, 0, 6 ); |
| 2188 | } |
| 2189 | } |
| 2190 | |
| 2191 | void MapDrawerGL::DrawSky( const m_Mat4& view_rotation_matrix ) |
| 2192 | { |
nothing calls this directly
no test coverage detected