Panda3D
|
00001 // Filename: graphicsPipe.h 00002 // Created by: mike (09Jan97) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef GRAPHICSPIPE_H 00016 #define GRAPHICSPIPE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "graphicsDevice.h" 00021 #include "typedReferenceCount.h" 00022 #include "pointerTo.h" 00023 #include "lightMutex.h" 00024 #include "displayInformation.h" 00025 00026 class GraphicsEngine; 00027 class GraphicsOutput; 00028 class GraphicsWindow; 00029 class GraphicsBuffer; 00030 class GraphicsStateGuardian; 00031 class FrameBufferProperties; 00032 class WindowProperties; 00033 class Texture; 00034 class WindowHandle; 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Class : GraphicsPipe 00038 // Description : An object to create GraphicsOutputs that share a 00039 // particular 3-D API. Normally, there will only be one 00040 // GraphicsPipe in an application, although it is 00041 // possible to have multiple of these at once if there 00042 // are multiple different API's available in the same 00043 // machine. 00044 // 00045 // Often, the GraphicsPipe corresponds to a physical 00046 // output device, hence the term "pipe", but this is not 00047 // necessarily the case. 00048 // 00049 // The GraphicsPipe is used by the GraphicsEngine object 00050 // to create and destroy windows; it keeps ownership of 00051 // the windows it creates. 00052 // 00053 // M. Asad added new/interim functionality where GraphicsPipe 00054 // now contains a device interface to directx/opengl which 00055 // will be used to handle multiple windows from same device. 00056 // 00057 //////////////////////////////////////////////////////////////////// 00058 class EXPCL_PANDA_DISPLAY GraphicsPipe : public TypedReferenceCount { 00059 protected: 00060 GraphicsPipe(); 00061 private: 00062 GraphicsPipe(const GraphicsPipe ©); 00063 void operator = (const GraphicsPipe ©); 00064 00065 PUBLISHED: 00066 virtual ~GraphicsPipe(); 00067 00068 enum OutputTypes { 00069 OT_window = 0x0001, 00070 OT_fullscreen_window = 0x0002, 00071 OT_buffer = 0x0004, 00072 OT_texture_buffer = 0x0008, 00073 }; 00074 00075 enum BufferCreationFlags { 00076 // Flags that control what type of output is returned. 00077 BF_refuse_parasite = 0x0001, 00078 BF_require_parasite = 0x0002, 00079 BF_refuse_window = 0x0004, 00080 BF_require_window = 0x0008, 00081 BF_require_callback_window = 0x0010, 00082 00083 // Miscellaneous control flags. 00084 BF_can_bind_color = 0x0040, // Need capability: bind the color bitplane to a tex. 00085 BF_can_bind_every = 0x0080, // Need capability: bind all bitplanes to a tex. 00086 BF_resizeable = 0x0100, // Buffer should allow set_size. 00087 BF_size_track_host = 0x0200, // Buffer should track the host size. 00088 BF_rtt_cumulative = 0x0400, // Buffer supports cumulative render-to-texture. 00089 BF_fb_props_optional = 0x0800, // FrameBufferProperties can be ignored. 00090 BF_size_square = 0x1000, // x_size must equal y_size (e.g. for cube maps) 00091 BF_size_power_2 = 0x2000, // x_size and y_size must each be a power of two 00092 }; 00093 00094 INLINE bool is_valid() const; 00095 INLINE int get_supported_types() const; 00096 INLINE bool supports_type(int flags) const; 00097 00098 INLINE int get_display_width() const; 00099 INLINE int get_display_height() const; 00100 00101 DisplayInformation *get_display_information(); 00102 virtual void lookup_cpu_data(); 00103 00104 virtual string get_interface_name() const=0; 00105 00106 public: 00107 enum PreferredWindowThread { 00108 PWT_app, 00109 PWT_draw 00110 }; 00111 virtual PreferredWindowThread get_preferred_window_thread() const; 00112 00113 INLINE GraphicsDevice *get_device() const; 00114 virtual PT(GraphicsDevice) make_device(void *scrn = NULL); 00115 00116 protected: 00117 virtual void close_gsg(GraphicsStateGuardian *gsg); 00118 00119 virtual PT(GraphicsOutput) make_output(const string &name, 00120 const FrameBufferProperties &fb_prop, 00121 const WindowProperties &win_prop, 00122 int flags, 00123 GraphicsEngine *engine, 00124 GraphicsStateGuardian *gsg, 00125 GraphicsOutput *host, 00126 int retry, 00127 bool &precertify); 00128 virtual PT(GraphicsStateGuardian) make_callback_gsg(GraphicsEngine *engine); 00129 00130 LightMutex _lock; 00131 00132 bool _is_valid; 00133 int _supported_types; 00134 int _display_width; 00135 int _display_height; 00136 PT(GraphicsDevice) _device; 00137 00138 DisplayInformation *_display_information; 00139 00140 static const int strip_properties[]; 00141 00142 public: 00143 00144 static TypeHandle get_class_type() { 00145 return _type_handle; 00146 } 00147 static void init_type() { 00148 TypedReferenceCount::init_type(); 00149 register_type(_type_handle, "GraphicsPipe", 00150 TypedReferenceCount::get_class_type()); 00151 } 00152 virtual TypeHandle get_type() const { 00153 return get_class_type(); 00154 } 00155 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00156 00157 private: 00158 static TypeHandle _type_handle; 00159 friend class GraphicsEngine; 00160 }; 00161 00162 #include "graphicsPipe.I" 00163 00164 #endif /* GRAPHICSPIPE_H */