···873873/*! Query the logical size of the given target. */
874874DECLSPEC void SDLCALL GPU_GetVirtualResolution(GPU_Target* target, Uint16* w, Uint16* h);
875875876876-/*! Converts screen space coordinates (such as from mouse input) to logical drawing coordinates. */
876876+/*! Converts screen space coordinates (such as from mouse input) to logical drawing coordinates. This interacts with GPU_SetCoordinateMode() when the y-axis is flipped (screen space is assumed to be inverted: (0,0) in the upper-left corner). */
877877DECLSPEC void SDLCALL GPU_GetVirtualCoords(GPU_Target* target, float* x, float* y, float displayX, float displayY);
878878879879/*! Reset the logical size of the given target to its original value. */
+7-1
src/SDL_gpu.c
···789789790790void GPU_GetVirtualCoords(GPU_Target* target, float* x, float* y, float displayX, float displayY)
791791{
792792- if(target == NULL)
792792+ if(target == NULL || _gpu_current_renderer == NULL)
793793 return;
794794795795+ // Scale from raw window/image coords to the virtual scale
795796 if(target->context != NULL)
796797 {
797798 if(x != NULL)
···808809 }
809810 else
810811 {
812812+ // What is the backing for this target?!
811813 if(x != NULL)
812814 *x = displayX;
813815 if(y != NULL)
814816 *y = displayY;
815817 }
818818+819819+ // Invert coordinates to math coords
820820+ if(_gpu_current_renderer->coordinate_mode)
821821+ *y = target->h - *y;
816822}
817823818824GPU_Rect GPU_MakeRect(float x, float y, float w, float h)