先把glfw3.h里的KeyCode的定义抄到咱这里来。
在YOTO下创建KeyCode.h:
#pragma once
#ifdef YT_PLATFORM_WINDOWS
///从glfw3中拿的
#define YT_KEY_SPACE 32
#define YT_KEY_APOSTROPHE 39 /* ' */
#define YT_KEY_COMMA 44 /* , */
#define YT_KEY_MINUS 45 /* - */
#define YT_KEY_PERIOD 46 /* . */
#define YT_KEY_SLASH 47 /* / */
#define YT_KEY_0 48
#define YT_KEY_1 49
#define YT_KEY_2 50
#define YT_KEY_3 51
#define YT_KEY_4 52
#define YT_KEY_5 53
#define YT_KEY_6 54
#define YT_KEY_7 55
#define YT_KEY_8 56
#define YT_KEY_9 57
#define YT_KEY_SEMICOLON 59 /* ; */
#define YT_KEY_EQUAL 61 /* = */
#define YT_KEY_A 65
#define YT_KEY_B 66
#define YT_KEY_C 67
#define YT_KEY_D 68
#define YT_KEY_E 69
#define YT_KEY_F 70
#define YT_KEY_G 71
#define YT_KEY_H 72
#define YT_KEY_I 73
#define YT_KEY_J 74
#define YT_KEY_K 75
#define YT_KEY_L 76
#define YT_KEY_M 77
#define YT_KEY_N 78
#define YT_KEY_O 79
#define YT_KEY_P 80
#define YT_KEY_Q 81
#define YT_KEY_R 82
#define YT_KEY_S 83
#define YT_KEY_T 84
#define YT_KEY_U 85
#define YT_KEY_V 86
#define YT_KEY_W 87
#define YT_KEY_X 88
#define YT_KEY_Y 89
#define YT_KEY_Z 90
#define YT_KEY_LEFT_BRACKET 91 /* [ */
#define YT_KEY_BACKSLASH 92 /* \ */
#define YT_KEY_RIGHT_BRACKET 93 /* ] */
#define YT_KEY_GRAVE_ACCENT 96 /* ` */
#define YT_KEY_WORLD_1 161 /* non-US #1 */
#define YT_KEY_WORLD_2 162 /* non-US #2 */
/* Function keys */
#define YT_KEY_ESCAPE 256
#define YT_KEY_ENTER 257
#define YT_KEY_TAB 258
#define YT_KEY_BACKSPACE 259
#define YT_KEY_INSERT 260
#define YT_KEY_DELETE 261
#define YT_KEY_RIGHT 262
#define YT_KEY_LEFT 263
#define YT_KEY_DOWN 264
#define YT_KEY_UP 265
#define YT_KEY_PAGE_UP 266
#define YT_KEY_PAGE_DOWN 267
#define YT_KEY_HOME 268
#define YT_KEY_END 269
#define YT_KEY_CAPS_LOCK 280
#define YT_KEY_SCROLL_LOCK 281
#define YT_KEY_NUM_LOCK 282
#define YT_KEY_PRINT_SCREEN 283
#define YT_KEY_PAUSE 284
#define YT_KEY_F1 290
#define YT_KEY_F2 291
#define YT_KEY_F3 292
#define YT_KEY_F4 293
#define YT_KEY_F5 294
#define YT_KEY_F6 295
#define YT_KEY_F7 296
#define YT_KEY_F8 297
#define YT_KEY_F9 298
#define YT_KEY_F10 299
#define YT_KEY_F11 300
#define YT_KEY_F12 301
#define YT_KEY_F13 302
#define YT_KEY_F14 303
#define YT_KEY_F15 304
#define YT_KEY_F16 305
#define YT_KEY_F17 306
#define YT_KEY_F18 307
#define YT_KEY_F19 308
#define YT_KEY_F20 309
#define YT_KEY_F21 310
#define YT_KEY_F22 311
#define YT_KEY_F23 312
#define YT_KEY_F24 313
#define YT_KEY_F25 314
#define YT_KEY_KP_0 320
#define YT_KEY_KP_1 321
#define YT_KEY_KP_2 322
#define YT_KEY_KP_3 323
#define YT_KEY_KP_4 324
#define YT_KEY_KP_5 325
#define YT_KEY_KP_6 326
#define YT_KEY_KP_7 327
#define YT_KEY_KP_8 328
#define YT_KEY_KP_9 329
#define YT_KEY_KP_DECIMAL 330
#define YT_KEY_KP_DIVIDE 331
#define YT_KEY_KP_MULTIPLY 332
#define YT_KEY_KP_SUBTRACT 333
#define YT_KEY_KP_ADD 334
#define YT_KEY_KP_ENTER 335
#define YT_KEY_KP_EQUAL 336
#define YT_KEY_LEFT_SHIFT 340
#define YT_KEY_LEFT_CONTROL 341
#define YT_KEY_LEFT_ALT 342
#define YT_KEY_LEFT_SUPER 343
#define YT_KEY_RIGHT_SHIFT 344
#define YT_KEY_RIGHT_CONTROL 345
#define YT_KEY_RIGHT_ALT 346
#define YT_KEY_RIGHT_SUPER 347
#define YT_KEY_MENU 348
#endif // YT_PLATFORM_WINDOWS
MouseButtonCodes.h:和KeyCode.h一样作用,把GLFW改成自己的
#pragma once
#define YT_MOUSE_BUTTON_1 0
#define YT_MOUSE_BUTTON_2 1
#define YT_MOUSE_BUTTON_3 2
#define YT_MOUSE_BUTTON_4 3
#define YT_MOUSE_BUTTON_5 4
#define YT_MOUSE_BUTTON_6 5
#define YT_MOUSE_BUTTON_7 6
#define YT_MOUSE_BUTTON_8 7
#define YT_MOUSE_BUTTON_LAST YT_MOUSE_BUTTON_8
#define YT_MOUSE_BUTTON_LEFT YT_MOUSE_BUTTON_1
#define YT_MOUSE_BUTTON_RIGHT YT_MOUSE_BUTTON_2
#define YT_MOUSE_BUTTON_MIDDLE YT_MOUSE_BUTTON_3`
YOTO.h:
#pragma once
#include "YOTO/Application.h"
#include"YOTO/Layer.h"
#include "YOTO/Log.h"
#include"YOTO/Input.h"
#include"YOTO/KeyCode.h"
#include"YOTO/MouseButtonCodes.h"
#include"YOTO/ImGui/ImGuiLayer.h"
//入口点
#include"YOTO/EntryPoint.h"
SandboxApp.cpp:在ExampleLayer测试轮询和KeyCode
#include
#include
class ExampleLayer:public YOTO::Layer
{
public:
ExampleLayer()
:Layer("Example") {
}
void OnUpdate()override {
//YT_CLIENT_INFO("测试update");
if (YOTO::Input::IsKeyPressed(YT_KEY_TAB)) {
YT_CLIENT_INFO("ExampleLayerOnUpdate:TAB按下了");
}
}
void OnEvent(YOTO::Event& event)override {
if (event.GetEventType() == YOTO::EventType::KeyPressed) {
YOTO:: KeyPressedEvent& e = (YOTO::KeyPressedEvent&)event;
YT_CLIENT_TRACE("ExampleLayer:{0}",(char)e.GetKeyCode());
if (e.GetKeyCode()==YT_KEY_TAB) {
YT_CLIENT_INFO("ExampleLayerOnEvent:TAB按下了");
}
}
//YT_CLIENT_TRACE("SandBoxApp:测试event{0}", event);
}
private:
};
class Sandbox:public YOTO::Application
{
public:
Sandbox() {
PushLayer(new ExampleLayer());
PushLayer(new YOTO::ImGuiLayer());
}
~Sandbox() {
}
private:
};
YOTO::Application* YOTO::CreateApplication() {
printf("helloworld");
return new Sandbox();
}
明日继续更新数学和ImGui停靠和视口