[Git][wxwidgets/wxwidgets][master] 5 commits: Use wxPaintDC when drawing wxSpinButton in dark mode

0 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Feb 20, 2026, 9:41:48 AM (yesterday) Feb 20
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 802e3109
    by Vadim Zeitlin at 2026-02-18T17:36:55+01:00
    Use wxPaintDC when drawing wxSpinButton in dark mode
    
    Using Win32 API directly resulted in wxWindow code still forwarding
    WM_PAINT to the default updown control window proc which repainted it
    using light mode colours, as the code in wxWindow supposes that the
    window was not really painted if wxPaintDC wasn't created.
    
    Work around this by just creating it here.
    
    Closes #26198.
    
  • 446fc382
    by Vadim Zeitlin at 2026-02-18T17:36:55+01:00
    Don't bother erasing wxSpinButton background in dark mode
    
    This is unnecessary and would just result in flicker.
    
    Note that we prefer to define a custom wxEVT_ERASE_BACKGROUND handler
    checking whether dark mode is active to just setting background style to
    wxBG_STYLE_PAINT because this also works correctly when dark mode is
    turned on or off while the application is running.
    
  • 485d3cb7
    by Vadim Zeitlin at 2026-02-20T15:24:56+01:00
    Merge branch 'msw-dark-spin'
    
    Fix wxSpinButton appearance in wxMSW dark mode.
    
    See #26203.
    
  • ed0abebb
    by Carlo Bramini at 2026-02-20T15:25:45+01:00
    Use correct name for Cairo DLL when using Cygwin
    
    Closes #26207.
    
  • b0d50ffe
    by Vadim Zeitlin at 2026-02-20T15:26:58+01:00
    Add wxGLContext::GetProcAddress()
    
    Implement this function as a trivial wrapper for wglGetProcAddress(),
    glXGetProcAddressARB() or eglGetProcAddress() depending on the platform
    (currently not implemented for macOS).
    
    Account for the known bug in some Windows OpenGL drivers by checking for
    manifestly invalid return values and handling them as null.
    
    Use the new function in wxGL code itself and in the pyramid sample.
    
    Closes #9215.
    
    Closes #26209.
    

13 changed files:

