Cinematic.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code 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 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __CINEMATIC_H__
  21. #define __CINEMATIC_H__
  22. /*
  23. ===============================================================================
  24. cinematic
  25. Multiple idCinematics can run simultaniously.
  26. A single idCinematic can be reused for multiple files if desired.
  27. ===============================================================================
  28. */
  29. // cinematic states
  30. typedef enum {
  31. FMV_IDLE,
  32. FMV_PLAY, // play
  33. FMV_EOF, // all other conditions, i.e. stop/EOF/abort
  34. FMV_ID_BLT,
  35. FMV_ID_IDLE,
  36. FMV_LOOPED,
  37. FMV_ID_WAIT
  38. } cinStatus_t;
  39. class idImage;
  40. // a cinematic stream generates an image buffer, which the caller will upload to a texture
  41. typedef struct {
  42. int imageWidth;
  43. int imageHeight; // will be a power of 2
  44. idImage* imageY;
  45. idImage* imageCr;
  46. idImage* imageCb;
  47. int status;
  48. } cinData_t;
  49. class idCinematic {
  50. public:
  51. // initialize cinematic play back data
  52. static void InitCinematic( void );
  53. // shutdown cinematic play back data
  54. static void ShutdownCinematic( void );
  55. // allocates and returns a private subclass that implements the methods
  56. // This should be used instead of new
  57. static idCinematic *Alloc();
  58. // frees all allocated memory
  59. virtual ~idCinematic();
  60. // returns false if it failed to load
  61. virtual bool InitFromFile( const char *qpath, bool looping );
  62. // returns the length of the animation in milliseconds
  63. virtual int AnimationLength();
  64. // the pointers in cinData_t will remain valid until the next UpdateForTime() call
  65. virtual cinData_t ImageForTime( int milliseconds );
  66. // closes the file and frees all allocated memory
  67. virtual void Close();
  68. // sets the cinematic to start at that time (can be in the past)
  69. virtual void ResetTime(int time);
  70. // gets the time the cinematic started
  71. virtual int GetStartTime();
  72. virtual void ExportToTGA( bool skipExisting = true );
  73. virtual float GetFrameRate() const;
  74. };
  75. /*
  76. ===============================================
  77. Sound meter.
  78. ===============================================
  79. */
  80. class idSndWindow : public idCinematic {
  81. public:
  82. idSndWindow() { showWaveform = false; }
  83. ~idSndWindow() {}
  84. bool InitFromFile( const char *qpath, bool looping );
  85. cinData_t ImageForTime( int milliseconds );
  86. int AnimationLength();
  87. private:
  88. bool showWaveform;
  89. };
  90. #endif /* !__CINEMATIC_H__ */