Panda3D
 All Classes Functions Variables Enumerations
tinySDLGraphicsWindow.h
1 // Filename: tinySDLGraphicsWindow.h
2 // Created by: drose (24Apr08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef TINYSDLGRAPHICSWINDOW_H
16 #define TINYSDLGRAPHICSWINDOW_H
17 
18 #include "pandabase.h"
19 
20 #ifdef HAVE_SDL
21 
22 #include "tinySDLGraphicsPipe.h"
23 #include "graphicsWindow.h"
24 #include "buttonHandle.h"
25 #include "SDL.h"
26 #include "zbuffer.h"
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : TinySDLGraphicsWindow
30 // Description : This graphics window class is implemented via SDL.
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_TINYDISPLAY TinySDLGraphicsWindow : public GraphicsWindow {
33 public:
34  TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
35  const string &name,
36  const FrameBufferProperties &fb_prop,
37  const WindowProperties &win_prop,
38  int flags,
40  GraphicsOutput *host);
41  virtual ~TinySDLGraphicsWindow();
42 
43  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
44  virtual void end_frame(FrameMode mode, Thread *current_thread);
45  virtual void end_flip();
46 
47  virtual void process_events();
48  virtual void set_properties_now(WindowProperties &properties);
49 
50  virtual bool supports_pixel_zoom() const;
51 
52 protected:
53  virtual void close_window();
54  virtual bool open_window();
55 
56 private:
57  void create_frame_buffer();
58  static ButtonHandle get_keyboard_button(SDLKey sym);
59  static ButtonHandle get_mouse_button(Uint8 button);
60 
61 private:
62  SDL_Surface *_screen;
63  ZBuffer *_frame_buffer;
64  unsigned int _flags;
65  unsigned int _pitch;
66 
67 public:
68  static TypeHandle get_class_type() {
69  return _type_handle;
70  }
71  static void init_type() {
72  GraphicsWindow::init_type();
73  register_type(_type_handle, "TinySDLGraphicsWindow",
74  GraphicsWindow::get_class_type());
75  }
76  virtual TypeHandle get_type() const {
77  return get_class_type();
78  }
79  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
80 
81 private:
82  static TypeHandle _type_handle;
83 };
84 
85 #include "tinySDLGraphicsWindow.I"
86 
87 #endif // HAVE_SDL
88 
89 #endif
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame...
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
A container for the various kinds of properties we might ask to have on a graphics window before we o...
virtual bool supports_pixel_zoom() const
Returns true if a call to set_pixel_zoom() will be respected, false if it will be ignored...
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
This is a base class for the various different classes that represent the result of a frame of render...
A thread; that is, a lightweight process.
Definition: thread.h:51
Encapsulates all the communication with a particular instance of a given rendering backend...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame...