00001 // Filename: config_crgsg.cxx 00002 // Created by: drose (06Oct99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "config_crgsg.h" 00020 #include "crGraphicsStateGuardian.h" 00021 #include "crSavedFrameBuffer.h" 00022 #include "crTextureContext.h" 00023 #include "crGeomNodeContext.h" 00024 00025 #include <dconfig.h> 00026 00027 Configure(config_crgsg); 00028 NotifyCategoryDef(crgsg, ":display:gsg"); 00029 00030 // Configure this variable true to cause the CRGSG to show each 00031 // transform space it renders by drawing a little unit axis. This 00032 // cannot be enabled when the player is compiled in NDEBUG mode. 00033 bool cr_show_transforms = config_crgsg.GetBool("cr-show-transforms", false); 00034 00035 // Configure this true to chromium.Hint the textures into the cheapest 00036 // possible mode. 00037 bool cr_cheap_textures = config_crgsg.GetBool("cr-cheap-textures", false); 00038 00039 // Configure this true to perform a cull traversal over the geometry 00040 // by default, false otherwise. The cull traversal provides support 00041 // for state-sorting, z-sorting, and binning. 00042 bool cr_cull_traversal = config_crgsg.GetBool("cr-cull-traversal", true); 00043 00044 // Configure this true to disable the use of mipmapping in the 00045 // renderer. 00046 bool cr_ignore_mipmaps = config_crgsg.GetBool("cr-ignore-mipmaps", false); 00047 00048 // Configure this true to enable full trilinear mipmapping on every 00049 // texture, whether it asks for it or not. 00050 bool cr_force_mipmaps = config_crgsg.GetBool("cr-force-mipmaps", false); 00051 00052 // Configure this true to cause mipmaps to be rendered with phony 00053 // colors, using mipmap_level_*.rgb if they are available. 00054 bool cr_show_mipmaps = config_crgsg.GetBool("cr-show-mipmaps", false); 00055 00056 // Configure this true to cause the generated mipmap images to be 00057 // written out to image files on the disk as they are generated. 00058 bool cr_save_mipmaps = config_crgsg.GetBool("cr-save-mipmaps", false); 00059 00060 // Configure this true to cause all lighting normals to automatically 00061 // be normalized by the graphics hardware before rendering. This is 00062 // necessary if you intend to render things under scale transforms and 00063 // expect lighting to work correctly. Maybe one day there will be 00064 // another way to set this at runtime, instead of only as a configure 00065 // variable. 00066 bool cr_auto_normalize_lighting = config_crgsg.GetBool("auto-normalize-lighting", false); 00067 00068 // Configure this true to try to implement decals using a 00069 // DepthOffsetAttrib, false to do them with the more reliable 3-pass 00070 // rendering method instead. 00071 bool cr_depth_offset_decals = config_crgsg.GetBool("depth-offset-decals", false); 00072 00073 // Configure this true to indicate the current version of GL fully 00074 // supports textures with B, G, R ordering; false if it only supports 00075 // R, G, B. false will always work, but true might be faster if the 00076 // implementation supports it. 00077 #ifdef GL_BGR 00078 bool cr_supports_bgr = config_crgsg.GetBool("cr-supports-bgr", false); 00079 #else 00080 // If it's not even defined, we can't use it. 00081 bool cr_supports_bgr = false; 00082 #endif // GL_BGR 00083 00084 CRDecalType cr_decal_type = GDT_offset; 00085 00086 static CRDecalType 00087 parse_decal_type(const string &type) { 00088 if (type == "mask") { 00089 return GDT_mask; 00090 } else if (type == "blend") { 00091 return GDT_blend; 00092 } else if (type == "offset") { 00093 return GDT_offset; 00094 } 00095 crgsg_cat.error() << "Invalid cr-decal-type: " << type << "\n"; 00096 return GDT_offset; 00097 } 00098 00099 ConfigureFn(config_crgsg) { 00100 init_libcrgsg(); 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: init_libcrgsg 00105 // Description: Initializes the library. This must be called at 00106 // least once before any of the functions or classes in 00107 // this library can be used. Normally it will be 00108 // called by the static initializers and need not be 00109 // called explicitly, but special cases exist. 00110 //////////////////////////////////////////////////////////////////// 00111 void 00112 init_libcrgsg() { 00113 static bool initialized = false; 00114 if (initialized) { 00115 return; 00116 } 00117 initialized = true; 00118 00119 string decal_type = config_crgsg.GetString("cr-decal-type", ""); 00120 if (!decal_type.empty()) { 00121 cr_decal_type = parse_decal_type(decal_type); 00122 } 00123 00124 CRGraphicsStateGuardian::init_type(); 00125 CRSavedFrameBuffer::init_type(); 00126 CRTextureContext::init_type(); 00127 CRGeomNodeContext::init_type(); 00128 00129 GraphicsStateGuardian::get_factory().register_factory 00130 (CRGraphicsStateGuardian::get_class_type(), 00131 CRGraphicsStateGuardian::make_GlGraphicsStateGuardian); 00132 }