![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 /* 00002 Copyright 2005-2010 Intel Corporation. All Rights Reserved. 00003 00004 This file is part of Threading Building Blocks. 00005 00006 Threading Building Blocks is free software; you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License 00008 version 2 as published by the Free Software Foundation. 00009 00010 Threading Building Blocks is distributed in the hope that it will be 00011 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00012 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Threading Building Blocks; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 As a special exception, you may use this file as part of a free software 00020 library without restriction. Specifically, if other files instantiate 00021 templates or use macros or inline functions from this file, or you compile 00022 this file and link it with other files to produce an executable, this 00023 file does not by itself cause the resulting executable to be covered by 00024 the GNU General Public License. This exception does not however 00025 invalidate any other reasons why the executable file might be covered by 00026 the GNU General Public License. 00027 */ 00028 00029 #include "video.h" 00030 #include <cassert> 00031 #include <stdio.h> 00032 00033 unsigned int * g_pImg = 0; 00034 int g_sizex, g_sizey; 00035 static video *g_video = 0; 00036 static int g_fps = 0; 00037 00038 #if _WIN32 || _WIN64 00039 00040 static DWORD g_msec = 0; 00041 #ifdef _WINDOWS 00042 HINSTANCE video::win_hInstance = 0; 00043 int video::win_iCmdShow = 0; 00044 void video::win_set_class(WNDCLASSEX &wcex) { } 00045 void video::win_load_accelerators(int idc) { } 00046 #endif //_WINDOWS 00047 00048 #else 00049 00050 #include <sched.h> 00051 #include <sys/time.h> 00052 struct timeval g_time; 00053 00054 #endif //_WIN32||_WIN64 00055 00056 video::video() 00057 : red_mask(0xff0000), red_shift(16), green_mask(0xff00), 00058 green_shift(8), blue_mask(0xff), blue_shift(0), depth(24) 00059 { 00060 assert(g_video == 0); 00061 g_video = this; title = "Video"; updating = calc_fps = false; 00062 } 00063 00064 bool video::init_window(int x, int y) 00065 { 00066 g_sizex = x; g_sizey = y; 00067 g_pImg = new unsigned int[x*y]; 00068 running = true; 00069 return false; 00070 } 00071 00072 bool video::init_console() 00073 { 00074 running = true; 00075 return true; 00076 } 00077 00078 void video::terminate() 00079 { 00080 if(calc_fps) { 00081 double fps = g_fps; 00082 #if _WIN32 || _WIN64 00083 fps /= (GetTickCount()-g_msec)/1000.0; 00084 #else 00085 struct timezone tz; struct timeval end_time; gettimeofday(&end_time, &tz); 00086 fps /= (end_time.tv_sec+1.0*end_time.tv_usec/1000000.0) - (g_time.tv_sec+1.0*g_time.tv_usec/1000000.0); 00087 #endif 00088 printf("%s: %.1f fps\n", title, fps); 00089 } 00090 g_video = 0; running = false; 00091 if(g_pImg) { delete[] g_pImg; g_pImg = 0; } 00092 } 00093 00094 video::~video() 00095 { 00096 if(g_video) terminate(); 00097 } 00098 00100 bool video::next_frame() 00101 { 00102 if(calc_fps){ 00103 if(!g_fps) { 00104 #if _WIN32 || _WIN64 00105 g_msec = GetTickCount(); 00106 #else 00107 struct timezone tz; gettimeofday(&g_time, &tz); 00108 #endif 00109 } 00110 g_fps++; 00111 } 00112 return running; 00113 } 00114 00116 void video::main_loop() 00117 { 00118 on_process(); 00119 } 00120 00122 void video::show_title() 00123 { 00124 } 00125 00127 00128 drawing_area::drawing_area(int x, int y, int sizex, int sizey) 00129 : start_x(x), start_y(y), size_x(sizex), size_y(sizey), pixel_depth(24), 00130 base_index(y*g_sizex + x), max_index(g_sizex*g_sizey), index_stride(g_sizex), ptr32(g_pImg) 00131 { 00132 assert(x < g_sizex); assert(y < g_sizey); 00133 assert(x+sizex <= g_sizex); assert(y+sizey <= g_sizey); 00134 00135 index = base_index; // current index 00136 } 00137 00138 drawing_area::~drawing_area() {}
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.