Panda3D
|
00001 // Filename: graphicsStateGuardian.I 00002 // Created by: drose (24Sep99) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: GraphicsStateGuardian::release_all 00018 // Access: Public 00019 // Description: Releases all prepared objects. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE void GraphicsStateGuardian:: 00022 release_all() { 00023 _prepared_objects->release_all(); 00024 } 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: GraphicsStateGuardian::release_all_textures 00028 // Access: Public 00029 // Description: Frees the resources for all textures associated with 00030 // this GSG. 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE int GraphicsStateGuardian:: 00033 release_all_textures() { 00034 return _prepared_objects->release_all_textures(); 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: GraphicsStateGuardian::release_all_geoms 00039 // Access: Public 00040 // Description: Frees the resources for all geoms associated with 00041 // this GSG. 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE int GraphicsStateGuardian:: 00044 release_all_geoms() { 00045 return _prepared_objects->release_all_geoms(); 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: GraphicsStateGuardian::release_all_vertex_buffers 00050 // Access: Public 00051 // Description: Frees the resources for all vertex buffers associated 00052 // with this GSG. 00053 //////////////////////////////////////////////////////////////////// 00054 INLINE int GraphicsStateGuardian:: 00055 release_all_vertex_buffers() { 00056 return _prepared_objects->release_all_vertex_buffers(); 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: GraphicsStateGuardian::release_all_index_buffers 00061 // Access: Public 00062 // Description: Frees the resources for all index buffers associated 00063 // with this GSG. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE int GraphicsStateGuardian:: 00066 release_all_index_buffers() { 00067 return _prepared_objects->release_all_index_buffers(); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: GraphicsStateGuardian::set_active 00072 // Access: Published 00073 // Description: Sets the active flag associated with the 00074 // GraphicsStateGuardian. If the GraphicsStateGuardian 00075 // is marked inactive, nothing is rendered. This is not 00076 // normally turned off unless there is a problem with 00077 // the rendering detected at a low level. 00078 //////////////////////////////////////////////////////////////////// 00079 INLINE void GraphicsStateGuardian:: 00080 set_active(bool active) { 00081 _active = active; 00082 } 00083 00084 //////////////////////////////////////////////////////////////////// 00085 // Function: GraphicsStateGuardian::is_active 00086 // Access: Published 00087 // Description: Returns the active flag associated with the 00088 // GraphicsStateGuardian. 00089 //////////////////////////////////////////////////////////////////// 00090 INLINE bool GraphicsStateGuardian:: 00091 is_active() const { 00092 return _active && _is_valid; 00093 } 00094 00095 //////////////////////////////////////////////////////////////////// 00096 // Function: GraphicsStateGuardian::is_valid 00097 // Access: Published 00098 // Description: Returns true if the GSG has been correctly 00099 // initialized within a graphics context, false if there 00100 // has been some problem or it hasn't been initialized 00101 // yet. 00102 //////////////////////////////////////////////////////////////////// 00103 INLINE bool GraphicsStateGuardian:: 00104 is_valid() const { 00105 return _is_valid; 00106 } 00107 00108 //////////////////////////////////////////////////////////////////// 00109 // Function: GraphicsStateGuardian::needs_reset 00110 // Access: Public 00111 // Description: Returns true if the gsg is marked as needing a 00112 // reset. 00113 //////////////////////////////////////////////////////////////////// 00114 INLINE bool GraphicsStateGuardian:: 00115 needs_reset() const { 00116 return _needs_reset; 00117 } 00118 00119 //////////////////////////////////////////////////////////////////// 00120 // Function: GraphicsStateGuardian::set_incomplete_render 00121 // Access: Public 00122 // Description: Sets the incomplete_render flag. When this is 00123 // true, the frame will be rendered even if some of the 00124 // geometry or textures in the scene are not available 00125 // (e.g. they have been temporarily paged out). When 00126 // this is false, the frame will be held up while this 00127 // data is reloaded. 00128 // 00129 // Setting this true allows for a smoother frame rate, 00130 // but occasionally parts of the frame will be invisible 00131 // or missing (they will generally come in within a 00132 // second or two). Setting this false guarantees that 00133 // every frame will be complete, but may cause more 00134 // chugs as things are loaded up at runtime. 00135 // 00136 // You may want to set this false during loading 00137 // screens, to guarantee that all of your assets are 00138 // available by the time you take the loading screen 00139 // down. 00140 // 00141 // This flag may also be set individually on each 00142 // DisplayRegion. It will be considered true for a 00143 // given DisplayRegion only if it is true on both the 00144 // GSG and on the DisplayRegion. 00145 //////////////////////////////////////////////////////////////////// 00146 INLINE void GraphicsStateGuardian:: 00147 set_incomplete_render(bool incomplete_render) { 00148 _incomplete_render = incomplete_render; 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: GraphicsStateGuardian::get_incomplete_render 00153 // Access: Public, Virtual 00154 // Description: Returns the incomplete_render flag. See 00155 // set_incomplete_render(). 00156 //////////////////////////////////////////////////////////////////// 00157 INLINE bool GraphicsStateGuardian:: 00158 get_incomplete_render() const { 00159 return _incomplete_render; 00160 } 00161 00162 //////////////////////////////////////////////////////////////////// 00163 // Function: GraphicsStateGuardian::get_effective_incomplete_render 00164 // Access: Public, Virtual 00165 // Description: Returns true if the GSG is effectively in 00166 // incomplete_render state, considering both the GSG's 00167 // incomplete_render and its current DisplayRegion's 00168 // incomplete_render flags. It only makes sense to call 00169 // this during the draw traversal; at other times this 00170 // return value will be meaningless. 00171 // 00172 // See CullTraverser::get_effective_incomplete_render() 00173 // for this same information during the cull traversal. 00174 //////////////////////////////////////////////////////////////////// 00175 INLINE bool GraphicsStateGuardian:: 00176 get_effective_incomplete_render() const { 00177 return _effective_incomplete_render; 00178 } 00179 00180 //////////////////////////////////////////////////////////////////// 00181 // Function: GraphicsStateGuardian::set_loader 00182 // Access: Public 00183 // Description: Sets the Loader object that will be used by this GSG 00184 // to load textures when necessary, if 00185 // get_incomplete_render() is true. 00186 //////////////////////////////////////////////////////////////////// 00187 INLINE void GraphicsStateGuardian:: 00188 set_loader(Loader *loader) { 00189 _loader = loader; 00190 } 00191 00192 //////////////////////////////////////////////////////////////////// 00193 // Function: GraphicsStateGuardian::get_loader 00194 // Access: Public, Virtual 00195 // Description: Returns the Loader object that will be used by this 00196 // GSG to load textures when necessary, if 00197 // get_incomplete_render() is true. 00198 //////////////////////////////////////////////////////////////////// 00199 INLINE Loader *GraphicsStateGuardian:: 00200 get_loader() const { 00201 return _loader; 00202 } 00203 00204 //////////////////////////////////////////////////////////////////// 00205 // Function: GraphicsStateGuardian::get_pipe 00206 // Access: Published 00207 // Description: Returns the graphics pipe on which this GSG was 00208 // created. 00209 //////////////////////////////////////////////////////////////////// 00210 INLINE GraphicsPipe *GraphicsStateGuardian:: 00211 get_pipe() const { 00212 return _pipe; 00213 } 00214 00215 //////////////////////////////////////////////////////////////////// 00216 // Function: GraphicsStateGuardian::get_threading_model 00217 // Access: Published 00218 // Description: Returns the threading model that was used to create 00219 // this GSG. 00220 //////////////////////////////////////////////////////////////////// 00221 INLINE const GraphicsThreadingModel &GraphicsStateGuardian:: 00222 get_threading_model() const { 00223 return _threading_model; 00224 } 00225 00226 //////////////////////////////////////////////////////////////////// 00227 // Function: GraphicsStateGuardian::is_hardware 00228 // Access: Published 00229 // Description: Returns true if this GSG appears to be 00230 // hardware-accelerated, or false if it is known to be 00231 // software only. 00232 //////////////////////////////////////////////////////////////////// 00233 INLINE bool GraphicsStateGuardian:: 00234 is_hardware() const { 00235 return _is_hardware; 00236 } 00237 00238 //////////////////////////////////////////////////////////////////// 00239 // Function: GraphicsStateGuardian::prefers_triangle_strips 00240 // Access: Published, Virtual 00241 // Description: Returns true if this GSG strongly prefers triangle 00242 // strips to individual triangles (such as SGI), or 00243 // false if it prefers to minimize the number of 00244 // primitive batches, even at the expense of triangle 00245 // strips (such as most PC hardware). 00246 //////////////////////////////////////////////////////////////////// 00247 INLINE bool GraphicsStateGuardian:: 00248 prefers_triangle_strips() const { 00249 return _prefers_triangle_strips; 00250 } 00251 00252 //////////////////////////////////////////////////////////////////// 00253 // Function: GraphicsStateGuardian::get_max_vertices_per_array 00254 // Access: Published, Virtual 00255 // Description: Returns the maximum number of vertices that should be 00256 // put into any one GeomVertexData object for use with 00257 // this GSG. 00258 //////////////////////////////////////////////////////////////////// 00259 INLINE int GraphicsStateGuardian:: 00260 get_max_vertices_per_array() const { 00261 return _max_vertices_per_array; 00262 } 00263 00264 //////////////////////////////////////////////////////////////////// 00265 // Function: GraphicsStateGuardian::get_max_vertices_per_primitive 00266 // Access: Published, Virtual 00267 // Description: Returns the maximum number of vertex indices that 00268 // should be put into any one GeomPrimitive object for 00269 // use with this GSG. 00270 //////////////////////////////////////////////////////////////////// 00271 INLINE int GraphicsStateGuardian:: 00272 get_max_vertices_per_primitive() const { 00273 return _max_vertices_per_primitive; 00274 } 00275 00276 //////////////////////////////////////////////////////////////////// 00277 // Function: GraphicsStateGuardian::get_max_texture_stages 00278 // Access: Published 00279 // Description: Returns the maximum number of simultaneous textures 00280 // that may be applied to geometry with multitexturing, 00281 // as supported by this particular GSG. If you exceed 00282 // this number, the lowest-priority texture stages will 00283 // not be applied. Use TextureStage::set_priority() to 00284 // adjust the relative importance of the different 00285 // texture stages. 00286 // 00287 // The value returned may not be meaningful until after 00288 // the graphics context has been fully created (e.g. the 00289 // window has been opened). 00290 //////////////////////////////////////////////////////////////////// 00291 INLINE int GraphicsStateGuardian:: 00292 get_max_texture_stages() const { 00293 if (max_texture_stages > 0) { 00294 return min(_max_texture_stages, (int)max_texture_stages); 00295 } 00296 return _max_texture_stages; 00297 } 00298 00299 //////////////////////////////////////////////////////////////////// 00300 // Function: GraphicsStateGuardian::get_max_texture_dimension 00301 // Access: Published 00302 // Description: Returns the largest possible texture size in any one 00303 // dimension supported by the GSG, or -1 if there is no 00304 // particular limit. 00305 // 00306 // The value returned may not be meaningful until after 00307 // the graphics context has been fully created (e.g. the 00308 // window has been opened). 00309 //////////////////////////////////////////////////////////////////// 00310 INLINE int GraphicsStateGuardian:: 00311 get_max_texture_dimension() const { 00312 return _max_texture_dimension; 00313 } 00314 00315 //////////////////////////////////////////////////////////////////// 00316 // Function: GraphicsStateGuardian::get_max_3d_texture_dimension 00317 // Access: Published 00318 // Description: Returns the largest possible texture size in any one 00319 // dimension for a 3-d texture, or -1 if there is no 00320 // particular limit. Returns 0 if 3-d textures are not 00321 // supported. 00322 // 00323 // The value returned may not be meaningful until after 00324 // the graphics context has been fully created (e.g. the 00325 // window has been opened). 00326 //////////////////////////////////////////////////////////////////// 00327 INLINE int GraphicsStateGuardian:: 00328 get_max_3d_texture_dimension() const { 00329 return _max_3d_texture_dimension; 00330 } 00331 00332 //////////////////////////////////////////////////////////////////// 00333 // Function: GraphicsStateGuardian::get_max_cube_map_dimension 00334 // Access: Published 00335 // Description: Returns the largest possible texture size in any one 00336 // dimension for a cube map texture, or -1 if there is 00337 // no particular limit. Returns 0 if cube map textures 00338 // are not supported. 00339 // 00340 // The value returned may not be meaningful until after 00341 // the graphics context has been fully created (e.g. the 00342 // window has been opened). 00343 //////////////////////////////////////////////////////////////////// 00344 INLINE int GraphicsStateGuardian:: 00345 get_max_cube_map_dimension() const { 00346 return _max_cube_map_dimension; 00347 } 00348 00349 //////////////////////////////////////////////////////////////////// 00350 // Function: GraphicsStateGuardian::get_supports_texture_combine 00351 // Access: Published 00352 // Description: Returns true if this particular GSG can use the 00353 // TextureStage::M_combine mode, which includes all of 00354 // the texture blend modes specified by 00355 // set_combine_rgb() and/or set_combine_alpha(). If 00356 // this is false, you must limit yourself to using the 00357 // simpler blend modes. 00358 //////////////////////////////////////////////////////////////////// 00359 INLINE bool GraphicsStateGuardian:: 00360 get_supports_texture_combine() const { 00361 return _supports_texture_combine; 00362 } 00363 00364 //////////////////////////////////////////////////////////////////// 00365 // Function: GraphicsStateGuardian::get_supports_texture_saved_result 00366 // Access: Published 00367 // Description: Returns true if this GSG can use the 00368 // TextureStage::CS_last_saved_result source, which 00369 // allows you to save the result of a TextureStage and 00370 // re-use it for multiple inputs. 00371 //////////////////////////////////////////////////////////////////// 00372 INLINE bool GraphicsStateGuardian:: 00373 get_supports_texture_saved_result() const { 00374 return _supports_texture_saved_result; 00375 } 00376 00377 //////////////////////////////////////////////////////////////////// 00378 // Function: GraphicsStateGuardian::get_supports_texture_dot3 00379 // Access: Published 00380 // Description: Returns true if this GSG can use the 00381 // TextureStage::CM_dot3_rgb or CM_dot3_rgba combine 00382 // modes. 00383 //////////////////////////////////////////////////////////////////// 00384 INLINE bool GraphicsStateGuardian:: 00385 get_supports_texture_dot3() const { 00386 return _supports_texture_dot3; 00387 } 00388 00389 //////////////////////////////////////////////////////////////////// 00390 // Function: GraphicsStateGuardian::get_supports_3d_texture 00391 // Access: Published 00392 // Description: Returns true if this GSG can render 3-d (volumetric) 00393 // textures. 00394 //////////////////////////////////////////////////////////////////// 00395 INLINE bool GraphicsStateGuardian:: 00396 get_supports_3d_texture() const { 00397 return _supports_3d_texture; 00398 } 00399 00400 //////////////////////////////////////////////////////////////////// 00401 // Function: GraphicsStateGuardian::get_supports_cube_map 00402 // Access: Published 00403 // Description: Returns true if this GSG can render cube map textures. 00404 //////////////////////////////////////////////////////////////////// 00405 INLINE bool GraphicsStateGuardian:: 00406 get_supports_cube_map() const { 00407 return _supports_cube_map; 00408 } 00409 00410 //////////////////////////////////////////////////////////////////// 00411 // Function: GraphicsStateGuardian::get_supports_tex_non_pow2 00412 // Access: Published 00413 // Description: Returns true if this GSG can handle non power of two 00414 // sized textures. 00415 //////////////////////////////////////////////////////////////////// 00416 INLINE bool GraphicsStateGuardian:: 00417 get_supports_tex_non_pow2() const { 00418 return _supports_tex_non_pow2; 00419 } 00420 00421 //////////////////////////////////////////////////////////////////// 00422 // Function: GraphicsStateGuardian::get_supports_compressed_texture 00423 // Access: Published 00424 // Description: Returns true if this GSG can compress textures as it 00425 // loads them into texture memory, and/or accept 00426 // pre-compressed textures for storing. 00427 //////////////////////////////////////////////////////////////////// 00428 INLINE bool GraphicsStateGuardian:: 00429 get_supports_compressed_texture() const { 00430 return _supports_compressed_texture; 00431 } 00432 00433 //////////////////////////////////////////////////////////////////// 00434 // Function: GraphicsStateGuardian::get_supports_compressed_texture_format 00435 // Access: Published, Virtual 00436 // Description: Returns true if this GSG can accept textures 00437 // pre-compressed in the indicated format. 00438 // compression_mode may be any of the 00439 // Texture::CompressionMode enums. 00440 //////////////////////////////////////////////////////////////////// 00441 INLINE bool GraphicsStateGuardian:: 00442 get_supports_compressed_texture_format(int compression_mode) const { 00443 return _compressed_texture_formats.get_bit(compression_mode); 00444 } 00445 00446 //////////////////////////////////////////////////////////////////// 00447 // Function: GraphicsStateGuardian::get_max_lights 00448 // Access: Published 00449 // Description: Returns the maximum number of simultaneous lights 00450 // that may be rendered on geometry, or -1 if there is 00451 // no particular limit. 00452 // 00453 // The value returned may not be meaningful until after 00454 // the graphics context has been fully created (e.g. the 00455 // window has been opened). 00456 //////////////////////////////////////////////////////////////////// 00457 INLINE int GraphicsStateGuardian:: 00458 get_max_lights() const { 00459 return _max_lights; 00460 } 00461 00462 //////////////////////////////////////////////////////////////////// 00463 // Function: GraphicsStateGuardian::get_max_clip_planes 00464 // Access: Published 00465 // Description: Returns the maximum number of simultaneous clip planes 00466 // that may be applied to geometry, or -1 if there is 00467 // no particular limit. 00468 // 00469 // The value returned may not be meaningful until after 00470 // the graphics context has been fully created (e.g. the 00471 // window has been opened). 00472 //////////////////////////////////////////////////////////////////// 00473 INLINE int GraphicsStateGuardian:: 00474 get_max_clip_planes() const { 00475 return _max_clip_planes; 00476 } 00477 00478 //////////////////////////////////////////////////////////////////// 00479 // Function: GraphicsStateGuardian::get_max_vertex_transforms 00480 // Access: Published 00481 // Description: Returns the maximum number of transform matrices that 00482 // may be simultaneously used to transform any one 00483 // vertex by the graphics hardware. If this number is 00484 // 0, then the hardware (or the graphics backend) 00485 // doesn't support soft-skinned vertices (in which case 00486 // Panda will animate the vertices in software). 00487 // 00488 // The value returned may not be meaningful until after 00489 // the graphics context has been fully created (e.g. the 00490 // window has been opened). 00491 //////////////////////////////////////////////////////////////////// 00492 INLINE int GraphicsStateGuardian:: 00493 get_max_vertex_transforms() const { 00494 return _max_vertex_transforms; 00495 } 00496 00497 //////////////////////////////////////////////////////////////////// 00498 // Function: GraphicsStateGuardian::get_max_vertex_transform_indices 00499 // Access: Published 00500 // Description: Returns the maximum number of transforms there may be 00501 // in a single TransformTable for this graphics 00502 // hardware. If this number is 0 (but 00503 // get_max_transforms() is nonzero), then the graphics 00504 // hardware (or API) doesn't support indexed transforms, 00505 // but can support direct transform references. 00506 // 00507 // The value returned may not be meaningful until after 00508 // the graphics context has been fully created (e.g. the 00509 // window has been opened). 00510 //////////////////////////////////////////////////////////////////// 00511 INLINE int GraphicsStateGuardian:: 00512 get_max_vertex_transform_indices() const { 00513 return _max_vertex_transform_indices; 00514 } 00515 00516 //////////////////////////////////////////////////////////////////// 00517 // Function: GraphicsStateGuardian::get_copy_texture_inverted 00518 // Access: Published 00519 // Description: Returns true if this particular GSG has the property 00520 // that any framebuffer-to-texture copy results in a 00521 // texture that is upside-down and backwards from 00522 // Panda's usual convention; that is, it copies into a 00523 // texture from the bottom up instead of from the top 00524 // down. 00525 // 00526 // If this is true, then on offscreen GraphicsBuffer 00527 // created for the purposes of rendering into a texture 00528 // should be created with the invert flag set true, to 00529 // compensate. Panda will do this automatically if you 00530 // create an offscreen buffer using 00531 // GraphicsOutput::make_texture_buffer(). 00532 //////////////////////////////////////////////////////////////////// 00533 INLINE bool GraphicsStateGuardian:: 00534 get_copy_texture_inverted() const { 00535 // If this is set from a Config variable, that overrides. 00536 if (copy_texture_inverted.has_value()) { 00537 return copy_texture_inverted; 00538 } 00539 00540 // Otherwise, use whatever behavior the GSG figured for itself. 00541 return _copy_texture_inverted; 00542 } 00543 00544 //////////////////////////////////////////////////////////////////// 00545 // Function: GraphicsStateGuardian::get_supports_generate_mipmap 00546 // Access: Published 00547 // Description: Returns true if this particular GSG can generate 00548 // mipmaps for a texture automatically, or if they must 00549 // be generated in software. If this is true, then 00550 // mipmaps can safely be enabled for rendered textures 00551 // (e.g. using the MultitexReducer). 00552 //////////////////////////////////////////////////////////////////// 00553 INLINE bool GraphicsStateGuardian:: 00554 get_supports_generate_mipmap() const { 00555 return _supports_generate_mipmap; 00556 } 00557 00558 //////////////////////////////////////////////////////////////////// 00559 // Function: GraphicsStateGuardian::get_supports_render_texture 00560 // Access: Published 00561 // Description: Returns true if this particular GSG can render 00562 // directly into a texture, or false if it must always 00563 // copy-to-texture at the end of each frame to achieve 00564 // this effect. 00565 //////////////////////////////////////////////////////////////////// 00566 INLINE bool GraphicsStateGuardian:: 00567 get_supports_render_texture() const { 00568 return _supports_render_texture; 00569 } 00570 00571 //////////////////////////////////////////////////////////////////// 00572 // Function: GraphicsStateGuardian::get_supports_depth_texture 00573 // Access: Published 00574 // Description: Returns true if this particular GSG supports 00575 // textures whose format is F_depth_stencil. This 00576 // returns true if the GSG supports GL_DEPTH_COMPONENT 00577 // textures, which are considered a limited but still 00578 // valid case of F_depth_stencil. 00579 //////////////////////////////////////////////////////////////////// 00580 INLINE bool GraphicsStateGuardian:: 00581 get_supports_depth_texture() const { 00582 return _supports_depth_texture; 00583 } 00584 00585 //////////////////////////////////////////////////////////////////// 00586 // Function: GraphicsStateGuardian::get_supports_depth_stencil 00587 // Access: Published 00588 // Description: Returns true if this particular GSG supports 00589 // textures whose format is F_depth_stencil. This 00590 // only returns true if the GSG supports the full 00591 // packed depth-stencil functionality. 00592 //////////////////////////////////////////////////////////////////// 00593 INLINE bool GraphicsStateGuardian:: 00594 get_supports_depth_stencil() const { 00595 return _supports_depth_stencil; 00596 } 00597 00598 //////////////////////////////////////////////////////////////////// 00599 // Function: GraphicsStateGuardian::get_supports_shadow_filter 00600 // Access: Published 00601 // Description: Returns true if this particular GSG supports 00602 // the filter mode FT_shadow for depth textures. 00603 //////////////////////////////////////////////////////////////////// 00604 INLINE bool GraphicsStateGuardian:: 00605 get_supports_shadow_filter() const { 00606 return _supports_shadow_filter; 00607 } 00608 00609 //////////////////////////////////////////////////////////////////// 00610 // Function: GraphicsStateGuardian::get_supports_basic_shaders 00611 // Access: Published 00612 // Description: Returns true if this particular GSG supports 00613 // arbfp1+arbvp1 or above. 00614 //////////////////////////////////////////////////////////////////// 00615 INLINE bool GraphicsStateGuardian:: 00616 get_supports_basic_shaders() const { 00617 return _supports_basic_shaders; 00618 } 00619 00620 //////////////////////////////////////////////////////////////////// 00621 // Function: GraphicsStateGuardian::get_supports_glsl 00622 // Access: Published 00623 // Description: Returns true if this particular GSG supports 00624 // GLSL shaders. 00625 //////////////////////////////////////////////////////////////////// 00626 INLINE bool GraphicsStateGuardian:: 00627 get_supports_glsl() const { 00628 return _supports_glsl; 00629 } 00630 00631 //////////////////////////////////////////////////////////////////// 00632 // Function: GraphicsStateGuardian::get_supports_stencil 00633 // Access: Published 00634 // Description: Returns true if this particular GSG supports 00635 // stencil buffers at all. 00636 //////////////////////////////////////////////////////////////////// 00637 INLINE bool GraphicsStateGuardian:: 00638 get_supports_stencil() const { 00639 return _supports_stencil; 00640 } 00641 00642 //////////////////////////////////////////////////////////////////// 00643 // Function: GraphicsStateGuardian::get_supports_two_sided_stencil 00644 // Access: Published 00645 // Description: Returns true if this particular GSG supports 00646 // two sided stencil: different stencil settings for the 00647 // front and back side of the same polygon. 00648 //////////////////////////////////////////////////////////////////// 00649 INLINE bool GraphicsStateGuardian:: 00650 get_supports_two_sided_stencil() const { 00651 return _supports_two_sided_stencil; 00652 } 00653 00654 //////////////////////////////////////////////////////////////////// 00655 // Function: GraphicsStateGuardian::get_supports_geometry_instancing 00656 // Access: Published 00657 // Description: Returns true if this particular GSG supports 00658 // hardware geometry instancing: the ability to render 00659 // multiple copies of a model. In OpenGL, this is 00660 // done using the EXT_draw_instanced extension. 00661 //////////////////////////////////////////////////////////////////// 00662 INLINE bool GraphicsStateGuardian:: 00663 get_supports_geometry_instancing() const { 00664 return _supports_geometry_instancing; 00665 } 00666 00667 //////////////////////////////////////////////////////////////////// 00668 // Function: GraphicsStateGuardian::get_maximum_simultaneous_render_targets 00669 // Access: Published 00670 // Description: Returns the maximum simultaneous render targets 00671 // supported. 00672 //////////////////////////////////////////////////////////////////// 00673 INLINE int GraphicsStateGuardian:: 00674 get_maximum_simultaneous_render_targets() const { 00675 return _maximum_simultaneous_render_targets; 00676 } 00677 00678 //////////////////////////////////////////////////////////////////// 00679 // Function: GraphicsStateGuardian::get_shader_model 00680 // Access: Published 00681 // Description: Returns the ShaderModel 00682 //////////////////////////////////////////////////////////////////// 00683 INLINE int GraphicsStateGuardian:: 00684 get_shader_model() const { 00685 return _shader_model; 00686 } 00687 00688 //////////////////////////////////////////////////////////////////// 00689 // Function: GraphicsStateGuardian::set_shader_model 00690 // Access: Published 00691 // Description: Sets the ShaderModel. This will override the auto- 00692 // detected shader model during GSG reset. Useful for 00693 // testing lower-end shaders. 00694 //////////////////////////////////////////////////////////////////// 00695 INLINE void GraphicsStateGuardian:: 00696 set_shader_model(int shader_model) { 00697 if (shader_model <= _auto_detect_shader_model) { 00698 _shader_model = shader_model; 00699 } 00700 } 00701 00702 //////////////////////////////////////////////////////////////////// 00703 // Function: GraphicsStateGuardian::get_color_scale_via_lighting 00704 // Access: Published 00705 // Description: Returns true if this particular GSG can implement (or 00706 // would prefer to implement) set color and/or color 00707 // scale using materials and/or ambient lights, or 00708 // false if we need to actually munge the color. 00709 //////////////////////////////////////////////////////////////////// 00710 INLINE bool GraphicsStateGuardian:: 00711 get_color_scale_via_lighting() const { 00712 return _color_scale_via_lighting; 00713 } 00714 00715 //////////////////////////////////////////////////////////////////// 00716 // Function: GraphicsStateGuardian::get_alpha_scale_via_texture 00717 // Access: Published 00718 // Description: Returns true if this particular GSG can implement (or 00719 // would prefer to implement) an alpha scale via an 00720 // additional Texture layer, or false if we need to 00721 // actually munge the alpha. 00722 //////////////////////////////////////////////////////////////////// 00723 INLINE bool GraphicsStateGuardian:: 00724 get_alpha_scale_via_texture() const { 00725 return _alpha_scale_via_texture; 00726 } 00727 00728 //////////////////////////////////////////////////////////////////// 00729 // Function: GraphicsStateGuardian::get_alpha_scale_via_texture 00730 // Access: Published 00731 // Description: This variant of get_alpha_scale_via_texture() answers 00732 // the question of whether the GSG can implement an 00733 // alpha scale via an additional Texture layer, 00734 // considering the current TextureAttrib that will be in 00735 // effect. This considers whether there is at least one 00736 // additional texture slot available on the GSG. 00737 //////////////////////////////////////////////////////////////////// 00738 INLINE bool GraphicsStateGuardian:: 00739 get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { 00740 return _alpha_scale_via_texture && 00741 (tex_attrib == (const TextureAttrib *)NULL || 00742 tex_attrib->get_num_on_stages() < get_max_texture_stages()); 00743 } 00744 00745 //////////////////////////////////////////////////////////////////// 00746 // Function: GraphicsStateGuardian::get_alpha_scale_texture_stage 00747 // Access: Published, Static 00748 // Description: Returns the TextureStage that will be used to apply 00749 // an alpha scale, if get_alpha_scale_via_texture() 00750 // returns true. 00751 //////////////////////////////////////////////////////////////////// 00752 INLINE TextureStage *GraphicsStateGuardian:: 00753 get_alpha_scale_texture_stage() { 00754 if (_alpha_scale_texture_stage == (TextureStage *)NULL) { 00755 _alpha_scale_texture_stage = new TextureStage("alpha-scale"); 00756 _alpha_scale_texture_stage->set_sort(1000000000); 00757 } 00758 return _alpha_scale_texture_stage; 00759 } 00760 00761 //////////////////////////////////////////////////////////////////// 00762 // Function: GraphicsStateGuardian::get_runtime_color_scale 00763 // Access: Published 00764 // Description: Returns true if this particular GSG can implement (or 00765 // would prefer to implement) set color and/or color 00766 // scale directly, without requiring any munging of 00767 // vertices or tricks with lighting. 00768 //////////////////////////////////////////////////////////////////// 00769 INLINE bool GraphicsStateGuardian:: 00770 get_runtime_color_scale() const { 00771 return _runtime_color_scale; 00772 } 00773 00774 //////////////////////////////////////////////////////////////////// 00775 // Function: GraphicsStateGuardian::get_coordinate_system 00776 // Access: Published 00777 // Description: Returns the coordinate system in effect on this 00778 // particular gsg. Normally, this will be the default 00779 // coordinate system, but it might be set differently at 00780 // runtime. 00781 //////////////////////////////////////////////////////////////////// 00782 INLINE CoordinateSystem GraphicsStateGuardian:: 00783 get_coordinate_system() const { 00784 return _coordinate_system; 00785 } 00786 00787 //////////////////////////////////////////////////////////////////// 00788 // Function: GraphicsStateGuardian::set_texture_quality_override 00789 // Access: Published 00790 // Description: Specifies the global quality_level to be imposed for 00791 // all Textures rendered by this GSG. This overrides 00792 // the value set on individual textures via 00793 // Texture::set_quality_level(). Set this to 00794 // Texture::QL_default in order to allow the individual 00795 // texture quality levels to be respected. 00796 // 00797 // This is mainly useful for the tinydisplay software 00798 // renderer. See Texture::set_quality_level(). 00799 //////////////////////////////////////////////////////////////////// 00800 INLINE void GraphicsStateGuardian:: 00801 set_texture_quality_override(Texture::QualityLevel quality_level) { 00802 _texture_quality_override = quality_level; 00803 } 00804 00805 //////////////////////////////////////////////////////////////////// 00806 // Function: GraphicsStateGuardian::get_texture_quality_override 00807 // Access: Published 00808 // Description: Returns the global quality_level override specified 00809 // by set_texture_quality_override. 00810 // 00811 // This is mainly useful for the tinydisplay software 00812 // renderer. See Texture::set_quality_level(). 00813 //////////////////////////////////////////////////////////////////// 00814 INLINE Texture::QualityLevel GraphicsStateGuardian:: 00815 get_texture_quality_override() const { 00816 return _texture_quality_override; 00817 } 00818 00819 //////////////////////////////////////////////////////////////////// 00820 // Function: GraphicsStateGuardian::reset_if_new 00821 // Access: Public 00822 // Description: Calls reset() to initialize the GSG, but only if it 00823 // hasn't been called yet. Returns true if the GSG was 00824 // new, false otherwise. 00825 //////////////////////////////////////////////////////////////////// 00826 INLINE bool GraphicsStateGuardian:: 00827 reset_if_new() { 00828 if (_needs_reset) { 00829 reset(); 00830 return true; 00831 } 00832 return false; 00833 } 00834 00835 //////////////////////////////////////////////////////////////////// 00836 // Function: GraphicsStateGuardian::mark_new 00837 // Access: Public 00838 // Description: Marks the GSG as "new", so that the next call to 00839 // reset_if_new() will be effective. 00840 //////////////////////////////////////////////////////////////////// 00841 INLINE void GraphicsStateGuardian:: 00842 mark_new() { 00843 _needs_reset = true; 00844 } 00845 00846 //////////////////////////////////////////////////////////////////// 00847 // Function: GraphicsStateGuardian::get_external_transform 00848 // Access: Public 00849 // Description: Fetches the external net transform. This 00850 // transform is generally only set when geometry is 00851 // about to be rendered. Therefore, this "get" function 00852 // is typically only meaningful during the geometry 00853 // rendering process. 00854 //////////////////////////////////////////////////////////////////// 00855 INLINE CPT(TransformState) GraphicsStateGuardian:: 00856 get_external_transform() const { 00857 return _inv_cs_transform->compose(_internal_transform); 00858 } 00859 00860 //////////////////////////////////////////////////////////////////// 00861 // Function: GraphicsStateGuardian::get_internal_transform 00862 // Access: Public 00863 // Description: Fetches the external net transform. This 00864 // transform is generally only set when geometry is 00865 // about to be rendered. Therefore, this "get" function 00866 // is typically only meaningful during the geometry 00867 // rendering process. 00868 //////////////////////////////////////////////////////////////////// 00869 INLINE CPT(TransformState) GraphicsStateGuardian:: 00870 get_internal_transform() const { 00871 return _internal_transform; 00872 } 00873 00874 //////////////////////////////////////////////////////////////////// 00875 // Function: GraphicsStateGuardian::get_current_display_region 00876 // Access: Public 00877 // Description: Returns the current display region being rendered to, 00878 // as set by the last call to prepare_display_region(). 00879 //////////////////////////////////////////////////////////////////// 00880 INLINE const DisplayRegion *GraphicsStateGuardian:: 00881 get_current_display_region() const { 00882 return _current_display_region; 00883 } 00884 00885 //////////////////////////////////////////////////////////////////// 00886 // Function: GraphicsStateGuardian::get_current_stereo_channel 00887 // Access: Public 00888 // Description: Returns the current stereo channel being rendered to, 00889 // as set by the last call to prepare_display_region(). 00890 //////////////////////////////////////////////////////////////////// 00891 INLINE Lens::StereoChannel GraphicsStateGuardian:: 00892 get_current_stereo_channel() const { 00893 return _current_stereo_channel; 00894 } 00895 00896 //////////////////////////////////////////////////////////////////// 00897 // Function: GraphicsStateGuardian::get_current_lens 00898 // Access: Public 00899 // Description: Returns the current lens being used to render, 00900 // according to the scene specified via the last call to 00901 // set_scene(). 00902 //////////////////////////////////////////////////////////////////// 00903 INLINE const Lens *GraphicsStateGuardian:: 00904 get_current_lens() const { 00905 return _current_lens; 00906 } 00907 00908 //////////////////////////////////////////////////////////////////// 00909 // Function: GraphicsStateGuardian::get_inv_cs_transform 00910 // Access: Public 00911 // Description: Returns the inverse of the transform returned by 00912 // get_cs_transform(). 00913 //////////////////////////////////////////////////////////////////// 00914 INLINE const TransformState *GraphicsStateGuardian:: 00915 get_inv_cs_transform() const { 00916 return _inv_cs_transform; 00917 } 00918 00919 //////////////////////////////////////////////////////////////////// 00920 // Function: GraphicsStateGuardian::set_current_properties 00921 // Access: Protected 00922 // Description: Notifies the gsg that it is about to render into a 00923 // window/buffer with the given FrameBufferProperties 00924 //////////////////////////////////////////////////////////////////// 00925 INLINE void GraphicsStateGuardian:: 00926 set_current_properties(const FrameBufferProperties *prop) { 00927 _current_properties = prop; 00928 } 00929