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 00082 // Miscellaneous control flags. 00083 BF_can_bind_color = 0x0040, // Need capability: bind the color bitplane to a tex. 00084 BF_can_bind_every = 0x0080, // Need capability: bind all bitplanes to a tex. 00085 BF_resizeable = 0x0100, // Buffer should allow set_size. 00086 BF_size_track_host = 0x0200, // Buffer should track the host size. 00087 BF_rtt_cumulative = 0x0400, // Buffer supports cumulative render-to-texture. 00088 BF_fb_props_optional = 0x0800, // FrameBufferProperties can be ignored. 00089 BF_size_square = 0x1000, // x_size must equal y_size (e.g. for cube maps) 00090 BF_size_power_2 = 0x2000, // x_size and y_size must each be a power of two 00091 }; 00092 00093 INLINE bool is_valid() const; 00094 INLINE int get_supported_types() const; 00095 INLINE bool supports_type(int flags) const; 00096 00097 INLINE int get_display_width() const; 00098 INLINE int get_display_height() const; 00099 00100 DisplayInformation *get_display_information(); 00101 virtual void lookup_cpu_data(); 00102 00103 virtual string get_interface_name() const=0; 00104 00105 public: 00106 enum PreferredWindowThread { 00107 PWT_app, 00108 PWT_draw 00109 }; 00110 virtual PreferredWindowThread get_preferred_window_thread() const; 00111 00112 INLINE GraphicsDevice *get_device() const; 00113 virtual PT(GraphicsDevice) make_device(void *scrn = NULL); 00114 00115 protected: 00116 virtual void close_gsg(GraphicsStateGuardian *gsg); 00117 00118 virtual PT(GraphicsOutput) make_output(const string &name, 00119 const FrameBufferProperties &fb_prop, 00120 const WindowProperties &win_prop, 00121 int flags, 00122 GraphicsEngine *engine, 00123 GraphicsStateGuardian *gsg, 00124 GraphicsOutput *host, 00125 int retry, 00126 bool &precertify); 00127 00128 LightMutex _lock; 00129 00130 bool _is_valid; 00131 int _supported_types; 00132 int _display_width; 00133 int _display_height; 00134 PT(GraphicsDevice) _device; 00135 00136 DisplayInformation *_display_information; 00137 00138 static const int strip_properties[]; 00139 00140 public: 00141 00142 static TypeHandle get_class_type() { 00143 return _type_handle; 00144 } 00145 static void init_type() { 00146 TypedReferenceCount::init_type(); 00147 register_type(_type_handle, "GraphicsPipe", 00148 TypedReferenceCount::get_class_type()); 00149 } 00150 virtual TypeHandle get_type() const { 00151 return get_class_type(); 00152 } 00153 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00154 00155 private: 00156 static TypeHandle _type_handle; 00157 friend class GraphicsEngine; 00158 }; 00159 00160 #include "graphicsPipe.I" 00161 00162 #endif /* GRAPHICSPIPE_H */