tinySDLGraphicsWindow.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Filename: tinySDLGraphicsWindow.h
  2. // Created by: drose (24Apr08)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef TINYSDLGRAPHICSWINDOW_H
  19. #define TINYSDLGRAPHICSWINDOW_H
  20. #include "pandabase.h"
  21. #ifdef HAVE_SDL
  22. #include "tinySDLGraphicsPipe.h"
  23. #include "graphicsWindow.h"
  24. #include "buttonHandle.h"
  25. #include "SDL.h"
  26. #include "zbuffer.h"
  27. ////////////////////////////////////////////////////////////////////
  28. // Class : TinySDLGraphicsWindow
  29. // Description : This graphics window class is implemented via SDL.
  30. ////////////////////////////////////////////////////////////////////
  31. class EXPCL_TINYDISPLAY TinySDLGraphicsWindow : public GraphicsWindow {
  32. public:
  33. TinySDLGraphicsWindow(GraphicsPipe *pipe,
  34. const string &name,
  35. const FrameBufferProperties &fb_prop,
  36. const WindowProperties &win_prop,
  37. int flags,
  38. GraphicsStateGuardian *gsg,
  39. GraphicsOutput *host);
  40. virtual ~TinySDLGraphicsWindow();
  41. virtual bool begin_frame(FrameMode mode, Thread *current_thread);
  42. virtual void end_frame(FrameMode mode, Thread *current_thread);
  43. virtual void begin_flip();
  44. virtual void process_events();
  45. virtual void set_properties_now(WindowProperties &properties);
  46. virtual bool supports_pixel_zoom() const;
  47. protected:
  48. virtual void close_window();
  49. virtual bool open_window();
  50. private:
  51. void create_frame_buffer();
  52. static ButtonHandle get_keyboard_button(SDLKey sym);
  53. static ButtonHandle get_mouse_button(Uint8 button);
  54. private:
  55. SDL_Surface *_screen;
  56. ZBuffer *_frame_buffer;
  57. unsigned int _flags;
  58. unsigned int _pitch;
  59. public:
  60. static TypeHandle get_class_type() {
  61. return _type_handle;
  62. }
  63. static void init_type() {
  64. GraphicsWindow::init_type();
  65. register_type(_type_handle, "TinySDLGraphicsWindow",
  66. GraphicsWindow::get_class_type());
  67. }
  68. virtual TypeHandle get_type() const {
  69. return get_class_type();
  70. }
  71. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  72. private:
  73. static TypeHandle _type_handle;
  74. };
  75. #include "tinySDLGraphicsWindow.I"
  76. #endif // HAVE_SDL
  77. #endif