mp-sfml/main.cc

42 lines
930 B
C++
Raw Normal View History

2024-07-25 15:46:49 +08:00
#include <cstdio>
2024-06-18 10:04:50 +08:00
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
2024-06-18 11:16:30 +08:00
#include <spdlog/spdlog.h>
2024-07-25 15:46:49 +08:00
#include "UtilTool.h"
2024-09-09 13:20:59 +08:00
#include "mediaService.h"
2024-06-18 10:04:50 +08:00
2024-07-25 15:46:49 +08:00
constexpr int CLIENT_WIDTH = 800;
constexpr int CLIENT_HEIGHT = 600;
2024-06-18 10:04:50 +08:00
2024-07-25 15:46:49 +08:00
int main(int argc, char** argv){
2024-09-09 13:20:59 +08:00
// spdlog::info("Current WorkDir Is: {}",argv[0]);
2024-07-25 15:46:49 +08:00
if(argc != 2){
spdlog::error("Usage: mp filename ");
return 0;
}
2024-09-09 13:20:59 +08:00
MediaService mediaService(argv[1], CLIENT_WIDTH, CLIENT_HEIGHT);
2024-07-25 15:46:49 +08:00
sf::RenderWindow window(sf::VideoMode(CLIENT_WIDTH, CLIENT_HEIGHT), "mp");
2024-06-18 10:04:50 +08:00
bool running = true;
while(running){
sf::Event event;
while(window.pollEvent(event)){
if(event.type == sf::Event::Closed){
running = false;
}
if(event.type == sf::Event::KeyPressed){
if(event.key.code == sf::Keyboard::Escape){
running = false;
}
}
2024-06-18 10:04:50 +08:00
}
window.clear();
2024-09-09 13:20:59 +08:00
window.draw(mediaService.GetSprite());
2024-06-18 10:04:50 +08:00
window.display();
}
return 0;
}