Browse Source

do first test drawing in wx

jp9000 12 years ago
parent
commit
27be0a515b
5 changed files with 44 additions and 0 deletions
  1. 37 0
      obs/obs-app.cpp
  2. 1 0
      obs/obs-app.hpp
  3. 2 0
      obs/window-obs-basic.hpp
  4. 1 0
      vs/2010/OBS/OBS.vcxproj
  5. 3 0
      vs/2010/OBS/OBS.vcxproj.filters

+ 37 - 0
obs/obs-app.cpp

@@ -15,6 +15,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
 
+#include <util/bmem.h>
 #include "obs-app.hpp"
 #include "window-obs-basic.hpp"
 #include "obs-wrappers.hpp"
@@ -26,9 +27,45 @@ bool OBSApp::OnInit()
 	if (!wxApp::OnInit())
 		return false;
 
+	if (!obs_startup())
+		return false;
+
 	wxInitAllImageHandlers();
 
 	OBSBasic *mainWindow = new OBSBasic();
+
+	const wxPanel *preview = mainWindow->GetPreviewPanel();
+	wxRect rc = mainWindow->GetPreviewPanel()->GetClientRect();
+
+	struct obs_video_info ovi;
+	ovi.adapter         = 0;
+	ovi.base_width      = rc.width;
+	ovi.base_height     = rc.height;
+	ovi.fps_num         = 30000;
+	ovi.fps_den         = 1001;
+	ovi.graphics_module = "libobs-opengl";
+	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
+
+	if (!obs_reset_video(&ovi))
+		return false;
+
 	mainWindow->Show();
 	return true;
 }
+
+int OBSApp::OnExit()
+{
+	obs_shutdown();
+	blog(LOG_INFO, "Number of memory leaks: %u", bnum_allocs());
+
+	wxApp::OnExit();
+	return 0;
+}

+ 1 - 0
obs/obs-app.hpp

@@ -23,4 +23,5 @@
 class OBSApp : public wxApp {
 public:
 	virtual bool OnInit();
+	virtual int OnExit();
 };

+ 2 - 0
obs/window-obs-basic.hpp

@@ -40,4 +40,6 @@ protected:
 
 public:
 	inline OBSBasic() : OBSBasicBase(NULL) {}
+
+	inline const wxPanel *GetPreviewPanel() const {return previewPanel;}
 };

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

@@ -174,6 +174,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\obs\obs-app.hpp" />
+    <ClInclude Include="..\..\..\obs\obs-wrappers.hpp" />
     <ClInclude Include="..\..\..\obs\OBSWindows.h" />
     <ClInclude Include="..\..\..\obs\window-obs-basic.hpp" />
     <ClInclude Include="..\..\..\obs\window-subclass.hpp" />

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

@@ -41,5 +41,8 @@
     <ClInclude Include="..\..\..\obs\obs-app.hpp">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\obs\obs-wrappers.hpp">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>