|
@@ -19,50 +19,35 @@ public:
|
19
|
19
|
window->Activate();
|
20
|
20
|
|
21
|
21
|
window->AddEventHandler(this,
|
22
|
|
- DKFunction([this](const DKWindow::WindowEvent& e)
|
23
|
|
- {
|
24
|
|
- DKLog("WindowEvent: %d, origin:(%.1f, %.1f), size:(%.1f x %.1f), content:(%.1f, %.1f), scale:%f",
|
25
|
|
- e.type,
|
26
|
|
- e.windowRect.origin.x, e.windowRect.origin.y,
|
27
|
|
- e.windowRect.size.width, e.windowRect.size.height,
|
28
|
|
- e.contentRect.size.width, e.contentRect.size.height,
|
29
|
|
- e.contentScaleFactor);
|
30
|
|
- if (e.type == DKWindow::WindowEvent::WindowClosed)
|
31
|
|
- DKApplication::Instance()->Terminate(0);
|
32
|
|
- }),
|
33
|
|
- DKFunction([this](const DKWindow::KeyboardEvent& e)
|
34
|
|
- {
|
35
|
|
- if (e.type == DKWindow::KeyboardEvent::KeyUp)
|
36
|
|
- {
|
37
|
|
- if (e.key == DKVK_ENTER || e.key == DKVK_RETURN)
|
38
|
|
- {
|
39
|
|
- window->SetTextInputEnabled(0, !window->IsTextInputEnabled(0));
|
40
|
|
- DKLog("TextInput: %d", window->IsTextInputEnabled(0));
|
41
|
|
- }
|
42
|
|
- else if (e.key == DKVK_ESCAPE)
|
43
|
|
- {
|
44
|
|
- window->HoldMouse(0, !window->IsMouseHeld(0));
|
45
|
|
- DKLog("HoldMouse: %d", window->IsMouseHeld(0));
|
46
|
|
- }
|
47
|
|
- }
|
48
|
|
- DKLog("KeyboardEvent: %d, %ls, %ls",
|
49
|
|
- e.type,
|
50
|
|
- (const wchar_t*)DKWindow::GetVKName(e.key),
|
51
|
|
- (const wchar_t*)e.text);
|
52
|
|
- }),
|
53
|
|
- DKFunction([this](const DKWindow::MouseEvent& e)
|
54
|
|
- {
|
55
|
|
- if (e.type != DKWindow::MouseEvent::Move || window->IsMouseHeld(0))
|
56
|
|
- {
|
57
|
|
- DKLog("MouseEvent: %d, btn:%d, location:%.1f, %.1f, delta:%.1f, %.1f",
|
58
|
|
- e.type, e.buttonId, e.location.x, e.location.y, e.delta.x, e.delta.y);
|
59
|
|
- }
|
60
|
|
- })
|
61
|
|
- );
|
|
22
|
+ DKFunction([this](const DKWindow::WindowEvent& e) {
|
|
23
|
+ if (e.type == DKWindow::WindowEvent::WindowClosed)
|
|
24
|
+ DKApplication::Instance()->Terminate(0);
|
|
25
|
+ }),
|
|
26
|
+ NULL, NULL);
|
|
27
|
+
|
62
|
28
|
}
|
63
|
29
|
void OnTerminate(void) override
|
64
|
30
|
{
|
65
|
31
|
DKLog("%s", DKGL_FUNCTION_NAME);
|
|
32
|
+ DKLog("Memory Pool Statistics");
|
|
33
|
+ size_t numBuckets = DKMemoryPoolNumberOfBuckets();
|
|
34
|
+ DKMemoryPoolBucketStatus* buckets = new DKMemoryPoolBucketStatus[numBuckets];
|
|
35
|
+ DKMemoryPoolQueryAllocationStatus(buckets, numBuckets);
|
|
36
|
+ size_t usedBytes = 0;
|
|
37
|
+ for (int i = 0; i < numBuckets; ++i)
|
|
38
|
+ {
|
|
39
|
+ if (buckets[i].totalChunks > 0)
|
|
40
|
+ {
|
|
41
|
+ DKLog("--> %lu: allocated:%lu, reserved:%.1fKB. (usage:%.1f%%)",
|
|
42
|
+ buckets[i].chunkSize,
|
|
43
|
+ buckets[i].chunkSize * buckets[i].usedChunks,
|
|
44
|
+ double(buckets[i].chunkSize * (buckets[i].totalChunks - buckets[i].usedChunks)) / 1024.0,
|
|
45
|
+ double(buckets[i].usedChunks) / double(buckets[i].totalChunks) * 100.0);
|
|
46
|
+ usedBytes += buckets[i].chunkSize * buckets[i].usedChunks;
|
|
47
|
+ }
|
|
48
|
+ }
|
|
49
|
+ DKLog("MemoryPool Usage: %.1fMB / %.1fMB", double(usedBytes) / (1024 * 1024), double(DKMemoryPoolSize()) / (1024 * 1024));
|
|
50
|
+ delete[] buckets;
|
66
|
51
|
}
|
67
|
52
|
};
|
68
|
53
|
|