Compare commits

..

4 Commits

Author SHA1 Message Date
Attila Uygun 41a1cfe6f5 tmp 2023-08-09 23:12:49 +02:00
Attila Uygun 92dbf5cd97 Add Platform::CreateMainWindow 2023-08-09 23:02:24 +02:00
Attila Uygun eb50e547b8 win log 2023-08-09 23:00:38 +02:00
Attila Uygun 2ac1520c9b tmp 2023-08-08 23:26:31 +02:00
4 changed files with 11 additions and 47 deletions

View File

@ -26,9 +26,7 @@ AudioMixer::AudioMixer()
#elif defined(__linux__)
audio_sink_{std::make_unique<AudioSinkAlsa>(this)} {
#elif defined(_WIN32)
// TODO: Implement AudioSinkWindows
audio_sink_{std::make_unique<AudioSinkNull>()},
audio_enabled_(false) {
audio_sink_{std::make_unique<AudioSinkNull>()} {
#endif
bool res = audio_sink_->Initialize();
CHECK(res) << "Failed to initialize audio sink.";

View File

@ -487,7 +487,6 @@ bool Engine::IsMobile() const {
}
void Engine::OnWindowCreated() {
if (renderer_)
renderer_->Initialize(platform_);
}

View File

@ -106,9 +106,8 @@ void Platform::Update() {
case ClientMessage: {
// WM_DELETE_WINDOW is the only registered type for now.
observer_->OnWindowDestroyed();
DestroyWindow();
should_exit_ = true;
return;
break;
}
case ConfigureNotify: {
XConfigureEvent xce = e.xconfigure;

View File

@ -6,8 +6,8 @@
// #include <memory>
//
#include "base/log.h"
#include "base/vecmath.h"
#include "engine/input_event.h"
// #include "base/vecmath.h"
// #include "engine/input_event.h"
#include "engine/platform/platform_observer.h"
using namespace base;
@ -20,22 +20,9 @@ Platform::Platform(HINSTANCE instance, int cmd_show)
: instance_(instance), cmd_show_(cmd_show) {
LOG(0) << "Initializing platform.";
root_path_ = ".\\";
data_path_ = ".\\";
shared_data_path_ = ".\\";
char dest[MAX_PATH];
memset(dest, 0, sizeof(dest));
if (GetModuleFileNameA(NULL, dest, MAX_PATH) > 0) {
std::string path = dest;
std::size_t last_slash_pos = path.find_last_of('\\');
if (last_slash_pos != std::string::npos)
path = path.substr(0, last_slash_pos + 1);
root_path_ = path;
data_path_ = path;
shared_data_path_ = path;
}
root_path_ = "./";
data_path_ = "./";
shared_data_path_ = "./";
LOG(0) << "Root path: " << root_path_.c_str();
LOG(0) << "Data path: " << data_path_.c_str();
@ -69,9 +56,12 @@ void Platform::CreateMainWindow() {
Platform::~Platform() {
LOG(0) << "Shutting down platform.";
DestroyWindow(wnd_);
}
void Platform::Update() {
DCHECK(!should_exit_);
MSG msg;
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
@ -122,28 +112,6 @@ LRESULT CALLBACK Platform::WndProc(HWND wnd,
platform->observer_->OnWindowDestroyed();
PostQuitMessage(0);
break;
case WM_MOUSEMOVE: {
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
auto input_event =
std::make_unique<InputEvent>(InputEvent::kDrag, 0, v);
platform->observer_->AddInputEvent(std::move(input_event));
} break;
case WM_LBUTTONDOWN: {
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
auto input_event =
std::make_unique<InputEvent>(InputEvent::kDragStart, 0, v);
platform->observer_->AddInputEvent(std::move(input_event));
} break;
case WM_LBUTTONUP: {
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
auto input_event =
std::make_unique<InputEvent>(InputEvent::kDragEnd, 0, v);
platform->observer_->AddInputEvent(std::move(input_event));
} break;
default:
return DefWindowProc(wnd, message, wparam, lparam);
}