add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / test2.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "guicast.h"
23 #include "vframe.h"
24 #include <sys/time.h>
25
26 class TestWindow : public BC_Window
27 {
28 public:
29         TestWindow() : BC_Window("test", 0, 0, 640, 480) {}
30 };
31
32 typedef struct
33 {
34         struct timeval start_time;
35         struct timeval last_time;
36         int64_t frames;
37 } status_t;
38
39
40
41 static void init_status(status_t *status)
42 {
43         gettimeofday(&status->start_time, 0);
44         gettimeofday(&status->last_time, 0);
45         status->frames = 0;
46 }
47
48 static void update_status(status_t *status)
49 {
50         struct timeval new_time;
51         gettimeofday(&new_time, 0);
52         if(new_time.tv_sec - status->last_time.tv_sec > 1)
53         {
54                 fprintf(stderr, "%lld frames.  %lld frames/sec      \r",
55                         status->frames,
56                         (int64_t)status->frames /
57                         (int64_t)(new_time.tv_sec - status->start_time.tv_sec));
58                 fflush(stdout);
59                 status->last_time = new_time;
60         };
61 }
62
63 static void stop_status()
64 {
65         fprintf(stderr, "\n\n");
66 }
67
68
69
70 int main(int argc, char *argv[])
71 {
72         TestWindow window;
73         status_t status;
74
75 //      int result = window.accel_available(BC_YUV422);
76 //      printf("accel_available == %d\n", result);
77         window.start_video();
78         BC_Bitmap *bitmap1 = window.new_bitmap(640, 480, BC_BGR8888);
79
80         init_status(&status);
81         while(1)
82         {
83                 window.draw_bitmap(bitmap1, 1);
84                 window.flash();
85                 update_status(&status);
86                 status.frames++;
87         }
88 };