ScummVM API documentation
surface.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_SCREEN_SURFACE_H
23 #define NUVIE_SCREEN_SURFACE_H
24 
25 #include "graphics/pixelformat.h"
26 
27 namespace Ultima {
28 namespace Nuvie {
29 
30 class OpenGL;
31 
33 private:
34  uint8 *buffer; // If the buffer is created, this is it
35  uint16 *zbuffer_priv;
36  Graphics::ManagedSurface *_rawSurface;
37  DisposeAfterUse::Flag _disposeSurface;
38 public:
39  OpenGL *opengl; // OpenGL surface
40 
41  // Pixel Format (also see 'Colour shifting values' later)
42  int bytes_per_pixel; // 2 or 4
43  int bits_per_pixel; // 16 or 32
44  int format_type; // 16, 555, 565, 32 or 888
45 
46  uint8 *pixels; // What we draw to
47  uint16 *zbuffer; // Z Buffer
48 
49  uint32 colour32[256]; // Palette as 16/32 bit colours
50 
51  // Dimentions
52  uint32 w, h; // Surface width and height
53  uint32 pitch; // Surface pitch
54 
55  // Guardband
56  uint32 gl, gr; // Guard left and right (left goes negetive)
57  uint32 gt, gb; // Guard top and bottom (up goes negetive)
58 
59  uint32 lock_count; // Number of locks on surface
60 
61 
62 public:
63 
64  // Default constructor for no created surface
65  RenderSurface();
66 
67  // Constructor for custom buffer
68  RenderSurface(uint32 width, uint32 height, uint32 bpp, uint8 *p);
69 
70  // Constructor for surface (with optional guardband)
71  RenderSurface(uint32 width, uint32 height, uint32 bpp, sint32 gb = 0);
72 
73  // Constructor for sdl surface
75 
76  // Constructor for opengl surface
77  RenderSurface(OpenGL *ogl);
78 
79 
80  // Destructor
81  virtual ~RenderSurface();
82 
83  // Create a 16 Bit Z Buffer for this surface
84  void create_zbuffer();
85 
86  // Set the buffer format from Graphics::PixelFormat
87  void set_format(const Graphics::PixelFormat *format);
88 
89  // Set a custom 565 format
90  void set_format565(int rsft = 11, int gsft = 5, int bsft = 0);
91 
92  // Set a custom 555 format
93  void set_format555(int rsft = 10, int gsft = 5, int bsft = 0);
94 
95  // Set a custom 888 format
96  void set_format888(int rsft = 16, int gsft = 8, int bsft = 0);
97 
98  // Get the pixel format
99  const Graphics::PixelFormat &getFormat() const {
100  return _rawSurface->format;
101  }
102 
103  // Draw Lines
104  void draw_line(int sx, int sy, int ex, int ey, unsigned char col);
105  void draw_3d_line(int x, int y, int sx, int sy, int sz, int ex, int ey, int ez, unsigned char col);
106 
107  // Colour shifting values
108  static uint8 Rloss;
109  static uint8 Gloss;
110  static uint8 Bloss;
111  static uint8 Rloss16;
112  static uint8 Gloss16;
113  static uint8 Bloss16;
114  static uint8 Rshift;
115  static uint8 Gshift;
116  static uint8 Bshift;
117  static uint32 Rmask;
118  static uint32 Gmask;
119  static uint32 Bmask;
120 
121 
122  //
123  // Shape Painting
124  //
125 
126  // Display a shape. Non translucent
127  //virtual void display(Shape* s, int x, int y, FrameID frame) = 0;
128 
129  // Display a shape. Translucent
130 // virtual void display_translucent(Shape* s, int x, int y, FrameID frame) = 0;
131 
132  // Display a shape. Flipped
133 // virtual void display_flipped(Shape* s, int x, int y, FrameID frame, bool trans = false) = 0;
134 
135 
136 
137  //FIX virtual void display8(uint8 *buf, int x, int y) = 0;
138 
139  Graphics::ManagedSurface *get_sdl_surface();
140  const unsigned char *get_pixels();
141 
142  static Graphics::ManagedSurface *createSurface(int w, int h,
143  const Graphics::PixelFormat &format);
144 private:
145 
146  // Draw Lines
147  void draw_line16(int sx, int sy, int ex, int ey, unsigned char col);
148 
149  // Draw Lines
150  void draw_line32(int sx, int sy, int ex, int ey, unsigned char col);
151 
152 };
153 
154 RenderSurface *CreateRenderSurface(uint32 width, uint32 height, uint32 bpp, uint8 *p);
155 RenderSurface *CreateRenderSurface(uint32 width, uint32 height, uint32 bpp, sint32 gb = 0);
156 RenderSurface *CreateRenderSurface(Graphics::ManagedSurface *surf);
157 RenderSurface *CreateRenderSurface(OpenGL *ogl);
158 
159 } // End of namespace Nuvie
160 } // End of namespace Ultima
161 
162 #endif
Definition: managed_surface.h:51
Definition: pixelformat.h:138
Definition: surface.h:32
Definition: detection.h:27
Definition: renderbuffer.h:27
PixelFormat & format
Definition: managed_surface.h:120