Changeset 7bf5433 in opengl-game
- Timestamp:
- Sep 12, 2019, 5:23:28 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- d2f607c
- Parents:
- 27c40ce
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
NewOpenGLGame.sln
r27c40ce r7bf5433 9 9 EndProject 10 10 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VulkanGame", "VulkanGame.vcxproj", "{3489E223-6118-49E3-98F3-8887B68AC32F}" 11 EndProject 12 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGLGame", "OpenGLGame.vcxproj", "{569037E7-4D03-4412-8CC1-DE51435C0BBE}" 11 13 EndProject 12 14 Global … … 42 44 {3489E223-6118-49E3-98F3-8887B68AC32F}.Release|x86.ActiveCfg = Release|Win32 43 45 {3489E223-6118-49E3-98F3-8887B68AC32F}.Release|x86.Build.0 = Release|Win32 46 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Debug|x64.ActiveCfg = Debug|x64 47 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Debug|x64.Build.0 = Debug|x64 48 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Debug|x86.ActiveCfg = Debug|Win32 49 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Debug|x86.Build.0 = Debug|Win32 50 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Release|x64.ActiveCfg = Release|x64 51 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Release|x64.Build.0 = Release|x64 52 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Release|x86.ActiveCfg = Release|Win32 53 {569037E7-4D03-4412-8CC1-DE51435C0BBE}.Release|x86.Build.0 = Release|Win32 44 54 EndGlobalSection 45 55 GlobalSection(SolutionProperties) = preSolution -
VulkanGame.vcxproj
r27c40ce r7bf5433 71 71 <PropertyGroup Label="UserMacros" /> 72 72 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> 73 <IncludePath>include; $(IncludePath)</IncludePath>73 <IncludePath>include;D:\VulkanSDK\1.1.108.0\Include;$(IncludePath)</IncludePath> 74 74 <LibraryPath>lib;D:\VulkanSDK\1.1.108.0\Lib;$(LibraryPath)</LibraryPath> 75 75 </PropertyGroup> … … 82 82 <LanguageStandard>stdcpp17</LanguageStandard> 83 83 <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GAMEGUI_INCLUDE_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> 84 <AdditionalIncludeDirectories>D:\VulkanSDK\1.1.108.0\Include;include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> 84 <AdditionalIncludeDirectories> 85 </AdditionalIncludeDirectories> 85 86 </ClCompile> 86 87 <Link> … … 139 140 </ItemGroup> 140 141 <ItemGroup> 142 <ClInclude Include="compiler.hpp" /> 141 143 <ClInclude Include="consts.hpp" /> 142 144 <ClInclude Include="crash-logger.hpp" /> -
game-gui-glfw.cpp
r27c40ce r7bf5433 1 1 #include "game-gui-glfw.hpp" 2 3 #include <queue> 2 4 3 5 #include "compiler.hpp" 4 6 #include "consts.hpp" 5 7 6 const int KEY_STATE_UNCHANGED = -1; 8 int GameGui_GLFW::s_keyState[GLFW_KEY_LAST]; 9 bool GameGui_GLFW::s_keyDown[GLFW_KEY_LAST]; 10 11 // queue<MouseEvent> mouseEvents; 7 12 8 13 string GameGui_GLFW::s_errorMessage; 9 10 int GameGui_GLFW::s_keyState[NUM_KEYS];11 bool GameGui_GLFW::s_keyDown[NUM_KEYS];12 14 13 15 string& GameGui_GLFW::getError() { … … 62 64 //glfwMakeContextCurrent(window); 63 65 64 //glfwSetMouseButtonCallback(window,mouse_button_callback);66 glfwSetMouseButtonCallback(window, glfw_mouse_button_callback); 65 67 glfwSetKeyCallback(window, glfw_key_callback); 66 68 67 fill(GameGui_GLFW::s_keyState, GameGui_GLFW::s_keyState + NUM_KEYS, KEY_STATE_UNCHANGED); 69 // fill(s_keyState, s_keyState + GLFW_KEY_LAST, RTWO_KEY_EVENT_NONE); 70 // fill(s_keyDown, s_keyDown + GLFW_KEY_LAST, false); 68 71 69 72 return window; … … 74 77 glfwDestroyWindow(window); 75 78 } 79 80 /* 81 void GameGui_GLFW::processEvents() { 82 fill(s_keyState, s_keyState + GLFW_KEY_LAST, RTWO_KEY_EVENT_NONE); 83 84 glfwPollEvents(); 85 } 86 87 unsigned char GameGui_GLFW::getKeyEvent(unsigned int key) { 88 return s_keyState[key]; 89 } 90 91 bool GameGui_GLFW::isKeyPressed(unsigned int key) { 92 return s_keyDown[key]; 93 } 94 95 int GameGui_GLFW::pollMouseEvent(MouseEvent* event) { 96 if (mouseEvents.empty()) { 97 return 0; 98 } 99 100 *event = mouseEvents.front(); 101 mouseEvents.pop(); 102 103 return 1; 104 } 105 */ 76 106 77 107 #ifdef GAMEGUI_INCLUDE_VULKAN … … 107 137 } 108 138 139 void glfw_mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { 140 double x, y; 141 glfwGetCursorPos(window, &x, &y); 142 143 /* 144 MouseEvent e { button, action, (int)x, (int)y }; 145 146 mouseEvents.push(e); 147 */ 148 } 149 109 150 void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { 110 151 GameGui_GLFW::s_keyState[key] = action; 152 /* 153 switch(action) { 154 case GLFW_PRESS: 155 s_keyState[key] = RTWO_KEY_EVENT_PRESSED; 156 break; 157 case GLFW_RELEASE: 158 s_keyState[key] = RTWO_KEY_EVENT_RELEASED; 159 break; 160 default: 161 s_keyState[key] = RTWO_KEY_EVENT_NONE; 162 break; 163 } 111 164 112 165 // should be true for GLFW_PRESS and GLFW_REPEAT 113 166 GameGui_GLFW::s_keyDown[key] = (action != GLFW_RELEASE); 167 */ 114 168 } -
game-gui-glfw.hpp
r27c40ce r7bf5433 10 10 #include <GLFW/glfw3.h> 11 11 12 #define NUM_KEYS (512)13 14 12 class GameGui_GLFW : public GameGui { 15 13 public: … … 18 16 // Both have to be public so that glfw_key_callback can access them 19 17 // TODO: Implement a more generic public api over this to get the key state 20 static int s_keyState[ NUM_KEYS];21 static bool s_keyDown[ NUM_KEYS];18 static int s_keyState[GLFW_KEY_LAST]; 19 static bool s_keyDown[GLFW_KEY_LAST]; 22 20 23 21 string& getError(); … … 28 26 void* createWindow(const string& title, int width, int height, bool fullscreen); 29 27 void destroyWindow(); 28 29 /* 30 void processEvents(); 31 32 unsigned char getKeyEvent(unsigned int key); 33 bool isKeyPressed(unsigned int key); 34 35 int pollMouseEvent(MouseEvent* event); 36 */ 30 37 31 38 #ifdef GAMEGUI_INCLUDE_VULKAN … … 43 50 44 51 void glfw_error_callback(int error, const char* description); 52 void glfw_mouse_button_callback(GLFWwindow* window, int button, int action, int mods); 45 53 void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); 46 54 -
opengl-game.cpp
r27c40ce r7bf5433 57 57 58 58 void OpenGLGame::mainLoop() { 59 //MouseEvent e; 60 59 61 while (!glfwWindowShouldClose(window)) { 62 /* 63 gui->processEvents(); 64 65 if (gui->getKeyEvent(GLFW_KEY_ESCAPE) == RTWO_KEY_EVENT_PRESSED) { 66 glfwSetWindowShouldClose(window, 1); 67 } 68 69 while (gui->pollMouseEvent(&e)) { 70 cout << "Mouse click detected at (" << e.x << ", " << e.y << ")" << endl; 71 } 72 */ 73 60 74 glfwPollEvents(); 61 75
Note:
See TracChangeset
for help on using the changeset viewer.