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