_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

intern_video.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
11 //*@file intern_video.h @brief The video headerfile for video sources only. */
12 //
13 // (c) Copyright 1999-2002 by Stephan Rasenbergver.
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __INTERN_VIDEO_H__
31 #define __INTERN_VIDEO_H__
32 
34 
35 /*----------------------------------------------------------------------------
36 -- Documentation
37 ----------------------------------------------------------------------------*/
38 
53 /*----------------------------------------------------------------------------
54 -- Includes
55 ----------------------------------------------------------------------------*/
56 
57 #include "SDL.h"
58 #include <vector>
59 
60 /*----------------------------------------------------------------------------
61 -- Declarations
62 ----------------------------------------------------------------------------*/
63 
65 {
66 public:
67  ColorIndexRange(unsigned int begin, unsigned int end) :
68  begin(begin), end(end)
69  {}
70 public:
71  unsigned int begin;
72  unsigned int end;
73 };
74 
75 // Do one cycle
76 extern void ColorCycleSurface(SDL_Surface &surface);
78 extern void LazilyMakeColorCyclingTextures(CGraphic *g, std::vector<ColorIndexRange> ranges);
79 extern void MakeColorCyclingTextures(CGraphic *g, int count);
80 
81 /*----------------------------------------------------------------------------
82 -- Variables
83 ----------------------------------------------------------------------------*/
84 
85 // Direct acces to clipping rectangle for macro CLIP_RECTANGLE
86 extern int ClipX1;
87 extern int ClipY1;
88 extern int ClipX2;
89 extern int ClipY2;
90 
91 /*----------------------------------------------------------------------------
92 -- Macros
93 ----------------------------------------------------------------------------*/
94 
112 #define CLIP_RECTANGLE(x, y, width, height) do { \
113  int f; \
114  if (x < ClipX1) { \
115  f = ClipX1 - x; \
116  if (width <= f) { \
117  return; \
118  } \
119  width -= f; \
120  x = ClipX1; \
121  } \
122  if ((x + width) > ClipX2 + 1) { \
123  if (x > ClipX2) { \
124  return; \
125  } \
126  width = ClipX2 - x + 1; \
127  } \
128  if (y < ClipY1) { \
129  f = ClipY1 - y; \
130  if (height <= f) { \
131  return; \
132  } \
133  height -= f; \
134  y = ClipY1; \
135  } \
136  if ((y + height) > ClipY2 + 1) { \
137  if (y > ClipY2) { \
138  return; \
139  } \
140  height = ClipY2 - y + 1; \
141  } \
142  } while(0)
143 
167 #define CLIP_RECTANGLE_OFS(x, y, width, height, ofsx, ofsy, endx) do { \
168  if (y < ClipY1) { \
169  ofsy = ClipY1 - y; \
170  if (height <= ofsy) { \
171  return; \
172  } \
173  height -= ofsy; \
174  y = ClipY1; \
175  } else { \
176  ofsy = 0; \
177  } \
178  if ((y + height) > ClipY2 + 1) { \
179  if (y > ClipY2) { \
180  return; \
181  } \
182  height = ClipY2 - y + 1; \
183  } \
184  if (x < ClipX1) { \
185  ofsx = ClipX1 - x; \
186  if (width <= ofsx) { \
187  return; \
188  } \
189  width -= ofsx; \
190  x = ClipX1; \
191  } else { \
192  ofsx = 0; \
193  } \
194  if ((x + width) > ClipX2 + 1) { \
195  if (x > ClipX2) { \
196  return; \
197  } \
198  endx = (x + width) - (ClipX2 + 1); \
199  width = ClipX2 - x + 1; \
200  } else { \
201  endx = 0; \
202  } \
203  } while(0)
204 
205 
206 /*----------------------------------------------------------------------------
207 -- Functions
208 ----------------------------------------------------------------------------*/
209 
210 
212 
213 #endif // !__INTERN_VIDEO_H__
ColorCycleSurface
void ColorCycleSurface(SDL_Surface &surface)
Definition: video.cpp:502
ClipY2
int ClipY2
current clipping bottom right
Definition: video.cpp:167
ColorIndexRange::ColorIndexRange
ColorIndexRange(unsigned int begin, unsigned int end)
Definition: intern_video.h:67
LazilyMakeColorCyclingTextures
void LazilyMakeColorCyclingTextures(CGraphic *g, std::vector< ColorIndexRange > ranges)
Make OpenGL textures for color cycling.
ClipX1
int ClipX1
Profile, frames out of sync.
Definition: video.cpp:164
ClipY1
int ClipY1
current clipping top left
Definition: video.cpp:165
MakeColorCyclingTextures
void MakeColorCyclingTextures(CGraphic *g, int count)
ColorIndexRange::begin
unsigned int begin
Definition: intern_video.h:71
ColorIndexRange::end
unsigned int end
Definition: intern_video.h:72
ClipX2
int ClipX2
current clipping top left
Definition: video.cpp:166
ColorIndexRange
Definition: intern_video.h:64
CGraphic
Definition: video.h:91
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.