mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	| @@ -43,6 +43,7 @@ | ||||
| static Uint64       g_Time = 0; | ||||
| static bool         g_MousePressed[3] = { false, false, false }; | ||||
| static GLuint       g_FontTexture = 0; | ||||
| static SDL_Cursor  *g_SdlCursorMap[ImGuiMouseCursor_Count_]; | ||||
|  | ||||
| // OpenGL2 Render function. | ||||
| // (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) | ||||
| @@ -250,6 +251,14 @@ bool    ImGui_ImplSdlGL2_Init(SDL_Window* window) | ||||
|     io.GetClipboardTextFn = ImGui_ImplSdlGL2_GetClipboardText; | ||||
|     io.ClipboardUserData = NULL; | ||||
|  | ||||
|     g_SdlCursorMap[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); | ||||
|     g_SdlCursorMap[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); | ||||
|     g_SdlCursorMap[ImGuiMouseCursor_Move] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); | ||||
|     g_SdlCursorMap[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS); | ||||
|     g_SdlCursorMap[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE); | ||||
|     g_SdlCursorMap[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW); | ||||
|     g_SdlCursorMap[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE); | ||||
|  | ||||
| #ifdef _WIN32 | ||||
|     SDL_SysWMinfo wmInfo; | ||||
|     SDL_VERSION(&wmInfo.version); | ||||
| @@ -265,6 +274,9 @@ bool    ImGui_ImplSdlGL2_Init(SDL_Window* window) | ||||
| void ImGui_ImplSdlGL2_Shutdown() | ||||
| { | ||||
|     ImGui_ImplSdlGL2_InvalidateDeviceObjects(); | ||||
|  | ||||
|     for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_Count_; cursor_n++) | ||||
|         SDL_FreeCursor(g_SdlCursorMap[cursor_n]); | ||||
| } | ||||
|  | ||||
| void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window) | ||||
| @@ -314,7 +326,14 @@ void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window) | ||||
| #endif | ||||
|  | ||||
|     // Hide OS mouse cursor if ImGui is drawing it | ||||
|     SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1); | ||||
|     if (io.MouseDrawCursor) | ||||
|         SDL_ShowCursor(0); | ||||
|     else | ||||
|     { | ||||
|         SDL_Cursor *cursor = g_SdlCursorMap[ImGui::GetMouseCursor()]; | ||||
|         SDL_SetCursor(cursor); | ||||
|         SDL_ShowCursor(1); | ||||
|     } | ||||
|  | ||||
|     // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. | ||||
|     ImGui::NewFrame(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Oliver Faircliff
					Oliver Faircliff