From 9102da27ec09777bcaa46218fa9968c76734dd49 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 Oct 2019 02:18:32 +0200 Subject: [PATCH] Document that wxGLCanvas now uses physical pixels Instruct people to use GetContentScaleFactor() to convert between logical coordinates used by wxWindow and physical ones used by wxGLCanvas. See https://github.com/wxWidgets/wxWidgets/pull/1485 --- docs/changes.txt | 5 +++++ interface/wx/glcanvas.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 84e9f3c69f..c09681c128 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -78,6 +78,11 @@ Changes in behaviour not resulting in compilation errors previous behaviour in wxMSW, when these events were always generated in this case. Please add wxTE_PROCESS_ENTER style if you relied on the old behaviour. +- wxGLCanvas now uses physical pixels on high DPI displays under platforms + where they're different from logical ones (wxGTK3, wxOSX). Multiply logical + coordinates, e.g. returned by wxWindow::GetSize() by GetContentScaleFactor() + before using them with OpenGL functions. + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/interface/wx/glcanvas.h b/interface/wx/glcanvas.h index f7a59b4d3d..b0a08bd7e2 100644 --- a/interface/wx/glcanvas.h +++ b/interface/wx/glcanvas.h @@ -748,6 +748,15 @@ enum context to the canvas, and then finally call SwapBuffers() to swap the buffers of the OpenGL canvas and thus show your current output. + Please note that wxGLContext always uses physical pixels, even on the + platforms where wxWindow uses logical pixels, affected by the coordinate + scaling, on high DPI displays. Thus, if you want to set the OpenGL view + port to the size of entire window, you must multiply the result returned by + wxWindow::GetClientSize() by wxWindow::GetContentScaleFactor() before + passing it to @c glViewport(). Same considerations apply to other OpenGL + functions and other coordinates, notably those retrieved from wxMouseEvent + in the event handlers. + Notice that versions of wxWidgets previous to 2.9 used to implicitly create a wxGLContext inside wxGLCanvas itself. This is still supported in the current version but is deprecated now and will be removed in the future,