1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | //{{{ Display Base Class
|
---|
10 |
|
---|
11 | // - no drawing is seen until the function flush() is called..
|
---|
12 | // This is acomplished through page-flipping or backbuffering.
|
---|
13 | // Dirty rectangles are maintained for each graphic activity, so
|
---|
14 | // speed is not the optimal. On a page-flipping system, the
|
---|
15 | // dirty rectangles are copied to the previous page after
|
---|
16 | // flipping On a back-buffer system, the dirty rectangles are
|
---|
17 | // copied from system to video memory.
|
---|
18 | //
|
---|
19 | // - a display maintains a list of devices associated with it
|
---|
20 | // (typically keyboard and mouse) these are typically added in
|
---|
21 | // externally by another unit.
|
---|
22 | //
|
---|
23 | // - a display maintains a list of clip areas which can be modified
|
---|
24 | // by external code (expected to a window manager)
|
---|
25 | //
|
---|
26 | // - a display is capable of opening and closing different video
|
---|
27 | // modes which may be different resolutions, color depth and flip
|
---|
28 | // methods
|
---|
29 | //
|
---|
30 |
|
---|
31 |
|
---|
32 | #ifndef __DISPLAY_HPP_
|
---|
33 | #define __DISPLAY_HPP_
|
---|
34 |
|
---|
35 | #include "arch.hh"
|
---|
36 | #include "init/init.hh"
|
---|
37 | #include "area/rectlist.hh"
|
---|
38 | #include "device/device.hh"
|
---|
39 | #include "image/image.hh"
|
---|
40 | #include "palette/pal.hh"
|
---|
41 | #include "window/cursor.hh"
|
---|
42 |
|
---|
43 | class i4_display_class;
|
---|
44 | struct i4_display_list_struct;
|
---|
45 | extern i4_display_list_struct *i4_display_list;
|
---|
46 |
|
---|
47 | // display's will add themselves to this list (possibly more than once)
|
---|
48 | // during their init if they determine they are available for use
|
---|
49 | struct i4_display_list_struct
|
---|
50 | {
|
---|
51 | public:
|
---|
52 | char *name;
|
---|
53 | int driver_id;
|
---|
54 | i4_display_class *display;
|
---|
55 | i4_display_list_struct *next;
|
---|
56 |
|
---|
57 | void add_to_list(char *_name, int _driver_id,
|
---|
58 | i4_display_class *_display,
|
---|
59 | i4_display_list_struct *_next);
|
---|
60 | };
|
---|
61 |
|
---|
62 | enum i4_frame_buffer_type { I4_FRONT_FRAME_BUFFER,
|
---|
63 | I4_BACK_FRAME_BUFFER };
|
---|
64 |
|
---|
65 |
|
---|
66 | enum i4_frame_access_type { I4_FRAME_BUFFER_READ,
|
---|
67 | I4_FRAME_BUFFER_WRITE };
|
---|
68 |
|
---|
69 | enum i4_refresh_type { I4_BLT_REFRESH,
|
---|
70 | I4_PAGE_FLIP_REFRESH };
|
---|
71 |
|
---|
72 | extern i4_display_list_struct *i4_display_list;
|
---|
73 |
|
---|
74 |
|
---|
75 | class i4_display_class : public i4_init_class
|
---|
76 | {
|
---|
77 | protected:
|
---|
78 | const i4_pal *pal;
|
---|
79 |
|
---|
80 | public:
|
---|
81 | const i4_pal *get_palette() { return pal; }
|
---|
82 |
|
---|
83 | static i4_display_class *first_display; // list of all displays currently available
|
---|
84 | i4_display_class *next_display;
|
---|
85 |
|
---|
86 | virtual i4_image_class *get_screen() = 0;
|
---|
87 | virtual i4_draw_context_class *get_context() = 0;
|
---|
88 |
|
---|
89 | // makes the physical display consistant with previous gfx calls
|
---|
90 | // either through page flipping or copying dirty rects from an
|
---|
91 | // off-screen buffer
|
---|
92 | virtual void flush() = 0;
|
---|
93 |
|
---|
94 | // width and height of the current mode
|
---|
95 | virtual w16 width() const = 0;
|
---|
96 | virtual w16 height() const = 0;
|
---|
97 |
|
---|
98 | //************************* Mode detection ***********************
|
---|
99 | class mode
|
---|
100 | {
|
---|
101 | public:
|
---|
102 | enum { MAX_MODE_NAME=60 } ;
|
---|
103 | char name[MAX_MODE_NAME];
|
---|
104 |
|
---|
105 | enum
|
---|
106 | {
|
---|
107 | RESOLUTION_DETERMINED_ON_OPEN=1, // (windowed?) in which case xres & yres are maximum values
|
---|
108 | BACK_BUFFER=2, // if not then page flipped should be true
|
---|
109 | PAGE_FLIPPED=4
|
---|
110 | };
|
---|
111 |
|
---|
112 | w16 xres,yres;
|
---|
113 | w8 bits_per_pixel; // 1, 8, 16, 24, or 32
|
---|
114 |
|
---|
115 | w32 red_mask;
|
---|
116 | w32 green_mask;
|
---|
117 | w32 blue_mask;
|
---|
118 |
|
---|
119 | w16 flags;
|
---|
120 | };
|
---|
121 |
|
---|
122 | virtual mode *current_mode() = 0; // will not be valid until initialize_mode is called
|
---|
123 |
|
---|
124 | virtual mode *get_first_mode(int driver_id) = 0;
|
---|
125 | virtual mode *get_next_mode() = 0;
|
---|
126 |
|
---|
127 |
|
---|
128 | // if you want to read/draw directly to/from the frame buffer you have to lock it
|
---|
129 | // first, be sure to release it as soon as possible. Normally locking the frame buffer is
|
---|
130 | // bad in a game because the 3d pipeline most be flushed before this can happen.
|
---|
131 | virtual i4_image_class *lock_frame_buffer(i4_frame_buffer_type type,
|
---|
132 | i4_frame_access_type access) = 0;
|
---|
133 | virtual void unlock_frame_buffer(i4_frame_buffer_type type) = 0;
|
---|
134 |
|
---|
135 | // tells you weither the current update model is BLT, or PAGE_FLIP
|
---|
136 | virtual i4_refresh_type update_model() = 0;
|
---|
137 |
|
---|
138 | // initialize_mode need not call close() to switch to another mode
|
---|
139 | // initialize_mode uses the last mode accessed by user (through get_first_mode or get_next_mode)
|
---|
140 | virtual i4_bool initialize_mode() = 0;
|
---|
141 |
|
---|
142 | // should be called before a program quits
|
---|
143 | virtual i4_bool close() = 0;
|
---|
144 |
|
---|
145 | // changes shape of the mouse cursor, return false on failure (no mouse or unchangeable mouse)
|
---|
146 | // cursor will be copied, so it can be deleted after this call
|
---|
147 | virtual i4_bool set_mouse_shape(i4_cursor_class *cursor) = 0;
|
---|
148 |
|
---|
149 | virtual i4_bool lock_mouse_in_place(i4_bool yes_no) = 0;
|
---|
150 |
|
---|
151 | // returns i4_T if the display is busy, i.e. doing a bitblt, pageflip, or other
|
---|
152 | // you usually must call kernel.process_events() before this will change
|
---|
153 | virtual i4_bool display_busy() const { return i4_F; }
|
---|
154 | };
|
---|
155 |
|
---|
156 | #endif
|
---|
157 |
|
---|