Browse Source

add a 'wrapper' file for wx

jp9000 12 years ago
parent
commit
7e89ebce46

+ 1 - 0
obs/CMakeLists.txt

@@ -30,6 +30,7 @@ link_libraries(${wxWidgets_LIBRARIES})
 add_executable(obs
 	window-obs-basic.cpp
 	window-subclass.cpp
+	wx-wrappers.cpp
 	obs-app.cpp
 	OBSWindows.cpp)
 

+ 1 - 0
obs/makefile.am

@@ -13,4 +13,5 @@ obs_PROGRAMS = obs
 obs_SOURCES = window-obs-basic.cpp \
 	      window-subclass.cpp \
 	      obs-app.cpp \
+	      wx-wrappers.cpp \
 	      OBSWindows.cpp

+ 2 - 6
obs/obs-app.cpp

@@ -19,6 +19,7 @@
 #include "obs-app.hpp"
 #include "window-obs-basic.hpp"
 #include "obs-wrappers.hpp"
+#include "wx-wrappers.hpp"
 
 IMPLEMENT_APP(OBSApp)
 
@@ -47,12 +48,7 @@ bool OBSApp::OnInit()
 	ovi.output_format   = VIDEO_FORMAT_RGBA;
 	ovi.output_width    = rc.width;
 	ovi.output_height   = rc.height;
-
-#ifdef __WXCOCOA__
-	ovi.window.view     = preview->GetHandle();
-#elif _WIN32
-	ovi.window.hwnd     = preview->GetHandle();
-#endif
+	ovi.window          = WxToGSWindow(preview);
 
 	if (!obs_reset_video(&ovi))
 		return false;

+ 2 - 0
obs/obs-wrappers.hpp

@@ -17,6 +17,8 @@
 
 #pragma once
 
+#include <obs.h>
+
 class OBSSource {
 	obs_source_t source;
 

+ 33 - 0
obs/wx-wrappers.cpp

@@ -0,0 +1,33 @@
+/******************************************************************************
+    Copyright (C) 2013 by Hugh Bailey <[email protected]>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+******************************************************************************/
+
+#include <wx/window.h>
+#include <obs.h>
+#include "wx-wrappers.hpp"
+
+gs_window WxToGSWindow(const wxWindow *wxwin)
+{
+	gs_window window;
+#ifdef __WXCOCOA__
+	window.view     = wxwin->GetHandle();
+#elif _WIN32
+	window.hwnd     = wxwin->GetHandle();
+#else
+	/* TODO: linux stuff */
+#endif
+	return window;
+}

+ 23 - 0
obs/wx-wrappers.hpp

@@ -0,0 +1,23 @@
+/******************************************************************************
+    Copyright (C) 2013 by Hugh Bailey <[email protected]>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+******************************************************************************/
+
+#pragma once
+
+struct gs_window;
+class wxWindow;
+
+gs_window WxToGSWindow(const wxWindow *window);

+ 2 - 0
vs/2010/OBS/OBS.vcxproj

@@ -171,6 +171,7 @@
     <ClCompile Include="..\..\..\obs\OBSWindows.cpp" />
     <ClCompile Include="..\..\..\obs\window-obs-basic.cpp" />
     <ClCompile Include="..\..\..\obs\window-subclass.cpp" />
+    <ClCompile Include="..\..\..\obs\wx-wrappers.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\obs\obs-app.hpp" />
@@ -178,6 +179,7 @@
     <ClInclude Include="..\..\..\obs\OBSWindows.h" />
     <ClInclude Include="..\..\..\obs\window-obs-basic.hpp" />
     <ClInclude Include="..\..\..\obs\window-subclass.hpp" />
+    <ClInclude Include="..\..\..\obs\wx-wrappers.hpp" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 6 - 0
vs/2010/OBS/OBS.vcxproj.filters

@@ -27,6 +27,9 @@
     <ClCompile Include="..\..\..\obs\obs-app.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\obs\wx-wrappers.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\obs\OBSWindows.h">
@@ -44,5 +47,8 @@
     <ClInclude Include="..\..\..\obs\obs-wrappers.hpp">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\obs\wx-wrappers.hpp">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>