Changes:

  • include/wx/glcanvas.h
    ... ... @@ -182,6 +182,8 @@ public:
    182 182
     // wxGLContextBase: OpenGL rendering context
    
    183 183
     // ----------------------------------------------------------------------------
    
    184 184
     
    
    185
    +using wxGLExtFunction = void (*)();
    
    186
    +
    
    185 187
     class WXDLLIMPEXP_GL wxGLContextBase : public wxObject
    
    186 188
     {
    
    187 189
     public:
    
    ... ... @@ -200,6 +202,20 @@ public:
    200 202
     
    
    201 203
         bool IsOK() const { return m_isOk; }
    
    202 204
     
    
    205
    +    // Get pointer to OpenGL extension function, return nullptr if not found.
    
    206
    +    static wxGLExtFunction GetProcAddress(const wxString& name);
    
    207
    +
    
    208
    +    // Same as above, but returns the function of the specified type.
    
    209
    +    template <typename T>
    
    210
    +    static T GetProcAddress(const wxString& name)
    
    211
    +    {
    
    212
    +        wxGCC_WARNING_SUPPRESS_CAST_FUNCTION_TYPE()
    
    213
    +
    
    214
    +        return reinterpret_cast<T>(GetProcAddress(name));
    
    215
    +
    
    216
    +        wxGCC_WARNING_RESTORE_CAST_FUNCTION_TYPE()
    
    217
    +    }
    
    218
    +
    
    203 219
     protected:
    
    204 220
         bool m_isOk;
    
    205 221
     };
    

  • include/wx/unix/private/glcanvas.h
    ... ... @@ -137,6 +137,7 @@ public:
    137 137
     
    
    138 138
         // Static functions of wxGLContext and wxGLCanvas.
    
    139 139
         virtual void ClearCurrentContext() = 0;
    
    140
    +    virtual wxGLExtFunction GetProcAddress(const wxString& name) = 0;
    
    140 141
     
    
    141 142
         virtual bool IsExtensionSupported(const char* extension) = 0;
    
    142 143
     
    

  • include/wx/unix/private/glegl.h
    ... ... @@ -145,6 +145,7 @@ public:
    145 145
         CreateCanvasImpl(wxGLCanvasUnix* canvas) override;
    
    146 146
     
    
    147 147
         void ClearCurrentContext() override;
    
    148
    +    wxGLExtFunction GetProcAddress(const wxString& name) override;
    
    148 149
     
    
    149 150
         bool IsExtensionSupported(const char* extension) override;
    
    150 151
         bool IsDisplaySupported(const wxGLAttributes& dispAttrs) override;
    

  • include/wx/unix/private/glx11.h
    ... ... @@ -87,6 +87,7 @@ public:
    87 87
         CreateCanvasImpl(wxGLCanvasUnix* canvas) override;
    
    88 88
     
    
    89 89
         void ClearCurrentContext() override;
    
    90
    +    wxGLExtFunction GetProcAddress(const wxString& name) override;
    
    90 91
     
    
    91 92
         bool IsExtensionSupported(const char* extension) override;
    
    92 93
         bool IsDisplaySupported(const wxGLAttributes& dispAttrs) override;
    

  • interface/wx/glcanvas.h
    ... ... @@ -436,6 +436,15 @@ public:
    436 436
         void EndList();
    
    437 437
     };
    
    438 438
     
    
    439
    +/**
    
    440
    +    Return type of wxGLContext::GetProcAddress().
    
    441
    +
    
    442
    +    Generic OpenGL function pointer type.
    
    443
    +
    
    444
    +    @since 3.3.2
    
    445
    + */
    
    446
    +using wxGLExtFunction = void (*)();
    
    447
    +
    
    439 448
     /**
    
    440 449
         @class wxGLContext
    
    441 450
     
    
    ... ... @@ -548,6 +557,62 @@ public:
    548 557
             @since 3.3.2
    
    549 558
         */
    
    550 559
         static void ClearCurrent();
    
    560
    +
    
    561
    +    /**
    
    562
    +        Tries to load an OpenGL extension function with the given name.
    
    563
    +
    
    564
    +        This function uses the platform-specific mechanism for retrieving the
    
    565
    +        address of OpenGL extension functions, e.g. `wglGetProcAddress()` on
    
    566
    +        MSW and either `glXGetProcAddress()` or `eglGetProcAddress()` under
    
    567
    +        Unix systems.
    
    568
    +
    
    569
    +        When calling the template function, the type of the function must be
    
    570
    +        specified as the template parameter, e.g.
    
    571
    +
    
    572
    +        @code
    
    573
    +        typedef void (*glGenBuffers_t) (GLsizei n, GLuint *buffers);
    
    574
    +        auto glGenBuffers = wxGLContext::GetProcAddress<glGenBuffers_t>("glGenBuffers");
    
    575
    +        if ( glGenBuffers )
    
    576
    +        {
    
    577
    +            // glGenBuffers is supported, use it
    
    578
    +            ...
    
    579
    +        }
    
    580
    +        @endcode
    
    581
    +
    
    582
    +        If the type is omitted, the function returns a generic
    
    583
    +        ::wxGLExtFunction pointer that should be cast to the appropriate type
    
    584
    +        by the caller.
    
    585
    +
    
    586
    +        @note Under MSW the returned value may be specific to the currently
    
    587
    +            active context and thus may not be valid for other contexts. So, it
    
    588
    +            is recommended to call this function for each context separately
    
    589
    +            and not to share the returned function pointers between contexts.
    
    590
    +
    
    591
    +        @par
    
    592
    +
    
    593
    +        @note This function is currently not implemented under macOS and always
    
    594
    +            returns @NULL there.
    
    595
    +
    
    596
    +        @since 3.3.2
    
    597
    +     */
    
    598
    +    template <typename T = wxGLExtFunction>
    
    599
    +    static T GetProcAddress(const wxString& name);
    
    600
    +
    
    601
    +    /*
    
    602
    +        Documenting the function returning wxGLExtFunction directly results in
    
    603
    +        bogus Doxygen warnings:
    
    604
    +
    
    605
    +interface/wx/glcanvas.h:596: warning: no uniquely matching class member found for
    
    606
    +  returning a generic function wxGLContext::pointer
    
    607
    +Possible candidates:
    
    608
    +  'wxChar * wxString::pointer' at line 383 of file interface/wx/string.h
    
    609
    +  'value_type * wxVector< T >::pointer' at line 31 of file interface/wx/vector.h
    
    610
    +
    
    611
    +        So don't do it.
    
    612
    +
    
    613
    +        /// @overload
    
    614
    +        static wxGLExtFunction GetProcAddress(const wxString& name);
    
    615
    +    */
    
    551 616
     };
    
    552 617
     
    
    553 618
     /**
    

  • samples/opengl/pyramid/oglpfuncs.cpp
    ... ... @@ -7,55 +7,18 @@
    7 7
     // Licence:     wxWindows licence
    
    8 8
     /////////////////////////////////////////////////////////////////////////////
    
    9 9
     
    
    10
    -#include "oglpfuncs.h"
    
    10
    +#include "wx/wxprec.h"
    
    11 11
     
    
    12
    -// Apple defines everything on his own
    
    13
    -#ifndef __APPLE__
    
    14
    -
    
    15
    -#if defined(_WIN32) || defined(__WIN32__)
    
    16
    -    #ifndef WIN32_LEAN_AND_MEAN
    
    17
    -        // Reduce a bit header VC++ compilation time
    
    18
    -        #define WIN32_LEAN_AND_MEAN 1
    
    19
    -        #define LE_ME_ISDEF
    
    20
    -    #endif
    
    21
    -
    
    22
    -    /*
    
    23
    -    APIENTRY is defined in oglpfuncs.h as well as by windows.h. Undefine
    
    24
    -    it to prevent a macro redefinition warning.
    
    25
    -    */
    
    26
    -    #undef APIENTRY
    
    27
    -    #include <windows.h> //For wglGetProcAddress
    
    28
    -    #ifdef LE_ME_ISDEF
    
    29
    -        #undef WIN32_LEAN_AND_MEAN
    
    30
    -        #undef LE_ME_ISDEF
    
    31
    -    #endif
    
    32
    -    // Our macro
    
    33
    -    #define MyGetProcAddress(name) wglGetProcAddress((LPCSTR)name)
    
    34
    -#else // Linux
    
    35
    -    // GLX_ARB_get_proc_address
    
    36
    -    // glXGetProcAddressARB is statically exported by all libGL implementations,
    
    37
    -    // while glXGetProcAddress may be not available.
    
    38
    -    #ifdef __cplusplus
    
    39
    -        extern "C" {
    
    40
    -    #endif
    
    41
    -    extern void (*glXGetProcAddressARB(const GLubyte *procName))();
    
    42
    -    #ifdef __cplusplus
    
    43
    -        }
    
    44
    -    #endif
    
    45
    -    #define MyGetProcAddress(name) (*glXGetProcAddressARB)((const GLubyte*)name)
    
    12
    +#ifndef WX_PRECOMP
    
    13
    +    #include "wx/wx.h"
    
    46 14
     #endif
    
    47 15
     
    
    48
    -// The function to get the pointers
    
    49
    -void* MyGetGLFuncAddress(const char* fname)
    
    50
    -{
    
    51
    -    void* pret = (void*) MyGetProcAddress(fname);
    
    16
    +// This header needs to be included before GL/gl.h included by wx/glcanvas.h.
    
    17
    +#include "oglstuff.h"
    
    18
    +#include "wx/glcanvas.h"
    
    52 19
     
    
    53
    -    // Some drivers return -apart from 0-, -1, 1, 2 or 3
    
    54
    -    if ( pret == (void*)-1 || pret == (void*)1 || pret == (void*)2 || pret == (void*)3 )
    
    55
    -        pret = nullptr;
    
    56
    -
    
    57
    -    return pret;
    
    58
    -}
    
    20
    +// Apple defines everything on his own
    
    21
    +#ifndef __APPLE__
    
    59 22
     
    
    60 23
     // Declare and initialize pointers
    
    61 24
     PFNGLACTIVETEXTUREPROC my_glActiveTexture = nullptr;
    
    ... ... @@ -96,7 +59,7 @@ PFNGLVERTEXATTRIBPOINTERPROC my_glVertexAttribPointer = nullptr;
    96 59
     
    
    97 60
     // Retrieve the pointers
    
    98 61
     #define GETANDTEST(type, name)                       \
    
    99
    -    my_ ## name = (type) MyGetGLFuncAddress(#name);  \
    
    62
    +    my_ ## name = wxGLContext::GetProcAddress<type>(#name);  \
    
    100 63
         if (name == nullptr)                                   \
    
    101 64
             return false;
    
    102 65
     
    

  • src/common/cairo.cpp
    ... ... @@ -328,7 +328,9 @@ wxCairo::wxCairo()
    328 328
     {
    
    329 329
         wxLogNull log;
    
    330 330
     
    
    331
    -#ifdef __WXMSW__
    
    331
    +#ifdef __CYGWIN__
    
    332
    +    wxString cairoDllStr("cygcairo-2.dll");
    
    333
    +#elif defined(__WXMSW__)
    
    332 334
         wxString cairoDllStr("libcairo-2.dll");
    
    333 335
     #elif defined(__WXOSX__)
    
    334 336
         wxString cairoDllStr("libcairo.2.dylib");
    

  • src/msw/glcanvas.cpp
    ... ... @@ -143,24 +143,12 @@ wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    143 143
     #define WGL_CONTEXT_ES_PROFILE_BIT_EXT            0x00000004
    
    144 144
     #endif
    
    145 145
     
    
    146
    -// This helper function only exists to suppress unavoidable gcc 8 warnings
    
    147
    -// about incompatible function casts.
    
    148
    -template <typename T>
    
    149
    -inline T wxWGLProcCast(PROC proc)
    
    150
    -{
    
    151
    -    wxGCC_WARNING_SUPPRESS_CAST_FUNCTION_TYPE()
    
    152
    -
    
    153
    -    return reinterpret_cast<T>(proc);
    
    154
    -
    
    155
    -    wxGCC_WARNING_RESTORE_CAST_FUNCTION_TYPE()
    
    156
    -}
    
    157
    -
    
    158 146
     // this macro defines a variable of type "name_t" called "name" and initializes
    
    159 147
     // it with the pointer to WGL function "name" (which may be null)
    
    160 148
     //
    
    161 149
     // NB: type name_t must be defined by the code using the macro
    
    162 150
     #define wxDEFINE_WGL_FUNC(name) \
    
    163
    -    name##_t name = wxWGLProcCast<name##_t>(wglGetProcAddress(#name))
    
    151
    +    name##_t name = wxGLContext::GetProcAddress<name##_t>(#name)
    
    164 152
     
    
    165 153
     // ----------------------------------------------------------------------------
    
    166 154
     // libraries
    
    ... ... @@ -628,6 +616,24 @@ void wxGLContextBase::ClearCurrent()
    628 616
         wglMakeCurrent(nullptr, nullptr);
    
    629 617
     }
    
    630 618
     
    
    619
    +/* static */
    
    620
    +wxGLExtFunction wxGLContextBase::GetProcAddress(const wxString& name)
    
    621
    +{
    
    622
    +    // PROC returned by wglGetProcAddress() is a pointer to function returning
    
    623
    +    // INT_PTR and not void, so we need to use another cast here.
    
    624
    +    const auto ptr =
    
    625
    +        reinterpret_cast<wxGLExtFunction>(wglGetProcAddress(name.utf8_str()));
    
    626
    +
    
    627
    +    // Some old drivers return invalid pointer values different from 0 for
    
    628
    +    // unsupported functions, deal with this here to free the caller from the
    
    629
    +    // need to check for this.
    
    630
    +    const auto ptrVal = reinterpret_cast<wxIntPtr>(ptr);
    
    631
    +    if ( ptrVal == -1 || ptrVal == 1 || ptrVal == 2 || ptrVal == 3 )
    
    632
    +        return nullptr;
    
    633
    +
    
    634
    +    return ptr;
    
    635
    +}
    
    636
    +
    
    631 637
     // ============================================================================
    
    632 638
     // wxGLCanvas
    
    633 639
     // ============================================================================
    

  • src/msw/spinbutt.cpp
    ... ... @@ -22,6 +22,7 @@
    22 22
     #ifndef WX_PRECOMP
    
    23 23
         #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
    
    24 24
         #include "wx/app.h"
    
    25
    +    #include "wx/dcclient.h"
    
    25 26
         #include "wx/dcmemory.h"
    
    26 27
     #endif
    
    27 28
     
    
    ... ... @@ -133,6 +134,12 @@ bool wxSpinButton::Create(wxWindow *parent,
    133 134
         SubclassWin(m_hWnd);
    
    134 135
     
    
    135 136
         Bind(wxEVT_PAINT, &wxSpinButton::OnPaint, this);
    
    137
    +    Bind(wxEVT_ERASE_BACKGROUND, [](wxEraseEvent& event)
    
    138
    +    {
    
    139
    +        // Do nothing in dark mode, the background will be erased in OnPaint().
    
    140
    +        if ( !wxMSWDarkMode::IsActive() )
    
    141
    +            event.Skip();
    
    142
    +    });
    
    136 143
     
    
    137 144
         SetInitialSize(size);
    
    138 145
     
    
    ... ... @@ -245,10 +252,8 @@ void wxSpinButton::OnPaint(wxPaintEvent& event)
    245 252
             bmp = wxBitmap(image);
    
    246 253
     #endif // wxUSE_IMAGE
    
    247 254
     
    
    248
    -        PAINTSTRUCT ps;
    
    249
    -        wxDCTemp dc(::BeginPaint(GetHwnd(), &ps), size);
    
    255
    +        wxPaintDC dc(this);
    
    250 256
             dc.DrawBitmap(bmp, 0, 0);
    
    251
    -        ::EndPaint(GetHwnd(), &ps);
    
    252 257
         }
    
    253 258
         else
    
    254 259
         {
    

  • src/osx/cocoa/glcanvas.mm
    ... ... @@ -261,4 +261,12 @@ void wxGLContextBase::ClearCurrent()
    261 261
         [NSOpenGLContext clearCurrentContext];
    
    262 262
     }
    
    263 263
     
    
    264
    +/* static */
    
    265
    +wxGLExtFunction wxGLContextBase::GetProcAddress(const wxString& WXUNUSED(name))
    
    266
    +{
    
    267
    +    // TODO: we should probably use wxDynamicLibrary to load the function but
    
    268
    +    // it's not clear what is the shared library to load them from.
    
    269
    +    return nullptr;
    
    270
    +}
    
    271
    +
    
    264 272
     #endif // wxUSE_GLCANVAS

  • src/unix/glcanvas.cpp
    ... ... @@ -266,6 +266,12 @@ void wxGLContextBase::ClearCurrent()
    266 266
         wxGLBackend::Get().ClearCurrentContext();
    
    267 267
     }
    
    268 268
     
    
    269
    +/* static */
    
    270
    +wxGLExtFunction wxGLContextBase::GetProcAddress(const wxString& name)
    
    271
    +{
    
    272
    +    return wxGLBackend::Get().GetProcAddress(name);
    
    273
    +}
    
    274
    +
    
    269 275
     // ----------------------------------------------------------------------------
    
    270 276
     // wxGLCanvasUnix
    
    271 277
     // ----------------------------------------------------------------------------
    

  • src/unix/glegl.cpp
    ... ... @@ -342,6 +342,11 @@ void wxGLBackendEGL::ClearCurrentContext()
    342 342
                        EGL_NO_SURFACE, EGL_NO_CONTEXT);
    
    343 343
     }
    
    344 344
     
    
    345
    +wxGLExtFunction wxGLBackendEGL::GetProcAddress(const wxString& name)
    
    346
    +{
    
    347
    +    return eglGetProcAddress(name.utf8_str());
    
    348
    +}
    
    349
    +
    
    345 350
     // ============================================================================
    
    346 351
     // wxGLCanvasEGL implementation
    
    347 352
     // ============================================================================
    
    ... ... @@ -378,13 +383,17 @@ EGLDisplay wxGLCanvasEGL::GetDisplay()
    378 383
                     eglQueryString(nullptr, EGL_EXTENSIONS),
    
    379 384
                     "EGL_EXT_platform_base") )
    
    380 385
             {
    
    381
    -            s_eglGetPlatformDisplay = reinterpret_cast<GetPlatformDisplayFunc>(
    
    382
    -                    eglGetProcAddress("eglGetPlatformDisplay"));
    
    386
    +            s_eglGetPlatformDisplay =
    
    387
    +                wxGLContext::GetProcAddress<GetPlatformDisplayFunc>(
    
    388
    +                    "eglGetPlatformDisplay"
    
    389
    +                );
    
    383 390
                 if ( !s_eglGetPlatformDisplay )
    
    384 391
                 {
    
    385 392
                     // Try the fallback if not available.
    
    386
    -                s_eglGetPlatformDisplay = reinterpret_cast<GetPlatformDisplayFunc>(
    
    387
    -                    eglGetProcAddress("eglGetPlatformDisplayEXT"));
    
    393
    +                s_eglGetPlatformDisplay =
    
    394
    +                    wxGLContext::GetProcAddress<GetPlatformDisplayFunc>(
    
    395
    +                        "eglGetPlatformDisplayEXT"
    
    396
    +                    );
    
    388 397
                 }
    
    389 398
             }
    
    390 399
         }
    
    ... ... @@ -541,8 +550,10 @@ EGLSurface wxGLCanvasEGL::CallCreatePlatformWindowSurface(void *window) const
    541 550
             static CreatePlatformWindowSurface s_eglCreatePlatformWindowSurface = nullptr;
    
    542 551
             if ( !s_eglCreatePlatformWindowSurface )
    
    543 552
             {
    
    544
    -            s_eglCreatePlatformWindowSurface = reinterpret_cast<CreatePlatformWindowSurface>(
    
    545
    -                eglGetProcAddress("eglCreatePlatformWindowSurface"));
    
    553
    +            s_eglCreatePlatformWindowSurface =
    
    554
    +                wxGLContext::GetProcAddress<CreatePlatformWindowSurface>(
    
    555
    +                    "eglCreatePlatformWindowSurface"
    
    556
    +                );
    
    546 557
             }
    
    547 558
     
    
    548 559
             // This check is normally superfluous but avoid crashing just in case
    
    ... ... @@ -564,8 +575,10 @@ EGLSurface wxGLCanvasEGL::CallCreatePlatformWindowSurface(void *window) const
    564 575
     
    
    565 576
             if ( wxGLBackendEGL_instance.IsExtensionSupported("EGL_EXT_platform_base") )
    
    566 577
             {
    
    567
    -            s_eglCreatePlatformWindowSurfaceEXT = reinterpret_cast<CreatePlatformWindowSurface>(
    
    568
    -                eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"));
    
    578
    +            s_eglCreatePlatformWindowSurfaceEXT =
    
    579
    +                wxGLContext::GetProcAddress<CreatePlatformWindowSurface>(
    
    580
    +                    "eglCreatePlatformWindowSurfaceEXT"
    
    581
    +                );
    
    569 582
             }
    
    570 583
         }
    
    571 584
     
    

  • src/unix/glx11.cpp
    ... ... @@ -503,8 +503,10 @@ wxGLContextX11::wxGLContextX11(wxGLCanvas *win,
    503 503
         PFNGLXCREATECONTEXTATTRIBSARBPROC wx_glXCreateContextAttribsARB = 0;
    
    504 504
         if (fbc)
    
    505 505
         {
    
    506
    -        wx_glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
    
    507
    -            glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB"));
    
    506
    +        wx_glXCreateContextAttribsARB =
    
    507
    +            wxGLContext::GetProcAddress<PFNGLXCREATECONTEXTATTRIBSARBPROC>(
    
    508
    +                "glXCreateContextAttribsARB"
    
    509
    +            );
    
    508 510
         }
    
    509 511
     
    
    510 512
         glXDestroyContext( dpy, tempContext );
    
    ... ... @@ -811,8 +813,10 @@ wxGLSetSwapInterval(Display* dpy, GLXDrawable drawable, int interval)
    811 813
             static bool s_glXSwapIntervalEXTInit = false;
    
    812 814
             if ( !s_glXSwapIntervalEXTInit )
    
    813 815
             {
    
    814
    -            s_glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
    
    815
    -                glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT");
    
    816
    +            s_glXSwapIntervalEXT =
    
    817
    +                wxGLContext::GetProcAddress<PFNGLXSWAPINTERVALEXTPROC>(
    
    818
    +                    "glXSwapIntervalEXT"
    
    819
    +                );
    
    816 820
     
    
    817 821
                 s_glXSwapIntervalEXTInit = true;
    
    818 822
     
    
    ... ... @@ -828,8 +832,10 @@ wxGLSetSwapInterval(Display* dpy, GLXDrawable drawable, int interval)
    828 832
             static bool s_glXSwapIntervalMESAInit = false;
    
    829 833
             if ( !s_glXSwapIntervalMESAInit )
    
    830 834
             {
    
    831
    -            s_glXSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
    
    832
    -                glXGetProcAddress((const GLubyte*)"glXSwapIntervalMESA");
    
    835
    +            s_glXSwapIntervalMESA =
    
    836
    +                wxGLContext::GetProcAddress<PFNGLXSWAPINTERVALMESAPROC>(
    
    837
    +                    "glXSwapIntervalMESA"
    
    838
    +                );
    
    833 839
     
    
    834 840
                 s_glXSwapIntervalMESAInit = true;
    
    835 841
     
    
    ... ... @@ -900,8 +906,10 @@ int wxMESAGetSwapInterval()
    900 906
             static bool s_glXGetSwapIntervalMESAInit = false;
    
    901 907
             if ( !s_glXGetSwapIntervalMESAInit )
    
    902 908
             {
    
    903
    -            s_glXGetSwapIntervalMESA = (PFNGLXGETSWAPINTERVALMESAPROC)
    
    904
    -                glXGetProcAddress((const GLubyte*)"glXGetSwapIntervalMESA");
    
    909
    +            s_glXGetSwapIntervalMESA =
    
    910
    +                wxGLContext::GetProcAddress<PFNGLXGETSWAPINTERVALMESAPROC>(
    
    911
    +                    "glXGetSwapIntervalMESA"
    
    912
    +                );
    
    905 913
     
    
    906 914
                 s_glXGetSwapIntervalMESAInit = true;
    
    907 915
     
    
    ... ... @@ -1011,4 +1019,11 @@ void wxGLBackendX11::ClearCurrentContext()
    1011 1019
         MakeCurrent(None, nullptr);
    
    1012 1020
     }
    
    1013 1021
     
    
    1022
    +wxGLExtFunction wxGLBackendX11::GetProcAddress(const wxString& name)
    
    1023
    +{
    
    1024
    +    return glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(
    
    1025
    +            static_cast<const char*>(name.utf8_str())
    
    1026
    +        ));
    
    1027
    +}
    
    1028
    +
    
    1014 1029
     #endif // wxUSE_GLCANVAS

Reply all
Reply to author
Forward
0 new messages