0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / ViewerTest / ViewerTest_AviCommands.cxx
1 // File:      ViewerTest_AviCommands.cxx
2 // Created:   30.06.08 18:02
3 // Author:    Alexander GRIGORIEV
4 // Copyright: Open Cascade 2008
5
6
7 #ifdef WNT
8 #include <windows.h>
9 #endif
10
11 #include <ViewerTest.hxx>
12 #include <Draw_Interpretor.hxx>
13 #include <OpenGl_AVIWriter.hxx>
14
15 static Standard_Integer avi_record(Draw_Interpretor& di,
16                                    Standard_Integer argc, const char** argv)
17 {
18   Standard_Integer aResult(1);
19   if (argc < 2) {
20     cout << "Syntax: " << argv[0] << " file | start | stop | save" << endl;
21   } else {
22
23 #ifndef WNT
24     cout << "AVI writer is implemented only in Windows version" << endl;
25 #else  
26     static OpenGl_AVIWriter * pAviWriter = 0L;
27
28     if (strncmp(argv[1], "file", 5) == 0) {
29       if (argc < 3) {
30         cout << "Please define the name of AVI file to create ..." << endl;
31       } else {
32         const char * aFilename = argv[2];
33         DWORD aFormat = mmioFOURCC('X','V','I','D');
34         if (argc > 3) {
35           const char * aFourcc = argv[3];
36           aFormat = mmioFOURCC(aFourcc[0], aFourcc[1], aFourcc[2], aFourcc[3]);
37         }
38         pAviWriter = new OpenGl_AVIWriter (aFilename, aFormat, 25);
39         aResult = 0;
40       }
41     } else if (pAviWriter == 0L) {
42       cout << "AVI Writer instance has not been initialized. Use command "
43            << argv[0] << " file ..." << endl;
44     } else if (strncmp(argv[1], "start", 6) == 0) {
45       pAviWriter->StartRecording();
46       aResult = 0;
47     } else if (strncmp(argv[1], "stop", 5) == 0) {
48       pAviWriter->StopRecording();
49       aResult = 0;
50     } else if (strncmp(argv[1], "save", 5) == 0) {
51       pAviWriter->StopRecording();
52       delete pAviWriter;
53       pAviWriter = 0L;
54       aResult = 0;
55     } else if (strncmp(argv[1], "status", 7) == 0) {
56       cout << pAviWriter->GetLastErrorMessage() << endl;
57       aResult = 0;
58     }
59 #endif
60   }
61   return aResult;
62 }
63
64 //=======================================================================
65 //function : AviCommands
66 //purpose  : 
67 //=======================================================================
68
69 void ViewerTest::AviCommands(Draw_Interpretor& theCommands)
70 {
71   const char* group = "ViewerTest AVI commands";
72
73   theCommands.Add("vrecord", "vrecord [option]\n"
74                   "where [option] can be:\n"
75                   "\tfile <filename.avi> <FOURCC=VIDX': Create AVI file "
76                                          "for recording,\n"
77                   "\tstart              : begin/restart recording,\n"
78                   "\tstop               : stop recording,\n"
79                   "\tstatus             : log error message,\n"
80                   "\tsave               : close the AVI file\n",
81                   __FILE__,
82                   &avi_record, group); //Draft_Modification
83 }
84
85
86