00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "glxGraphicsPipe.h"
00016 #include "glxGraphicsWindow.h"
00017 #include "glxGraphicsBuffer.h"
00018 #include "glxGraphicsPixmap.h"
00019 #include "glxGraphicsStateGuardian.h"
00020 #include "posixGraphicsStateGuardian.h"
00021 #include "config_glxdisplay.h"
00022 #include "frameBufferProperties.h"
00023
00024 TypeHandle glxGraphicsPipe::_type_handle;
00025
00026
00027
00028
00029
00030
00031 glxGraphicsPipe::
00032 glxGraphicsPipe(const string &display) : x11GraphicsPipe(display) {
00033 if (_display == None) {
00034
00035 return;
00036 }
00037
00038 string display_spec (XDisplayString(_display));
00039
00040 int errorBase, eventBase;
00041 if (!glXQueryExtension(_display, &errorBase, &eventBase)) {
00042 glxdisplay_cat.error()
00043 << "OpenGL GLX extension not supported on display \"" << display_spec
00044 << "\".\n";
00045 return;
00046 }
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 string glxGraphicsPipe::
00060 get_interface_name() const {
00061 return "OpenGL";
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071 PT(GraphicsPipe) glxGraphicsPipe::
00072 pipe_constructor() {
00073 return new glxGraphicsPipe;
00074 }
00075
00076
00077
00078
00079
00080
00081 PT(GraphicsOutput) glxGraphicsPipe::
00082 make_output(const string &name,
00083 const FrameBufferProperties &fb_prop,
00084 const WindowProperties &win_prop,
00085 int flags,
00086 GraphicsEngine *engine,
00087 GraphicsStateGuardian *gsg,
00088 GraphicsOutput *host,
00089 int retry,
00090 bool &precertify) {
00091
00092 if (!_is_valid) {
00093 return NULL;
00094 }
00095
00096 glxGraphicsStateGuardian *glxgsg = 0;
00097 if (gsg != 0) {
00098 DCAST_INTO_R(glxgsg, gsg, NULL);
00099 }
00100
00101 bool support_rtt;
00102 support_rtt = false;
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 if (retry == 0) {
00115 if (((flags&BF_require_parasite)!=0)||
00116 ((flags&BF_refuse_window)!=0)||
00117 ((flags&BF_resizeable)!=0)||
00118 ((flags&BF_size_track_host)!=0)||
00119 ((flags&BF_rtt_cumulative)!=0)||
00120 ((flags&BF_can_bind_color)!=0)||
00121 ((flags&BF_can_bind_every)!=0)) {
00122 return NULL;
00123 }
00124 return new glxGraphicsWindow(engine, this, name, fb_prop, win_prop,
00125 flags, gsg, host);
00126 }
00127
00128
00129
00130 if (retry == 1) {
00131 if ((host==0)||
00132 (!gl_support_fbo)||
00133 ((flags&BF_require_parasite)!=0)||
00134 ((flags&BF_require_window)!=0)) {
00135 return NULL;
00136 }
00137
00138
00139 int _fbo_multisample = 0;
00140 if (!ConfigVariableBool("framebuffer-object-multisample", false, PRC_DESC("Enabled Multisample."))) {
00141 _fbo_multisample = 16;
00142 }
00143 if ((flags & BF_fb_props_optional)==0) {
00144 if ((fb_prop.get_indexed_color() > 0)||
00145 (fb_prop.get_back_buffers() > 0)||
00146 (fb_prop.get_accum_bits() > 0)||
00147 (fb_prop.get_multisamples() > _fbo_multisample)) {
00148 return NULL;
00149 }
00150 }
00151
00152
00153 if ((glxgsg != 0) &&
00154 (glxgsg->is_valid()) &&
00155 (!glxgsg->needs_reset()) &&
00156 (glxgsg->_supports_framebuffer_object) &&
00157 (glxgsg->_glDrawBuffers != 0)&&
00158 (fb_prop.is_basic())) {
00159 precertify = true;
00160 }
00161 return new GLGraphicsBuffer(engine, this, name, fb_prop, win_prop,
00162 flags, gsg, host);
00163 }
00164
00165
00166 if (glxgsg == NULL || glxgsg->_supports_fbconfig) {
00167 if (retry == 2) {
00168 if (!glx_support_pbuffer) {
00169 return NULL;
00170 }
00171
00172 if (((flags&BF_require_parasite)!=0)||
00173 ((flags&BF_require_window)!=0)||
00174 ((flags&BF_resizeable)!=0)||
00175 ((flags&BF_size_track_host)!=0)) {
00176 return NULL;
00177 }
00178
00179 if (!support_rtt) {
00180 if (((flags&BF_rtt_cumulative)!=0)||
00181 ((flags&BF_can_bind_every)!=0)) {
00182
00183
00184 return NULL;
00185 }
00186 }
00187
00188 return new glxGraphicsBuffer(engine, this, name, fb_prop, win_prop,
00189 flags, gsg, host);
00190 }
00191 }
00192
00193
00194 if (retry == 3) {
00195 if (!glx_support_pixmap) {
00196 return NULL;
00197 }
00198
00199 if (((flags&BF_require_parasite)!=0)||
00200 ((flags&BF_require_window)!=0)||
00201 ((flags&BF_resizeable)!=0)||
00202 ((flags&BF_size_track_host)!=0)) {
00203 return NULL;
00204 }
00205
00206 if (((flags&BF_rtt_cumulative)!=0)||
00207 ((flags&BF_can_bind_every)!=0)) {
00208 return NULL;
00209 }
00210
00211 return new glxGraphicsPixmap(engine, this, name, fb_prop, win_prop,
00212 flags, gsg, host);
00213 }
00214
00215
00216 return NULL;
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 PT(GraphicsStateGuardian) glxGraphicsPipe::
00229 make_callback_gsg(GraphicsEngine *engine) {
00230
00231
00232
00233 return new PosixGraphicsStateGuardian(engine, this);
00234 }