-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.cpp
More file actions
82 lines (60 loc) · 2.04 KB
/
Main.cpp
File metadata and controls
82 lines (60 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "src/App.h"
#include "assert.h"
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>
vulkanApp App;
void CursorPositionCallback(GLFWwindow* window, double xpos, double ypos)
{
App.MouseMove((float)xpos, (float)ypos);
}
void MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
{
App.MouseAction(button, action, mods);
}
void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
{
App.Scroll((float)yoffset);
}
void WindowSizeCallback(GLFWwindow* Window, int Width, int Height)
{
App.Resize(Width, Height);
}
void KeyCallback(GLFWwindow* Window, int Key, int Scancode, int Action, int Mods)
{
App.KeyEvent(Key, Action);
}
void CursorPositionCallback(GLFWwindow* window, double xpos, double ypos);
void MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
void WindowSizeCallback(GLFWwindow* Window, int Width, int Height);
void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
int main(int argc, char* argv[])
{
if(argc == 1) return 0;
std::string ModelFile = argv[1];
float ModelSize = 1.0f;
if(argc>=3) ModelSize = std::stof(argv[2]);
int Width = 1920;
int Height = 1080;
GLFWwindow *Window;
int rc = glfwInit();
assert(rc);
glfwWindowHint( GLFW_CLIENT_API, GLFW_NO_API );
Window = glfwCreateWindow(Width, Height, "Gralib", 0, 0);
assert(Window);
glfwSetCursorPosCallback(Window, CursorPositionCallback);
glfwSetMouseButtonCallback(Window, MouseButtonCallback);
glfwSetScrollCallback(Window, ScrollCallback);
glfwSetWindowSizeCallback(Window, WindowSizeCallback);
glfwSetKeyCallback(Window, KeyCallback);
App.Initialize(glfwGetWin32Window(Window), ModelFile, ModelSize);
while (!glfwWindowShouldClose(Window))
{
glfwPollEvents();
App.Render();
glfwSwapBuffers(Window);
}
App.Destroy();
}