diff options
author | Aki <please@ignore.pl> | 2022-01-31 22:19:15 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-01-31 22:19:15 +0100 |
commit | 975a232cfb08410177af2ba06251e4c553780e7b (patch) | |
tree | 3df7b72e1fed61ee4375f4304c424053017653fa /Stars45 | |
parent | c01469dddabe404506ef3a64542e8423f9e11f2c (diff) | |
download | starshatter-975a232cfb08410177af2ba06251e4c553780e7b.zip starshatter-975a232cfb08410177af2ba06251e4c553780e7b.tar.gz starshatter-975a232cfb08410177af2ba06251e4c553780e7b.tar.bz2 |
Removed AVI recording functionality
Diffstat (limited to 'Stars45')
-rw-r--r-- | Stars45/AviFile.cpp | 203 | ||||
-rw-r--r-- | Stars45/AviFile.h | 87 | ||||
-rw-r--r-- | Stars45/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Stars45/Game.cpp | 140 | ||||
-rw-r--r-- | Stars45/Game.h | 6 | ||||
-rw-r--r-- | Stars45/Starshatter.cpp | 3 |
6 files changed, 1 insertions, 439 deletions
diff --git a/Stars45/AviFile.cpp b/Stars45/AviFile.cpp deleted file mode 100644 index f2e069c..0000000 --- a/Stars45/AviFile.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* Starshatter OpenSource Distribution - Copyright (c) 1997-2004, Destroyer Studios LLC. - All Rights Reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name "Destroyer Studios" nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - SUBSYSTEM: nGenEx.lib - FILE: AviFile.cpp - AUTHOR: John DiCamillo - - - OVERVIEW - ======== - AviFile reader / writer -*/ - - -#include "MemDebug.h" -#include "AviFile.h" - -#include <vfw.h> -#include <stdio.h> -#include <stdlib.h> - -// +--------------------------------------------------------------------+ - -void Print(const char* fmt, ...); - -// +--------------------------------------------------------------------+ - -AviFile::AviFile(const char* fname) -: filename(fname), fps(0), play(true), pfile(0), ps(0), ps_comp(0), -nframe(0), nsamp(0), iserr(false), frame_size(0) -{ - AVIFileInit(); -} - -AviFile::AviFile(const char* fname, const Rect& r, int frame_rate) -: filename(fname), rect(r), fps(frame_rate), play(false), pfile(0), -ps(0), ps_comp(0), nframe(0), nsamp(0), iserr(false) -{ - Print("\n\nAviFile(%s, w=%d, h=%d, f=%d FPS)\n", fname, r.w, r.h, fps); - frame_size = r.w * r.h * 3; - - AVIFileInit(); - HRESULT hr = AVIFileOpen(&pfile, fname, OF_WRITE|OF_CREATE, 0); - - if (hr != AVIERR_OK) { - Print("AviFile - open failed. %08x\n", hr); - iserr = true; - return; - } - - Print("AviFile - open successful\n"); - - AVISTREAMINFO strhdr; - ZeroMemory(&strhdr,sizeof(strhdr)); - - strhdr.fccType = streamtypeVIDEO; - strhdr.fccHandler = 0; - strhdr.dwScale = 1000 / fps; - strhdr.dwRate = 1000; - strhdr.dwSuggestedBufferSize = frame_size; - - SetRect(&strhdr.rcFrame, 0, 0, r.w, r.h); - - hr = AVIFileCreateStream(pfile, &ps, &strhdr); - - if (hr != AVIERR_OK) { - Print("AviFile - create stream failed. %08x\n", hr); - iserr = true; - return; - } - - Print("AviFile - create stream successful\n"); - - AVICOMPRESSOPTIONS opts; - ZeroMemory(&opts,sizeof(opts)); - opts.fccType = streamtypeVIDEO; - //opts.fccHandler = mmioFOURCC('W','M','V','3'); - opts.fccHandler = mmioFOURCC('D','I','B',' '); // (full frames) - opts.dwFlags = 8; - - hr = AVIMakeCompressedStream(&ps_comp, ps, &opts, 0); - if (hr != AVIERR_OK) { - Print("AviFile - compressed stream failed. %08x\n", hr); - iserr=true; - return; - } - - Print("AviFile - make compressed stream successful\n"); - - BITMAPINFOHEADER bmih; - ZeroMemory(&bmih, sizeof(BITMAPINFOHEADER)); - - bmih.biSize = sizeof(BITMAPINFOHEADER); - bmih.biBitCount = 24; - bmih.biCompression = BI_RGB; - bmih.biWidth = rect.w; - bmih.biHeight = rect.h; - bmih.biPlanes = 1; - bmih.biSizeImage = frame_size; - - hr = AVIStreamSetFormat(ps_comp, 0, &bmih, sizeof(BITMAPINFOHEADER)); - - if (hr != AVIERR_OK) { - Print("AviFile - stream format failed. %08x\n", hr); - iserr=true; - return; - } - - Print("AviFile - stream format successful\n"); -} - -AviFile::~AviFile() -{ - if (!play) { - Print("*** Closing AVI file '%s' with %d frames\n", (const char*) filename, nframe); - } - - if (ps_comp) AVIStreamRelease(ps_comp); - if (ps) AVIStreamRelease(ps); - if (pfile) AVIFileRelease(pfile); - - AVIFileExit(); -} - -// +--------------------------------------------------------------------+ -// -// Note that AVI frames use DIB format - Y is inverted. -// So we need to flip the native bmp before sending to the -// file. - -HRESULT -AviFile::AddFrame(const Bitmap& bmp) -{ - HRESULT hr = E_FAIL; - - if (!iserr && !play && bmp.IsHighColor() && bmp.Width() == rect.w && bmp.Height() == rect.h) { - int w = bmp.Width(); - int h = bmp.Height(); - BYTE* buffer = new(__FILE__,__LINE__) BYTE[frame_size]; - BYTE* dst = buffer; - - for (int y = 0; y < bmp.Height(); y++) { - Color* src = bmp.HiPixels() + (h - 1 - y) * w; - - for (int x = 0; x < bmp.Width(); x++) { - *dst++ = (BYTE) src->Blue(); - *dst++ = (BYTE) src->Green(); - *dst++ = (BYTE) src->Red(); - src++; - } - } - -#pragma warning(suppress: 6001) - hr = AVIStreamWrite(ps_comp, nframe, 1, buffer, frame_size, AVIIF_KEYFRAME, 0, 0); - - if (SUCCEEDED(hr)) { - nframe++; - } - else { - Print("AVIStreamWriteFile failed. %08x\n", hr); - iserr = true; - } - - delete [] buffer; - } - - return hr; -} - -// +--------------------------------------------------------------------+ - -HRESULT -AviFile::GetFrame(double seconds, Bitmap& bmp) -{ - HRESULT hr = E_FAIL; - return hr; -} - diff --git a/Stars45/AviFile.h b/Stars45/AviFile.h deleted file mode 100644 index 4c1c2ca..0000000 --- a/Stars45/AviFile.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Starshatter OpenSource Distribution - Copyright (c) 1997-2004, Destroyer Studios LLC. - All Rights Reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name "Destroyer Studios" nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - SUBSYSTEM: nGenEx.lib - FILE: AviFile.h - AUTHOR: John DiCamillo - - - OVERVIEW - ======== - PCX image file loader -*/ - -#ifndef AviFile_h -#define AviFile_h - -#include "Text.h" -#include "Color.h" -#include "Bitmap.h" -#include "Geometry.h" - -// +--------------------------------------------------------------------+ - -struct IAVIFile; -struct IAVIStream; - -// +--------------------------------------------------------------------+ - -class AviFile -{ -public: - static const char* TYPENAME() { return "AviFile"; } - - // open for reading: - AviFile(const char* fname); - - // create for writing - AviFile(const char* fname, const Rect& rect, int frame_rate=30); - ~AviFile(); - - HRESULT AddFrame(const Bitmap& bmp); - HRESULT GetFrame(double seconds, Bitmap& bmp); - -private: - Rect rect; - Text filename; - int fps; - - IAVIFile* pfile; // created by CreateAvi - IAVIStream* ps; - IAVIStream* ps_comp; // video stream, when first created - DWORD frame_size; // total bytes per frame of video - DWORD nframe; // which frame will be added next - DWORD nsamp; // which sample will be added next - bool play; - bool iserr; // if true, then no function will do anything -}; - -// +--------------------------------------------------------------------+ - - -#endif // AviFile_h diff --git a/Stars45/CMakeLists.txt b/Stars45/CMakeLists.txt index 65d7671..0fe8069 100644 --- a/Stars45/CMakeLists.txt +++ b/Stars45/CMakeLists.txt @@ -6,7 +6,6 @@ add_executable( Asteroid.cpp AudDlg.cpp AudioConfig.cpp - AviFile.cpp AwardDlg.cpp AwardShowDlg.cpp Bitmap.cpp diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp index 93fd3dd..a596776 100644 --- a/Stars45/Game.cpp +++ b/Stars45/Game.cpp @@ -49,7 +49,6 @@ #include "Video.h" #include "VideoFactory.h" #include "VideoSettings.h" -#include "AviFile.h" #include "ContentBundle.h" // +--------------------------------------------------------------------+ @@ -91,7 +90,7 @@ Game::Game() gamma(128), max_tex_size(2048), screen(0), totaltime(0), hInst(0), hwnd(0), frame_rate(0), frame_count(0), frame_count0(0), frame_time(0), frame_time0(0), gui_seconds(0), content(0), - status(Game::OK), exit_code(0), window_style(0), avi_file(0) + status(Game::OK), exit_code(0), window_style(0) { if (!game) { panicbuf[0] = 0; @@ -125,7 +124,6 @@ Game::~Game() delete video; delete soundcard; delete video_settings; - delete avi_file; if (status == EXIT) ShowStats(); @@ -1026,33 +1024,6 @@ Game::UpdateScreen() if (!screen || !video) return; if (screen->Refresh()) { - if (Keyboard::KeyDown(VK_F12)) { - if (Keyboard::KeyDown(VK_SHIFT)) { - if (!avi_file) { - AVICapture(); // begin capturing - SetMaxFrameLength(MAX_FRAME_TIME_VIDEO); - } - else { - delete avi_file; // end capture; - avi_file = 0; - SetMaxFrameLength(MAX_FRAME_TIME_NORMAL); - } - } - else { - if (!avi_file) { - ScreenCapture(); - } - else { - delete avi_file; // end capture; - avi_file = 0; - SetMaxFrameLength(MAX_FRAME_TIME_NORMAL); - } - } - } - else if (avi_file) { - AVICapture(); // continue capturing... - } - video->Present(); } else { @@ -1118,115 +1089,6 @@ Game::GetScreenHeight() // +--------------------------------------------------------------------+ void -Game::ScreenCapture(const char* name) -{ - if (server || !video || !screen) return; - - static DWORD last_shot = 0; - static DWORD shot_num = 1; - DataLoader* loader = DataLoader::GetLoader(); - char filename[256]; - - if (!name && (real_time - last_shot) < 1000) - return; - - // try not to overwrite existing screen shots... - if (loader) { - bool use_file_sys = loader->IsFileSystemEnabled(); - loader->UseFileSystem(true); - loader->SetDataPath(0); - List<Text> shot_list; - loader->ListFiles("*.PCX", shot_list); - loader->UseFileSystem(use_file_sys); - - for (int i = 0; i < shot_list.size(); i++) { - Text* s = shot_list[i]; - int n = 0; - - sscanf_s(s->data()+1, "%d", &n); - if (shot_num <= (DWORD) n) - shot_num = n+1; - } - - shot_list.destroy(); - } - - if (name) - strcpy_s(filename, name); - else - sprintf_s(filename, "A%d.PCX", shot_num++); //-V576 - - Bitmap bmp; - - if (video && video->Capture(bmp)) { - PcxImage pcx(bmp.Width(), bmp.Height(), (LPDWORD) bmp.HiPixels()); - pcx.Save((char*) filename); - } - - last_shot = real_time; -} - -// +--------------------------------------------------------------------+ - -void -Game::AVICapture(const char* name) -{ - if (server || !video || !screen) return; - - if (!avi_file) { - char filename[256]; - Bitmap bmp; - DataLoader* loader = DataLoader::GetLoader(); - DWORD avi_num = 1; - - // try not to overwrite existing screen shots... - if (loader) { - bool use_file_sys = loader->IsFileSystemEnabled(); - loader->UseFileSystem(true); - loader->SetDataPath(0); - List<Text> avi_list; - loader->ListFiles("*.avi", avi_list); - loader->UseFileSystem(use_file_sys); - - for (int i = 0; i < avi_list.size(); i++) { - Text* s = avi_list[i]; - int n = 0; - - sscanf_s(s->data()+1, "%d", &n); - if (avi_num <= (DWORD) n) - avi_num = n+1; - } - - avi_list.destroy(); - } - - if (name) - strcpy_s(filename, name); - else - sprintf_s(filename, "A%d.avi", avi_num); //-V576 - - if (video && video->Capture(bmp)) { - //bmp.ScaleTo(bmp.Width()/2, bmp.Height()/2); - avi_file = new(__FILE__,__LINE__) AviFile(filename, Rect(0,0,bmp.Width(),bmp.Height()), VIDEO_FPS); - } - - } - - else { - Bitmap bmp; - - if (video && video->Capture(bmp)) { - //bmp.ScaleTo(bmp.Width()/2, bmp.Height()/2); - avi_file->AddFrame(bmp); - } - } -} - - - -// +--------------------------------------------------------------------+ - -void Game::CollectStats() { frame_count++; diff --git a/Stars45/Game.h b/Stars45/Game.h index cce3c35..264c745 100644 --- a/Stars45/Game.h +++ b/Stars45/Game.h @@ -63,7 +63,6 @@ class SoundCard; class Video; class VideoFactory; class VideoSettings; -class AviFile; class Text; // +--------------------------------------------------------------------+ @@ -91,9 +90,6 @@ public: virtual void Pause(bool f); int Status() const { return status; } - virtual void ScreenCapture(const char* name = 0); - virtual void AVICapture(const char* fname = 0); - const RenderStats& GetPolyStats() { return stats; } // @@ -220,8 +216,6 @@ protected: int exit_code; Color screen_color; - AviFile* avi_file; - static bool active; static bool paused; static bool server; diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp index 348538d..f9fefbf 100644 --- a/Stars45/Starshatter.cpp +++ b/Stars45/Starshatter.cpp @@ -1875,9 +1875,6 @@ Starshatter::DoGameKeys() if (cam_dir) { double spin = (PI/2) * Game::FrameTime(); // Game::GUITime(); - if (avi_file) - spin /= 6; - if (KeyDown(KEY_CAM_EXT_PLUS_AZ)) cam_dir->ExternalAzimuth(spin); |