]> git.saurik.com Git - wxWidgets.git/commitdiff
Refactor all code common to X11 OpenGL implementations into glx11.h/.cpp
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 15 Apr 2007 23:06:45 +0000 (23:06 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 15 Apr 2007 23:06:45 +0000 (23:06 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45486 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

13 files changed:
Makefile.in
build/bakefiles/files.bkl
include/wx/glcanvas.h
include/wx/gtk/app.h
include/wx/gtk/glcanvas.h
include/wx/gtk1/glcanvas.h
include/wx/unix/glx11.h [new file with mode: 0644]
include/wx/x11/glcanvas.h
src/gtk/app.cpp
src/gtk/glcanvas.cpp
src/gtk1/glcanvas.cpp
src/unix/glx11.cpp [new file with mode: 0644]
src/x11/glcanvas.cpp

index a58fb996bc4648920b21af24b0c073a72dbe0441..a36b00d940ddc37a1579b7cac1816b2138285127 100644 (file)
@@ -62,6 +62,7 @@ EXTRALIBS_ODBC = @EXTRALIBS_ODBC@
 EXTRALIBS_GUI = @EXTRALIBS_GUI@
 EXTRALIBS_OPENGL = @EXTRALIBS_OPENGL@
 EXTRALIBS_SDL = @EXTRALIBS_SDL@
+CXXWARNINGS = @CXXWARNINGS@
 HOST_SUFFIX = @HOST_SUFFIX@
 wx_top_builddir = @wx_top_builddir@
 
@@ -786,7 +787,7 @@ MONODLL_CXXFLAGS = $(__monodll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
        -DwxUSE_BASE=1 -DWXMAKINGDLL -I$(top_srcdir)/src/stc/scintilla/include \
        -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DLINK_LEXERS \
-       $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 MONODLL_OBJECTS =  \
        monodll_appbase.o \
        monodll_arcall.o \
@@ -895,7 +896,7 @@ MONOLIB_CXXFLAGS = $(__monolib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
        -DwxUSE_BASE=1 -I$(top_srcdir)/src/stc/scintilla/include \
        -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DLINK_LEXERS \
-       $(CPPFLAGS) $(CXXFLAGS)
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 MONOLIB_OBJECTS =  \
        monolib_appbase.o \
        monolib_arcall.o \
@@ -999,8 +1000,8 @@ BASEDLL_CXXFLAGS = $(__basedll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DwxUSE_GUI=0 -DWXMAKINGDLL_BASE -DwxUSE_BASE=1 $(PIC_FLAG) $(CPPFLAGS) \
-       $(CXXFLAGS)
+       -DwxUSE_GUI=0 -DWXMAKINGDLL_BASE -DwxUSE_BASE=1 $(PIC_FLAG) $(CXXWARNINGS) \
+       $(CPPFLAGS) $(CXXFLAGS)
 BASEDLL_OBJECTS =  \
        $(__basedll___win32rc) \
        basedll_appbase.o \
@@ -1090,7 +1091,7 @@ BASELIB_CXXFLAGS = $(__baselib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DwxUSE_GUI=0 -DwxUSE_BASE=1 $(CPPFLAGS) $(CXXFLAGS)
+       -DwxUSE_GUI=0 -DwxUSE_BASE=1 $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 BASELIB_OBJECTS =  \
        baselib_appbase.o \
        baselib_arcall.o \
@@ -1174,7 +1175,7 @@ NETDLL_CXXFLAGS = $(__netdll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 -DWXUSINGDLL \
-       -DWXMAKINGDLL_NET $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXMAKINGDLL_NET $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 NETDLL_OBJECTS =  \
        $(__netdll___win32rc) \
        netdll_fs_inet.o \
@@ -1192,8 +1193,8 @@ NETDLL_ODEP =  $(___pch_wxprec_netdll_wx_wxprec_h_gch___depname)
 NETLIB_CXXFLAGS = $(__netlib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
-       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 $(CPPFLAGS) \
-       $(CXXFLAGS)
+       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 \
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 NETLIB_OBJECTS =  \
        netlib_fs_inet.o \
        netlib_ftp.o \
@@ -1216,8 +1217,8 @@ COREDLL_CXXFLAGS = $(__coredll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0 $(PIC_FLAG) $(CPPFLAGS) \
-       $(CXXFLAGS)
+       -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0 $(PIC_FLAG) $(CXXWARNINGS) \
+       $(CPPFLAGS) $(CXXFLAGS)
 COREDLL_OBJECTS =  \
        $(__coredll___win32rc) \
        coredll_event.o \
@@ -1237,7 +1238,7 @@ CORELIB_CXXFLAGS = $(__corelib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DwxUSE_BASE=0 $(CPPFLAGS) $(CXXFLAGS)
+       -DwxUSE_BASE=0 $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 CORELIB_OBJECTS =  \
        corelib_event.o \
        corelib_fs_mem.o \
@@ -1256,7 +1257,7 @@ ADVDLL_CXXFLAGS = $(__advdll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DWXUSINGDLL \
-       -DWXMAKINGDLL_ADV $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXMAKINGDLL_ADV $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 ADVDLL_OBJECTS =  \
        $(__advdll___win32rc) \
        $(__ADVANCED_SRC_OBJECTS_2) \
@@ -1269,7 +1270,8 @@ ADVLIB_CFLAGS = $(__advlib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
 ADVLIB_CXXFLAGS = $(__advlib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
-       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CPPFLAGS) $(CXXFLAGS)
+       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 ADVLIB_OBJECTS =  \
        $(__ADVANCED_SRC_OBJECTS_3) \
        $(__PLUGIN_ADV_SRC_OBJECTS_3)
@@ -1278,7 +1280,8 @@ MEDIADLL_CXXFLAGS = $(__mediadll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DWXUSINGDLL -DWXMAKINGDLL_MEDIA $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXUSINGDLL -DWXMAKINGDLL_MEDIA $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 MEDIADLL_OBJECTS =  \
        $(__mediadll___win32rc) \
        mediadll_mediactrlcmn.o \
@@ -1288,7 +1291,7 @@ MEDIALIB_CXXFLAGS = $(__medialib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       $(CPPFLAGS) $(CXXFLAGS)
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 MEDIALIB_OBJECTS =  \
        medialib_mediactrlcmn.o \
        $(__MEDIA_PLATFORM_SRC_OBJECTS_3)
@@ -1297,8 +1300,8 @@ ODBCDLL_CXXFLAGS = $(__odbcdll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DwxUSE_GUI=0 -DWXUSINGDLL -DWXMAKINGDLL_ODBC $(PIC_FLAG) $(CPPFLAGS) \
-       $(CXXFLAGS)
+       -DwxUSE_GUI=0 -DWXUSINGDLL -DWXMAKINGDLL_ODBC $(PIC_FLAG) $(CXXWARNINGS) \
+       $(CPPFLAGS) $(CXXFLAGS)
 ODBCDLL_OBJECTS =  \
        $(__odbcdll___win32rc) \
        odbcdll_db.o \
@@ -1308,7 +1311,7 @@ ODBCLIB_CXXFLAGS = $(__odbclib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DwxUSE_GUI=0 $(CPPFLAGS) $(CXXFLAGS)
+       -DwxUSE_GUI=0 $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 ODBCLIB_OBJECTS =  \
        odbclib_db.o \
        odbclib_dbtable.o
@@ -1317,7 +1320,8 @@ DBGRIDDLL_CXXFLAGS = $(__dbgriddll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DWXUSINGDLL -DWXMAKINGDLL_DBGRID $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXUSINGDLL -DWXMAKINGDLL_DBGRID $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 DBGRIDDLL_OBJECTS =  \
        $(__dbgriddll___win32rc) \
        dbgriddll_dbgrid.o
@@ -1326,7 +1330,7 @@ DBGRIDLIB_CXXFLAGS = $(__dbgridlib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       $(CPPFLAGS) $(CXXFLAGS)
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 DBGRIDLIB_OBJECTS =  \
        dbgridlib_dbgrid.o
 DBGRIDLIB_ODEP =  $(___pch_wxprec_dbgridlib_wx_wxprec_h_gch___depname)
@@ -1334,7 +1338,8 @@ HTMLDLL_CXXFLAGS = $(__htmldll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DWXUSINGDLL -DWXMAKINGDLL_HTML $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXUSINGDLL -DWXMAKINGDLL_HTML $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 HTMLDLL_OBJECTS =  \
        $(__htmldll___win32rc) \
        $(__HTML_SRC_PLATFORM_OBJECTS_2) \
@@ -1366,7 +1371,7 @@ HTMLLIB_CXXFLAGS = $(__htmllib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       $(CPPFLAGS) $(CXXFLAGS)
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 HTMLLIB_OBJECTS =  \
        $(__HTML_SRC_PLATFORM_OBJECTS_3) \
        htmllib_helpctrl.o \
@@ -1397,7 +1402,7 @@ QADLL_CXXFLAGS = $(__qadll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DWXUSINGDLL \
-       -DWXMAKINGDLL_QA $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXMAKINGDLL_QA $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 QADLL_OBJECTS =  \
        $(__qadll___win32rc) \
        qadll_debugrpt.o \
@@ -1406,7 +1411,8 @@ QADLL_ODEP =  $(___pch_wxprec_qadll_wx_wxprec_h_gch___depname)
 QALIB_CXXFLAGS = $(__qalib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
-       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CPPFLAGS) $(CXXFLAGS)
+       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 QALIB_OBJECTS =  \
        qalib_debugrpt.o \
        qalib_dbgrptg.o
@@ -1415,7 +1421,7 @@ XMLDLL_CXXFLAGS = $(__xmldll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 -DWXUSINGDLL \
-       -DWXMAKINGDLL_XML $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXMAKINGDLL_XML $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 XMLDLL_OBJECTS =  \
        $(__xmldll___win32rc) \
        xmldll_xml.o \
@@ -1424,8 +1430,8 @@ XMLDLL_ODEP =  $(___pch_wxprec_xmldll_wx_wxprec_h_gch___depname)
 XMLLIB_CXXFLAGS = $(__xmllib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
-       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 $(CPPFLAGS) \
-       $(CXXFLAGS)
+       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 \
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 XMLLIB_OBJECTS =  \
        xmllib_xml.o \
        xmllib_xtixml.o
@@ -1434,7 +1440,7 @@ XRCDLL_CXXFLAGS = $(__xrcdll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DWXUSINGDLL \
-       -DWXMAKINGDLL_XRC $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXMAKINGDLL_XRC $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 XRCDLL_OBJECTS =  \
        $(__xrcdll___win32rc) \
        xrcdll_xh_animatctrl.o \
@@ -1496,7 +1502,8 @@ XRCDLL_ODEP =  $(___pch_wxprec_xrcdll_wx_wxprec_h_gch___depname)
 XRCLIB_CXXFLAGS = $(__xrclib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
-       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CPPFLAGS) $(CXXFLAGS)
+       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 XRCLIB_OBJECTS =  \
        xrclib_xh_animatctrl.o \
        xrclib_xh_bmp.o \
@@ -1558,7 +1565,7 @@ AUIDLL_CXXFLAGS = $(__auidll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DWXUSINGDLL \
-       -DWXMAKINGDLL_AUI $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXMAKINGDLL_AUI $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 AUIDLL_OBJECTS =  \
        $(__auidll___win32rc) \
        auidll_framemanager.o \
@@ -1570,7 +1577,8 @@ AUIDLL_ODEP =  $(___pch_wxprec_auidll_wx_wxprec_h_gch___depname)
 AUILIB_CXXFLAGS = $(__auilib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
-       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CPPFLAGS) $(CXXFLAGS)
+       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 AUILIB_OBJECTS =  \
        auilib_framemanager.o \
        auilib_dockart.o \
@@ -1582,7 +1590,8 @@ RICHTEXTDLL_CXXFLAGS = $(__richtextdll_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       -DWXUSINGDLL -DWXMAKINGDLL_RICHTEXT $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXUSINGDLL -DWXMAKINGDLL_RICHTEXT $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 RICHTEXTDLL_OBJECTS =  \
        $(__richtextdll___win32rc) \
        richtextdll_richtextctrl.o \
@@ -1599,7 +1608,7 @@ RICHTEXTLIB_CXXFLAGS = $(__richtextlib_PCH_INC) -D__WX$(TOOLKIT)__ \
        $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
        $(__THREAD_DEFINE_p) $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) \
        $(__INC_ZLIB_p) $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
-       $(CPPFLAGS) $(CXXFLAGS)
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 RICHTEXTLIB_OBJECTS =  \
        richtextlib_richtextctrl.o \
        richtextlib_richtextbuffer.o \
@@ -1617,7 +1626,8 @@ STCDLL_CXXFLAGS = $(__stcdll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
        -I$(top_srcdir)/src/stc/scintilla/include \
        -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DLINK_LEXERS \
-       -DWXUSINGDLL -DWXMAKINGDLL_STC $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXUSINGDLL -DWXMAKINGDLL_STC $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 STCDLL_OBJECTS =  \
        $(__stcdll___win32rc) \
        stcdll_stc.o \
@@ -1630,7 +1640,7 @@ STCLIB_CXXFLAGS = $(__stclib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) \
        -I$(top_srcdir)/src/stc/scintilla/include \
        -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DLINK_LEXERS \
-       $(CPPFLAGS) $(CXXFLAGS)
+       $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 STCLIB_OBJECTS =  \
        stclib_stc.o \
        stclib_PlatWX.o \
@@ -1640,7 +1650,7 @@ GLDLL_CXXFLAGS = $(__gldll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
        $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) -DWXUSINGDLL \
-       -DWXMAKINGDLL_GL $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS)
+       -DWXMAKINGDLL_GL $(PIC_FLAG) $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS)
 GLDLL_OBJECTS =  \
        $(__gldll___win32rc) \
        gldll_glcmn.o \
@@ -1649,7 +1659,8 @@ GLDLL_ODEP =  $(___pch_wxprec_gldll_wx_wxprec_h_gch___depname)
 GLLIB_CXXFLAGS = $(__gllib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
        $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
        $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \
-       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CPPFLAGS) $(CXXFLAGS)
+       $(__INC_ODBC_p) $(__INC_REGEX_p) $(__INC_EXPAT_p) $(CXXWARNINGS) $(CPPFLAGS) \
+       $(CXXFLAGS)
 GLLIB_OBJECTS =  \
        gllib_glcmn.o \
        $(__OPENGL_SRC_PLATFORM_OBJECTS_1)
@@ -1769,14 +1780,16 @@ COND_USE_STC_1___wxscintilla___depname = \
 @COND_TOOLKIT_WINCE@NET_WINCE_HDR = wx/msw/wince/net.h
 @COND_TOOLKIT_MSW@MSW_HTML_HDR = wx/msw/helpbest.h
 @COND_TOOLKIT_COCOA@OPENGL_HDR_PLATFORM = wx/cocoa/glcanvas.h
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@OPENGL_HDR_PLATFORM = wx/gtk1/glcanvas.h
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@OPENGL_HDR_PLATFORM = wx/gtk/glcanvas.h
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@OPENGL_HDR_PLATFORM \
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@    = wx/gtk1/glcanvas.h wx/unix/glx11.h
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@OPENGL_HDR_PLATFORM \
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@   = wx/gtk/glcanvas.h wx/unix/glx11.h
 @COND_TOOLKIT_MAC@OPENGL_HDR_PLATFORM = wx/mac/glcanvas.h \
 @COND_TOOLKIT_MAC@     wx/mac/carbon/glcanvas.h
-@COND_TOOLKIT_MOTIF@OPENGL_HDR_PLATFORM = wx/x11/glcanvas.h
+@COND_TOOLKIT_MOTIF@OPENGL_HDR_PLATFORM = wx/x11/glcanvas.h wx/unix/glx11.h
 @COND_TOOLKIT_MSW@OPENGL_HDR_PLATFORM = wx/msw/glcanvas.h
 @COND_TOOLKIT_WINCE@OPENGL_HDR_PLATFORM = wx/msw/glcanvas.h
-@COND_TOOLKIT_X11@OPENGL_HDR_PLATFORM = wx/x11/glcanvas.h
+@COND_TOOLKIT_X11@OPENGL_HDR_PLATFORM = wx/x11/glcanvas.h wx/unix/glx11.h
 COND_TOOLKIT__BASE_MACOSX_HDR =  \
        wx/unix/apptbase.h \
        wx/unix/apptrait.h \
@@ -11289,15 +11302,17 @@ COND_USE_SOSYMLINKS_1___gldll___so_symlinks_uninst_cmd = rm -f \
 @COND_PLATFORM_WIN32_1@__gldll___win32rc = gldll_version_rc.o
 @COND_TOOLKIT_COCOA@__OPENGL_SRC_PLATFORM_OBJECTS = gldll_glcanvas.o
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@__OPENGL_SRC_PLATFORM_OBJECTS \
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@    = gldll_glcanvas.o
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@    = gldll_glcanvas.o gldll_glx11.o
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__OPENGL_SRC_PLATFORM_OBJECTS \
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@   = gldll_glcanvas.o
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@   = gldll_glcanvas.o gldll_glx11.o
 @COND_TOOLKIT_MAC@__OPENGL_SRC_PLATFORM_OBJECTS = gldll_glcanvas.o
-@COND_TOOLKIT_MOTIF@__OPENGL_SRC_PLATFORM_OBJECTS = gldll_glcanvas.o
+@COND_TOOLKIT_MOTIF@__OPENGL_SRC_PLATFORM_OBJECTS = \
+@COND_TOOLKIT_MOTIF@   gldll_glcanvas.o gldll_glx11.o
 @COND_TOOLKIT_MSW@__OPENGL_SRC_PLATFORM_OBJECTS = gldll_glcanvas.o
 @COND_TOOLKIT_PM@__OPENGL_SRC_PLATFORM_OBJECTS = gldll_glcanvas.o
 @COND_TOOLKIT_WINCE@__OPENGL_SRC_PLATFORM_OBJECTS = gldll_glcanvas.o
-@COND_TOOLKIT_X11@__OPENGL_SRC_PLATFORM_OBJECTS = gldll_glcanvas.o
+@COND_TOOLKIT_X11@__OPENGL_SRC_PLATFORM_OBJECTS = \
+@COND_TOOLKIT_X11@     gldll_glcanvas.o gldll_glx11.o
 COND_MONOLITHIC_0___WXLIBGLDEP_CORE_p = \
        -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX)
 @COND_MONOLITHIC_0@__WXLIBGLDEP_CORE_p = $(COND_MONOLITHIC_0___WXLIBGLDEP_CORE_p)
@@ -11321,15 +11336,17 @@ COND_SHARED_0_USE_GUI_1_USE_OPENGL_1___gllib___depname = \
 @COND_USE_PCH_1@       = .pch/wxprec_gllib/wx/wxprec.h.gch
 @COND_TOOLKIT_COCOA@__OPENGL_SRC_PLATFORM_OBJECTS_1 = gllib_glcanvas.o
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@__OPENGL_SRC_PLATFORM_OBJECTS_1 \
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@    = gllib_glcanvas.o
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@    = gllib_glcanvas.o gllib_glx11.o
 @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__OPENGL_SRC_PLATFORM_OBJECTS_1 \
-@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@   = gllib_glcanvas.o
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@   = gllib_glcanvas.o gllib_glx11.o
 @COND_TOOLKIT_MAC@__OPENGL_SRC_PLATFORM_OBJECTS_1 = gllib_glcanvas.o
-@COND_TOOLKIT_MOTIF@__OPENGL_SRC_PLATFORM_OBJECTS_1 = gllib_glcanvas.o
+@COND_TOOLKIT_MOTIF@__OPENGL_SRC_PLATFORM_OBJECTS_1 = \
+@COND_TOOLKIT_MOTIF@   gllib_glcanvas.o gllib_glx11.o
 @COND_TOOLKIT_MSW@__OPENGL_SRC_PLATFORM_OBJECTS_1 = gllib_glcanvas.o
 @COND_TOOLKIT_PM@__OPENGL_SRC_PLATFORM_OBJECTS_1 = gllib_glcanvas.o
 @COND_TOOLKIT_WINCE@__OPENGL_SRC_PLATFORM_OBJECTS_1 = gllib_glcanvas.o
-@COND_TOOLKIT_X11@__OPENGL_SRC_PLATFORM_OBJECTS_1 = gllib_glcanvas.o
+@COND_TOOLKIT_X11@__OPENGL_SRC_PLATFORM_OBJECTS_1 = \
+@COND_TOOLKIT_X11@     gllib_glcanvas.o gllib_glx11.o
 @COND_SHARED_1@____wxgl_namedll_DEP = $(__gldll___depname)
 @COND_SHARED_0@____wxgl_namelib_DEP = $(__gllib___depname)
 COND_WITH_PLUGIN_SDL_1___sound_sdl___depname = \
@@ -30043,6 +30060,18 @@ gldll_glcmn.o: $(srcdir)/src/common/glcmn.cpp $(GLDLL_ODEP)
 @COND_TOOLKIT_PM@gldll_glcanvas.o: $(srcdir)/src/os2/glcanvas.cpp $(GLDLL_ODEP)
 @COND_TOOLKIT_PM@      $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $(srcdir)/src/os2/glcanvas.cpp
 
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@gldll_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLDLL_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@   $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@gldll_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLDLL_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@    $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
+@COND_TOOLKIT_MOTIF@gldll_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLDLL_ODEP)
+@COND_TOOLKIT_MOTIF@   $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
+@COND_TOOLKIT_X11@gldll_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLDLL_ODEP)
+@COND_TOOLKIT_X11@     $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
 gllib_glcmn.o: $(srcdir)/src/common/glcmn.cpp $(GLLIB_ODEP)
        $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $(srcdir)/src/common/glcmn.cpp
 
@@ -30073,6 +30102,18 @@ gllib_glcmn.o: $(srcdir)/src/common/glcmn.cpp $(GLLIB_ODEP)
 @COND_TOOLKIT_PM@gllib_glcanvas.o: $(srcdir)/src/os2/glcanvas.cpp $(GLLIB_ODEP)
 @COND_TOOLKIT_PM@      $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $(srcdir)/src/os2/glcanvas.cpp
 
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@gllib_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLLIB_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@   $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@gllib_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLLIB_ODEP)
+@COND_TOOLKIT_GTK_TOOLKIT_VERSION_@    $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
+@COND_TOOLKIT_MOTIF@gllib_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLLIB_ODEP)
+@COND_TOOLKIT_MOTIF@   $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
+@COND_TOOLKIT_X11@gllib_glx11.o: $(srcdir)/src/unix/glx11.cpp $(GLLIB_ODEP)
+@COND_TOOLKIT_X11@     $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $(srcdir)/src/unix/glx11.cpp
+
 sound_sdl_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp
        $(CXXC) -c -o $@ $(SOUND_SDL_CXXFLAGS) $(srcdir)/src/unix/sound_sdl.cpp
 
index 7a71693347bd18d05f44b346842bbd2c121e01f8..f97e4baa2c00ba6456be66246c609561b596f6e5 100644 (file)
@@ -2682,7 +2682,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/generic/calctrl.cpp
     src/generic/datavgen.cpp
     src/generic/datectlg.cpp
-<!--     src/generic/editlbox.cpp -->
+    <!-- src/generic/editlbox.cpp -->
     src/generic/grid.cpp
     src/generic/gridctrl.cpp
     src/generic/gridsel.cpp
@@ -2706,7 +2706,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     wx/dataview.h
     wx/dateevt.h
     wx/dcbuffer.h
-<!--     wx/editlbox.h -->
+    <!-- wx/editlbox.h -->
     wx/generic/aboutdlgg.h
     wx/generic/animate.h
     wx/generic/bmpcbox.h
@@ -3107,12 +3107,18 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/common/glcmn.cpp
     <if cond="TOOLKIT=='MAC'">src/mac/carbon/glcanvas.cpp</if>
     <if cond="TOOLKIT=='COCOA'">src/cocoa/glcanvas.mm</if>
-    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">src/gtk/glcanvas.cpp</if>
-    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">src/gtk1/glcanvas.cpp</if>
+    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">
+        src/gtk/glcanvas.cpp
+        src/unix/glx11.cpp
+    </if>
+    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">
+        src/gtk1/glcanvas.cpp
+        src/unix/glx11.cpp
+    </if>
     <if cond="TOOLKIT=='MSW'">src/msw/glcanvas.cpp</if>
     <if cond="TOOLKIT=='WINCE'">src/msw/glcanvas.cpp</if>
-    <if cond="TOOLKIT=='MOTIF'">src/x11/glcanvas.cpp</if>
-    <if cond="TOOLKIT=='X11'">src/x11/glcanvas.cpp</if>
+    <if cond="TOOLKIT=='MOTIF'">src/x11/glcanvas.cpp src/unix/glx11.cpp</if>
+    <if cond="TOOLKIT=='X11'">src/x11/glcanvas.cpp src/unix/glx11.cpp</if>
     <if cond="TOOLKIT=='PM'">src/os2/glcanvas.cpp</if>
 </set>
 
@@ -3124,12 +3130,18 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 <set var="OPENGL_HDR_PLATFORM" hints="files">
     <if cond="TOOLKIT=='MAC'">wx/mac/glcanvas.h wx/mac/carbon/glcanvas.h</if>
     <if cond="TOOLKIT=='COCOA'">wx/cocoa/glcanvas.h</if>
-    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">wx/gtk/glcanvas.h</if>
-    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">wx/gtk1/glcanvas.h</if>
+    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">
+        wx/gtk/glcanvas.h
+        wx/unix/glx11.h
+    </if>
+    <if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">
+        wx/gtk1/glcanvas.h
+        wx/unix/glx11.h
+    </if>
     <if cond="TOOLKIT=='MSW'">wx/msw/glcanvas.h</if>
     <if cond="TOOLKIT=='WINCE'">wx/msw/glcanvas.h</if>
-    <if cond="TOOLKIT=='MOTIF'">wx/x11/glcanvas.h</if>
-    <if cond="TOOLKIT=='X11'">wx/x11/glcanvas.h</if>
+    <if cond="TOOLKIT=='MOTIF'">wx/x11/glcanvas.h wx/unix/glx11.h</if>
+    <if cond="TOOLKIT=='X11'">wx/x11/glcanvas.h wx/unix/glx11.h</if>
 </set>
 
 <set var="OPENGL_HDR" hints="files">
index 9e1c89ea8e297ce15dc9cb2ff3805699db870a32..adbbb033a1341891ddbd8105b8461e0d79eb2b95 100644 (file)
@@ -155,6 +155,22 @@ protected:
 #endif // WXWIN_COMPATIBILITY_2_8
 };
 
+// ----------------------------------------------------------------------------
+// wxGLApp: a special wxApp subclass for OpenGL applications which must be used
+//          to select a visual compatible with the given attributes
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_GL wxGLAppBase : public wxApp
+{
+public:
+    wxGLAppBase() : wxApp() { }
+
+    // use this in the constructor of the user-derived wxGLApp class to
+    // determine if an OpenGL rendering context with these attributes
+    // is available - returns true if so, false if not.
+    virtual bool InitGLVisual(const int *attribList) = 0;
+};
+
 #if defined(__WXMSW__)
     #include "wx/msw/glcanvas.h"
 #elif defined(__WXMOTIF__) || defined(__WXX11__)
@@ -171,20 +187,22 @@ protected:
     #error "wxGLCanvas not supported in this wxWidgets port"
 #endif
 
-class WXDLLIMPEXP_GL wxGLApp : public wxApp
+// wxMac and wxMSW don't need anything extra in wxGLAppBase, so declare it here
+#ifndef wxGL_APP_DEFINED
+
+class WXDLLIMPEXP_GL wxGLApp : public wxGLAppBase
 {
 public:
-    wxGLApp() : wxApp() { }
+    wxGLApp() : wxGLAppBase() { }
 
-    // use this in the constructor of the user-derived wxGLApp class to
-    // determine if an OpenGL rendering context with these attributes
-    // is available - returns true if so, false if not.
-    bool InitGLVisual(const int *attribList);
+    virtual bool InitGLVisual(const int *attribList);
 
 private:
     DECLARE_DYNAMIC_CLASS(wxGLApp)
 };
 
+#endif // !wxGL_APP_DEFINED
+
 #endif // wxUSE_GLCANVAS
 
 #endif // _WX_GLCANVAS_H_BASE_
index 3d862eafd45db3520e66d1f302c57b5a5a3b82ef..ce21f6dce86d78a2509f044e7334d37f3097196d 100644 (file)
@@ -52,18 +52,27 @@ public:
     bool IsInAssert() const { return m_isInAssert; }
 #endif // __WXDEBUG__
 
+    // GTK-specific methods
+    // -------------------
+
+    // this can be overridden to return a specific visual to be used for GTK+
+    // instead of the default one (it's used by wxGLApp)
+    //
+    // must return XVisualInfo pointer (it is not freed by caller)
+    virtual void *GetXVisualInfo() { return NULL; }
+
+
+    // implementation only from now on
+    // -------------------------------
+
     guint m_idleTag;
     // temporarily disable idle events
     void SuspendIdleCallback();
 
-    // Used by the the wxGLApp and wxGLCanvas class for GL-based X visual
-    // selection.
-    void           *m_glVisualInfo; // this is actually an XVisualInfo*
-    void           *m_glFBCInfo; // this is actually an GLXFBConfig*
     // This returns the current visual: either that used by wxRootWindow
     // or the XVisualInfo* for SGI.
     GdkVisual      *GetGdkVisual();
-    
+
 private:
     // true if we're inside an assert modal dialog
 #ifdef __WXDEBUG__
index 35ef0d4322bf3b790a98e7860d6c74ee903ae6d1..31bf5d00c6895a3a57635e6f34b67029affc11eb 100644 (file)
 #ifndef _WX_GLCANVAS_H_
 #define _WX_GLCANVAS_H_
 
-extern "C"
-{
-    #include <GL/gl.h>
-    #include <GL/glx.h>
-    #include <GL/glu.h>
-}
-
-//---------------------------------------------------------------------------
-// wxGLContext
-//---------------------------------------------------------------------------
-
-
-class WXDLLEXPORT wxGLContext : public wxGLContextBase
-{
-public:
-    wxGLContext(wxWindow* win, const wxGLContext* other = NULL);
-    virtual ~wxGLContext();
-
-    virtual void SetCurrent(const wxGLCanvas& win) const;
-
-private:
-    GLXContext m_glContext;
-
-    DECLARE_CLASS(wxGLContext)
-};
+#include "wx/unix/glx11.h"
 
 //---------------------------------------------------------------------------
 // wxGLCanvas
 //---------------------------------------------------------------------------
 
-class WXDLLEXPORT wxGLCanvas : public wxGLCanvasBase
+class WXDLLEXPORT wxGLCanvas : public wxGLCanvasX11
 {
 public:
     wxGLCanvas(wxWindow *parent,
@@ -63,20 +39,11 @@ public:
                 const int *attribList = NULL,
                 const wxPalette& palette = wxNullPalette);
 
-    virtual ~wxGLCanvas();
-
 
-    // implement wxGLCanvasBase methods
+    // implement wxGLCanvasX11 methods
     // --------------------------------
 
-    virtual void SwapBuffers();
-
-
-    // GTK-specific helpers
-    // --------------------
-
-    // return GLX version: 13 means 1.3
-    static int GetGLXVersion();
+    virtual Window GetXWindow() const;
 
 
     // deprecated methods
@@ -125,10 +92,6 @@ public:
     // implementation from now on
     void OnInternalIdle();
 
-    void             *m_vi; // actually an XVisualInfo*
-    GLXFBConfig      *m_fbc;
-    bool              m_canFreeVi;
-    bool              m_canFreeFBC;
     GtkWidget        *m_glWidget;
     bool              m_exposed;
 
@@ -138,14 +101,6 @@ public:
     const bool        m_createImplicitContext;
 #endif // WXWIN_COMPATIBILITY_2_8
 
-    // returns an XVisualInfo* based on desired GL attributes;
-    // returns NULL if an appropriate visual is not found. The
-    // caller is reponsible for using XFree() to deallocate
-    // the returned structure.
-    static void* ChooseGLVisual(const int *attribList);
-    static void* ChooseGLFBC(const int *attribList);
-    static void GetGLAttribListFromWX(const int *wx_attribList, int *gl_attribList );
-
 private:
     DECLARE_CLASS(wxGLCanvas)
 };
index c93bbc5706a9c0018b441f5588f01885c74325c3..031be9dc66b97ed0e81d3291894f24982ebe34f0 100644 (file)
 #ifndef _WX_GLCANVAS_H_
 #define _WX_GLCANVAS_H_
 
-extern "C"
-{
-    #include <GL/gl.h>
-    #include <GL/glx.h>
-    #include <GL/glu.h>
-}
-
-//---------------------------------------------------------------------------
-// wxGLContext
-//---------------------------------------------------------------------------
-
-
-class WXDLLEXPORT wxGLContext : public wxGLContextBase
-{
-public:
-    wxGLContext(wxWindow* win, const wxGLContext* other = NULL);
-    virtual ~wxGLContext();
-
-    virtual void SetCurrent(const wxGLCanvas& win) const;
-
-private:
-    GLXContext m_glContext;
-
-    DECLARE_CLASS(wxGLContext)
-};
+#include "wx/unix/glx11.h"
 
 //---------------------------------------------------------------------------
 // wxGLCanvas
 //---------------------------------------------------------------------------
 
-class WXDLLEXPORT wxGLCanvas : public wxGLCanvasBase
+class WXDLLEXPORT wxGLCanvas : public wxGLCanvasX11
 {
 public:
     wxGLCanvas(wxWindow *parent,
@@ -63,20 +39,11 @@ public:
                 const int *attribList = NULL,
                 const wxPalette& palette = wxNullPalette);
 
-    virtual ~wxGLCanvas();
-
 
-    // implement wxGLCanvasBase methods
-    // --------------------------------
+    // implement wxGLCanvasX11 methods
+    // -------------------------------
 
-    virtual void SwapBuffers();
-
-
-    // GTK-specific helpers
-    // --------------------
-
-    // return GLX version: 13 means 1.3
-    static int GetGLXVersion();
+    virtual Window GetXWindow() const;
 
 
     // deprecated methods
@@ -126,10 +93,6 @@ public:
     virtual void OnInternalIdle();
 
 
-    void             *m_vi; // actually an XVisualInfo*
-    GLXFBConfig      *m_fbc;
-    bool              m_canFreeVi;
-    bool              m_canFreeFBC;
     GtkWidget        *m_glWidget;
 
 #if WXWIN_COMPATIBILITY_2_8
@@ -138,14 +101,6 @@ public:
     const bool        m_createImplicitContext;
 #endif // WXWIN_COMPATIBILITY_2_8
 
-    // returns an XVisualInfo* based on desired GL attributes;
-    // returns NULL if an appropriate visual is not found. The
-    // caller is reponsible for using XFree() to deallocate
-    // the returned structure.
-    static void* ChooseGLVisual(const int *attribList);
-    static void* ChooseGLFBC(const int *attribList);
-    static void GetGLAttribListFromWX(const int *wx_attribList, int *gl_attribList );
-
 private:
     DECLARE_CLASS(wxGLCanvas)
 };
diff --git a/include/wx/unix/glx11.h b/include/wx/unix/glx11.h
new file mode 100644 (file)
index 0000000..d122db0
--- /dev/null
@@ -0,0 +1,162 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/unix/glx11.h
+// Purpose:     class common for all X11-based wxGLCanvas implementations
+// Author:      Vadim Zeitlin
+// Created:     2007-04-15
+// RCS-ID:      $Id$
+// Copyright:   (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_UNIX_GLX11_H_
+#define _WX_UNIX_GLX11_H_
+
+#include <GL/glx.h>
+
+// ----------------------------------------------------------------------------
+// wxGLContext
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxGLContext : public wxGLContextBase
+{
+public:
+    wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
+    virtual ~wxGLContext();
+
+    virtual void SetCurrent(const wxGLCanvas& win) const;
+
+private:
+    // attach context to the drawable or unset it (if NULL)
+    static void MakeCurrent(GLXDrawable drawable, GLXContext context);
+
+    GLXContext m_glContext;
+
+    DECLARE_CLASS(wxGLContext)
+};
+
+// ----------------------------------------------------------------------------
+// wxGLCanvasX11
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxGLCanvasX11 : public wxGLCanvasBase
+{
+public:
+    // initialization and dtor
+    // -----------------------
+
+    // default ctor doesn't do anything, InitVisual() must be called
+    wxGLCanvasX11();
+
+    // initializes the XVisualInfo corresponding to the given attributes
+    bool InitVisual(const int *attribList);
+
+    // frees XVisualInfo info
+    virtual ~wxGLCanvasX11();
+
+
+    // implement wxGLCanvasBase methods
+    // --------------------------------
+
+    virtual void SwapBuffers();
+
+
+    // X11-specific methods
+    // --------------------
+
+    // return GLX version: 13 means 1.3 &c
+    static int GetGLXVersion();
+
+    // get the X11 handle of this window
+    virtual Window GetXWindow() const = 0;
+
+
+    // override some wxWindow methods
+    // ------------------------------
+
+    // return true only if the window is realized: OpenGL context can't be
+    // created until we are
+    virtual bool IsShownOnScreen() const;
+
+
+    // implementation only from now on
+    // -------------------------------
+
+    // get the GLXFBConfig/XVisualInfo we use
+    GLXFBConfig *GetGLXFBConfig() const { return m_fbc; }
+    XVisualInfo *GetXVisualInfo() const { return m_vi; }
+
+    // initialize the global default GL visual, return false if matching visual
+    // not found
+    static bool InitDefaultVisualInfo(const int *attribList);
+
+    // get the default GL X11 visual (may be NULL, shouldn't be freed by caller)
+    static XVisualInfo *GetDefaultXVisualInfo() { return ms_glVisualInfo; }
+
+    // free the global GL visual, called by wxGLApp
+    static void FreeDefaultVisualInfo();
+
+private:
+    // fills in glattrs with attributes defined by wxattrs which must be
+    // 0-terminated if it is non-NULL
+    //
+    // n is the max size of glattrs, false is returned if we overflow it, it
+    // should be at least 16 to accommodate the default attributes
+    static bool ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n);
+
+    // initializes XVisualInfo (in any case) and, if supported, GLXFBConfig
+    //
+    // returns false if XVisualInfo couldn't be initialized, otherwise caller
+    // is responsible for freeing the pointers
+    static bool InitXVisualInfo(const int *attribList,
+                                GLXFBConfig **pFBC, XVisualInfo **pXVisual);
+
+
+    // this is only used if it's supported i.e. if GL >= 1.3
+    GLXFBConfig *m_fbc;
+
+    // used for all GL versions, obtained from GLXFBConfig for GL >= 1.3
+    XVisualInfo *m_vi;
+
+    // the global/default versions of the above
+    static GLXFBConfig *ms_glFBCInfo;
+    static XVisualInfo *ms_glVisualInfo;
+};
+
+// ----------------------------------------------------------------------------
+// wxGLApp
+// ----------------------------------------------------------------------------
+
+// this is used in wx/glcanvas.h, prevent it from defining a generic wxGLApp
+#define wxGL_APP_DEFINED
+
+class wxGLApp : public wxGLAppBase
+{
+public:
+    wxGLApp();
+
+    // implement wxGLAppBase method
+    virtual bool InitGLVisual(const int *attribList)
+    {
+        return wxGLCanvasX11::InitDefaultVisualInfo(attribList);
+    }
+
+    // and implement this wxGTK::wxApp method too
+    virtual void *GetXVisualInfo()
+    {
+        return wxGLCanvasX11::GetDefaultXVisualInfo();
+    }
+
+    // and override this wxApp method to clean up
+    virtual int OnExit()
+    {
+        wxGLCanvasX11::FreeDefaultVisualInfo();
+
+        return wxGLAppBase::OnExit();
+    }
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxGLApp);
+};
+
+#endif // _WX_UNIX_GLX11_H_
+
index e06246e2f5a110a4bfd454a50ddb99c57e86ff78..4e20ce6a568c0856beaa78c3ba5d263d05b19f21 100644 (file)
 #ifndef _WX_GLCANVAS_H_
 #define _WX_GLCANVAS_H_
 
-#include "wx/gdicmn.h"
+#include "wx/unix/glx11.h"
 
-#include <GL/glx.h>
-
-//---------------------------------------------------------------------------
-// classes
-//---------------------------------------------------------------------------
-
-class WXDLLEXPORT wxGLContext : public wxGLContextBase
-{
-public:
-    wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
-    virtual ~wxGLContext();
-
-    virtual void SetCurrent(const wxGLCanvas& win) const;
-
-private:
-    GLXContext       m_glContext;
-
-    DECLARE_CLASS(wxGLContext)
-};
-
-
-class WXDLLEXPORT wxGLCanvas : public wxGLCanvasBase
+class WXDLLEXPORT wxGLCanvas : public wxGLCanvasX11
 {
 public:
     wxGLCanvas(wxWindow *parent,
@@ -57,13 +36,10 @@ public:
                 const int *attribList = NULL,
                 const wxPalette& palette = wxNullPalette);
 
-    virtual ~wxGLCanvas();
-
-    virtual void SwapBuffers();
-
+    // implement wxGLCanvasX11 methods
+    // --------------------------------
 
-    // implementation
-    void *m_vi;
+    virtual Window GetXWindow() const;
 
 protected:
     virtual int GetColourIndex(const wxColour& col);
index 5cfde2e126141eb9f9a2fb17c6dc2b6e6ea8cd3c..a2137b6e65ea5642c4543ec12e79041388e6fbe9 100644 (file)
@@ -329,21 +329,12 @@ wxApp::wxApp()
     m_idleTag = 0;
     g_isIdle = true;
     wxapp_install_idle_handler();
-
-    // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp
-    m_glVisualInfo = (void *) NULL;
-    m_glFBCInfo = (void *) NULL;
 }
 
 wxApp::~wxApp()
 {
     if (m_idleTag)
         g_source_remove( m_idleTag );
-
-    if (m_glFBCInfo)
-        XFree(m_glFBCInfo);
-    if (m_glVisualInfo)
-        XFree(m_glVisualInfo);
 }
 
 bool wxApp::OnInitGui()
@@ -353,7 +344,7 @@ bool wxApp::OnInitGui()
 
     // if this is a wxGLApp (derived from wxApp), and we've already
     // chosen a specific visual, then derive the GdkVisual from that
-    if (m_glVisualInfo != NULL)
+    if ( GetXVisualInfo() )
     {
         GdkVisual* vis = gtk_widget_get_default_visual();
 
@@ -396,8 +387,9 @@ GdkVisual *wxApp::GetGdkVisual()
 {
     GdkVisual *visual = NULL;
 
-    if (m_glVisualInfo)
-        visual = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo)->visualid );
+    XVisualInfo *xvi = (XVisualInfo *)GetXVisualInfo();
+    if ( xvi )
+        visual = gdkx_visual_get( xvi->visualid );
     else
         visual = gdk_drawable_get_visual( wxGetRootWindow()->window );
 
index c7bdfbfd19d82650c9e0e228f0cbd3ee4a805d7b..352246f4786263060459e84696acebb85d6bf8f1 100644 (file)
@@ -33,79 +33,6 @@ extern "C"
 #include "wx/gtk/win_gtk.h"
 #include "wx/gtk/private.h"
 
-//---------------------------------------------------------------------------
-// global data
-//---------------------------------------------------------------------------
-
-XVisualInfo *g_vi = (XVisualInfo*) NULL;
-
-// ----------------------------------------------------------------------------
-// helper functions
-// ----------------------------------------------------------------------------
-
-// wrapper around glXMakeContextCurrent/glXMakeCurrent depending on GLX
-// version
-static void wxMakeContextCurrent(GLXDrawable drawable, GLXContext context)
-{
-    if (wxGLCanvas::GetGLXVersion() >= 13)
-        glXMakeContextCurrent( GDK_DISPLAY(), drawable, drawable, context);
-    else // GLX <= 1.2 doesn't have glXMakeContextCurrent()
-        glXMakeCurrent( GDK_DISPLAY(), drawable, context);
-}
-
-//---------------------------------------------------------------------------
-// wxGLContext
-//---------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxGLContext,wxObject)
-
-wxGLContext::wxGLContext(wxWindow* win, const wxGLContext* other)
-{
-    wxGLCanvas *gc = (wxGLCanvas*) win;
-
-    if (wxGLCanvas::GetGLXVersion() >= 13)
-    {
-        GLXFBConfig *fbc = gc->m_fbc;
-        wxCHECK_RET( fbc, _T("invalid GLXFBConfig for OpenGl") );
-        m_glContext = glXCreateNewContext( GDK_DISPLAY(), fbc[0], GLX_RGBA_TYPE,
-                                           other ? other->m_glContext : None,
-                                           GL_TRUE );
-    }
-    else // GLX <= 1.2
-    {
-        XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
-        wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
-        m_glContext = glXCreateContext( GDK_DISPLAY(), vi,
-                                        other ? other->m_glContext : None,
-                                        GL_TRUE );
-    }
-
-    wxASSERT_MSG( m_glContext, _T("Couldn't create OpenGl context") );
-}
-
-wxGLContext::~wxGLContext()
-{
-    if ( !m_glContext )
-        return;
-
-    if ( m_glContext == glXGetCurrentContext() )
-        wxMakeContextCurrent(None, NULL);
-
-    glXDestroyContext( GDK_DISPLAY(), m_glContext );
-}
-
-void wxGLContext::SetCurrent(const wxGLCanvas& win) const
-{
-    if ( !m_glContext )
-        return;
-
-    GdkWindow *window = GTK_PIZZA(win.m_wxwindow)->bin_window;
-    wxCHECK_RET( window, _T("window must be shown") );
-
-    wxMakeContextCurrent(GDK_WINDOW_XWINDOW(window), m_glContext);
-}
-
-
 #if WXWIN_COMPATIBILITY_2_8
 
 //-----------------------------------------------------------------------------
@@ -263,48 +190,12 @@ bool wxGLCanvas::Create(wxWindow *parent,
     m_exposed = false;
     m_noExpose = true;
     m_nativeSizeEvent = true;
-    m_fbc = NULL;
-    m_vi = NULL;
 
-    if (wxGLCanvas::GetGLXVersion() >= 13)
-    {
-        // GLX >= 1.3 uses a GLXFBConfig
-        GLXFBConfig * fbc = NULL;
-        if (wxTheApp->m_glFBCInfo != NULL)
-        {
-            fbc = (GLXFBConfig *) wxTheApp->m_glFBCInfo;
-            m_canFreeFBC = false; // owned by wxTheApp - don't free upon destruction
-        }
-        else
-        {
-            fbc = (GLXFBConfig *) wxGLCanvas::ChooseGLFBC(attribList);
-            m_canFreeFBC = true;
-        }
-        m_fbc = fbc;  // save for later use
-        wxCHECK_MSG( m_fbc, false, _T("required FBConfig couldn't be found") );
-    }
+    if ( !InitVisual(attribList) )
+        return false;
 
-    XVisualInfo *vi = NULL;
-    if (wxTheApp->m_glVisualInfo != NULL)
-    {
-        vi = (XVisualInfo *)wxTheApp->m_glVisualInfo;
-        m_canFreeVi = false; // owned by wxTheApp - don't free upon destruction
-    }
-    else
-    {
-        if (wxGLCanvas::GetGLXVersion() >= 13)
-        // GLX >= 1.3
-            vi = glXGetVisualFromFBConfig(GDK_DISPLAY(), m_fbc[0]);
-        else
-            // GLX <= 1.2
-            vi = (XVisualInfo *) ChooseGLVisual(attribList);
-
-        m_canFreeVi = true;
-    }
+    XVisualInfo * const xvi = GetXVisualInfo();
 
-    m_vi = vi;  // save for later use
-
-    wxCHECK_MSG( m_vi, false, _T("required visual couldn't be found") );
     GdkVisual *visual;
     GdkColormap *colormap;
 
@@ -320,9 +211,9 @@ bool wxGLCanvas::Create(wxWindow *parent,
         colormap = gdk_screen_get_default_colormap(screen);
         visual = gdk_colormap_get_visual(colormap);
 
-        if (GDK_VISUAL_XVISUAL(visual)->visualid != vi->visualid)
+        if (GDK_VISUAL_XVISUAL(visual)->visualid != xvi->visualid)
         {
-            visual = gdk_x11_screen_lookup_visual( screen, vi->visualid );
+            visual = gdk_x11_screen_lookup_visual( screen, xvi->visualid );
             colormap = gdk_colormap_new(visual, FALSE);
         }
 
@@ -331,7 +222,7 @@ bool wxGLCanvas::Create(wxWindow *parent,
     else
 #endif // GTK+ >= 2.2
     {
-        visual = gdkx_visual_get( vi->visualid );
+        visual = gdkx_visual_get( xvi->visualid );
         colormap = gdk_colormap_new( visual, TRUE );
 
         gtk_widget_push_colormap( colormap );
@@ -368,167 +259,10 @@ bool wxGLCanvas::Create(wxWindow *parent,
     return true;
 }
 
-wxGLCanvas::~wxGLCanvas()
-{
-    GLXFBConfig * fbc = (GLXFBConfig *) m_fbc;
-    if (fbc && m_canFreeFBC)
-        XFree( fbc );
-
-    XVisualInfo *vi = (XVisualInfo *) m_vi;
-    if (vi && m_canFreeVi)
-        XFree( vi );
-}
-
-void* wxGLCanvas::ChooseGLVisual(const int *attribList)
-{
-    int data[512];
-    GetGLAttribListFromWX( attribList, data );
-
-    Display *dpy = GDK_DISPLAY();
-
-    return glXChooseVisual( dpy, DefaultScreen(dpy), data );
-}
-
-void* wxGLCanvas::ChooseGLFBC(const int *attribList)
-{
-    int data[512];
-    GetGLAttribListFromWX( attribList, data );
-
-    int returned;
-    return glXChooseFBConfig( GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
-                              data, &returned );
-}
-
-
-void
-wxGLCanvas::GetGLAttribListFromWX(const int *wx_attribList, int *gl_attribList)
-{
-    if ( !wx_attribList )
-    {
-        if (wxGLCanvas::GetGLXVersion() >= 13)
-        {
-            // leave GLX >= 1.3 choose the default attributes
-            gl_attribList[0] = 0;
-        }
-        else // GLX < 1.3
-        {
-            int i = 0;
-            // default settings if attriblist = 0
-            gl_attribList[i++] = GLX_RGBA;
-            gl_attribList[i++] = GLX_DOUBLEBUFFER;
-            gl_attribList[i++] = GLX_DEPTH_SIZE;   gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_RED_SIZE;     gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_GREEN_SIZE;   gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_BLUE_SIZE;    gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_ALPHA_SIZE;   gl_attribList[i++] = 0;
-            gl_attribList[i++] = None;
-        }
-    }
-    else // have non-default attributes
-    {
-        int arg=0, p=0;
-        while( (wx_attribList[arg]!=0) && (p<510) )
-        {
-            switch( wx_attribList[arg++] )
-            {
-                case WX_GL_RGBA:
-                    if (wxGLCanvas::GetGLXVersion() <= 12)
-                    {
-                        // for GLX >= 1.3, GLX_RGBA is useless (setting this flags will crash on most opengl implm)
-                        gl_attribList[p++] = GLX_RGBA;
-                    }
-                    break;
-                case WX_GL_BUFFER_SIZE:
-                    gl_attribList[p++] = GLX_BUFFER_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_LEVEL:
-                    gl_attribList[p++] = GLX_LEVEL;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_DOUBLEBUFFER:
-                    gl_attribList[p++] = GLX_DOUBLEBUFFER;
-                    gl_attribList[p++] = 1;
-                    break;
-                case WX_GL_STEREO:
-                    gl_attribList[p++] = GLX_STEREO;
-                    break;
-                case WX_GL_AUX_BUFFERS:
-                    gl_attribList[p++] = GLX_AUX_BUFFERS;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_RED:
-                    gl_attribList[p++] = GLX_RED_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_GREEN:
-                    gl_attribList[p++] = GLX_GREEN_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_BLUE:
-                    gl_attribList[p++] = GLX_BLUE_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ALPHA:
-                    gl_attribList[p++] = GLX_ALPHA_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_DEPTH_SIZE:
-                    gl_attribList[p++] = GLX_DEPTH_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_STENCIL_SIZE:
-                    gl_attribList[p++] = GLX_STENCIL_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_RED:
-                    gl_attribList[p++] = GLX_ACCUM_RED_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_GREEN:
-                    gl_attribList[p++] = GLX_ACCUM_GREEN_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_BLUE:
-                    gl_attribList[p++] = GLX_ACCUM_BLUE_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_ALPHA:
-                    gl_attribList[p++] = GLX_ACCUM_ALPHA_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        gl_attribList[p] = 0;
-    }
-}
-
-/* static */
-int wxGLCanvas::GetGLXVersion()
-{
-    static int s_glxVersion = 0;
-    if ( s_glxVersion == 0 )
-    {
-        // check the GLX version
-        int glxMajorVer, glxMinorVer;
-        bool ok = glXQueryVersion(GDK_DISPLAY(), &glxMajorVer, &glxMinorVer);
-        wxASSERT_MSG( ok, _T("GLX version not found") );
-        if (!ok)
-            s_glxVersion = 10; // 1.0 by default
-        else
-            s_glxVersion = glxMajorVer*10 + glxMinorVer;
-    }
-
-    return s_glxVersion;
-}
-
-void wxGLCanvas::SwapBuffers()
+Window wxGLCanvas::GetXWindow() const
 {
     GdkWindow *window = GTK_PIZZA(m_wxwindow)->bin_window;
-    glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( window ) );
+    return window ? GDK_WINDOW_XWINDOW(window) : 0;
 }
 
 void wxGLCanvas::OnInternalIdle()
@@ -562,33 +296,4 @@ void wxGLCanvas::GTKInitImplicitContext()
 
 #endif // WXWIN_COMPATIBILITY_2_8
 
-//---------------------------------------------------------------------------
-// wxGLApp
-//---------------------------------------------------------------------------
-
-bool wxGLApp::InitGLVisual(const int *attribList)
-{
-    if ( wxGLCanvas::GetGLXVersion() >= 13 )
-    {
-        if (m_glFBCInfo)
-            XFree(m_glFBCInfo);
-        m_glFBCInfo = wxGLCanvas::ChooseGLFBC(attribList);
-
-        if ( !m_glFBCInfo )
-            return false;
-
-        if (m_glVisualInfo)
-            XFree(m_glVisualInfo);
-        m_glVisualInfo = glXGetVisualFromFBConfig(GDK_DISPLAY(), ((GLXFBConfig *)m_glFBCInfo)[0]);
-    }
-    else // GLX <= 1.2
-    {
-        if (m_glVisualInfo)
-            XFree(m_glVisualInfo);
-        m_glVisualInfo = wxGLCanvas::ChooseGLVisual(attribList);
-    }
-
-    return m_glVisualInfo != NULL;
-}
-
 #endif // wxUSE_GLCANVAS
index 9179b7a0c2ad20cafabf24ba899c0f1c25953459..e865645b87932fe0ec966e8b944fe208116a8c43 100644 (file)
@@ -33,12 +33,6 @@ extern "C"
 #include "wx/gtk1/win_gtk.h"
 #include "wx/gtk1/private.h"
 
-//---------------------------------------------------------------------------
-// global data
-//---------------------------------------------------------------------------
-
-XVisualInfo *g_vi = (XVisualInfo*) NULL;
-
 //-----------------------------------------------------------------------------
 // idle system
 //-----------------------------------------------------------------------------
@@ -46,73 +40,6 @@ XVisualInfo *g_vi = (XVisualInfo*) NULL;
 extern void wxapp_install_idle_handler();
 extern bool g_isIdle;
 
-// ----------------------------------------------------------------------------
-// helper functions
-// ----------------------------------------------------------------------------
-
-// wrapper around glXMakeContextCurrent/glXMakeCurrent depending on GLX
-// version
-static void wxMakeContextCurrent(GLXDrawable drawable, GLXContext context)
-{
-    if (wxGLCanvas::GetGLXVersion() >= 13)
-        glXMakeContextCurrent( GDK_DISPLAY(), drawable, drawable, context);
-    else // GLX <= 1.2 doesn't have glXMakeContextCurrent()
-        glXMakeCurrent( GDK_DISPLAY(), drawable, context);
-}
-
-//---------------------------------------------------------------------------
-// wxGLContext
-//---------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxGLContext,wxObject)
-
-wxGLContext::wxGLContext(wxWindow* win, const wxGLContext* other)
-{
-    wxGLCanvas *gc = (wxGLCanvas*) win;
-
-    if (wxGLCanvas::GetGLXVersion() >= 13)
-    {
-        GLXFBConfig *fbc = gc->m_fbc;
-        wxCHECK_RET( fbc, _T("invalid GLXFBConfig for OpenGl") );
-        m_glContext = glXCreateNewContext( GDK_DISPLAY(), fbc[0], GLX_RGBA_TYPE,
-                                           other ? other->m_glContext : None,
-                                           GL_TRUE );
-    }
-    else // GLX <= 1.2
-    {
-        XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
-        wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
-        m_glContext = glXCreateContext( GDK_DISPLAY(), vi,
-                                        other ? other->m_glContext : None,
-                                        GL_TRUE );
-    }
-
-    wxASSERT_MSG( m_glContext, _T("Couldn't create OpenGl context") );
-}
-
-wxGLContext::~wxGLContext()
-{
-    if ( !m_glContext )
-        return;
-
-    if ( m_glContext == glXGetCurrentContext() )
-        wxMakeContextCurrent(None, NULL);
-
-    glXDestroyContext( GDK_DISPLAY(), m_glContext );
-}
-
-void wxGLContext::SetCurrent(const wxGLCanvas& win) const
-{
-    if ( !m_glContext )
-        return;
-
-    GdkWindow *window = GTK_PIZZA(win.m_wxwindow)->bin_window;
-    wxCHECK_RET( window, _T("window must be shown") );
-
-    wxMakeContextCurrent(GDK_WINDOW_XWINDOW(window), m_glContext);
-}
-
-
 #if WXWIN_COMPATIBILITY_2_8
 
 //-----------------------------------------------------------------------------
@@ -282,53 +209,12 @@ bool wxGLCanvas::Create(wxWindow *parent,
 {
     m_noExpose = true;
     m_nativeSizeEvent = true;
-    m_fbc = NULL;
-    m_vi = NULL;
-
-    if (wxGLCanvas::GetGLXVersion() >= 13)
-    {
-        // GLX >= 1.3 uses a GLXFBConfig
-        GLXFBConfig * fbc = NULL;
-        if (wxTheApp->m_glFBCInfo != NULL)
-        {
-            fbc = (GLXFBConfig *) wxTheApp->m_glFBCInfo;
-            m_canFreeFBC = false; // owned by wxTheApp - don't free upon destruction
-        }
-        else
-        {
-            fbc = (GLXFBConfig *) wxGLCanvas::ChooseGLFBC(attribList);
-            m_canFreeFBC = true;
-        }
-        m_fbc = fbc;  // save for later use
-        wxCHECK_MSG( m_fbc, false, _T("required FBConfig couldn't be found") );
-    }
-
-    XVisualInfo *vi = NULL;
-    if (wxTheApp->m_glVisualInfo != NULL)
-    {
-        vi = (XVisualInfo *)wxTheApp->m_glVisualInfo;
-        m_canFreeVi = false; // owned by wxTheApp - don't free upon destruction
-    }
-    else
-    {
-        if (wxGLCanvas::GetGLXVersion() >= 13)
-        // GLX >= 1.3
-            vi = glXGetVisualFromFBConfig(GDK_DISPLAY(), m_fbc[0]);
-        else
-            // GLX <= 1.2
-            vi = (XVisualInfo *) ChooseGLVisual(attribList);
-
-        m_canFreeVi = true;
-    }
 
-    m_vi = vi;  // save for later use
+    if ( !InitVisual(attribList) )
+        return false;
 
-    wxCHECK_MSG( m_vi, false, _T("required visual couldn't be found") );
-    GdkVisual *visual;
-    GdkColormap *colormap;
-
-    visual = gdkx_visual_get( vi->visualid );
-    colormap = gdk_colormap_new( visual, TRUE );
+    GdkVisual *visual = gdkx_visual_get( GetXVisualInfo()->visualid );
+    GdkColormap *colormap = gdk_colormap_new( visual, TRUE );
 
     gtk_widget_push_colormap( colormap );
     gtk_widget_push_visual( visual );
@@ -373,167 +259,10 @@ bool wxGLCanvas::Create(wxWindow *parent,
     return true;
 }
 
-wxGLCanvas::~wxGLCanvas()
-{
-    GLXFBConfig * fbc = (GLXFBConfig *) m_fbc;
-    if (fbc && m_canFreeFBC)
-        XFree( fbc );
-
-    XVisualInfo *vi = (XVisualInfo *) m_vi;
-    if (vi && m_canFreeVi)
-        XFree( vi );
-}
-
-void* wxGLCanvas::ChooseGLVisual(const int *attribList)
-{
-    int data[512];
-    GetGLAttribListFromWX( attribList, data );
-
-    Display *dpy = GDK_DISPLAY();
-
-    return glXChooseVisual( dpy, DefaultScreen(dpy), data );
-}
-
-void* wxGLCanvas::ChooseGLFBC(const int *attribList)
-{
-    int data[512];
-    GetGLAttribListFromWX( attribList, data );
-
-    int returned;
-    return glXChooseFBConfig( GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
-                              data, &returned );
-}
-
-
-void
-wxGLCanvas::GetGLAttribListFromWX(const int *wx_attribList, int *gl_attribList)
-{
-    if ( !wx_attribList )
-    {
-        if (wxGLCanvas::GetGLXVersion() >= 13)
-        {
-            // leave GLX >= 1.3 choose the default attributes
-            gl_attribList[0] = 0;
-        }
-        else // GLX < 1.3
-        {
-            int i = 0;
-            // default settings if attriblist = 0
-            gl_attribList[i++] = GLX_RGBA;
-            gl_attribList[i++] = GLX_DOUBLEBUFFER;
-            gl_attribList[i++] = GLX_DEPTH_SIZE;   gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_RED_SIZE;     gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_GREEN_SIZE;   gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_BLUE_SIZE;    gl_attribList[i++] = 1;
-            gl_attribList[i++] = GLX_ALPHA_SIZE;   gl_attribList[i++] = 0;
-            gl_attribList[i++] = None;
-        }
-    }
-    else // have non-default attributes
-    {
-        int arg=0, p=0;
-        while( (wx_attribList[arg]!=0) && (p<510) )
-        {
-            switch( wx_attribList[arg++] )
-            {
-                case WX_GL_RGBA:
-                    if (wxGLCanvas::GetGLXVersion() <= 12)
-                    {
-                        // for GLX >= 1.3, GLX_RGBA is useless (setting this flags will crash on most opengl implm)
-                        gl_attribList[p++] = GLX_RGBA;
-                    }
-                    break;
-                case WX_GL_BUFFER_SIZE:
-                    gl_attribList[p++] = GLX_BUFFER_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_LEVEL:
-                    gl_attribList[p++] = GLX_LEVEL;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_DOUBLEBUFFER:
-                    gl_attribList[p++] = GLX_DOUBLEBUFFER;
-                    gl_attribList[p++] = 1;
-                    break;
-                case WX_GL_STEREO:
-                    gl_attribList[p++] = GLX_STEREO;
-                    break;
-                case WX_GL_AUX_BUFFERS:
-                    gl_attribList[p++] = GLX_AUX_BUFFERS;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_RED:
-                    gl_attribList[p++] = GLX_RED_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_GREEN:
-                    gl_attribList[p++] = GLX_GREEN_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_BLUE:
-                    gl_attribList[p++] = GLX_BLUE_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ALPHA:
-                    gl_attribList[p++] = GLX_ALPHA_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_DEPTH_SIZE:
-                    gl_attribList[p++] = GLX_DEPTH_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_STENCIL_SIZE:
-                    gl_attribList[p++] = GLX_STENCIL_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_RED:
-                    gl_attribList[p++] = GLX_ACCUM_RED_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_GREEN:
-                    gl_attribList[p++] = GLX_ACCUM_GREEN_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_BLUE:
-                    gl_attribList[p++] = GLX_ACCUM_BLUE_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                case WX_GL_MIN_ACCUM_ALPHA:
-                    gl_attribList[p++] = GLX_ACCUM_ALPHA_SIZE;
-                    gl_attribList[p++] = wx_attribList[arg++];
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        gl_attribList[p] = 0;
-    }
-}
-
-/* static */
-int wxGLCanvas::GetGLXVersion()
-{
-    static int s_glxVersion = 0;
-    if ( s_glxVersion == 0 )
-    {
-        // check the GLX version
-        int glxMajorVer, glxMinorVer;
-        bool ok = glXQueryVersion(GDK_DISPLAY(), &glxMajorVer, &glxMinorVer);
-        wxASSERT_MSG( ok, _T("GLX version not found") );
-        if (!ok)
-            s_glxVersion = 10; // 1.0 by default
-        else
-            s_glxVersion = glxMajorVer*10 + glxMinorVer;
-    }
-
-    return s_glxVersion;
-}
-
-void wxGLCanvas::SwapBuffers()
+Window wxGLCanvas::GetXWindow() const
 {
     GdkWindow *window = GTK_PIZZA(m_wxwindow)->bin_window;
-    glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( window ) );
+    return window ? GDK_WINDOW_XWINDOW(window) : 0;
 }
 
 void wxGLCanvas::OnInternalIdle()
@@ -566,33 +295,4 @@ void wxGLCanvas::GTKInitImplicitContext()
 
 #endif // WXWIN_COMPATIBILITY_2_8
 
-//---------------------------------------------------------------------------
-// wxGLApp
-//---------------------------------------------------------------------------
-
-bool wxGLApp::InitGLVisual(const int *attribList)
-{
-    if ( wxGLCanvas::GetGLXVersion() >= 13 )
-    {
-        if (m_glFBCInfo)
-            XFree(m_glFBCInfo);
-        m_glFBCInfo = wxGLCanvas::ChooseGLFBC(attribList);
-
-        if ( !m_glFBCInfo )
-            return false;
-
-        if (m_glVisualInfo)
-            XFree(m_glVisualInfo);
-        m_glVisualInfo = glXGetVisualFromFBConfig(GDK_DISPLAY(), ((GLXFBConfig *)m_glFBCInfo)[0]);
-    }
-    else // GLX <= 1.2
-    {
-        if (m_glVisualInfo)
-            XFree(m_glVisualInfo);
-        m_glVisualInfo = wxGLCanvas::ChooseGLVisual(attribList);
-    }
-
-    return m_glVisualInfo != NULL;
-}
-
 #endif // wxUSE_GLCANVAS
diff --git a/src/unix/glx11.cpp b/src/unix/glx11.cpp
new file mode 100644 (file)
index 0000000..576c7c8
--- /dev/null
@@ -0,0 +1,359 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        src/univ/glx11.cpp
+// Purpose:     code common to all X11-based wxGLCanvas implementations
+// Author:      Vadim Zeitlin
+// Created:     2007-04-15
+// RCS-ID:      $Id$
+// Copyright:   (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if wxUSE_GLCANVAS
+
+#ifndef WX_PRECOMP
+#endif //WX_PRECOMP
+
+#include "wx/glcanvas.h"
+
+// ============================================================================
+// wxGLContext implementation
+// ============================================================================
+
+IMPLEMENT_CLASS(wxGLContext, wxObject)
+
+wxGLContext::wxGLContext(wxGLCanvas *gc, const wxGLContext *other)
+{
+    if ( wxGLCanvas::GetGLXVersion() >= 13 )
+    {
+        GLXFBConfig *fbc = gc->GetGLXFBConfig();
+        wxCHECK_RET( fbc, _T("invalid GLXFBConfig for OpenGL") );
+
+        m_glContext = glXCreateNewContext( wxGetX11Display(), fbc[0], GLX_RGBA_TYPE,
+                                           other ? other->m_glContext : None,
+                                           GL_TRUE );
+    }
+    else // GLX <= 1.2
+    {
+        XVisualInfo *vi = gc->GetXVisualInfo();
+        wxCHECK_RET( vi, _T("invalid visual for OpenGL") );
+
+        m_glContext = glXCreateContext( wxGetX11Display(), vi,
+                                        other ? other->m_glContext : None,
+                                        GL_TRUE );
+    }
+
+    wxASSERT_MSG( m_glContext, _T("Couldn't create OpenGL context") );
+}
+
+wxGLContext::~wxGLContext()
+{
+    if ( !m_glContext )
+        return;
+
+    if ( m_glContext == glXGetCurrentContext() )
+        MakeCurrent(None, NULL);
+
+    glXDestroyContext( wxGetX11Display(), m_glContext );
+}
+
+void wxGLContext::SetCurrent(const wxGLCanvas& win) const
+{
+    if ( !m_glContext )
+        return;
+
+    const Window xid = win.GetXWindow();
+    wxCHECK_RET( xid, _T("window must be shown") );
+
+    MakeCurrent(xid, m_glContext);
+}
+
+// wrapper around glXMakeContextCurrent/glXMakeCurrent depending on GLX
+// version
+/* static */
+void wxGLContext::MakeCurrent(GLXDrawable drawable, GLXContext context)
+{
+    if (wxGLCanvas::GetGLXVersion() >= 13)
+        glXMakeContextCurrent( wxGetX11Display(), drawable, drawable, context);
+    else // GLX <= 1.2 doesn't have glXMakeContextCurrent()
+        glXMakeCurrent( wxGetX11Display(), drawable, context);
+}
+
+// ============================================================================
+// wxGLCanvasX11 implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// initialization methods and dtor
+// ----------------------------------------------------------------------------
+
+wxGLCanvasX11::wxGLCanvasX11()
+{
+    m_fbc = NULL;
+    m_vi = NULL;
+}
+
+bool wxGLCanvasX11::InitVisual(const int *attribList)
+{
+    return InitXVisualInfo(attribList, &m_fbc, &m_vi);
+}
+
+wxGLCanvasX11::~wxGLCanvasX11()
+{
+    if ( m_fbc && m_fbc != ms_glFBCInfo )
+        XFree(m_fbc);
+
+    if ( m_vi && m_vi != ms_glVisualInfo )
+        XFree(m_vi);
+}
+
+// ----------------------------------------------------------------------------
+// working with GL attributes
+// ----------------------------------------------------------------------------
+
+bool
+wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n)
+{
+    wxCHECK_MSG( n >= 16, false, _T("GL attributes buffer too small") );
+
+    if ( !wxattrs )
+    {
+        if ( GetGLXVersion() >= 13 )
+        {
+            // leave GLX >= 1.3 choose the default attributes
+            glattrs[0] = None;
+        }
+        else // GLX < 1.3
+        {
+            // default settings if attriblist = 0
+            size_t i = 0;
+            glattrs[i++] = GLX_RGBA;
+            glattrs[i++] = GLX_DOUBLEBUFFER;
+            glattrs[i++] = GLX_DEPTH_SIZE;   glattrs[i++] = 1;
+            glattrs[i++] = GLX_RED_SIZE;     glattrs[i++] = 1;
+            glattrs[i++] = GLX_GREEN_SIZE;   glattrs[i++] = 1;
+            glattrs[i++] = GLX_BLUE_SIZE;    glattrs[i++] = 1;
+            glattrs[i++] = GLX_ALPHA_SIZE;   glattrs[i++] = 0;
+            glattrs[i++] = None;
+
+            wxASSERT_MSG( i < n, _T("GL attributes buffer too small") );
+        }
+    }
+    else // have non-default attributes
+    {
+        size_t p = 0;
+        for ( int arg = 0; wxattrs[arg] != 0; )
+        {
+            // check if we have any space left, knowing that we may insert 2
+            // more elements during this loop iteration and we always need to
+            // terminate the list with None (hence -3)
+            if ( p >= n - 2 )
+                return false;
+
+            // notice that for boolean attributes we use "continue" in the
+            // switch to skip the assignment of the attribute value at the end
+            // of the loop which is done for integer attributes
+            switch ( wxattrs[arg++] )
+            {
+                case WX_GL_RGBA:
+                    // for GLX >= 1.3, GLX_RGBA is useless and apparently
+                    // harmful for some implementations
+                    //
+                    // FIXME: is this true?
+                    if ( GetGLXVersion() <= 12 )
+                    {
+                        glattrs[p++] = GLX_RGBA;
+                    }
+                    continue;
+
+                case WX_GL_BUFFER_SIZE:
+                    glattrs[p++] = GLX_BUFFER_SIZE;
+                    break;
+
+                case WX_GL_LEVEL:
+                    glattrs[p++] = GLX_LEVEL;
+                    break;
+
+                case WX_GL_DOUBLEBUFFER:
+                    glattrs[p++] = GLX_DOUBLEBUFFER;
+                    continue;
+
+                case WX_GL_STEREO:
+                    glattrs[p++] = GLX_STEREO;
+                    break;
+
+                case WX_GL_AUX_BUFFERS:
+                    glattrs[p++] = GLX_AUX_BUFFERS;
+                    break;
+
+                case WX_GL_MIN_RED:
+                    glattrs[p++] = GLX_RED_SIZE;
+                    break;
+
+                case WX_GL_MIN_GREEN:
+                    glattrs[p++] = GLX_GREEN_SIZE;
+                    break;
+
+                case WX_GL_MIN_BLUE:
+                    glattrs[p++] = GLX_BLUE_SIZE;
+                    break;
+
+                case WX_GL_MIN_ALPHA:
+                    glattrs[p++] = GLX_ALPHA_SIZE;
+                    break;
+
+                case WX_GL_DEPTH_SIZE:
+                    glattrs[p++] = GLX_DEPTH_SIZE;
+                    break;
+
+                case WX_GL_STENCIL_SIZE:
+                    glattrs[p++] = GLX_STENCIL_SIZE;
+                    break;
+
+                case WX_GL_MIN_ACCUM_RED:
+                    glattrs[p++] = GLX_ACCUM_RED_SIZE;
+                    break;
+
+                case WX_GL_MIN_ACCUM_GREEN:
+                    glattrs[p++] = GLX_ACCUM_GREEN_SIZE;
+                    break;
+
+                case WX_GL_MIN_ACCUM_BLUE:
+                    glattrs[p++] = GLX_ACCUM_BLUE_SIZE;
+                    break;
+
+                case WX_GL_MIN_ACCUM_ALPHA:
+                    glattrs[p++] = GLX_ACCUM_ALPHA_SIZE;
+                    break;
+
+                default:
+                    wxLogDebug(_T("Unsupported OpenGL attribute %d"),
+                               wxattrs[arg - 1]);
+                    continue;
+            }
+
+            // copy attribute value as is
+            glattrs[p++] = wxattrs[arg++];
+        }
+
+        glattrs[p] = None;
+    }
+
+    return true;
+}
+
+/* static */
+bool
+wxGLCanvasX11::InitXVisualInfo(const int *attribList,
+                               GLXFBConfig **pFBC,
+                               XVisualInfo **pXVisual)
+{
+    int data[512];
+    if ( !ConvertWXAttrsToGL(attribList, data, WXSIZEOF(data)) )
+        return false;
+
+    Display * const dpy = wxGetX11Display();
+
+    if ( GetGLXVersion() >= 13 )
+    {
+        int returned;
+        *pFBC = glXChooseFBConfig(dpy, DefaultScreen(dpy), data, &returned);
+
+        if ( *pFBC )
+        {
+            *pXVisual = glXGetVisualFromFBConfig(wxGetX11Display(), **pFBC);
+            if ( !*pXVisual )
+            {
+                XFree(*pFBC);
+                *pFBC = NULL;
+            }
+        }
+    }
+    else // GLX <= 1.2
+    {
+        *pFBC = NULL;
+        *pXVisual = glXChooseVisual(dpy, DefaultScreen(dpy), data);
+    }
+
+    return *pXVisual != NULL;
+}
+
+// ----------------------------------------------------------------------------
+// default visual management
+// ----------------------------------------------------------------------------
+
+XVisualInfo *wxGLCanvasX11::ms_glVisualInfo = NULL;
+GLXFBConfig *wxGLCanvasX11::ms_glFBCInfo = NULL;
+
+/* static */
+bool wxGLCanvasX11::InitDefaultVisualInfo(const int *attribList)
+{
+    FreeDefaultVisualInfo();
+
+    return InitXVisualInfo(attribList, &ms_glFBCInfo, &ms_glVisualInfo);
+}
+
+/* static */
+void wxGLCanvasX11::FreeDefaultVisualInfo()
+{
+    if ( ms_glFBCInfo )
+    {
+        XFree(ms_glFBCInfo);
+        ms_glFBCInfo = NULL;
+    }
+
+    if ( ms_glVisualInfo )
+    {
+        XFree(ms_glVisualInfo);
+        ms_glVisualInfo = NULL;
+    }
+}
+
+// ----------------------------------------------------------------------------
+// other GL methods
+// ----------------------------------------------------------------------------
+
+/* static */
+int wxGLCanvasX11::GetGLXVersion()
+{
+    static int s_glxVersion = 0;
+    if ( s_glxVersion == 0 )
+    {
+        // check the GLX version
+        int glxMajorVer, glxMinorVer;
+        bool ok = glXQueryVersion(wxGetX11Display(), &glxMajorVer, &glxMinorVer);
+        wxASSERT_MSG( ok, _T("GLX version not found") );
+        if (!ok)
+            s_glxVersion = 10; // 1.0 by default
+        else
+            s_glxVersion = glxMajorVer*10 + glxMinorVer;
+    }
+
+    return s_glxVersion;
+}
+
+void wxGLCanvasX11::SwapBuffers()
+{
+    const Window xid = GetXWindow();
+    wxCHECK_RET( xid, _T("window must be shown") );
+
+    glXSwapBuffers(wxGetX11Display(), xid);
+}
+
+bool wxGLCanvasX11::IsShownOnScreen() const
+{
+    return GetXWindow() && wxGLCanvasBase::IsShownOnScreen();
+}
+
+#endif // wxUSE_GLCANVAS
+
index f3917ebdf359d09a8a651933ab284416c8be7b53..acc31346dd9f7366e7bab730f861c357581f291d 100644 (file)
 #include "wx/glcanvas.h"
 
 #ifndef WX_PRECOMP
-    #include "wx/log.h"
     #include "wx/app.h"
     #include "wx/utils.h"
 #endif
 
-#ifdef __VMS
-# pragma message disable nosimpint
-#endif
-#include <X11/Xlib.h>
-#ifdef __VMS
-# pragma message enable nosimpint
-#endif
-#include "wx/x11/private.h"
-
-// ----------------------------------------------------------------------------
-// local functions
-// ----------------------------------------------------------------------------
-
-static inline Window wxGetClientAreaWindow(const wxWindow* win)
-{
-    return (Window)win->
-#ifdef __WXMOTIF__
-    GetClientXWindow();
-#else
-    GetClientAreaWindow();
-#endif
-}
-
 // ============================================================================
 // implementation
 // ============================================================================
 
-// ----------------------------------------------------------------------------
-// wxGLContext
-// ----------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxGLContext, wxObject)
-
-wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other)
-{
-    XVisualInfo *vi = (XVisualInfo *) win->m_vi;
-    wxASSERT_MSG( vi, wxT("invalid visual in wxGLCanvas") );
-
-    m_glContext = glXCreateContext( (Display *)wxGetDisplay(),
-                                    vi,
-                                    other ? other->m_glContext : None,
-                                    GL_TRUE);
-
-    wxASSERT_MSG( m_glContext, wxT("Couldn't create OpenGL context") );
-}
-
-wxGLContext::~wxGLContext()
-{
-    if (!m_glContext)
-        return;
-
-    if (m_glContext == glXGetCurrentContext())
-    {
-        glXMakeCurrent( (Display*) wxGetDisplay(), None, NULL);
-    }
-
-    glXDestroyContext( (Display*) wxGetDisplay(), m_glContext );
-}
-
-void wxGLContext::SetCurrent(const wxGLCanvas& win) const
-{
-    if (m_glContext)
-    {
-        Display* display = (Display*) wxGetDisplay();
-        glXMakeCurrent(display, wxGetClientAreaWindow(&win), m_glContext);
-    }
-}
-
-// ----------------------------------------------------------------------------
-// wxGLCanvas
-// ----------------------------------------------------------------------------
-
 IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
 
 wxGLCanvas::wxGLCanvas(wxWindow *parent,
@@ -132,103 +63,23 @@ bool wxGLCanvas::Create(wxWindow *parent,
                         const int *attribList,
                         const wxPalette& palette)
 {
-    m_vi = NULL;
-
     if ( !wxWindow::Create(parent, id, pos, size, style, name) )
         return false;
 
-    XVisualInfo *vi, vi_templ;
-    XWindowAttributes xwa;
-    int val, n;
-
-    Display* display = (Display*) wxGetDisplay();
-
-    // Check for the presence of the GLX extension
-    if(!glXQueryExtension(display, NULL, NULL))
-    {
-        wxLogDebug(wxT("wxGLCanvas: GLX extension is missing"));
+    if ( !InitVisual(attribList) )
         return false;
-    }
-
-    if(attribList) {
-      int data[512], arg=0, p=0;
-
-      while( (attribList[arg]!=0) && (p<512) )
-      {
-        switch( attribList[arg++] )
-        {
-          case WX_GL_RGBA: data[p++] = GLX_RGBA; break;
-          case WX_GL_BUFFER_SIZE:
-            data[p++]=GLX_BUFFER_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_LEVEL:
-            data[p++]=GLX_LEVEL; data[p++]=attribList[arg++]; break;
-          case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break;
-          case WX_GL_STEREO: data[p++] = GLX_STEREO; break;
-          case WX_GL_AUX_BUFFERS:
-            data[p++]=GLX_AUX_BUFFERS; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_RED:
-            data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_GREEN:
-            data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_BLUE:
-            data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_ALPHA:
-            data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_DEPTH_SIZE:
-            data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_STENCIL_SIZE:
-            data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_ACCUM_RED:
-            data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_ACCUM_GREEN:
-            data[p++]=GLX_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_ACCUM_BLUE:
-            data[p++]=GLX_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break;
-          case WX_GL_MIN_ACCUM_ALPHA:
-            data[p++]=GLX_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
-          default:
-            break;
-        }
-      }
-      data[p] = 0;
-
-      // Get an appropriate visual
-      vi = glXChooseVisual(display, DefaultScreen(display), data);
-      if(!vi) return false;
-
-      // Here we should make sure that vi is the same visual as the
-      // one used by the xwindow drawable in wxCanvas.  However,
-      // there is currently no mechanism for this in wx_canvs.cc.
-    }
-    else // default attributes
-    {
-        // By default, we use the visual of xwindow
-      XGetWindowAttributes(display, wxGetClientAreaWindow(this), &xwa);
-      vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
-      vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
-      if(!vi) return false;
-      glXGetConfig(display, vi, GLX_USE_GL, &val);
-      if(!val) return false;
-    }
-
-    m_vi = vi;  // safe for later use
-
-    wxCHECK_MSG( m_vi, false, wxT("required visual couldn't be found") );
 
     return true;
 }
 
-wxGLCanvas::~wxGLCanvas()
-{
-    XVisualInfo *vi = (XVisualInfo *) m_vi;
-
-    if (vi)
-        XFree( vi );
-}
-
-void wxGLCanvas::SwapBuffers()
+Window wxGLCanvas::GetXWindow() const
 {
-    glXSwapBuffers((Display *)wxGetDisplay(), wxGetClientAreaWindow(this));
+    return (Window)
+#ifdef __WXMOTIF__
+        GetClientXWindow();
+#else
+        GetClientAreaWindow();
+#endif
 }
 
 int wxGLCanvas::GetColourIndex(const wxColour& col_)