mirror of https://github.com/auygun/kaliber.git
Compare commits
6 Commits
41a1cfe6f5
...
b292f423ba
Author | SHA1 | Date |
---|---|---|
Attila Uygun | b292f423ba | |
Attila Uygun | 2985fed3d4 | |
Attila Uygun | 6619cd368b | |
Attila Uygun | ba1e5cc681 | |
Attila Uygun | f8df7d86f6 | |
Attila Uygun | 6e952e511e |
|
@ -26,7 +26,9 @@ AudioMixer::AudioMixer()
|
|||
#elif defined(__linux__)
|
||||
audio_sink_{std::make_unique<AudioSinkAlsa>(this)} {
|
||||
#elif defined(_WIN32)
|
||||
audio_sink_{std::make_unique<AudioSinkNull>()} {
|
||||
// TODO: Implement AudioSinkWindows
|
||||
audio_sink_{std::make_unique<AudioSinkNull>()},
|
||||
audio_enabled_(false) {
|
||||
#endif
|
||||
bool res = audio_sink_->Initialize();
|
||||
CHECK(res) << "Failed to initialize audio sink.";
|
||||
|
|
|
@ -487,6 +487,7 @@ bool Engine::IsMobile() const {
|
|||
}
|
||||
|
||||
void Engine::OnWindowCreated() {
|
||||
if (renderer_)
|
||||
renderer_->Initialize(platform_);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,8 +106,9 @@ void Platform::Update() {
|
|||
case ClientMessage: {
|
||||
// WM_DELETE_WINDOW is the only registered type for now.
|
||||
observer_->OnWindowDestroyed();
|
||||
DestroyWindow();
|
||||
should_exit_ = true;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
case ConfigureNotify: {
|
||||
XConfigureEvent xce = e.xconfigure;
|
||||
|
|
|
@ -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,9 +20,22 @@ Platform::Platform(HINSTANCE instance, int cmd_show)
|
|||
: instance_(instance), cmd_show_(cmd_show) {
|
||||
LOG(0) << "Initializing platform.";
|
||||
|
||||
root_path_ = "./";
|
||||
data_path_ = "./";
|
||||
shared_data_path_ = "./";
|
||||
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;
|
||||
}
|
||||
|
||||
LOG(0) << "Root path: " << root_path_.c_str();
|
||||
LOG(0) << "Data path: " << data_path_.c_str();
|
||||
|
@ -56,12 +69,9 @@ 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) {
|
||||
|
@ -112,6 +122,28 @@ 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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue