![]() ![]() I was telling the engine the visible image potion using uv coordinates, i calculate them myself, these are the same data you recieve when rendering an image using gl_handle, the same data you recive from imgui, the UV coodinates, and i am using them to calculate the click coordinates relative to the inner world of the engine, i pass them to the engine using EngineInbox.SetViewPortion(uv1.x,uv1.y,uv2.x,uv2. My mistake was that i tried to calculate the screen cursor position myself using cursor position relative to window + imgui window position relative to sdl window and i got slightly wrong results, now i am using 'GetCursorScreenPos()'Īnd about this : EngineInbox.SetViewPortion(uv1.x,uv1.y,uv2.x,uv2.y) It is complicated because i want the black poriton ( engine screen ) to be with scrolling, and i want the user to be able to resize the window and scroll it to navigate through the engine's screen, and when he clicks, whereever the scrolling is, i still calculate the currect coordinates relative to the internal engine world, in other words, the coordinates of the click relative to the top left corner of the drawn image ( the engine screen ) and that with scrollling included. The coordinate system for a window is based on the coordinate system of the display device. Then i pass the click to the engine, now i am getting wrong results of about 2 to 12 pixels deppending on the position of the horizontal and virtical scroll bar of the back portion, then what i do is to hide the cursor and ask the engine to draw it when the cursor passes through it. If (mx>=rendering_x & my>=rendering_y & mxGetWidth() įmy = (float(my)-rendering_y)+uv1_y*Umb::Graphics::GetDisplay()->GetHeight() Įvent->SetCoord(mx,my) /// transform click relative to black portion UmbPointerMoveEvent * event = dynamic_cast(update_frame->event) ![]() If (update_frame->event->GetType() = UmbEventType::POINTER_MOVE) Uv2.x = ImGui::GetContentRegionAvail().x / engine_screen->w +uv1.x ĮngineInbox.SetViewPortion(uv1.x,uv1.y,uv2.x,uv2.y) Uv1.y = abs(ImGui::GetWindowContentRegionMin().y)/engine_screen->h Uv1.x = abs(ImGui::GetWindowContentRegionMin().x)/engine_screen->w ImVec2 uv1,uv2 /// top left and button down range ( 0. The tool also provides information about the DPI scaling and the raw/ physical DPI of the current monitor. / tell the engine the current view potion The tracked cursor position is provided in physical/ unscaled Windows pixels and in coordinates scaled by DPI-virtualization. ImGui::Image((ImTextureID)GPU_GetImageHandle(engine_screen->image),ImVec2(engine_screen->w,engine_screen->h)) ImVec2 w_pos = ImGui::GetCursorPos() ,c_pos = ImGui::GetWindowPos() ĮngineInbox.SetRenderingPosition(w_pos.x+c_pos.x,w_pos.y+c_pos.y) / tell the engine the current draw position ImVec2 win_region = ImGui::GetContentRegionAvail() ĮngineInbox.SetRenderingWindowSize(win_region.x,win_region.y) / move the draw cursor to the top left corner of the window / tell the inbox if it should receive inputĮngineInbox.SetInputOn(ImGui::GetWindowIsFocused()) ![]()
0 Comments
Leave a Reply. |