tinyWinGraphicsPipe.cxx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Filename: tinyWinGraphicsPipe.cxx
  2. // Created by: drose (06May08)
  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. #include "pandabase.h"
  15. #ifdef WIN32
  16. #include "tinyWinGraphicsPipe.h"
  17. #include "config_tinydisplay.h"
  18. #include "config_windisplay.h"
  19. #include "tinyWinGraphicsWindow.h"
  20. #include "tinyGraphicsBuffer.h"
  21. TypeHandle TinyWinGraphicsPipe::_type_handle;
  22. ////////////////////////////////////////////////////////////////////
  23. // Function: TinyWinGraphicsPipe::Constructor
  24. // Access: Public
  25. // Description:
  26. ////////////////////////////////////////////////////////////////////
  27. TinyWinGraphicsPipe::
  28. TinyWinGraphicsPipe() {
  29. }
  30. ////////////////////////////////////////////////////////////////////
  31. // Function: TinyWinGraphicsPipe::Destructor
  32. // Access: Public, Virtual
  33. // Description:
  34. ////////////////////////////////////////////////////////////////////
  35. TinyWinGraphicsPipe::
  36. ~TinyWinGraphicsPipe() {
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: TinyWinGraphicsPipe::get_interface_name
  40. // Access: Published, Virtual
  41. // Description: Returns the name of the rendering interface
  42. // associated with this GraphicsPipe. This is used to
  43. // present to the user to allow him/her to choose
  44. // between several possible GraphicsPipes available on a
  45. // particular platform, so the name should be meaningful
  46. // and unique for a given platform.
  47. ////////////////////////////////////////////////////////////////////
  48. string TinyWinGraphicsPipe::
  49. get_interface_name() const {
  50. return "TinyPanda";
  51. }
  52. ////////////////////////////////////////////////////////////////////
  53. // Function: TinyWinGraphicsPipe::pipe_constructor
  54. // Access: Public, Static
  55. // Description: This function is passed to the GraphicsPipeSelection
  56. // object to allow the user to make a default
  57. // TinyWinGraphicsPipe.
  58. ////////////////////////////////////////////////////////////////////
  59. PT(GraphicsPipe) TinyWinGraphicsPipe::
  60. pipe_constructor() {
  61. return new TinyWinGraphicsPipe;
  62. }
  63. ////////////////////////////////////////////////////////////////////
  64. // Function: TinyWinGraphicsPipe::make_output
  65. // Access: Protected, Virtual
  66. // Description: Creates a new window or buffer on the pipe, if possible.
  67. // This routine is only called from GraphicsEngine::make_output.
  68. ////////////////////////////////////////////////////////////////////
  69. PT(GraphicsOutput) TinyWinGraphicsPipe::
  70. make_output(const string &name,
  71. const FrameBufferProperties &fb_prop,
  72. const WindowProperties &win_prop,
  73. int flags,
  74. GraphicsEngine *engine,
  75. GraphicsStateGuardian *gsg,
  76. GraphicsOutput *host,
  77. int retry,
  78. bool &precertify) {
  79. if (!_is_valid) {
  80. return NULL;
  81. }
  82. TinyGraphicsStateGuardian *tinygsg = 0;
  83. if (gsg != 0) {
  84. DCAST_INTO_R(tinygsg, gsg, NULL);
  85. }
  86. // First thing to try: a TinyWinGraphicsWindow
  87. if (retry == 0) {
  88. if (((flags&BF_require_parasite)!=0)||
  89. ((flags&BF_refuse_window)!=0)||
  90. ((flags&BF_resizeable)!=0)||
  91. ((flags&BF_size_track_host)!=0)||
  92. ((flags&BF_rtt_cumulative)!=0)||
  93. ((flags&BF_can_bind_color)!=0)||
  94. ((flags&BF_can_bind_every)!=0)) {
  95. return NULL;
  96. }
  97. if ((flags & BF_fb_props_optional)==0) {
  98. if ((fb_prop.get_aux_rgba() > 0)||
  99. (fb_prop.get_aux_hrgba() > 0)||
  100. (fb_prop.get_aux_float() > 0)) {
  101. return NULL;
  102. }
  103. }
  104. return new TinyWinGraphicsWindow(engine, this, name, fb_prop, win_prop,
  105. flags, gsg, host);
  106. }
  107. // Second thing to try: a TinyGraphicsBuffer
  108. if (retry == 1) {
  109. if (((flags&BF_require_parasite)!=0)||
  110. ((flags&BF_require_window)!=0)) {
  111. return NULL;
  112. }
  113. return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop,
  114. flags, gsg, host);
  115. }
  116. // Nothing else left to try.
  117. return NULL;
  118. }
  119. #endif // WIN32