| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file video.h |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created OpenJazz.h |
| 10 | * - 13th July 2009: Created graphics.h from parts of OpenJazz.h |
| 11 | * - 26th July 2009: Renamed graphics.h to video.h |
| 12 | * |
| 13 | * @par Licence: |
| 14 | * Copyright (c) 2005-2017 AJ Thomson |
| 15 | * Copyright (c) 2015-2026 Carsten Teibes |
| 16 | * |
| 17 | * OpenJazz is distributed under the terms of |
| 18 | * the GNU General Public License, version 2.0 |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef OJ_VIDEO_H |
| 23 | #define OJ_VIDEO_Hcxx . . $ `src/io/gfx/video.h:23:9`! |
| 24 | |
| 25 | #include "setup.h"cxx . . $ `<file>/src/setup.h`/ |
| 26 | #include "paletteeffects.h"cxx . . $ `<file>/src/io/gfx/paletteeffects.h`/ |
| 27 | #include "platforms/platforms.h"cxx . . $ `<file>/src/platforms/platforms.h`/ |
| 28 | |
| 29 | #ifdef OJ_SDL3 |
| 30 | #include <SDL3/SDL.h> |
| 31 | #else |
| 32 | #include <SDL.h> |
| 33 | #endif |
| 34 | |
| 35 | // Constants |
| 36 | |
| 37 | // Original screen dimensions |
| 38 | #define SWcxx . . $ `src/io/gfx/video.h:38:9`! 320 |
| 39 | #define SHcxx . . $ `src/io/gfx/video.h:39:9`! 200 |
| 40 | |
| 41 | #define MIN_SCALEcxx . . $ `src/io/gfx/video.h:41:9`! 1 |
| 42 | #ifdef SCALEcxx . . $ `<built-in>:466:9`! |
| 43 | #define MAX_SCALEcxx . . $ `src/io/gfx/video.h:43:10`! 4 |
| 44 | #else |
| 45 | #define MAX_SCALE 1 |
| 46 | #endif |
| 47 | |
| 48 | // Maximum screen dimensions |
| 49 | #define MAX_SCREEN_WIDTHcxx . . $ `src/io/gfx/video.h:49:9`! (32 * 256 * MAX_SCALE) |
| 50 | #define MAX_SCREEN_HEIGHTcxx . . $ `src/io/gfx/video.h:50:9`! (32 * 64 * MAX_SCALE) |
| 51 | |
| 52 | // Default configuration |
| 53 | #ifndef DEFAULT_SCREEN_WIDTH |
| 54 | #define DEFAULT_SCREEN_WIDTHcxx . . $ `src/io/gfx/video.h:54:10`! SW |
| 55 | #endif |
| 56 | #ifndef DEFAULT_SCREEN_HEIGHT |
| 57 | #define DEFAULT_SCREEN_HEIGHTcxx . . $ `src/io/gfx/video.h:57:10`! SH |
| 58 | #endif |
| 59 | |
| 60 | // Fullscreen and Window flags are only for SDL1.2 |
| 61 | #if OJ_SDL2cxx . . $ `<built-in>:465:9`! || OJ_SDL3 |
| 62 | #ifdef WINDOWED_FLAGS |
| 63 | #pragma message "Ignoring WINDOWED_FLAGS when not building with SDL 1.2" |
| 64 | #endif |
| 65 | #ifdef FULLSCREEN_FLAGS |
| 66 | #pragma message "Ignoring FULLSCREEN_FLAGS when not building with SDL 1.2" |
| 67 | #endif |
| 68 | #else |
| 69 | #ifndef WINDOWED_FLAGS |
| 70 | #define WINDOWED_FLAGS (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE) |
| 71 | #endif |
| 72 | #ifndef FULLSCREEN_FLAGS |
| 73 | #define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE) |
| 74 | #endif |
| 75 | #endif |
| 76 | |
| 77 | // Time interval |
| 78 | #define T_MENU_FRAMEcxx . . $ `src/io/gfx/video.h:78:9`! 20 |
| 79 | |
| 80 | // Class |
| 81 | |
| 82 | /// Video output |
| 83 | class Videocxx . . $ Video# { |
| 84 | public: |
| 85 | Videocxx . . $ Video#Video(49f6e7a06ebc5aa8). (); |
| 86 | |
| 87 | bool initcxx . . $ Video#init(63f3bea6ba3175f4). (SetupOptionscxx . . $ SetupOptions# cfg); |
| 88 | void deinitcxx . . $ Video#deinit(49f6e7a06ebc5aa8). (); |
| 89 | bool resetcxx . . $ Video#reset(cf9ef193275fa6d8). (int width, int height); |
| 90 | |
| 91 | void setPalettecxx . . $ Video#setPalette(d5421d17e1a4b2b2). (SDL_Color *palette); |
| 92 | SDL_Color* getPalettecxx . . $ Video#getPalette(a696971525c6d1f6). () const; |
| 93 | void changePalettecxx . . $ Video#changePalette(dc6239902d762776). (SDL_Color *palette, unsigned char first, unsigned int amount); |
| 94 | |
| 95 | // Surface |
| 96 | SDL_Surface* createSurfacecxx . . $ Video#createSurface(5ec4649223a2dfef). (const unsigned char* pixels, int width, int height); |
| 97 | void destroySurfacecxx . . $ Video#destroySurface(60a0b30a00b4fc6d). (SDL_Surface *surface); |
| 98 | void setSurfacePalettecxx . . $ Video#setSurfacePalette(b59f7f041c83eb39). (SDL_Surface *surface, SDL_Color *palette, int start, int length); |
| 99 | void restoreSurfacePalettecxx . . $ Video#restoreSurfacePalette(60a0b30a00b4fc6d). (SDL_Surface *surface); |
| 100 | void enableColorKeycxx . . $ Video#enableColorKey(905504f46e4e09c1). (SDL_Surface *surface, unsigned int index); |
| 101 | unsigned int getColorKeycxx . . $ Video#getColorKey(77e0245589bafc78). (SDL_Surface *surface); |
| 102 | void setClipRectcxx . . $ Video#setClipRect(382a02f39687f508). (SDL_Surface *surface, const SDL_Rect *rect); |
| 103 | |
| 104 | void drawRectcxx . . $ Video#drawRect(a4376a5627a47301). (int x, int y, int width, int height, int index, bool fill = true); |
| 105 | |
| 106 | int getMinWidthcxx . . $ Video#getMinWidth(455f465bc33b4cdf). () const; |
| 107 | int getMaxWidthcxx . . $ Video#getMaxWidth(455f465bc33b4cdf). () const; |
| 108 | int getMinHeightcxx . . $ Video#getMinHeight(455f465bc33b4cdf). () const; |
| 109 | int getMaxHeightcxx . . $ Video#getMaxHeight(455f465bc33b4cdf). () const; |
| 110 | int getWidthcxx . . $ Video#getWidth(455f465bc33b4cdf). () const; |
| 111 | int getHeightcxx . . $ Video#getHeight(455f465bc33b4cdf). () const; |
| 112 | void setTitlecxx . . $ Video#setTitle(85c52e162fed56f9). (const char *title); |
| 113 | int getScaleFactorcxx . . $ Video#getScaleFactor(455f465bc33b4cdf). () const; |
| 114 | scalerTypecxx . . $ scalerType# getScaleMethodcxx . . $ Video#getScaleMethod(79c99e9ca623648). () const; |
| 115 | void setScalingcxx . . $ Video#setScaling(37c85713de463f11). (int newScaleFactor, scalerTypecxx . . $ scalerType# newScaleMethod); |
| 116 | bool isFullscreencxx . . $ Video#isFullscreen(50ce9a9e25b4a850). () const; |
| 117 | |
| 118 | void moviePlaybackcxx . . $ Video#moviePlayback(b45ddcbc8423892c). (bool status); |
| 119 | |
| 120 | void updatecxx . . $ Video#update(568d8a17e3151145). (SDL_Event *event); |
| 121 | void flipcxx . . $ Video#flip(b4cc491d773144d4). (int mspf, PaletteEffectcxx . . $ PaletteEffect#* paletteEffects = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, bool effectsStopped = false); |
| 122 | |
| 123 | void clearScreencxx . . $ Video#clearScreen(d4f767463ce0a6b3). (int index); |
| 124 | |
| 125 | private: |
| 126 | void findResolutionscxx . . $ Video#findResolutions(49f6e7a06ebc5aa8). (); |
| 127 | void exposecxx . . $ Video#expose(49f6e7a06ebc5aa8). (); |
| 128 | void commonDeinitcxx . . $ Video#commonDeinit(49f6e7a06ebc5aa8). (); |
| 129 | |
| 130 | #if OJ_SDL3 || OJ_SDL2cxx . . $ `<built-in>:465:9`! |
| 131 | SDL_Window* windowcxx . . $ Video#window.; ///< Output window |
| 132 | SDL_Renderer* renderercxx . . $ Video#renderer.; ///< Output renderer |
| 133 | SDL_Texture* texturecxx . . $ Video#texture.; ///< Output texture |
| 134 | #endif |
| 135 | #if OJ_SDL2cxx . . $ `<built-in>:465:9`! |
| 136 | SDL_Surface* textureSurfacecxx . . $ Video#textureSurface.; |
| 137 | #endif |
| 138 | SDL_Surface* screencxx . . $ Video#screen.; ///< Output surface |
| 139 | |
| 140 | // Palettes |
| 141 | SDL_Color* currentPalettecxx . . $ Video#currentPalette.; ///< Current palette |
| 142 | #if OJ_SDL3 |
| 143 | SDL_Palette* texturePalette; ///< Screen palette |
| 144 | SDL_Palette* logicalPalette; ///< Logical palette (greyscale) |
| 145 | #else |
| 146 | SDL_Color logicalPalettecxx . . $ Video#logicalPalette.[MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!]; ///< Logical palette (greyscale) |
| 147 | #endif |
| 148 | |
| 149 | int minWcxx . . $ Video#minW.; ///< Smallest possible width |
| 150 | int maxWcxx . . $ Video#maxW.; ///< Largest possible width |
| 151 | int minHcxx . . $ Video#minH.; ///< Smallest possible height |
| 152 | int maxHcxx . . $ Video#maxH.; ///< Largest possible height |
| 153 | int screenWcxx . . $ Video#screenW.; ///< Real width |
| 154 | int screenHcxx . . $ Video#screenH.; ///< Real height |
| 155 | int scaleFactorcxx . . $ Video#scaleFactor.; ///< Scaling factor |
| 156 | scalerTypecxx . . $ scalerType# scaleMethodcxx . . $ Video#scaleMethod.; ///< Filtering |
| 157 | bool fullscreencxx . . $ Video#fullscreen.; ///< Full-screen mode |
| 158 | bool isPlayingMoviecxx . . $ Video#isPlayingMovie.; |
| 159 | }; |
| 160 | |
| 161 | // Inline functions |
| 162 | |
| 163 | inline SDL_Color* Videocxx . . $ Video#::getPalettecxx . . $ Video#getPalette(a696971525c6d1f6). () const { return currentPalettecxx . . $ Video#currentPalette.; } ///< Returns the current display palette. |
| 164 | inline int Videocxx . . $ Video#::getMinWidthcxx . . $ Video#getMinWidth(455f465bc33b4cdf). () const { return minWcxx . . $ Video#minW.; } ///< Returns the minimum possible screen width. |
| 165 | inline int Videocxx . . $ Video#::getMaxWidthcxx . . $ Video#getMaxWidth(455f465bc33b4cdf). () const { return maxWcxx . . $ Video#maxW.; } ///< Returns the maximum possible screen width. |
| 166 | inline int Videocxx . . $ Video#::getMinHeightcxx . . $ Video#getMinHeight(455f465bc33b4cdf). () const { return minHcxx . . $ Video#minH.; } ///< Returns the minimum possible screen height. |
| 167 | inline int Videocxx . . $ Video#::getMaxHeightcxx . . $ Video#getMaxHeight(455f465bc33b4cdf). () const { return maxHcxx . . $ Video#maxH.; } ///< Returns the maximum possible screen height. |
| 168 | inline int Videocxx . . $ Video#::getWidthcxx . . $ Video#getWidth(455f465bc33b4cdf). () const { return screenWcxx . . $ Video#screenW.; } ///< Returns the current width of the window or screen. |
| 169 | inline int Videocxx . . $ Video#::getHeightcxx . . $ Video#getHeight(455f465bc33b4cdf). () const { return screenHcxx . . $ Video#screenH.; } ///< Returns the current height of the window or screen. |
| 170 | inline int Videocxx . . $ Video#::getScaleFactorcxx . . $ Video#getScaleFactor(455f465bc33b4cdf). () const { return scaleFactorcxx . . $ Video#scaleFactor.;} ///< Returns the current scaling factor. |
| 171 | inline scalerTypecxx . . $ scalerType# Videocxx . . $ Video#::getScaleMethodcxx . . $ Video#getScaleMethod(79c99e9ca623648). () const { return scaleMethodcxx . . $ Video#scaleMethod.; } ///< Returns the current scaling method. |
| 172 | inline bool Videocxx . . $ Video#::isFullscreencxx . . $ Video#isFullscreen(50ce9a9e25b4a850). () const { return fullscreencxx . . $ Video#fullscreen.; } ///< Determines whether or not full-screen mode is being used. |
| 173 | |
| 174 | // Variables |
| 175 | |
| 176 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! SDL_Surface* canvascxx . . $ canvas.; ///< Surface used for drawing |
| 177 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! int canvasWcxx . . $ canvasW.; ///< Drawing surface width |
| 178 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! int canvasHcxx . . $ canvasH.; ///< Drawing surface height |
| 179 | |
| 180 | EXTERNcxx . . $ `src/OpenJazz.h:38:10`! Videocxx . . $ Video# videocxx . . $ video.; ///< Video output |
| 181 | |
| 182 | #endif |