抽象多媒体类, 修复gtest问题
This commit is contained in:
17
main.cc
17
main.cc
@@ -4,29 +4,20 @@
|
||||
#include <SFML/Window.hpp>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include "UtilTool.h"
|
||||
#include "mediaService.h"
|
||||
|
||||
constexpr int CLIENT_WIDTH = 800;
|
||||
constexpr int CLIENT_HEIGHT = 600;
|
||||
|
||||
|
||||
int main(int argc, char** argv){
|
||||
spdlog::info("Current WorkDir Is: {}",argv[0]);
|
||||
// spdlog::info("Current WorkDir Is: {}",argv[0]);
|
||||
if(argc != 2){
|
||||
spdlog::error("Usage: mp filename ");
|
||||
return 0;
|
||||
}
|
||||
if(!UtilTool::CheckFileIsImage(argv[1])){
|
||||
spdlog::info("Unsupport File Type: {}",argv[1]);
|
||||
return 0;
|
||||
}
|
||||
sf::Texture texture;
|
||||
texture.loadFromFile(argv[1]);
|
||||
MediaService mediaService(argv[1], CLIENT_WIDTH, CLIENT_HEIGHT);
|
||||
sf::RenderWindow window(sf::VideoMode(CLIENT_WIDTH, CLIENT_HEIGHT), "mp");
|
||||
sf::Sprite sprite;
|
||||
sprite.setTexture(texture);
|
||||
auto imgSize = texture.getSize();
|
||||
auto scale = std::min(static_cast<float>(CLIENT_WIDTH)/imgSize.x,static_cast<float>(CLIENT_HEIGHT)/imgSize.y);
|
||||
sprite.setScale(scale, scale);
|
||||
bool running = true;
|
||||
|
||||
while(running){
|
||||
@@ -43,7 +34,7 @@ int main(int argc, char** argv){
|
||||
|
||||
}
|
||||
window.clear();
|
||||
window.draw(sprite);
|
||||
window.draw(mediaService.GetSprite());
|
||||
window.display();
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user