Skip to content

Commit

Permalink
add a keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
khang06 committed May 26, 2020
1 parent 7cac4ce commit 4faa36c
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 114 deletions.
6 changes: 5 additions & 1 deletion Chikara/Main.cpp
Expand Up @@ -51,7 +51,7 @@ void Main::initWindow()
glfwInit(); //Init glfw
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); //Set the glfw api to GLFW_NO_API because we are using Vulkan
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); //Change the ability to resize the window
r.window = glfwCreateWindow(width, height, "Chikara", nullptr, nullptr); //Now we create the window
r.window = glfwCreateWindow(default_width, default_height, "Chikara", nullptr, nullptr); //Now we create the window
glfwSetWindowUserPointer(r.window, &r);
glfwSetFramebufferSizeCallback(r.window, r.framebufferResizeCallback);
}
Expand Down Expand Up @@ -89,6 +89,7 @@ void Main::initVulkan()
r.createImGuiCommandBuffers();
r.createSyncObjects();
r.initImGui();
r.PrepareKeyboard();
}

auto timer = std::chrono::steady_clock();
Expand Down Expand Up @@ -173,6 +174,8 @@ void Main::recreateSwapChain()
glfwGetFramebufferSize(r.window, &width, &height);
glfwWaitEvents();
}
r.window_width = width;
r.window_height = height;

vkDeviceWaitIdle(r.device);

Expand All @@ -195,6 +198,7 @@ void Main::recreateSwapChain()
r.createCommandBuffers();
r.createImGuiCommandBuffers();
r.initImGui();
r.PrepareKeyboard();
}

#pragma endregion
Expand Down
3 changes: 2 additions & 1 deletion Chikara/Midi.cpp
Expand Up @@ -209,7 +209,8 @@ void Midi::loadMidi()

} catch(const char* e)
{
std::cout << "\n" << e;
MessageBoxA(NULL, "This MIDI doesn't appear to be valid.", "Fatal Error", MB_ICONERROR);
exit(1);
}
}

Expand Down
10 changes: 5 additions & 5 deletions Chikara/Misc.cpp
@@ -1,10 +1,10 @@
#include "Misc.h"

uint32_t encode_color(glm::vec3& col) {
return (((uint32_t)(col.r * 255) << 24) & 0xff000000) |
(((uint32_t)(col.g * 255) << 16) & 0xff0000) |
(((uint32_t)(col.b * 255) << 8) & 0xff00) |
0xFF;
uint32_t encode_color(glm::vec3 col) {
return ((0xFF << 24) & 0xff000000) |
(((uint32_t)(col.b * 255) << 16) & 0xff0000) |
(((uint32_t)(col.g * 255) << 8) & 0xff00) |
((uint32_t)(col.r * 255) & 0xff);
}

glm::vec3 decode_color(uint32_t col) {
Expand Down
2 changes: 1 addition & 1 deletion Chikara/Misc.h
Expand Up @@ -5,5 +5,5 @@
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

uint32_t encode_color(glm::vec3& col);
uint32_t encode_color(glm::vec3 col);
glm::vec3 decode_color(uint32_t col);

0 comments on commit 4faa36c

Please sign in to comment.