tinySDLGraphicsWindow.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #ifndef TINYSDLGRAPHICSWINDOW_H
  15. #define TINYSDLGRAPHICSWINDOW_H
  16. #include "pandabase.h"
  17. #ifdef HAVE_SDL
  18. #include "tinySDLGraphicsPipe.h"
  19. #include "graphicsWindow.h"
  20. #include "buttonHandle.h"
  21. #include "SDL.h"
  22. #include "zbuffer.h"
  23. ////////////////////////////////////////////////////////////////////
  24. // Class : TinySDLGraphicsWindow
  25. // Description : This graphics window class is implemented via SDL.
  26. ////////////////////////////////////////////////////////////////////
  27. class EXPCL_TINYDISPLAY TinySDLGraphicsWindow : public GraphicsWindow {
  28. public:
  29. TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
  30. const string &name,
  31. const FrameBufferProperties &fb_prop,
  32. const WindowProperties &win_prop,
  33. int flags,
  34. GraphicsStateGuardian *gsg,
  35. GraphicsOutput *host);
  36. virtual ~TinySDLGraphicsWindow();
  37. virtual bool begin_frame(FrameMode mode, Thread *current_thread);
  38. virtual void end_frame(FrameMode mode, Thread *current_thread);
  39. virtual void begin_flip();
  40. virtual void process_events();
  41. virtual void set_properties_now(WindowProperties &properties);
  42. virtual bool supports_pixel_zoom() const;
  43. protected:
  44. virtual void close_window();
  45. virtual bool open_window();
  46. private:
  47. void create_frame_buffer();
  48. static ButtonHandle get_keyboard_button(SDLKey sym);
  49. static ButtonHandle get_mouse_button(Uint8 button);
  50. private:
  51. SDL_Surface *_screen;
  52. ZBuffer *_frame_buffer;
  53. unsigned int _flags;
  54. unsigned int _pitch;
  55. public:
  56. static TypeHandle get_class_type() {
  57. return _type_handle;
  58. }
  59. static void init_type() {
  60. GraphicsWindow::init_type();
  61. register_type(_type_handle, "TinySDLGraphicsWindow",
  62. GraphicsWindow::get_class_type());
  63. }
  64. virtual TypeHandle get_type() const {
  65. return get_class_type();
  66. }
  67. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  68. private:
  69. static TypeHandle _type_handle;
  70. };
  71. #include "tinySDLGraphicsWindow.I"
  72. #endif // HAVE_SDL
  73. #endif