source: golgotha/src/i4/video/x11/x11_display.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 4.1 KB
Line 
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#ifndef __X11_DISPLAY
10#define __X11_DISPLAY
11
12#include <X11/Xlib.h>
13#include <X11/Xutil.h>
14#include <X11/keysym.h>
15
16#include "image/image.hh"
17#include "video/display.hh"
18#include "video/x11/mitshm.hh"
19#include "time/time.hh"
20#include "video/x11/x11_input.hh"
21
22
23class x11_display_input_class : public x11_input_class
24{
25public:
26  virtual void resize(int w, int h);
27  virtual void note_event(XEvent &xev);
28
29};
30
31class x11_display_class : public i4_display_class
32
33protected:
34  virtual XVisualInfo *get_visual(Display *display);
35
36public:
37  i4_display_list_struct me;
38  x11_shm_extension_class *shm_extension;
39
40  x11_display_input_class input;
41
42
43  i4_bool open_display();
44  void close_display();
45
46
47  i4_bool open_X_window(w32 width, w32 height, i4_display_class::mode *mode);
48  void    create_X_image(w32 width, w32 height);
49  void    destroy_X_image();
50  void    close_X_window();
51
52  // returns false if an error occured
53  i4_bool copy_part_to_vram(i4_coord x, i4_coord y,
54                            i4_coord x1, i4_coord y1,
55                            i4_coord x2, i4_coord y2);
56
57  class x11_mode : public mode
58  {
59  public:
60    i4_display_class *assoc;     // pointer to use, so we can confirm we created this mode
61  };
62
63  x11_mode amode, cur_mode;
64
65  // generic image which will take the type of the screen when we copy the save portion
66  i4_image_class *mouse_pict;   
67
68  i4_image_class *mouse_save, *screen;
69
70  i4_draw_context_class *context;
71
72  i4_coord                 mouse_hot_x,mouse_hot_y;
73  const i4_pal            *mouse_pal;
74  i4_color                 mouse_trans;
75  x11_shm_image_class     *shm_image;
76  XImage                  *ximage;
77 
78  virtual i4_bool set_mouse_shape(i4_cursor_class *cursor);
79
80  virtual i4_image_class *get_screen() { return screen; }
81
82  virtual w16 width() const { return screen->width(); }
83  virtual w16 height() const { return screen->height(); }
84
85  // makes the physical display consistant with previous gfx calls
86  // either through page flipping or copying dirty rects from an
87  // off-screen buffer
88  virtual void flush();
89
90  // returns some descriptive name for this display
91  virtual char *name() { return "X11 display"; }
92
93  virtual i4_draw_context_class *get_context() { return context; }
94  x11_display_class();
95
96  virtual mode *current_mode() { return &cur_mode; }
97  virtual mode *get_first_mode(int driver_id);
98  virtual mode *get_next_mode() { return 0; }
99
100
101  // initialize_mode need not call close() to switch to another mode
102  virtual i4_bool initialize_mode();
103
104  // should be called before a program quits
105  virtual i4_bool close();
106
107  virtual i4_bool lock_mouse_in_place(i4_bool yes_no)
108  {
109    return input.lock_mouse_in_place(yes_no);
110  }
111
112  // if you want to read/draw directly to/from the frame buffer you have to lock it
113  // first, be sure to release it as soon as possible.  Normally locking the frame buffer is
114  // bad in a game because the 3d pipeline most be flushed before this can happen.
115  virtual i4_image_class *lock_frame_buffer(i4_frame_buffer_type type,
116                                            i4_frame_access_type access)
117  {
118    return screen;
119  }
120
121  virtual void unlock_frame_buffer(i4_frame_buffer_type type) { ; }
122 
123  // tells you weither the current update model is BLT, or PAGE_FLIP
124  virtual i4_refresh_type update_model() { return I4_BLT_REFRESH; }
125
126
127
128  virtual i4_bool display_busy() const
129  {
130    //    if (shm_extension && shm_extension->need_sync_event)
131    //      return i4_T;
132    //    else
133    return i4_F;
134  }
135
136  void init();
137};
138
139extern x11_display_class x11_display_instance;
140
141#endif
142
143
144
Note: See TracBrowser for help on using the repository browser.