diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..b7923b22be --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/built_x64 +/built +/samples +/thirdparty diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..8675a25c0e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: cpp +compiler: + - gcc + - clang +before_script: + - sudo apt-get install python-dev libpng-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libjpeg-dev libopenal-dev libode-dev nvidia-cg-toolkit +script: python makepanda/makepanda.py --everything +notifications: + irc: + channels: + - "chat.freenode.net#panda3d" + on_success: change + on_failure: change + use_notice: true + skip_join: true diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..d23c583266 --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2008, Carnegie Mellon University. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of Carnegie Mellon University nor the names of + other contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(This is the Modified BSD License. See also +http://www.opensource.org/licenses/bsd-license.php ) diff --git a/README.md b/README.md new file mode 100644 index 0000000000..a216893938 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +[![Build Status](https://travis-ci.org/panda3d/panda3d.svg?branch=master)](https://travis-ci.org/panda3d/panda3d) + + + +Panda3D +======= + +Panda3D is a game engine, a framework for 3D rendering and game development for +Python and C++ programs. Panda3D is open-source and free for any purpose, +including commercial ventures, thanks to its +[liberal license](https://www.panda3d.org/license.php). To learn more about +Panda3D's capabilities, visit the [gallery](https://www.panda3d.org/gallery.php) +and the [feature list](https://www.panda3d.org/features.php). To learn how to +use Panda3D, check the [documentation](https://www.panda3d.org/documentation.php) +resources. If you get stuck, ask for help from our active +[community](https://www.panda3d.org/community.php). + +Panda3D is licensed under the Modified BSD License. See the LICENSE file for +more details. + +Building Panda3D +================ + +Windows +------- + +We currently build using the Microsoft Visual C++ 2010 compiler. You do not +need Microsoft Visual Studio to build Panda3D, though - the relevant compilers +are included as part of the Windows 7.1 SDK. + +You will also need to have the third-party dependency libraries available for +the build scripts to use. These are available from here: +https://www.panda3d.org/forums/viewtopic.php?f=9&t=16346 + +After acquiring these dependencies, you may simply build Panda3D from the +command prompt using the following command: + +```bash +makepanda\makepanda.bat --everything --installer +``` + +When the build succeeds, it will produce an .exe file that you can use to +install Panda3D on your system. + +Linux +----- + +Building Panda3D on Linux is easy. All you need is to invoke the makepanda +script using the version of Python that you want Panda3D to be built against. + +Run makepanda.py with the --help option to see which options are available. +Usually, you will want to specify the --everything option (which builds with +support for all features for which it detects the prerequisite dependencies) +and the --installer option (which produces an installable .deb or .rpm file +for you to install, depending on your distribution). + +The following command illustrates how to build Panda3D with some common +options: +```bash +python2.7 makepanda/makepanda.py --everything --installer --no-egl --no-gles --no-gles2 +``` + +You will probably see some warnings saying that it's unable to find several +dependency packages. You should determine which ones you want to include in +your build and install the respective development packages. You may visit +[this manual page](https://www.panda3d.org/manual/index.php/Dependencies) +for an overview of the various dependencies. + +If you are on Ubuntu, this command should cover the most frequently +used third-party packages: + +```bash +sudo apt-get install python-dev libpng-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libjpeg-dev libeigen3-dev libopenal-dev libode-dev libbullet-dev nvidia-cg-toolkit +``` + +Once Panda3D has built, you can either install the .deb or .rpm package that +it produced (if relevant to your platform, and you added --installer). On +other systems, you will need to use the installpanda script to install it onto +your system. Careful: it is not easy to uninstall Panda3D in this way! + +```bash +python2.7 makepanda/installpanda.py --prefix=/usr/local +``` diff --git a/direct/.gitignore b/direct/.gitignore index 9ecbb69fa0..97b7fbcf49 100644 --- a/direct/.gitignore +++ b/direct/.gitignore @@ -1,5 +1,8 @@ *.pyc /__init__.py -/built/ +# These are files that are generated within the source tree by the +# ppremake system. Makefile pp.dep +/built/ +Opt?-* diff --git a/direct/src/filter/CommonFilters.py b/direct/src/filter/CommonFilters.py index 2d05e74fb5..ee3de9ac8d 100644 --- a/direct/src/filter/CommonFilters.py +++ b/direct/src/filter/CommonFilters.py @@ -338,7 +338,6 @@ class CommonFilters: if ("Inverted" in configuration): text += " o_color = float4(1, 1, 1, 1) - o_color;\n" text += "}\n" - print text self.finalQuad.setShader(Shader.make(text)) for tex in self.textures: diff --git a/doc/README b/doc/README deleted file mode 100644 index 1c62f16602..0000000000 --- a/doc/README +++ /dev/null @@ -1,33 +0,0 @@ -Panda3D is an open source 3D Engine originally developed, and still -actively maintained, by the Walt Disney VR Studio. Additional -development and support for the open source community is provided by -the Entertainment Technology Center of Carnegie Mellon University. - -At the present, we are providing two completely unrelated systems for -building Panda. The original build system, ppremake, is still in -active use by the VR Studio, and is useful if you want advanced build -control. The other build system, makepanda, is designed to build -quickly and painlessly, and is used to generate the official releases. - -The ppremake system is a makefile generator, and allows you to -configure your build environment to a high degree of customization. -It is a fairly complex build system, and it requires some comfort with -using the command-line make utilities. - -The makepanda system is a Python script that directly invokes the -compiler to build the Panda sources. Its emphasis is on providing a -hands-off, simple approach to building Panda. - -Both systems may require you to first install a number of third-party -tools if you would like to make them available for Panda, such as -FreeType or OpenSSL. You may also download a zip file that contains -precompiled versions of these third-party libraries from the Panda -website, which is especially useful when used in conjunction with the -makepanda system. - -If you are interested in compiling Panda for yourself, you are welcome -to use either build system. Please refer to the documents INSTALL-PP -or INSTALL-MK, in this directory, for build instructions for ppremake -and makepanda, respectively. You may also be interested in -downloading the prebuilt Panda3D binaries from the Panda website at -http://www.panda3d.org/ . diff --git a/dtool/.gitignore b/dtool/.gitignore index b570f28ee1..d306650d5e 100644 --- a/dtool/.gitignore +++ b/dtool/.gitignore @@ -1,4 +1,7 @@ -/built/ /dtool_config.h +# These are files that are generated within the source tree by the +# ppremake system. Makefile pp.dep +/built/ +Opt?-* diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index 216d8a7abb..48e1bda523 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -12,11 +12,11 @@ // //////////////////////////////////////////////////////////////////// - #include "cppEnumType.h" #include "cppTypedef.h" #include "cppExpression.h" #include "cppSimpleType.h" +#include "cppConstType.h" #include "cppScope.h" #include "cppParser.h" #include "indent.h" @@ -29,7 +29,8 @@ CPPEnumType:: CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope, const CPPFile &file) : - CPPExtensionType(T_enum, ident, current_scope, file) + CPPExtensionType(T_enum, ident, current_scope, file), + _last_value(NULL) { } @@ -41,12 +42,31 @@ CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope, CPPInstance *CPPEnumType:: add_element(const string &name, CPPExpression *value) { CPPType *type = - CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, - CPPSimpleType::F_unsigned)); + CPPType::new_type(new CPPConstType(new CPPSimpleType( + CPPSimpleType::T_int, CPPSimpleType::F_unsigned))); + CPPIdentifier *ident = new CPPIdentifier(name); CPPInstance *inst = new CPPInstance(type, ident); - inst->_initializer = value; _elements.push_back(inst); + + if (value == (CPPExpression *)NULL) { + if (_last_value == (CPPExpression *)NULL) { + // This is the first value, and should therefore be 0. + static CPPExpression *const zero = new CPPExpression(0); + value = zero; + + } else if (_last_value->_type == CPPExpression::T_integer) { + value = new CPPExpression(_last_value->_u._integer + 1); + + } else { + // We may not be able to determine the value just yet. No + // problem; we'll just define it as another expression. + static CPPExpression *const one = new CPPExpression(1); + value = new CPPExpression('+', _last_value, one); + } + } + inst->_initializer = value; + _last_value = value; return inst; } diff --git a/dtool/src/cppparser/cppEnumType.h b/dtool/src/cppparser/cppEnumType.h index e559eb7b53..35d36b28f4 100644 --- a/dtool/src/cppparser/cppEnumType.h +++ b/dtool/src/cppparser/cppEnumType.h @@ -52,6 +52,7 @@ public: typedef vector Elements; Elements _elements; + CPPExpression *_last_value; }; diff --git a/makepanda/.gitignore b/makepanda/.gitignore new file mode 100644 index 0000000000..94487b9516 --- /dev/null +++ b/makepanda/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/panda/.gitignore b/panda/.gitignore index 0d20b6487c..3fbb4b2955 100644 --- a/panda/.gitignore +++ b/panda/.gitignore @@ -1 +1,7 @@ *.pyc +# These are files that are generated within the source tree by the +# ppremake system. +Makefile +pp.dep +/built/ +Opt?-* diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx index aa6b502e0b..937fa0815b 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx @@ -117,10 +117,9 @@ get_properties(FrameBufferProperties &properties, properties.set_back_buffers(1); properties.set_rgb_color(1); - properties.set_color_bits(red_size+green_size+blue_size); + properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size); properties.set_stencil_bits(stencil_size); properties.set_depth_bits(depth_size); - properties.set_alpha_bits(alpha_size); properties.set_multisamples(samples); // Set both hardware and software bits, indicating not-yet-known. diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index d16b5795c1..63ee5dc244 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -71,13 +71,14 @@ get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_for properties.clear(); // Now update our framebuffer_mode and bit depth appropriately. - GLint double_buffer, stereo, aux_buffers, color_size, alpha_size, - depth_size, stencil_size, accum_size, sample_buffers, samples, - renderer_id, accelerated, window, pbuffer; + GLint double_buffer, stereo, aux_buffers, color_float, color_size, + alpha_size, depth_size, stencil_size, accum_size, sample_buffers, + samples, renderer_id, accelerated, window, pbuffer; [pixel_format getValues:&double_buffer forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:screen]; [pixel_format getValues:&stereo forAttribute:NSOpenGLPFAStereo forVirtualScreen:screen]; [pixel_format getValues:&aux_buffers forAttribute:NSOpenGLPFAAuxBuffers forVirtualScreen:screen]; + [pixel_format getValues:&color_float forAttribute:NSOpenGLPFAColorFloat forVirtualScreen:screen]; [pixel_format getValues:&color_size forAttribute:NSOpenGLPFAColorSize forVirtualScreen:screen]; [pixel_format getValues:&alpha_size forAttribute:NSOpenGLPFAAlphaSize forVirtualScreen:screen]; [pixel_format getValues:&depth_size forAttribute:NSOpenGLPFADepthSize forVirtualScreen:screen]; @@ -93,6 +94,7 @@ get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_for properties.set_back_buffers(double_buffer); properties.set_stereo(stereo); properties.set_rgb_color(1); + properties.set_float_color(color_float); properties.set_color_bits(color_size); properties.set_stencil_bits(stencil_size); properties.set_depth_bits(depth_size); @@ -145,7 +147,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // Don't let it fall back to a different renderer. attribs.push_back(NSOpenGLPFANoRecovery); - + // Consider pixel formats with properties equal // to or better than we requested. attribs.push_back(NSOpenGLPFAMinimumPolicy); @@ -192,7 +194,7 @@ choose_pixel_format(const FrameBufferProperties &properties, attribs.push_back(NSOpenGLPFARendererID); attribs.push_back(kCGLRendererGenericFloatID); } - + if (properties.get_force_hardware()) { attribs.push_back(NSOpenGLPFAAccelerated); } diff --git a/panda/src/display/Sources.pp b/panda/src/display/Sources.pp index 118e87be77..98c9e3d24e 100644 --- a/panda/src/display/Sources.pp +++ b/panda/src/display/Sources.pp @@ -43,7 +43,6 @@ windowHandle.I windowHandle.h \ windowProperties.I windowProperties.h \ renderBuffer.h \ - stencilRenderStates.h \ stereoDisplayRegion.I stereoDisplayRegion.h \ displaySearchParameters.h \ displayInformation.h \ @@ -80,7 +79,6 @@ parasiteBuffer.cxx \ windowHandle.cxx \ windowProperties.cxx \ - stencilRenderStates.cxx \ stereoDisplayRegion.cxx \ subprocessWindow.cxx \ touchInfo.cxx @@ -118,7 +116,6 @@ windowHandle.I windowHandle.h \ windowProperties.I windowProperties.h \ renderBuffer.h \ - stencilRenderStates.h \ stereoDisplayRegion.I stereoDisplayRegion.h \ subprocessWindow.h subprocessWindow.I \ subprocessWindowBuffer.h subprocessWindowBuffer.I \ diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 012a323317..5b207a446a 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -419,7 +419,18 @@ ConfigVariableInt depth_bits PRC_DESC("The minimum number of depth buffer bits requested.")); ConfigVariableInt color_bits ("color-bits", 0, - PRC_DESC("The minimum number of color buffer bits requested.")); + PRC_DESC("The minimum number of total color buffer bits requested. This " + "value is like red-bits + blue-bits + green-bits except Panda " + "won't care how the bits are divided up.")); +ConfigVariableInt red_bits +("red-bits", 0, + PRC_DESC("The minimum number of red color buffer bits requested.")); +ConfigVariableInt green_bits +("green-bits", 0, + PRC_DESC("The minimum number of green color buffer bits requested.")); +ConfigVariableInt blue_bits +("blue-bits", 0, + PRC_DESC("The minimum number of blue color buffer bits requested.")); ConfigVariableInt alpha_bits ("alpha-bits", 0, PRC_DESC("The minimum number of alpha buffer bits requested.")); diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index d36f24c5bf..24ed75bbb8 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -96,6 +96,9 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableBool framebuffer_srgb; extern EXPCL_PANDA_DISPLAY ConfigVariableBool framebuffer_float; extern EXPCL_PANDA_DISPLAY ConfigVariableInt depth_bits; extern EXPCL_PANDA_DISPLAY ConfigVariableInt color_bits; +extern EXPCL_PANDA_DISPLAY ConfigVariableInt red_bits; +extern EXPCL_PANDA_DISPLAY ConfigVariableInt green_bits; +extern EXPCL_PANDA_DISPLAY ConfigVariableInt blue_bits; extern EXPCL_PANDA_DISPLAY ConfigVariableInt alpha_bits; extern EXPCL_PANDA_DISPLAY ConfigVariableInt stencil_bits; extern EXPCL_PANDA_DISPLAY ConfigVariableInt accum_bits; diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index eb6da4b0ea..d596427195 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -65,7 +65,7 @@ is_stereo() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::operator << // Access: Public -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE ostream & operator << (ostream &out, const FrameBufferProperties &properties) { @@ -76,7 +76,7 @@ operator << (ostream &out, const FrameBufferProperties &properties) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_depth_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_depth_bits() const { @@ -86,17 +86,50 @@ get_depth_bits() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_color_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_color_bits() const { - return _property[FBP_color_bits]; + return max(_property[FBP_color_bits], + _property[FBP_red_bits] + + _property[FBP_green_bits] + + _property[FBP_blue_bits]); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_red_bits +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_red_bits() const { + return _property[FBP_red_bits]; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_green_bits +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_green_bits() const { + return _property[FBP_green_bits]; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_blue_bits +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_blue_bits() const { + return _property[FBP_blue_bits]; } //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_alpha_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_alpha_bits() const { @@ -106,7 +139,7 @@ get_alpha_bits() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_stencil_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_stencil_bits() const { @@ -116,7 +149,7 @@ get_stencil_bits() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_accum_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_accum_bits() const { @@ -126,7 +159,7 @@ get_accum_bits() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_aux_rgba // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_aux_rgba() const { @@ -136,7 +169,7 @@ get_aux_rgba() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_aux_hrgba // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_aux_hrgba() const { @@ -146,7 +179,7 @@ get_aux_hrgba() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_aux_float // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_aux_float() const { @@ -156,7 +189,7 @@ get_aux_float() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_multisamples // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_multisamples() const { @@ -177,7 +210,7 @@ get_coverage_samples() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_back_buffers // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE int FrameBufferProperties:: get_back_buffers() const { @@ -187,7 +220,7 @@ get_back_buffers() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_indexed_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_indexed_color() const { @@ -197,7 +230,7 @@ get_indexed_color() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_rgb_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_rgb_color() const { @@ -207,7 +240,7 @@ get_rgb_color() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_stereo // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_stereo() const { @@ -217,7 +250,7 @@ get_stereo() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_force_hardware // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_force_hardware() const { @@ -227,7 +260,7 @@ get_force_hardware() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_force_software // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_force_software() const { @@ -237,7 +270,7 @@ get_force_software() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_srgb_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_srgb_color() const { @@ -247,7 +280,7 @@ get_srgb_color() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_float_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_float_color() const { @@ -257,7 +290,7 @@ get_float_color() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::get_float_depth // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE bool FrameBufferProperties:: get_float_depth() const { @@ -267,7 +300,7 @@ get_float_depth() const { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_depth_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_depth_bits(int n) { @@ -278,7 +311,7 @@ set_depth_bits(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_color_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_color_bits(int n) { @@ -286,10 +319,62 @@ set_color_bits(int n) { _specified[FBP_color_bits] = true; } +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_rgba_bits +// Access: Published +// Description: Sets all color bit requirements separately. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_rgba_bits(int r, int g, int b, int a) { + _property[FBP_red_bits] = r; + _specified[FBP_red_bits] = true; + _property[FBP_green_bits] = g; + _specified[FBP_green_bits] = true; + _property[FBP_blue_bits] = b; + _specified[FBP_blue_bits] = true; + _property[FBP_alpha_bits] = a; + _specified[FBP_alpha_bits] = true; + _property[FBP_color_bits] = r + g + b; + _specified[FBP_color_bits] = true; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_red_bits +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_red_bits(int n) { + _property[FBP_red_bits] = n; + _specified[FBP_red_bits] = true; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_green_bits +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_green_bits(int n) { + _property[FBP_green_bits] = n; + _specified[FBP_green_bits] = true; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_blue_bits +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_blue_bits(int n) { + _property[FBP_blue_bits] = n; + _specified[FBP_blue_bits] = true; +} + //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_alpha_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_alpha_bits(int n) { @@ -300,7 +385,7 @@ set_alpha_bits(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_stencil_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_stencil_bits(int n) { @@ -311,7 +396,7 @@ set_stencil_bits(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_accum_bits // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_accum_bits(int n) { @@ -322,7 +407,7 @@ set_accum_bits(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_aux_rgba // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_aux_rgba(int n) { @@ -334,7 +419,7 @@ set_aux_rgba(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_aux_hrgba // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_aux_hrgba(int n) { @@ -346,7 +431,7 @@ set_aux_hrgba(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_aux_float // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_aux_float(int n) { @@ -358,7 +443,7 @@ set_aux_float(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_multisamples // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_multisamples(int n) { @@ -381,7 +466,7 @@ set_coverage_samples(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_back_buffers // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_back_buffers(int n) { @@ -392,7 +477,7 @@ set_back_buffers(int n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_indexed_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_indexed_color(bool n) { @@ -407,7 +492,7 @@ set_indexed_color(bool n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_rgb_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_rgb_color(bool n) { @@ -422,7 +507,7 @@ set_rgb_color(bool n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_stereo // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_stereo(bool n) { @@ -437,7 +522,7 @@ set_stereo(bool n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_force_hardware // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_force_hardware(bool n) { @@ -452,7 +537,7 @@ set_force_hardware(bool n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_force_software // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_force_software(bool n) { @@ -467,7 +552,7 @@ set_force_software(bool n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_srgb_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_srgb_color(bool n) { @@ -482,7 +567,7 @@ set_srgb_color(bool n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_float_color // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_float_color(bool n) { @@ -497,7 +582,7 @@ set_float_color(bool n) { //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::set_float_depth // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// INLINE void FrameBufferProperties:: set_float_depth(bool n) { diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index 50053169dd..8b38b4b3e1 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -16,6 +16,7 @@ #include "string_utils.h" #include "renderBuffer.h" #include "config_display.h" +#include "texture.h" //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::Constructor @@ -100,6 +101,9 @@ get_default() { display_cat.error() << " framebuffer-stereo #t\n"; display_cat.error() << " depth-bits N\n"; display_cat.error() << " color-bits N\n"; + display_cat.error() << " red-bits N\n"; + display_cat.error() << " green-bits N\n"; + display_cat.error() << " blue-bits N\n"; display_cat.error() << " alpha-bits N\n"; display_cat.error() << " stencil-bits N\n"; display_cat.error() << " multisamples N\n"; @@ -143,6 +147,15 @@ get_default() { if (color_bits > 0) { default_props.set_color_bits(color_bits); } + if (red_bits > 0) { + default_props.set_red_bits(red_bits); + } + if (green_bits > 0) { + default_props.set_green_bits(green_bits); + } + if (blue_bits > 0) { + default_props.set_blue_bits(blue_bits); + } if (alpha_bits > 0) { default_props.set_alpha_bits(alpha_bits); } @@ -166,7 +179,7 @@ get_default() { } //////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::operator == +// Function: FrameBufferProperties::operator == // Access: Published // Description: //////////////////////////////////////////////////////////////////// @@ -251,6 +264,15 @@ output(ostream &out) const { if (_property[FBP_color_bits] > 0) { out << "color_bits=" << _property[FBP_color_bits] << " "; } + if (_property[FBP_red_bits] > 0) { + out << "red_bits=" << _property[FBP_red_bits] << " "; + } + if (_property[FBP_green_bits] > 0) { + out << "green_bits=" << _property[FBP_green_bits] << " "; + } + if (_property[FBP_blue_bits] > 0) { + out << "blue_bits=" << _property[FBP_blue_bits] << " "; + } if (_property[FBP_alpha_bits] > 0) { out << "alpha_bits=" << _property[FBP_alpha_bits] << " "; } @@ -384,6 +406,15 @@ is_basic() const { if (_property[FBP_color_bits] > 1) { return false; } + if (_property[FBP_red_bits] > 1) { + return false; + } + if (_property[FBP_green_bits] > 1) { + return false; + } + if (_property[FBP_blue_bits] > 1) { + return false; + } if (_property[FBP_alpha_bits] > 1) { return false; } @@ -662,3 +693,121 @@ verify_hardware_software(const FrameBufferProperties &props, const string &rende return true; } + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::setup_color_texture +// Access: Public +// Description: Sets the texture up for render-to-texture matching +// these framebuffer properties. +// +// Returns true if there was a format that had enough +// bits, false otherwise. Of course, this is no +// guarantee that a particular graphics back-end +// supports rendering to textures of that format. +//////////////////////////////////////////////////////////////////// +bool FrameBufferProperties:: +setup_color_texture(Texture *tex) const { + // Note by rdb: I'm not entirely happy about this system. I'd + // eventually like to move to a system in which framebuffer color + // formats and texture formats are unified (like in Direct3D and + // OpenGL) and where a table such as the below one would be + // generated dynamically by the GSG to reflect the formats that + // are supported for render-to-texture. + + static const int num_formats = 12; + static const struct { + unsigned char color_bits, red_bits, green_bits, blue_bits, alpha_bits; + bool has_float; + Texture::Format format; + } formats[num_formats] = { + //{ 1, 1, 0, 0, 0, F_red}, + { 1, 1, 1, 1, 0, false, Texture::F_rgb }, + { 1, 1, 1, 1, 1, false, Texture::F_rgba }, + { 24, 8, 8, 8, 0, false, Texture::F_rgb8 }, + { 24, 8, 8, 8, 8, false, Texture::F_rgba8 }, + { 16, 16, 0, 0, 0, true, Texture::F_r16 }, + { 32, 16, 16, 0, 0, true, Texture::F_rg16 }, + { 48, 16, 16, 16, 0, true, Texture::F_rgb16 }, + { 48, 16, 16, 16, 16, true, Texture::F_rgba16 }, + { 32, 32, 0, 0, 0, true, Texture::F_r32 }, + { 64, 32, 32, 0, 0, true, Texture::F_rg32 }, + { 96, 32, 32, 32, 0, true, Texture::F_rgb32 }, + { 96, 32, 32, 32, 32, true, Texture::F_rgba32 }, + }; + + if (get_srgb_color()) { + // These are the only sRGB formats. Deal with it. + if (get_alpha_bits() == 0) { + tex->set_format(Texture::F_srgb); + } else { + tex->set_format(Texture::F_srgb_alpha); + } + + return (get_color_bits() <= 24 && + get_red_bits() <= 8 && + get_green_bits() <= 8 && + get_blue_bits() <= 8 && + get_alpha_bits() <= 8); + + } else { + if (get_float_color()) { + tex->set_component_type(Texture::T_float); + } + + for (int i = 0; i < num_formats; ++i) { + if (get_color_bits() <= (int)formats[i].color_bits && + get_red_bits() <= (int)formats[i].red_bits && + get_green_bits() <= (int)formats[i].green_bits && + get_blue_bits() <= (int)formats[i].blue_bits && + get_alpha_bits() <= (int)formats[i].alpha_bits && + get_float_color() <= formats[i].has_float) { + + tex->set_format(formats[i].format); + return true; + } + } + + // Can't get requested bits. Choose a generic format and return. + tex->set_format((get_alpha_bits() == 0) ? Texture::F_rgb : Texture::F_rgba); + return false; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::setup_depth_texture +// Access: Public +// Description: Sets the texture up for render-to-texture matching +// these framebuffer properties. +// +// Returns true if there was a format that had enough +// bits, false otherwise. Of course, this is no +// guarantee that a particular graphics back-end +// supports rendering to textures of that format. +//////////////////////////////////////////////////////////////////// +bool FrameBufferProperties:: +setup_depth_texture(Texture *tex) const { + if (get_float_depth()) { + tex->set_component_type(Texture::T_float); + tex->set_format(Texture::F_depth_component32); + return (get_depth_bits() <= 32); + + } else if (get_depth_bits() <= 1) { + tex->set_format(Texture::F_depth_component); + return true; + + } else if (get_depth_bits() <= 16) { + tex->set_format(Texture::F_depth_component16); + return true; + + } else if (get_depth_bits() <= 24) { + tex->set_format(Texture::F_depth_component24); + return true; + + } else if (get_depth_bits() <= 32) { + tex->set_format(Texture::F_depth_component32); + return true; + } + + tex->set_format(Texture::F_depth_component); + return false; +} diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h index dea4926238..57ba098600 100644 --- a/panda/src/display/frameBufferProperties.h +++ b/panda/src/display/frameBufferProperties.h @@ -18,6 +18,8 @@ #include "pandabase.h" #include "pnotify.h" +class Texture; + //////////////////////////////////////////////////////////////////// // Class : FrameBufferProperties // Description : A container for the various kinds of properties we @@ -31,6 +33,9 @@ private: // This section has to start with "depth" and end with "accum" FBP_depth_bits, FBP_color_bits, + FBP_red_bits, + FBP_green_bits, + FBP_blue_bits, FBP_alpha_bits, FBP_stencil_bits, FBP_accum_bits, @@ -72,6 +77,9 @@ PUBLISHED: // Individual queries. INLINE int get_depth_bits() const; INLINE int get_color_bits() const; + INLINE int get_red_bits() const; + INLINE int get_green_bits() const; + INLINE int get_blue_bits() const; INLINE int get_alpha_bits() const; INLINE int get_stencil_bits() const; INLINE int get_accum_bits() const; @@ -93,6 +101,10 @@ PUBLISHED: // Individual assigners. INLINE void set_depth_bits(int n); INLINE void set_color_bits(int n); + INLINE void set_rgba_bits(int r, int g, int b, int a); + INLINE void set_red_bits(int n); + INLINE void set_green_bits(int n); + INLINE void set_blue_bits(int n); INLINE void set_alpha_bits(int n); INLINE void set_stencil_bits(int n); INLINE void set_accum_bits(int n); @@ -136,6 +148,9 @@ PUBLISHED: int get_aux_mask() const; int get_buffer_mask() const; bool verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const; + + bool setup_color_texture(Texture *tex) const; + bool setup_depth_texture(Texture *tex) const; }; INLINE ostream &operator << (ostream &out, const FrameBufferProperties &properties); diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 1e8131e6b4..65ca18054b 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -258,8 +258,6 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, // it is rendered. _runtime_color_scale = false; - _stencil_render_states = 0; - // The default is no shader support. _auto_detect_shader_model = SM_00; _shader_model = SM_00; @@ -279,11 +277,6 @@ GraphicsStateGuardian:: ~GraphicsStateGuardian() { remove_gsg(this); - if (_stencil_render_states) { - delete _stencil_render_states; - _stencil_render_states = 0; - } - if (_shader_generator) { delete _shader_generator; _shader_generator = 0; @@ -1988,12 +1981,6 @@ reset() { _last_max_stage_index = 0; _is_valid = true; - - if (_stencil_render_states) { - delete _stencil_render_states; - _stencil_render_states = 0; - } - _stencil_render_states = new StencilRenderStates(this); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 8484ee1be6..0cc5a3a587 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -45,7 +45,6 @@ #include "texture.h" #include "occlusionQueryContext.h" #include "timerQueryContext.h" -#include "stencilRenderStates.h" #include "loader.h" #include "shaderAttrib.h" #include "texGenAttrib.h" @@ -532,8 +531,6 @@ protected: int _stereo_buffer_mask; - StencilRenderStates *_stencil_render_states; - int _auto_detect_shader_model; int _shader_model; diff --git a/panda/src/display/p3display_composite2.cxx b/panda/src/display/p3display_composite2.cxx index 35755515f4..4d613bb588 100644 --- a/panda/src/display/p3display_composite2.cxx +++ b/panda/src/display/p3display_composite2.cxx @@ -12,7 +12,6 @@ #include "nativeWindowHandle.cxx" #include "parasiteBuffer.cxx" #include "standardMunger.cxx" -#include "stencilRenderStates.cxx" #include "touchInfo.cxx" #include "stereoDisplayRegion.cxx" #include "subprocessWindow.cxx" diff --git a/panda/src/display/stencilRenderStates.cxx b/panda/src/display/stencilRenderStates.cxx deleted file mode 100644 index 76773e3dfd..0000000000 --- a/panda/src/display/stencilRenderStates.cxx +++ /dev/null @@ -1,111 +0,0 @@ -// Filename: stencilRenderStates.cxx -// Created by: aignacio (17May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#include "graphicsStateGuardian.h" -#include "stencilRenderStates.h" - -//////////////////////////////////////////////////////////////////// -// Function: StencilRenderStates::Constructor -// Description: Constructor. All data is set to the default. -//////////////////////////////////////////////////////////////////// -StencilRenderStates:: -StencilRenderStates (GraphicsStateGuardian *gsg) { - - int index; - - // clear all - for (index = 0; index < SRS_total; index++) { - _stencil_render_state_array [index] = 0; - _stencil_function_array [index] = 0; - } - - // set default render states - set_stencil_render_state (false, SRS_reference, 0); - - set_stencil_render_state (false, SRS_read_mask, ~0); - set_stencil_render_state (false, SRS_write_mask, ~0); - - set_stencil_render_state (false, SRS_front_enable, 0); - set_stencil_render_state (false, SRS_front_comparison_function, SCF_always); - set_stencil_render_state (false, SRS_front_stencil_fail_operation, SO_keep); - set_stencil_render_state (false, SRS_front_stencil_pass_z_fail_operation, SO_keep); - set_stencil_render_state (false, SRS_front_stencil_pass_z_pass_operation, SO_keep); - - set_stencil_render_state (false, SRS_back_enable, 0); - set_stencil_render_state (false, SRS_back_comparison_function, SCF_always); - set_stencil_render_state (false, SRS_back_stencil_fail_operation, SO_keep); - set_stencil_render_state (false, SRS_back_stencil_pass_z_fail_operation, SO_keep); - set_stencil_render_state (false, SRS_back_stencil_pass_z_pass_operation, SO_keep); - - _gsg = gsg; -} - -//////////////////////////////////////////////////////////////////// -// Function: StencilRenderStates::Destructor -// Description: -//////////////////////////////////////////////////////////////////// -StencilRenderStates:: -~StencilRenderStates (void) { - -} - -//////////////////////////////////////////////////////////////////// -// Function: StencilRenderStates::set_stencil_render_state -// Description: Sets the current render state for the specified -// stencil render state. The execute_function -// parameter can be used to defer the actual setting -// of the render state at the API level. This is -// useful for the OpenGL API where certain render -// states are not independent/atomic (i.e. -// glStencilFunc and glStencilOp). -//////////////////////////////////////////////////////////////////// -void StencilRenderStates:: -set_stencil_render_state (bool execute_function, StencilRenderStates::StencilRenderState stencil_render_state, StencilType value) { - - // DEBUG - if (false) { - printf ("SRS %d %d %d \n", execute_function, stencil_render_state, value); - } - - _stencil_render_state_array [stencil_render_state] = value; - - if (execute_function) { - StencilFunction stencil_function; - - stencil_function = _stencil_function_array [stencil_render_state]; - if (stencil_function) { - stencil_function (stencil_render_state, this); - } - } -} - -//////////////////////////////////////////////////////////////////// -// Function: StencilRenderStates::get_stencil_render_state -// Description: Gets the current render state for the specified -// stencil render state. -//////////////////////////////////////////////////////////////////// -StencilType StencilRenderStates:: -get_stencil_render_state (StencilRenderStates::StencilRenderState stencil_render_state) { - return _stencil_render_state_array [stencil_render_state]; -} - -//////////////////////////////////////////////////////////////////// -// Function: StencilRenderStates::set_stencil_function -// Description: Registers an API specific callback for setting a -// specified stencil render state. -//////////////////////////////////////////////////////////////////// -void StencilRenderStates:: -set_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilFunction stencil_function) { - _stencil_function_array [stencil_render_state] = stencil_function; -} diff --git a/panda/src/display/stencilRenderStates.h b/panda/src/display/stencilRenderStates.h deleted file mode 100644 index 6afb0b77fa..0000000000 --- a/panda/src/display/stencilRenderStates.h +++ /dev/null @@ -1,101 +0,0 @@ -// Filename: stencilRenderStates.h -// Created by: aignacio (17May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#ifndef STENCILRENDERSTATES_H -#define STENCILRENDERSTATES_H - -class GraphicsStateGuardian; -typedef unsigned int StencilType; - -//////////////////////////////////////////////////////////////////// -// Class : StencilRenderStates -// Description : An abstract cross-platform class for setting stencil -// buffer render states. Each gsg needs to create its -// own low-level API specific functions on how to set -// each render state. The "set_stencil_render_state" -// function can be used in an immediate-mode fashion. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_DISPLAY StencilRenderStates { - -PUBLISHED: - enum StencilRenderState - { - SRS_front_enable, - SRS_back_enable, - - SRS_front_comparison_function, - SRS_front_stencil_fail_operation, - SRS_front_stencil_pass_z_fail_operation, - SRS_front_stencil_pass_z_pass_operation, - - SRS_reference, - SRS_read_mask, - SRS_write_mask, - - SRS_back_comparison_function, - SRS_back_stencil_fail_operation, - SRS_back_stencil_pass_z_fail_operation, - SRS_back_stencil_pass_z_pass_operation, - - SRS_clear, - SRS_clear_value, - - SRS_total, - - SRS_first = 0, - }; - - enum StencilComparisonFunction - { - SCF_never, - SCF_less_than, - SCF_equal, - SCF_less_than_or_equal, - SCF_greater_than, - SCF_not_equal, - SCF_greater_than_or_equal, - SCF_always, - }; - - enum StencilOperation - { - SO_keep, - SO_zero, - SO_replace, - SO_increment, - SO_decrement, - SO_invert, - SO_increment_saturate, - SO_decrement_saturate, - }; - -public: - typedef void (*StencilFunction) (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states); - - StencilRenderStates (GraphicsStateGuardian *gsg); - ~StencilRenderStates (void); - - void set_stencil_render_state (bool execute_function, StencilRenderStates::StencilRenderState stencil_render_state, StencilType value); - StencilType get_stencil_render_state (StencilRenderStates::StencilRenderState stencil_render_state); - - void set_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilFunction stencil_function); - - GraphicsStateGuardian *_gsg; - -private: - StencilType _stencil_render_state_array [SRS_total]; - StencilFunction _stencil_function_array [SRS_total]; -}; - -#endif diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index c8b0730ea4..019eaf9837 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -303,7 +303,7 @@ upload_texture(DXTextureContext8 *dtc, bool force) { dtc->delete_texture(); dtc->update_data_size_bytes(0); dtc->mark_unloaded(); - + if (_effective_incomplete_render && !force) { bool has_image = _supports_compressed_texture ? tex->has_ram_image() : tex->has_uncompressed_ram_image(); if (!has_image && tex->might_have_ram_image() && @@ -321,7 +321,7 @@ upload_texture(DXTextureContext8 *dtc, bool force) { } } } - + return dtc->create_texture(*_screen); } @@ -634,7 +634,7 @@ clear(DrawableRegion *clearable) { } } } - + if (FAILED(hr)) { dxgsg8_cat.error() << "clear_buffer failed: Clear returned " << D3DERRORSTRING(hr); @@ -1025,7 +1025,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { (D3DPT_TRIANGLELIST, min_vertex, max_vertex, reader->get_num_primitives(), - index_pointer, index_type, vertex_pointer, + index_pointer, index_type, vertex_pointer, _data_reader->get_format()->get_array(0)->get_stride()); } } else { @@ -2074,9 +2074,6 @@ reset() { PRINT_REFCNT(dxgsg8, _d3d_device); - void dx_set_stencil_functions (StencilRenderStates *stencil_render_states); - dx_set_stencil_functions (_stencil_render_states); - // Now that the GSG has been initialized, make it available for // optimizations. add_gsg(this); @@ -2468,7 +2465,7 @@ set_state_and_transform(const RenderState *target, do_issue_depth_write(); _state_mask.set_bit(depth_write_slot); } - + int fog_slot = FogAttrib::get_class_slot(); if (_target_rs->get_attrib(fog_slot) != _state_rs->get_attrib(fog_slot) || !_state_mask.get_bit(fog_slot)) { @@ -2650,22 +2647,22 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { const LMatrix4 &light_mat = transform->get_mat(); LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); LVector3f dir = LCAST(float, light_obj->get_direction() * rel_mat); - + D3DCOLORVALUE black; black.r = black.g = black.b = black.a = 0.0f; - + ZeroMemory(&fdata, sizeof(D3DLIGHT8)); - + fdata.Type = D3DLIGHT_DIRECTIONAL; fdata.Ambient = black ; LColorf color = LCAST(float, light_obj->get_specular_color()); fdata.Specular = *(D3DCOLORVALUE *)(color.get_data()); - + fdata.Direction = *(D3DVECTOR *)dir.get_data(); - + fdata.Range = __D3DLIGHT_RANGE_MAX; fdata.Falloff = 1.0f; - + fdata.Attenuation0 = 1.0f; // constant fdata.Attenuation1 = 0.0f; // linear fdata.Attenuation2 = 0.0f; // quadratic @@ -2983,12 +2980,12 @@ do_issue_texture() { // that there are 3-d texture coordinates, because of the // 3-component texture coordinate in get_constant_value(). { - _d3d_device->SetTextureStageState(si, D3DTSS_TEXCOORDINDEX, + _d3d_device->SetTextureStageState(si, D3DTSS_TEXCOORDINDEX, texcoord_index | D3DTSS_TCI_CAMERASPACEPOSITION); texcoord_dimensions = 3; const LTexCoord3 &v = _target_tex_gen->get_constant_value(stage); - CPT(TransformState) squash = + CPT(TransformState) squash = TransformState::make_pos_hpr_scale(v, LVecBase3::zero(), LVecBase3::zero()); tex_mat = tex_mat->compose(squash); @@ -4006,7 +4003,7 @@ create_swap_chain(DXScreenData *new_context) { bool DXGraphicsStateGuardian8:: release_swap_chain(DXScreenData *new_context) { HRESULT hr; - wdxdisplay8_cat.debug() + wdxdisplay8_cat.debug() << "Releasing swap chain " << new_context->_swap_chain << "\n"; if (new_context->_swap_chain) { hr = new_context->_swap_chain->Release(); @@ -4310,9 +4307,7 @@ draw_indexed_primitive_up(D3DPRIMITIVETYPE primitive_type, //////////////////////////////////////////////////////////////////// // DX stencil code section //////////////////////////////////////////////////////////////////// - -static int dx_stencil_comparison_function_array [ ] = -{ +static int dx_stencil_comparison_function_array[] = { D3DCMP_NEVER, D3DCMP_LESS, D3DCMP_EQUAL, @@ -4323,8 +4318,7 @@ static int dx_stencil_comparison_function_array [ ] = D3DCMP_ALWAYS, }; -static int dx_stencil_operation_array [ ] = -{ +static int dx_stencil_operation_array[] = { D3DSTENCILOP_KEEP, D3DSTENCILOP_ZERO, D3DSTENCILOP_REPLACE, @@ -4336,84 +4330,6 @@ static int dx_stencil_operation_array [ ] = D3DSTENCILOP_DECRSAT, }; -void dx_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - StencilType render_state_value; - - DXGraphicsStateGuardian8 *gsg; - LPDIRECT3DDEVICE8 device; - - gsg = (DXGraphicsStateGuardian8 *) stencil_render_states -> _gsg; - device = gsg->get_d3d_device(); - - render_state_value = stencil_render_states -> get_stencil_render_state (stencil_render_state); - - if (dxgsg8_cat.is_debug()) { - dxgsg8_cat.debug() - << "SRS: " << StencilAttrib::stencil_render_state_name_array [stencil_render_state] << ", " << render_state_value << "\n"; - } - - switch (stencil_render_state) - { - case StencilRenderStates::SRS_front_enable: - device->SetRenderState (D3DRS_STENCILENABLE, render_state_value); - break; - - case StencilRenderStates::SRS_back_enable: - // not supported in DX8 - break; - - case StencilRenderStates::SRS_front_comparison_function: - device->SetRenderState (D3DRS_STENCILFUNC, dx_stencil_comparison_function_array [render_state_value]); - break; - case StencilRenderStates::SRS_front_stencil_fail_operation: - device->SetRenderState (D3DRS_STENCILFAIL, dx_stencil_operation_array [render_state_value]); - break; - case StencilRenderStates::SRS_front_stencil_pass_z_fail_operation: - device->SetRenderState (D3DRS_STENCILZFAIL, dx_stencil_operation_array [render_state_value]); - break; - case StencilRenderStates::SRS_front_stencil_pass_z_pass_operation: - device->SetRenderState (D3DRS_STENCILPASS, dx_stencil_operation_array [render_state_value]); - break; - - case StencilRenderStates::SRS_reference: - device->SetRenderState (D3DRS_STENCILREF, render_state_value); - break; - - case StencilRenderStates::SRS_read_mask: - device->SetRenderState (D3DRS_STENCILMASK, render_state_value); - break; - case StencilRenderStates::SRS_write_mask: - device->SetRenderState (D3DRS_STENCILWRITEMASK, render_state_value); - break; - - case StencilRenderStates::SRS_back_comparison_function: - // not supported in DX8 - break; - case StencilRenderStates::SRS_back_stencil_fail_operation: - // not supported in DX8 - break; - case StencilRenderStates::SRS_back_stencil_pass_z_fail_operation: - // not supported in DX8 - break; - case StencilRenderStates::SRS_back_stencil_pass_z_pass_operation: - // not supported in DX8 - break; - - default: - break; - } -} - -void dx_set_stencil_functions (StencilRenderStates *stencil_render_states) { - if (stencil_render_states) { - StencilRenderStates::StencilRenderState stencil_render_state; - - for (stencil_render_state = StencilRenderStates::SRS_first; stencil_render_state < StencilRenderStates::SRS_total; stencil_render_state = (StencilRenderStates::StencilRenderState) ((int) stencil_render_state + 1)) { - stencil_render_states -> set_stencil_function (stencil_render_state, dx_stencil_function); - } - } -} - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian8::do_issue_stencil // Access: Protected @@ -4421,48 +4337,56 @@ void dx_set_stencil_functions (StencilRenderStates *stencil_render_states) { //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian8:: do_issue_stencil() { - if (!_supports_stencil) { return; } - StencilRenderStates *stencil_render_states; - const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib_def(StencilAttrib::get_class_slot())); - stencil_render_states = this -> _stencil_render_states; - if (stencil && stencil_render_states) { + const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib(StencilAttrib::get_class_slot())); - if (dxgsg8_cat.is_debug()) { + if (stencil != (const StencilAttrib *)NULL) { + // DEBUG + if (false) { dxgsg8_cat.debug() << "STENCIL STATE CHANGE\n"; dxgsg8_cat.debug() << "\n" - << "SRS_front_enable " << stencil -> get_render_state (StencilAttrib::SRS_front_enable) << "\n" - << "SRS_front_comparison_function " << stencil -> get_render_state (StencilAttrib::SRS_front_comparison_function) << "\n" - << "SRS_front_stencil_fail_operation " << stencil -> get_render_state (StencilAttrib::SRS_front_stencil_fail_operation) << "\n" - << "SRS_front_stencil_pass_z_fail_operation " << stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_fail_operation) << "\n" - << "SRS_front_stencil_pass_z_pass_operation " << stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_pass_operation) << "\n" - << "SRS_reference " << stencil -> get_render_state (StencilAttrib::SRS_reference) << "\n" - << "SRS_read_mask " << stencil -> get_render_state (StencilAttrib::SRS_read_mask) << "\n" - << "SRS_write_mask " << stencil -> get_render_state (StencilAttrib::SRS_write_mask) << "\n"; + << "SRS_front_comparison_function " << stencil->get_render_state(StencilAttrib::SRS_front_comparison_function) << "\n" + << "SRS_front_stencil_fail_operation " << stencil->get_render_state(StencilAttrib::SRS_front_stencil_fail_operation) << "\n" + << "SRS_front_stencil_pass_z_fail_operation " << stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_fail_operation) << "\n" + << "SRS_front_stencil_pass_z_pass_operation " << stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_pass_operation) << "\n" + << "SRS_reference " << stencil->get_render_state(StencilAttrib::SRS_reference) << "\n" + << "SRS_read_mask " << stencil->get_render_state(StencilAttrib::SRS_read_mask) << "\n" + << "SRS_write_mask " << stencil->get_render_state(StencilAttrib::SRS_write_mask) << "\n"; } - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_enable, stencil -> get_render_state (StencilAttrib::SRS_front_enable)); - if (stencil -> get_render_state (StencilAttrib::SRS_front_enable)) { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_comparison_function, stencil -> get_render_state (StencilAttrib::SRS_front_comparison_function)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_pass_z_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_pass_z_pass_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_pass_operation)); + unsigned int front_compare; + front_compare = stencil->get_render_state(StencilAttrib::SRS_front_comparison_function); + if (front_compare != RenderAttrib::M_none) { + set_render_state(D3DRS_STENCILENABLE, TRUE); + set_render_state(D3DRS_STENCILFUNC, dx_stencil_comparison_function_array[front_compare]); + set_render_state(D3DRS_STENCILFAIL, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_front_stencil_fail_operation)]); + set_render_state(D3DRS_STENCILZFAIL, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_fail_operation)]); + set_render_state(D3DRS_STENCILPASS, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_pass_operation)]); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_reference, stencil -> get_render_state (StencilAttrib::SRS_reference)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_read_mask, stencil -> get_render_state (StencilAttrib::SRS_read_mask)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_write_mask, stencil -> get_render_state (StencilAttrib::SRS_write_mask)); - } - } - else { - - if (dxgsg8_cat.is_debug()) { - dxgsg8_cat.debug() << "STENCIL STATE CHANGE TO OFF \n"; + set_render_state(D3DRS_STENCILREF, stencil->get_render_state(StencilAttrib::SRS_reference)); + set_render_state(D3DRS_STENCILMASK, stencil->get_render_state(StencilAttrib::SRS_read_mask)); + set_render_state(D3DRS_STENCILWRITEMASK, stencil->get_render_state(StencilAttrib::SRS_write_mask)); + } else { + set_render_state(D3DRS_STENCILENABLE, FALSE); } - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_enable, 0); + if (stencil->get_render_state(StencilAttrib::SRS_clear)) { + _d3d_device->Clear(0, NULL, D3DCLEAR_STENCIL, 0, 0.0f, stencil->get_render_state(StencilAttrib::SRS_clear_value)); + } + + } else { + // DEBUG + if (false) { + dxgsg8_cat.debug() << "STENCIL STATE CHANGE TO OFF\n"; + } + + set_render_state(D3DRS_STENCILENABLE, FALSE); } } @@ -4474,7 +4398,7 @@ get_d3d_device() { //////////////////////////////////////////////////////////////////// // Function: dxGraphicsStateGuardian8::do_issue_scissor // Access: Protected -// Description: +// Description: //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian8:: do_issue_scissor() { @@ -4511,7 +4435,7 @@ set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat dxgsg8_cat.error() << "SetViewport(" << vp.X << ", " << vp.Y << ", " << vp.Width << ", " << vp.Height << ") failed" << D3DERRORSTRING(hr); - + D3DVIEWPORT8 vp_old; _d3d_device->GetViewport(&vp_old); dxgsg8_cat.error() @@ -4552,32 +4476,34 @@ FrameBufferProperties DXGraphicsStateGuardian8:: calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype) { FrameBufferProperties props; int index=0; - int alpha=0; - int color=0; + int r=0, g=0, b=0, a=0; switch (cformat) { - case D3DFMT_R8G8B8: index=0; color=24; alpha=0; break; - case D3DFMT_A8R8G8B8: index=0; color=24; alpha=8; break; - case D3DFMT_X8R8G8B8: index=0; color=24; alpha=0; break; - case D3DFMT_R5G6B5: index=0; color=16; alpha=0; break; - case D3DFMT_X1R5G5B5: index=0; color=15; alpha=0; break; - case D3DFMT_A1R5G5B5: index=0; color=15; alpha=1; break; - case D3DFMT_A4R4G4B4: index=0; color=12; alpha=4; break; - case D3DFMT_R3G3B2: index=0; color= 8; alpha=0; break; - case D3DFMT_A8R3G3B2: index=0; color= 8; alpha=8; break; - case D3DFMT_X4R4G4B4: index=0; color=12; alpha=0; break; - case D3DFMT_A2B10G10R10: index=0; color=30; alpha=2; break; - case D3DFMT_A8P8: index=1; color= 8; alpha=8; break; - case D3DFMT_P8: index=1; color= 8; alpha=0; break; + case D3DFMT_R8G8B8: r=8; g=8; b=8; a=0; break; + case D3DFMT_A8R8G8B8: r=8; g=8; b=8; a=8; break; + case D3DFMT_X8R8G8B8: r=8; g=8; b=8; a=0; break; + case D3DFMT_R5G6B5: r=5; g=6; b=5; a=0; break; + case D3DFMT_X1R5G5B5: r=5; g=5; b=5; a=0; break; + case D3DFMT_A1R5G5B5: r=5; g=5; b=5; a=1; break; + case D3DFMT_A4R4G4B4: r=4; g=4; b=4; a=4; break; + case D3DFMT_R3G3B2: r=3; g=3; b=2; a=0; break; + case D3DFMT_A8R3G3B2: r=3; g=3; b=2; a=8; break; + case D3DFMT_X4R4G4B4: r=4; g=4; b=4; a=0; break; + case D3DFMT_A2B10G10R10: r=10;g=10;b=10;a=2; break; + case D3DFMT_A8P8: index=8; a=8; break; + case D3DFMT_P8: index=8; a=0; break; + default: break; } - props.set_color_bits(color); - props.set_alpha_bits(alpha); - if (index) { + if (index > 0) { props.set_rgb_color(0); props.set_indexed_color(1); - } else if (color) { + props.set_color_bits(index); + } else if (r + g + b > 0) { props.set_rgb_color(1); props.set_indexed_color(0); + props.set_rgba_bits(r, g, b, a); } + props.set_alpha_bits(a); + int depth=0; int stencil=0; switch (dformat) { @@ -4587,6 +4513,7 @@ calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype) { case D3DFMT_D16: depth=16; stencil=0; break; case D3DFMT_D24X8: depth=24; stencil=0; break; case D3DFMT_D24X4S4: depth=24; stencil=4; break; + default: break; } props.set_depth_bits(depth); props.set_stencil_bits(stencil); @@ -4607,8 +4534,8 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, // avoid divide by zero and negative exponents gamma = 1.0; } - gamma_correction = 1.0 / (double) gamma; - + gamma_correction = 1.0 / (double) gamma; + for (i = 0; i < 256; i++) { double r; double g; @@ -4619,11 +4546,11 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, g = (double) original_green_table [i] / GAMMA_1; b = (double) original_blue_table [i] / GAMMA_1; } - else { + else { r = ((double) i / 255.0); g = r; b = r; - } + } r = pow (r, gamma_correction); g = pow (g, gamma_correction); @@ -4639,14 +4566,14 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, b = 1.0; } - r = r * GAMMA_1; - g = g * GAMMA_1; - b = b * GAMMA_1; + r = r * GAMMA_1; + g = g * GAMMA_1; + b = b * GAMMA_1; red_table [i] = r; green_table [i] = g; blue_table [i] = b; - } + } } //////////////////////////////////////////////////////////////////// @@ -4656,13 +4583,13 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, //////////////////////////////////////////////////////////////////// bool DXGraphicsStateGuardian8:: get_gamma_table(void) { - bool get; + bool get; get = false; if (_gamma_table_initialized == false) { HDC hdc = GetDC(NULL); - if (hdc) { + if (hdc) { if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { _gamma_table_initialized = true; get = true; @@ -4671,26 +4598,26 @@ get_gamma_table(void) { ReleaseDC (NULL, hdc); } } - + return get; } //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian8::static_set_gamma // Access: Public, Static -// Description: Static function for setting gamma which is needed +// Description: Static function for setting gamma which is needed // for atexit. //////////////////////////////////////////////////////////////////// bool DXGraphicsStateGuardian8:: static_set_gamma(bool restore, PN_stdfloat gamma) { - bool set; + bool set; HDC hdc = GetDC(NULL); set = false; - if (hdc) { + if (hdc) { unsigned short ramp [256 * 3]; - if (restore && _gamma_table_initialized) { + if (restore && _gamma_table_initialized) { _create_gamma_table (gamma, &_orignial_gamma_table [0], &_orignial_gamma_table [256], &_orignial_gamma_table [512], &ramp [0], &ramp [256], &ramp [512]); } else { @@ -4700,7 +4627,7 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { if (SetDeviceGammaRamp (hdc, ramp)) { set = true; } - + ReleaseDC (NULL, hdc); } @@ -4719,7 +4646,7 @@ set_gamma(PN_stdfloat gamma) { set = static_set_gamma(false, gamma); if (set) { - _gamma = gamma; + _gamma = gamma; } return set; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index de152695ce..dd421bbc2f 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -2769,9 +2769,6 @@ reset() { PRINT_REFCNT(dxgsg9, _d3d_device); - void dx_set_stencil_functions (StencilRenderStates *stencil_render_states); - dx_set_stencil_functions (_stencil_render_states); - // Now that the GSG has been initialized, make it available for // optimizations. add_gsg(this); @@ -5261,9 +5258,7 @@ check_dx_allocation (HRESULT result, int allocation_size, int attempts) //////////////////////////////////////////////////////////////////// // DX stencil code section //////////////////////////////////////////////////////////////////// - -static int dx_stencil_comparison_function_array [ ] = -{ +static int dx_stencil_comparison_function_array[] = { D3DCMP_NEVER, D3DCMP_LESS, D3DCMP_EQUAL, @@ -5274,8 +5269,7 @@ static int dx_stencil_comparison_function_array [ ] = D3DCMP_ALWAYS, }; -static int dx_stencil_operation_array [ ] = -{ +static int dx_stencil_operation_array[] = { D3DSTENCILOP_KEEP, D3DSTENCILOP_ZERO, D3DSTENCILOP_REPLACE, @@ -5287,93 +5281,6 @@ static int dx_stencil_operation_array [ ] = D3DSTENCILOP_DECRSAT, }; -void dx_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - StencilType render_state_value; - - DXGraphicsStateGuardian9 *gsg; - - gsg = (DXGraphicsStateGuardian9 *) stencil_render_states -> _gsg; - - render_state_value = stencil_render_states -> get_stencil_render_state (stencil_render_state); - - // DEBUG - if (false) { - dxgsg9_cat.debug() - << "SRS: " << StencilAttrib::stencil_render_state_name_array [stencil_render_state] << ", " << render_state_value << "\n"; - } - - switch (stencil_render_state) - { - case StencilRenderStates::SRS_front_enable: - gsg -> set_render_state (D3DRS_STENCILENABLE, render_state_value); - break; - - case StencilRenderStates::SRS_back_enable: - if (gsg -> get_supports_two_sided_stencil()) { - gsg -> set_render_state (D3DRS_TWOSIDEDSTENCILMODE, render_state_value); - } - break; - - case StencilRenderStates::SRS_front_comparison_function: - gsg -> set_render_state (D3DRS_STENCILFUNC, dx_stencil_comparison_function_array [render_state_value]); - break; - case StencilRenderStates::SRS_front_stencil_fail_operation: - gsg -> set_render_state (D3DRS_STENCILFAIL, dx_stencil_operation_array [render_state_value]); - break; - case StencilRenderStates::SRS_front_stencil_pass_z_fail_operation: - gsg -> set_render_state (D3DRS_STENCILZFAIL, dx_stencil_operation_array [render_state_value]); - break; - case StencilRenderStates::SRS_front_stencil_pass_z_pass_operation: - gsg -> set_render_state (D3DRS_STENCILPASS, dx_stencil_operation_array [render_state_value]); - break; - - case StencilRenderStates::SRS_reference: - gsg -> set_render_state (D3DRS_STENCILREF, render_state_value); - break; - - case StencilRenderStates::SRS_read_mask: - gsg -> set_render_state (D3DRS_STENCILMASK, render_state_value); - break; - case StencilRenderStates::SRS_write_mask: - gsg -> set_render_state (D3DRS_STENCILWRITEMASK, render_state_value); - break; - - case StencilRenderStates::SRS_back_comparison_function: - if (gsg -> get_supports_two_sided_stencil()) { - gsg -> set_render_state (D3DRS_CCW_STENCILFUNC, dx_stencil_comparison_function_array [render_state_value]); - } - break; - case StencilRenderStates::SRS_back_stencil_fail_operation: - if (gsg -> get_supports_two_sided_stencil()) { - gsg -> set_render_state (D3DRS_CCW_STENCILFAIL, dx_stencil_operation_array [render_state_value]); - } - break; - case StencilRenderStates::SRS_back_stencil_pass_z_fail_operation: - if (gsg -> get_supports_two_sided_stencil()) { - gsg -> set_render_state (D3DRS_CCW_STENCILZFAIL, dx_stencil_operation_array [render_state_value]); - } - break; - case StencilRenderStates::SRS_back_stencil_pass_z_pass_operation: - if (gsg -> get_supports_two_sided_stencil()) { - gsg -> set_render_state (D3DRS_CCW_STENCILPASS, dx_stencil_operation_array [render_state_value]); - } - break; - - default: - break; - } -} - -void dx_set_stencil_functions (StencilRenderStates *stencil_render_states) { - if (stencil_render_states) { - StencilRenderStates::StencilRenderState stencil_render_state; - - for (stencil_render_state = StencilRenderStates::SRS_first; stencil_render_state < StencilRenderStates::SRS_total; stencil_render_state = (StencilRenderStates::StencilRenderState) ((int) stencil_render_state + 1)) { - stencil_render_states -> set_stencil_function (stencil_render_state, dx_stencil_function); - } - } -} - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian9::do_issue_stencil // Access: Protected @@ -5385,70 +5292,84 @@ do_issue_stencil() { return; } - StencilRenderStates *stencil_render_states; - const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib_def(StencilAttrib::get_class_slot())); - stencil_render_states = this -> _stencil_render_states; - if (stencil && stencil_render_states) { + const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib(StencilAttrib::get_class_slot())); + if (stencil != (const StencilAttrib *)NULL) { // DEBUG if (false) { dxgsg9_cat.debug() << "STENCIL STATE CHANGE\n"; dxgsg9_cat.debug() << "\n" - << "SRS_front_enable " << stencil -> get_render_state (StencilAttrib::SRS_front_enable) << "\n" - << "SRS_back_enable " << stencil -> get_render_state (StencilAttrib::SRS_back_enable) << "\n" - << "SRS_front_comparison_function " << stencil -> get_render_state (StencilAttrib::SRS_front_comparison_function) << "\n" - << "SRS_front_stencil_fail_operation " << stencil -> get_render_state (StencilAttrib::SRS_front_stencil_fail_operation) << "\n" - << "SRS_front_stencil_pass_z_fail_operation " << stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_fail_operation) << "\n" - << "SRS_front_stencil_pass_z_pass_operation " << stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_pass_operation) << "\n" - << "SRS_reference " << stencil -> get_render_state (StencilAttrib::SRS_reference) << "\n" - << "SRS_read_mask " << stencil -> get_render_state (StencilAttrib::SRS_read_mask) << "\n" - << "SRS_write_mask " << stencil -> get_render_state (StencilAttrib::SRS_write_mask) << "\n" - << "SRS_back_comparison_function " << stencil -> get_render_state (StencilAttrib::SRS_back_comparison_function) << "\n" - << "SRS_back_stencil_fail_operation " << stencil -> get_render_state (StencilAttrib::SRS_back_stencil_fail_operation) << "\n" - << "SRS_back_stencil_pass_z_fail_operation " << stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_fail_operation) << "\n" - << "SRS_back_stencil_pass_z_pass_operation " << stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_pass_operation) << "\n"; + << "SRS_front_comparison_function " << stencil->get_render_state(StencilAttrib::SRS_front_comparison_function) << "\n" + << "SRS_front_stencil_fail_operation " << stencil->get_render_state(StencilAttrib::SRS_front_stencil_fail_operation) << "\n" + << "SRS_front_stencil_pass_z_fail_operation " << stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_fail_operation) << "\n" + << "SRS_front_stencil_pass_z_pass_operation " << stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_pass_operation) << "\n" + << "SRS_reference " << stencil->get_render_state(StencilAttrib::SRS_reference) << "\n" + << "SRS_read_mask " << stencil->get_render_state(StencilAttrib::SRS_read_mask) << "\n" + << "SRS_write_mask " << stencil->get_render_state(StencilAttrib::SRS_write_mask) << "\n" + << "SRS_back_comparison_function " << stencil->get_render_state(StencilAttrib::SRS_back_comparison_function) << "\n" + << "SRS_back_stencil_fail_operation " << stencil->get_render_state(StencilAttrib::SRS_back_stencil_fail_operation) << "\n" + << "SRS_back_stencil_pass_z_fail_operation " << stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_fail_operation) << "\n" + << "SRS_back_stencil_pass_z_pass_operation " << stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_pass_operation) << "\n"; } - bool on; + bool on = false; - on = false; - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_enable, stencil -> get_render_state (StencilAttrib::SRS_front_enable)); - if (stencil -> get_render_state (StencilAttrib::SRS_front_enable)) { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_comparison_function, stencil -> get_render_state (StencilAttrib::SRS_front_comparison_function)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_pass_z_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_pass_z_pass_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_pass_operation)); + unsigned int front_compare; + front_compare = stencil->get_render_state(StencilAttrib::SRS_front_comparison_function); + + if (front_compare != RenderAttrib::M_none) { + set_render_state(D3DRS_STENCILENABLE, TRUE); + set_render_state(D3DRS_STENCILFUNC, dx_stencil_comparison_function_array[front_compare]); + set_render_state(D3DRS_STENCILFAIL, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_front_stencil_fail_operation)]); + set_render_state(D3DRS_STENCILZFAIL, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_fail_operation)]); + set_render_state(D3DRS_STENCILPASS, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_pass_operation)]); on = true; + } else { + set_render_state(D3DRS_STENCILENABLE, FALSE); } - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_enable, stencil -> get_render_state (StencilAttrib::SRS_back_enable)); - if (stencil -> get_render_state (StencilAttrib::SRS_back_enable)) { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_comparison_function, stencil -> get_render_state (StencilAttrib::SRS_back_comparison_function)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_stencil_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_back_stencil_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_stencil_pass_z_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_stencil_pass_z_pass_operation, stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_pass_operation)); - on = true; + if (_supports_two_sided_stencil) { + unsigned int back_compare; + back_compare = stencil->get_render_state(StencilAttrib::SRS_back_comparison_function); + + if (back_compare != RenderAttrib::M_none) { + set_render_state(D3DRS_TWOSIDEDSTENCILMODE, TRUE); + set_render_state(D3DRS_CCW_STENCILFUNC, dx_stencil_comparison_function_array[back_compare]); + set_render_state(D3DRS_CCW_STENCILFAIL, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_back_stencil_fail_operation)]); + set_render_state(D3DRS_CCW_STENCILZFAIL, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_fail_operation)]); + set_render_state(D3DRS_CCW_STENCILPASS, dx_stencil_operation_array[ + stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_pass_operation)]); + on = true; + } else { + set_render_state(D3DRS_TWOSIDEDSTENCILMODE, FALSE); + } } if (on) { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_reference, stencil -> get_render_state (StencilAttrib::SRS_reference)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_read_mask, stencil -> get_render_state (StencilAttrib::SRS_read_mask)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_write_mask, stencil -> get_render_state (StencilAttrib::SRS_write_mask)); + set_render_state(D3DRS_STENCILREF, stencil->get_render_state(StencilAttrib::SRS_reference)); + set_render_state(D3DRS_STENCILMASK, stencil->get_render_state(StencilAttrib::SRS_read_mask)); + set_render_state(D3DRS_STENCILWRITEMASK, stencil->get_render_state(StencilAttrib::SRS_write_mask)); } - if (stencil -> get_render_state (StencilAttrib::SRS_clear)) { - _d3d_device->Clear(0, NULL, D3DCLEAR_STENCIL, 0, 0.0f, stencil -> get_render_state (StencilAttrib::SRS_clear_value)); + if (stencil->get_render_state(StencilAttrib::SRS_clear)) { + _d3d_device->Clear(0, NULL, D3DCLEAR_STENCIL, 0, 0.0f, stencil->get_render_state(StencilAttrib::SRS_clear_value)); } - } - else { + } else { // DEBUG if (false) { - dxgsg9_cat.debug() << "STENCIL STATE CHANGE TO OFF \n"; + dxgsg9_cat.debug() << "STENCIL STATE CHANGE TO OFF\n"; } - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_enable, 0); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_enable, 0); + set_render_state(D3DRS_STENCILENABLE, FALSE); + if (_supports_two_sided_stencil) { + set_render_state(D3DRS_TWOSIDEDSTENCILMODE, FALSE); + } } } @@ -5482,32 +5403,34 @@ calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype, DWORD multisamplequality) { FrameBufferProperties props; int index=0; - int alpha=0; - int color=0; + int r=0, g=0, b=0, a=0; switch (cformat) { - case D3DFMT_R8G8B8: index=0; color=24; alpha=0; break; - case D3DFMT_A8R8G8B8: index=0; color=24; alpha=8; break; - case D3DFMT_X8R8G8B8: index=0; color=24; alpha=0; break; - case D3DFMT_R5G6B5: index=0; color=16; alpha=0; break; - case D3DFMT_X1R5G5B5: index=0; color=15; alpha=0; break; - case D3DFMT_A1R5G5B5: index=0; color=15; alpha=1; break; - case D3DFMT_A4R4G4B4: index=0; color=12; alpha=4; break; - case D3DFMT_R3G3B2: index=0; color= 8; alpha=0; break; - case D3DFMT_A8R3G3B2: index=0; color= 8; alpha=8; break; - case D3DFMT_X4R4G4B4: index=0; color=12; alpha=0; break; - case D3DFMT_A2B10G10R10: index=0; color=30; alpha=2; break; - case D3DFMT_A8P8: index=1; color= 8; alpha=8; break; - case D3DFMT_P8: index=1; color= 8; alpha=0; break; + case D3DFMT_R8G8B8: r=8; g=8; b=8; a=0; break; + case D3DFMT_A8R8G8B8: r=8; g=8; b=8; a=8; break; + case D3DFMT_X8R8G8B8: r=8; g=8; b=8; a=0; break; + case D3DFMT_R5G6B5: r=5; g=6; b=5; a=0; break; + case D3DFMT_X1R5G5B5: r=5; g=5; b=5; a=0; break; + case D3DFMT_A1R5G5B5: r=5; g=5; b=5; a=1; break; + case D3DFMT_A4R4G4B4: r=4; g=4; b=4; a=4; break; + case D3DFMT_R3G3B2: r=3; g=3; b=2; a=0; break; + case D3DFMT_A8R3G3B2: r=3; g=3; b=2; a=8; break; + case D3DFMT_X4R4G4B4: r=4; g=4; b=4; a=0; break; + case D3DFMT_A2B10G10R10: r=10;g=10;b=10;a=2; break; + case D3DFMT_A8P8: index=8; a=8; break; + case D3DFMT_P8: index=8; a=0; break; + default: break; } - props.set_color_bits(color); - props.set_alpha_bits(alpha); - if (index) { + if (index > 0) { props.set_rgb_color(0); props.set_indexed_color(1); - } else if (color) { + props.set_color_bits(index); + } else if (r + g + b > 0) { props.set_rgb_color(1); props.set_indexed_color(0); + props.set_rgba_bits(r, g, b, a); } + props.set_alpha_bits(a); + int depth=0; int stencil=0; switch (dformat) { @@ -5517,6 +5440,7 @@ calc_fb_properties(DWORD cformat, DWORD dformat, case D3DFMT_D16: depth=16; stencil=0; break; case D3DFMT_D24X8: depth=24; stencil=0; break; case D3DFMT_D24X4S4: depth=24; stencil=4; break; + default: break; } props.set_depth_bits(depth); props.set_stencil_bits(stencil); diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx index 1209a8a482..7d434a63b5 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx @@ -123,10 +123,9 @@ get_properties(FrameBufferProperties &properties, properties.set_back_buffers(1); properties.set_rgb_color(1); - properties.set_color_bits(red_size+green_size+blue_size); + properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size); properties.set_stencil_bits(stencil_size); properties.set_depth_bits(depth_size); - properties.set_alpha_bits(alpha_size); properties.set_multisamples(samples); // Set both hardware and software bits, indicating not-yet-known. diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index ae5e228e9a..038bb6b8ef 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -626,18 +626,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, // Adjust the texture format based on the requested framebuffer settings. switch (slot) { case RTP_depth: - if (_fb_properties.get_float_depth()) { - tex->set_format(Texture::F_depth_component32); - tex->set_component_type(Texture::T_float); - } else if (_fb_properties.get_depth_bits() > 24) { - tex->set_format(Texture::F_depth_component32); - } else if (_fb_properties.get_depth_bits() > 16) { - tex->set_format(Texture::F_depth_component24); - } else if (_fb_properties.get_depth_bits() > 8) { - tex->set_format(Texture::F_depth_component16); - } else { - tex->set_format(Texture::F_depth_component); - } + _fb_properties.setup_depth_texture(tex); break; case RTP_depth_stencil: tex->set_format(Texture::F_depth_stencil); @@ -663,25 +652,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, tex->set_component_type(Texture::T_float); break; default: - if (_fb_properties.get_srgb_color()) { - if (_fb_properties.get_alpha_bits() == 0) { - tex->set_format(Texture::F_srgb); - } else { - tex->set_format(Texture::F_srgb_alpha); - } - } else { - if (_fb_properties.get_float_color()) { - tex->set_component_type(Texture::T_float); - } - if (_fb_properties.get_color_bits() > 16 * 3) { - tex->set_format(Texture::F_rgba32); - tex->set_component_type(Texture::T_float); - } else if (_fb_properties.get_color_bits() > 8 * 3) { - tex->set_format(Texture::F_rgba16); - } else { - tex->set_format(Texture::F_rgba); - } - } + _fb_properties.setup_color_texture(tex); } #ifndef OPENGLES diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 6adcb3b4c0..cdd186cef4 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -337,11 +337,6 @@ CLP(GraphicsStateGuardian):: } close_gsg(); - - if (_stencil_render_states) { - delete _stencil_render_states; - _stencil_render_states = 0; - } } //////////////////////////////////////////////////////////////////// @@ -2103,9 +2098,6 @@ reset() { report_my_gl_errors(); - void gl_set_stencil_functions (StencilRenderStates *stencil_render_states); - gl_set_stencil_functions(_stencil_render_states); - #if defined(HAVE_CG) && !defined(OPENGLES) typedef struct { @@ -11511,18 +11503,7 @@ bind_fbo(GLuint fbo) { // GL stencil code section //////////////////////////////////////////////////////////////////// -static int gl_stencil_comparison_function_array [ ] = { - GL_NEVER, - GL_LESS, - GL_EQUAL, - GL_LEQUAL, - GL_GREATER, - GL_NOTEQUAL, - GL_GEQUAL, - GL_ALWAYS, -}; - -static int gl_stencil_operations_array [ ] = { +static int gl_stencil_operations_array[] = { GL_KEEP, GL_ZERO, GL_REPLACE, @@ -11539,144 +11520,6 @@ static int gl_stencil_operations_array [ ] = { GL_DECR, }; -void __glActiveStencilFace (GraphicsStateGuardian *gsg, GLenum face) { - CLP(GraphicsStateGuardian) *glgsg; - - glgsg = (CLP(GraphicsStateGuardian) *) gsg; - if (gsg -> get_supports_two_sided_stencil ( ) && - glgsg -> _glActiveStencilFaceEXT) { - if (face == GL_FRONT) { - // glActiveStencilFaceEXT (GL_FRONT); - glgsg -> _glActiveStencilFaceEXT (GL_FRONT); - } - else { - // glActiveStencilFaceEXT (GL_BACK); - glgsg -> _glActiveStencilFaceEXT (GL_BACK); - } - } -} - -void gl_front_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - - __glActiveStencilFace (stencil_render_states -> _gsg, GL_FRONT); - glStencilFunc - ( - gl_stencil_comparison_function_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_front_comparison_function)], - stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_reference), - stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_read_mask) - ); -} -void gl_front_stencil_operation (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - __glActiveStencilFace (stencil_render_states -> _gsg, GL_FRONT); - glStencilOp - ( - gl_stencil_operations_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_front_stencil_fail_operation)], - gl_stencil_operations_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_front_stencil_pass_z_fail_operation)], - gl_stencil_operations_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_front_stencil_pass_z_pass_operation)] - ); -} - -void gl_back_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - - bool supports_two_sided_stencil; - - supports_two_sided_stencil = stencil_render_states -> _gsg -> get_supports_two_sided_stencil ( ); - if (supports_two_sided_stencil) { - __glActiveStencilFace (stencil_render_states -> _gsg, GL_BACK); - glStencilFunc - ( - gl_stencil_comparison_function_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_back_comparison_function)], - stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_reference), - stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_read_mask) - ); - } -} - -void gl_back_stencil_operation (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - - bool supports_two_sided_stencil; - - supports_two_sided_stencil = stencil_render_states -> _gsg -> get_supports_two_sided_stencil ( ); - if (supports_two_sided_stencil) { - __glActiveStencilFace (stencil_render_states -> _gsg, GL_BACK); - glStencilOp - ( - gl_stencil_operations_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_back_stencil_fail_operation)], - gl_stencil_operations_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_back_stencil_pass_z_fail_operation)], - gl_stencil_operations_array [stencil_render_states -> get_stencil_render_state (StencilRenderStates::SRS_back_stencil_pass_z_pass_operation)] - ); - } -} - -void gl_front_back_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - gl_front_stencil_function (stencil_render_state, stencil_render_states); - gl_back_stencil_function (stencil_render_state, stencil_render_states); -} - -void gl_stencil_function (StencilRenderStates::StencilRenderState stencil_render_state, StencilRenderStates *stencil_render_states) { - - StencilType render_state_value; - bool supports_two_sided_stencil; - - supports_two_sided_stencil = stencil_render_states -> _gsg -> get_supports_two_sided_stencil ( ); - - render_state_value = stencil_render_states -> get_stencil_render_state (stencil_render_state); - switch (stencil_render_state) { - case StencilRenderStates::SRS_front_enable: - if (render_state_value) { - glEnable (GL_STENCIL_TEST); - } - else { - glDisable (GL_STENCIL_TEST); - } - break; -#ifndef OPENGLES - case StencilRenderStates::SRS_back_enable: - if (supports_two_sided_stencil) { - if (render_state_value) { - glEnable (GL_STENCIL_TEST_TWO_SIDE_EXT); - } - else { - glDisable (GL_STENCIL_TEST_TWO_SIDE_EXT); - } - } - break; -#endif - - case StencilRenderStates::SRS_write_mask: - glStencilMask (render_state_value); - break; - - default: - break; - } -} - -void gl_set_stencil_functions (StencilRenderStates *stencil_render_states) { - - if (stencil_render_states) { - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_front_enable, gl_stencil_function); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_back_enable, gl_stencil_function); - - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_front_comparison_function, gl_front_stencil_function); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_front_stencil_fail_operation, gl_front_stencil_operation); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_front_stencil_pass_z_fail_operation, gl_front_stencil_operation); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_front_stencil_pass_z_pass_operation, gl_front_stencil_operation); - - // GL seems to support different read masks and/or reference values for front and back, but DX does not. - // This needs to be cross-platform so do it the DX way by setting the same read mask and reference for both front and back. - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_reference, gl_front_back_stencil_function); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_read_mask, gl_front_back_stencil_function); - - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_write_mask, gl_stencil_function); - - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_back_comparison_function, gl_back_stencil_function); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_back_stencil_fail_operation, gl_back_stencil_operation); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_back_stencil_pass_z_fail_operation, gl_back_stencil_operation); - stencil_render_states -> set_stencil_function (StencilRenderStates::SRS_back_stencil_pass_z_pass_operation, gl_back_stencil_operation); - } -} - //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::do_issue_stencil // Access: Protected @@ -11688,72 +11531,84 @@ do_issue_stencil() { return; } - const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib_def(StencilAttrib::get_class_slot())); - - StencilRenderStates *stencil_render_states; - stencil_render_states = this -> _stencil_render_states; - if (stencil && stencil_render_states) { + const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib(StencilAttrib::get_class_slot())); + if (stencil != (const StencilAttrib *)NULL) { // DEBUG if (false) { GLCAT.debug() << "STENCIL STATE CHANGE\n"; GLCAT.debug() << "\n" - << "SRS_front_enable " << (int)stencil -> get_render_state (StencilAttrib::SRS_front_enable) << "\n" - << "SRS_back_enable " << (int)stencil -> get_render_state (StencilAttrib::SRS_back_enable) << "\n" - << "SRS_front_comparison_function " << (int)stencil -> get_render_state (StencilAttrib::SRS_front_comparison_function) << "\n" - << "SRS_front_stencil_fail_operation " << (int)stencil -> get_render_state (StencilAttrib::SRS_front_stencil_fail_operation) << "\n" - << "SRS_front_stencil_pass_z_fail_operation " << (int)stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_fail_operation) << "\n" - << "SRS_front_stencil_pass_z_pass_operation " << (int)stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_pass_operation) << "\n" - << "SRS_reference " << (int)stencil -> get_render_state (StencilAttrib::SRS_reference) << "\n" - << "SRS_read_mask " << (int)stencil -> get_render_state (StencilAttrib::SRS_read_mask) << "\n" - << "SRS_write_mask " << (int)stencil -> get_render_state (StencilAttrib::SRS_write_mask) << "\n" - << "SRS_back_comparison_function " << (int)stencil -> get_render_state (StencilAttrib::SRS_back_comparison_function) << "\n" - << "SRS_back_stencil_fail_operation " << (int)stencil -> get_render_state (StencilAttrib::SRS_back_stencil_fail_operation) << "\n" - << "SRS_back_stencil_pass_z_fail_operation " << (int)stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_fail_operation) << "\n" - << "SRS_back_stencil_pass_z_pass_operation " << (int)stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_pass_operation) << "\n"; + << "SRS_front_comparison_function " << (int)stencil->get_render_state(StencilAttrib::SRS_front_comparison_function) << "\n" + << "SRS_front_stencil_fail_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_front_stencil_fail_operation) << "\n" + << "SRS_front_stencil_pass_z_fail_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_fail_operation) << "\n" + << "SRS_front_stencil_pass_z_pass_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_pass_operation) << "\n" + << "SRS_reference " << (int)stencil->get_render_state(StencilAttrib::SRS_reference) << "\n" + << "SRS_read_mask " << (int)stencil->get_render_state(StencilAttrib::SRS_read_mask) << "\n" + << "SRS_write_mask " << (int)stencil->get_render_state(StencilAttrib::SRS_write_mask) << "\n" + << "SRS_back_comparison_function " << (int)stencil->get_render_state(StencilAttrib::SRS_back_comparison_function) << "\n" + << "SRS_back_stencil_fail_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_back_stencil_fail_operation) << "\n" + << "SRS_back_stencil_pass_z_fail_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_fail_operation) << "\n" + << "SRS_back_stencil_pass_z_pass_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_pass_operation) << "\n"; } - { - bool on; + if (_supports_two_sided_stencil) { + //TODO: add support for OpenGL 2.0-style glStencilFuncSeparate. + unsigned int back_compare; + back_compare = stencil->get_render_state(StencilAttrib::SRS_back_comparison_function); - on = false; - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_enable, stencil -> get_render_state (StencilAttrib::SRS_front_enable)); - if (stencil -> get_render_state (StencilAttrib::SRS_front_enable)) { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_comparison_function, stencil -> get_render_state (StencilAttrib::SRS_front_comparison_function)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_pass_z_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_stencil_pass_z_pass_operation, stencil -> get_render_state (StencilAttrib::SRS_front_stencil_pass_z_pass_operation)); - on = true; + if (back_compare != RenderAttrib::M_none) { + glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT); + _glActiveStencilFaceEXT(GL_BACK); + + glStencilFunc( + PANDA_TO_GL_COMPAREFUNC(back_compare), + stencil->get_render_state(StencilAttrib::SRS_reference), + stencil->get_render_state(StencilAttrib::SRS_read_mask)); + + glStencilOp( + gl_stencil_operations_array[stencil->get_render_state(StencilAttrib::SRS_back_stencil_fail_operation)], + gl_stencil_operations_array[stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_fail_operation)], + gl_stencil_operations_array[stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_pass_operation)] + ); + glStencilMask(stencil->get_render_state(StencilAttrib::SRS_write_mask)); + } else { + glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); } - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_enable, stencil -> get_render_state (StencilAttrib::SRS_back_enable)); - if (stencil -> get_render_state (StencilAttrib::SRS_back_enable)) { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_comparison_function, stencil -> get_render_state (StencilAttrib::SRS_back_comparison_function)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_stencil_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_back_stencil_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_stencil_pass_z_fail_operation, stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_fail_operation)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_stencil_pass_z_pass_operation, stencil -> get_render_state (StencilAttrib::SRS_back_stencil_pass_z_pass_operation)); - on = true; - } - - if (on) { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_reference, stencil -> get_render_state (StencilAttrib::SRS_reference)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_read_mask, stencil -> get_render_state (StencilAttrib::SRS_read_mask)); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_write_mask, stencil -> get_render_state (StencilAttrib::SRS_write_mask)); - } + _glActiveStencilFaceEXT(GL_FRONT); } - if (stencil -> get_render_state (StencilAttrib::SRS_clear)) { - GLbitfield mask = 0; + unsigned int front_compare; + front_compare = stencil->get_render_state(StencilAttrib::SRS_front_comparison_function); + if (front_compare != RenderAttrib::M_none) { + glEnable(GL_STENCIL_TEST); + + glStencilFunc( + PANDA_TO_GL_COMPAREFUNC(front_compare), + stencil->get_render_state(StencilAttrib::SRS_reference), + stencil->get_render_state(StencilAttrib::SRS_read_mask)); + + glStencilOp( + gl_stencil_operations_array[stencil->get_render_state(StencilAttrib::SRS_front_stencil_fail_operation)], + gl_stencil_operations_array[stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_fail_operation)], + gl_stencil_operations_array[stencil->get_render_state(StencilAttrib::SRS_front_stencil_pass_z_pass_operation)] + ); + glStencilMask(stencil->get_render_state(StencilAttrib::SRS_write_mask)); + } else { + glDisable(GL_STENCIL_TEST); + } + + if (stencil->get_render_state(StencilAttrib::SRS_clear)) { // clear stencil buffer - glClearStencil(stencil -> get_render_state (StencilAttrib::SRS_clear_value)); - mask |= GL_STENCIL_BUFFER_BIT; - glClear(mask); + glClearStencil(stencil->get_render_state(StencilAttrib::SRS_clear_value)); + glClear(GL_STENCIL_BUFFER_BIT); + } + } else { + glDisable(GL_STENCIL_TEST); + if (_supports_two_sided_stencil) { + glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); } - } - else { - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_front_enable, 0); - stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_enable, 0); } } diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 96471c1b9d..e9c44e9e8d 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -47,12 +47,12 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _supports_fbconfig = false; _supports_pbuffer = false; _uses_sgix_pbuffer = false; - + if (share_with != (glxGraphicsStateGuardian *)NULL) { _prepared_objects = share_with->get_prepared_objects(); _share_context = share_with->_context; } - + _checked_get_proc_address = false; _glXGetProcAddress = NULL; _temp_context = (GLXContext)NULL; @@ -126,10 +126,10 @@ get_properties(FrameBufferProperties &properties, XVisualInfo *visual) { } else { properties.set_indexed_color(1); } - properties.set_color_bits(red_size+green_size+blue_size); + + properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size); properties.set_stencil_bits(stencil_size); properties.set_depth_bits(depth_size); - properties.set_alpha_bits(alpha_size); properties.set_accum_bits(ared_size+agreen_size+ablue_size+aalpha_size); // Set both hardware and software bits, indicating not-yet-known. @@ -144,7 +144,7 @@ get_properties(FrameBufferProperties &properties, XVisualInfo *visual) { // indicated GLXFBConfig //////////////////////////////////////////////////////////////////// void glxGraphicsStateGuardian:: -get_properties_advanced(FrameBufferProperties &properties, +get_properties_advanced(FrameBufferProperties &properties, bool &context_has_pbuffer, bool &context_has_pixmap, bool &slow, GLXFBConfig config) { properties.clear(); @@ -212,10 +212,9 @@ get_properties_advanced(FrameBufferProperties &properties, properties.set_indexed_color(true); } - properties.set_color_bits(red_size+green_size+blue_size); + properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size); properties.set_stencil_bits(stencil_size); properties.set_depth_bits(depth_size); - properties.set_alpha_bits(alpha_size); properties.set_accum_bits(ared_size+agreen_size+ablue_size+aalpha_size); properties.set_multisamples(samples); @@ -488,7 +487,7 @@ query_gl_version() { // two of these together. if (glgsg_cat.is_debug()) { glgsg_cat.debug() - << "GLX_VERSION = " << _glx_version_major << "." << _glx_version_minor + << "GLX_VERSION = " << _glx_version_major << "." << _glx_version_minor << "\n"; } } @@ -583,7 +582,7 @@ query_glx_extensions() { _supports_swap_control = has_extension("GLX_SGI_swap_control"); if (_supports_swap_control) { - _glXSwapIntervalSGI = + _glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)get_extension_func("glXSwapIntervalSGI"); if (_glXSwapIntervalSGI == NULL) { glxdisplay_cat.error() @@ -689,7 +688,7 @@ query_glx_extensions() { } if (has_extension("GLX_ARB_create_context")) { - _glXCreateContextAttribs = + _glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC)get_extension_func("glXCreateContextAttribsARB"); } else { _glXCreateContextAttribs = NULL; diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 563f1b4714..475d9d8fb5 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -54,7 +54,7 @@ PfmVizzer(PfmFile &pfm) : _pfm(pfm) { // texture image. //////////////////////////////////////////////////////////////////// void PfmVizzer:: -project(const Lens *lens) { +project(const Lens *lens, const PfmFile *undist_lut) { nassertv(_pfm.is_valid()); static LMatrix4f to_uv(0.5f, 0.0f, 0.0f, 0.0f, @@ -77,7 +77,19 @@ project(const Lens *lens) { _pfm.set_point4(xi, yi, LVecBase4f(0, 0, 0, 0)); } } else { - p = to_uv.xform_point(LCAST(PN_float32, film)); + // Now the lens gives us coordinates in the range [-1, 1]. + // Rescale these to [0, 1]. + LPoint3f uvw = film * to_uv; + + if (undist_lut != NULL) { + // Apply the undistortion map, if given. + LPoint3f p2; + undist_lut->calc_bilinear_point(p2, uvw[0], 1.0 - uvw[1]); + uvw = p2; + uvw[1] = 1.0 - uvw[1]; + } + + p = uvw; } } } diff --git a/panda/src/grutil/pfmVizzer.h b/panda/src/grutil/pfmVizzer.h index df2f00eac2..e19c72091d 100644 --- a/panda/src/grutil/pfmVizzer.h +++ b/panda/src/grutil/pfmVizzer.h @@ -36,7 +36,7 @@ PUBLISHED: INLINE PfmFile &get_pfm(); INLINE const PfmFile &get_pfm() const; - BLOCKING void project(const Lens *lens); + BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = NULL); BLOCKING void extrude(const Lens *lens); INLINE void set_vis_inverse(bool vis_inverse); diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index 6d4ad703aa..7aac015f96 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -87,7 +87,7 @@ osxGraphicsStateGuardian:: // Description: Resets all internal state as if the gsg were newly // created. //////////////////////////////////////////////////////////////////// -void osxGraphicsStateGuardian::reset() +void osxGraphicsStateGuardian::reset() { /* if(_aglcontext != (AGLContext)NULL) @@ -153,7 +153,7 @@ draw_resize_box() { // viewport size. PN_stdfloat inner_x = 1.0f - (15.0f * 2.0f / _viewport_width); PN_stdfloat inner_y = (15.0f * 2.0f / _viewport_height) - 1.0f; - + // Draw the quad. We just use the slow, simple immediate mode calls // here. It's just one quad, after all. glBegin(GL_QUADS); @@ -177,7 +177,7 @@ draw_resize_box() { //////////////////////////////////////////////////////////////////// // Function: osxGraphicsStateGuardian::build_gl // Access: Public, Virtual -// Description: This function will build up a context for a gsg.. +// Description: This function will build up a context for a gsg.. //////////////////////////////////////////////////////////////////// OSStatus osxGraphicsStateGuardian:: build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { @@ -187,9 +187,9 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { } OSStatus err = noErr; - + GDHandle display = GetMainDevice(); - + pvector attrib; if (!fb_props.get_indexed_color()) { attrib.push_back(AGL_RGBA); @@ -200,11 +200,11 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { attrib.push_back(AGL_PIXEL_SIZE); attrib.push_back(color_bits); attrib.push_back(AGL_RED_SIZE); - attrib.push_back(color_bits / 3); + attrib.push_back(fb_props.get_red_bits()); attrib.push_back(AGL_GREEN_SIZE); - attrib.push_back(color_bits / 3); + attrib.push_back(fb_props.get_green_bits()); attrib.push_back(AGL_BLUE_SIZE); - attrib.push_back(color_bits / 3); + attrib.push_back(fb_props.get_blue_bits()); attrib.push_back(AGL_ALPHA_SIZE); attrib.push_back(alpha_bits); } @@ -265,10 +265,10 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { err = -1; } } else { - aglSetInteger(_aglcontext, AGL_BUFFER_NAME, &_shared_buffer); - err = report_agl_error("aglSetInteger AGL_BUFFER_NAME"); + aglSetInteger(_aglcontext, AGL_BUFFER_NAME, &_shared_buffer); + err = report_agl_error("aglSetInteger AGL_BUFFER_NAME"); } - + } else { osxdisplay_cat.error() << "osxGraphicsStateGuardian::build_gl Error Getting Pixel Format\n" ; @@ -282,10 +282,10 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { if (err == noErr) { describe_pixel_format(fb_props); } - + if (osxdisplay_cat.is_debug()) { osxdisplay_cat.debug() - << "osxGraphicsStateGuardian::build_gl Returning :" << err << "\n"; + << "osxGraphicsStateGuardian::build_gl Returning :" << err << "\n"; osxdisplay_cat.debug() << fb_props << "\n"; } @@ -314,12 +314,15 @@ describe_pixel_format(FrameBufferProperties &fb_props) { } int color_bits = 0; if (aglDescribePixelFormat(_aglPixFmt, AGL_RED_SIZE, &value)) { + fb_props.set_red_bits(value); color_bits += value; } if (aglDescribePixelFormat(_aglPixFmt, AGL_GREEN_SIZE, &value)) { + fb_props.set_green_bits(value); color_bits += value; } if (aglDescribePixelFormat(_aglPixFmt, AGL_BLUE_SIZE, &value)) { + fb_props.set_blue_bits(value); color_bits += value; } fb_props.set_color_bits(color_bits); @@ -399,13 +402,13 @@ get_gamma_table() { //////////////////////////////////////////////////////////////////// // Function: osxGraphicsStateGuardian::static_set_gamma // Access: Public, Static -// Description: Static function for setting gamma which is needed +// Description: Static function for setting gamma which is needed // for atexit. //////////////////////////////////////////////////////////////////// bool osxGraphicsStateGuardian:: static_set_gamma(bool restore, PN_stdfloat gamma) { - bool set; - + bool set; + set = false; if (restore) { @@ -414,23 +417,23 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { return set; } // CGDisplayRestoreColorSyncSettings(); - + // CGGammaValue gOriginalRedTable[ 256 ]; // CGGammaValue gOriginalGreenTable[ 256 ]; // CGGammaValue gOriginalBlueTable[ 256 ]; - + // CGTableCount sampleCount; // CGDisplayErr cgErr; - + // cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount); - + CGGammaValue redTable[ 256 ]; CGGammaValue greenTable[ 256 ]; CGGammaValue blueTable[ 256 ]; - + short j, i; short y[3]; - + for (j = 0; j < 3; j++) { y[j] = 255; } @@ -438,18 +441,18 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { y[0] = 256 * gamma; y[1] = 256 * gamma; y[2] = 256 * gamma; - + for (i = 0; i < 256; i++) { redTable[i] = _gOriginalRedTable[ i ] * (y[ 0 ] ) / 256; greenTable[ i ] = _gOriginalGreenTable[ i ] * (y[ 1 ] ) / 256; blueTable[ i ] = _gOriginalBlueTable[ i ] * (y[ 2 ] ) / 256; } _cgErr = CGSetDisplayTransferByTable( 0, 256, redTable, greenTable, blueTable); - + if (_cgErr == 0) { set = true; } - + return set; } diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index d417221be8..03262e26c7 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -37,7 +37,7 @@ #include "thread.h" #include "renderAttribRegistry.h" #include "py_panda.h" - + LightReMutex *RenderState::_states_lock = NULL; RenderState::States *RenderState::_states = NULL; CPT(RenderState) RenderState::_empty_state; @@ -67,7 +67,7 @@ TypeHandle RenderState::_type_handle; // spurious warning if all constructors are private. //////////////////////////////////////////////////////////////////// RenderState:: -RenderState() : +RenderState() : _flags(0), _auto_shader_state(NULL), _lock("RenderState") @@ -230,6 +230,31 @@ compare_sort(const RenderState &other) const { return 0; } +//////////////////////////////////////////////////////////////////// +// Function: RenderState::compare_mask +// Access: Published +// Description: This version of compare_to takes a slot mask that +// indicates which attributes to include in the +// comparison. Unlike compare_to, this method +// compares the attributes by pointer. +//////////////////////////////////////////////////////////////////// +int RenderState:: +compare_mask(const RenderState &other, SlotMask compare_mask) const { + SlotMask mask = (_filled_slots | other._filled_slots) & compare_mask; + int slot = mask.get_lowest_on_bit(); + while (slot >= 0) { + const RenderAttrib *a = _attributes[slot]._attrib; + const RenderAttrib *b = other._attributes[slot]._attrib; + if (a != b) { + return a < b ? -1 : 1; + } + mask.clear_bit(slot); + slot = mask.get_lowest_on_bit(); + } + + return 0; +} + //////////////////////////////////////////////////////////////////// // Function: RenderState::cull_callback // Access: Published @@ -464,7 +489,7 @@ compose(const RenderState *other) const { // to decrement it again later, when the composition entry is // removed from the cache. result->cache_ref(); - + // (If the result was just this again, we still store the // result, but we don't increment the reference count, since // that would be a self-referential leak.) @@ -558,7 +583,7 @@ invert_compose(const RenderState *other) const { // to decrement it again later, when the composition entry is // removed from the cache. result->cache_ref(); - + // (If the result was just this again, we still store the // result, but we don't increment the reference count, since // that would be a self-referential leak.) @@ -759,7 +784,7 @@ get_auto_shader_state() const { //////////////////////////////////////////////////////////////////// // Function: RenderState::output // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// void RenderState:: output(ostream &out) const { @@ -789,12 +814,12 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// // Function: RenderState::write // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// void RenderState:: write(ostream &out, int indent_level) const { if (is_empty()) { - indent(out, indent_level) + indent(out, indent_level) << "(empty)\n"; } @@ -804,7 +829,7 @@ write(ostream &out, int indent_level) const { const Attribute &attrib = _attributes[slot]; nassertv(attrib._attrib != (RenderAttrib *)NULL); attrib._attrib->write(out, indent_level); - + mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); } @@ -927,7 +952,7 @@ get_num_unused_states() { if (pgraph_cat.is_debug()) { pgraph_cat.debug() - << "Unused state: " << (void *)state << ":" + << "Unused state: " << (void *)state << ":" << state->get_ref_count() << " =\n"; state->write(pgraph_cat.debug(false), 2); } @@ -1062,7 +1087,7 @@ garbage_collect() { } num_this_pass = min(num_this_pass, size); int stop_at_element = (_garbage_index + num_this_pass) % size; - + int num_elements = 0; int si = _garbage_index; do { @@ -1092,7 +1117,7 @@ garbage_collect() { state->cache_unref(); delete state; } - } + } si = (si + 1) % size; } while (si != stop_at_element); @@ -1193,7 +1218,7 @@ list_cycles(ostream &out) { if (r_detect_reverse_cycles(state, state, 1, _last_cycle_detect, &cycle_desc)) { // This state begins a cycle. CompositionCycleDesc::iterator csi; - + out << "\nReverse cycle detected of length " << cycle_desc.size() + 1 << ":\n" << "state "; for (csi = cycle_desc.begin(); csi != cycle_desc.end(); ++csi) { @@ -1209,7 +1234,7 @@ list_cycles(ostream &out) { out << (void *)state << ":" << state->get_ref_count() << " =\n"; state->write(out, 2); - + cycle_desc.clear(); } } @@ -1272,7 +1297,7 @@ validate_states() { pgraph_cat.error() << "RenderState::_states cache is invalid!\n"; return false; - } + } int size = _states->get_size(); int si = 0; @@ -1447,7 +1472,7 @@ do_calc_auto_shader_state() { state->_attributes[slot].set(new_attrib, 0); state->_filled_slots.set_bit(slot); } - + mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); } @@ -1455,7 +1480,7 @@ do_calc_auto_shader_state() { return return_new(state); } - + //////////////////////////////////////////////////////////////////// // Function: RenderState::return_new // Access: Private, Static @@ -1553,7 +1578,7 @@ return_unique(RenderState *state) { attrib._attrib = attrib._attrib->get_unique(); mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); - } + } } int si = _states->find(state); @@ -1561,7 +1586,7 @@ return_unique(RenderState *state) { // There's an equivalent state already in the set. Return it. return _states->get_key(si); } - + // Not already in the set; add it. if (garbage_collect_states) { // If we'll be garbage collecting states explicitly, we'll @@ -1627,11 +1652,11 @@ do_compose(const RenderState *other) const { // with B's override value. result.set(a._attrib->compose(b._attrib), b._override); } - + mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); } - + // If we have any ShaderAttrib with auto-shader enabled, // remove any shader inputs on it. This is a workaround for an // issue that makes the shader-generator regenerate the shader @@ -1640,7 +1665,7 @@ do_compose(const RenderState *other) const { if (sattrib->auto_shader()) { sattrib = DCAST(ShaderAttrib, sattrib->clear_all_shader_inputs()); } - + return return_new(new_state); } @@ -1680,7 +1705,7 @@ do_invert_compose(const RenderState *other) const { // Compose. result.set(a._attrib->invert_compose(b._attrib), 0); } - + mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); } @@ -1697,7 +1722,7 @@ do_invert_compose(const RenderState *other) const { void RenderState:: detect_and_break_cycles() { PStatTimer timer(_state_break_cycles_pcollector); - + ++_last_cycle_detect; if (r_detect_cycles(this, this, 1, _last_cycle_detect, NULL)) { // Ok, we have a cycle. This will be a leak unless we break the @@ -1706,7 +1731,7 @@ detect_and_break_cycles() { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; } - + ((RenderState *)this)->remove_cache_pointers(); } else { ++_last_cycle_detect; @@ -1715,12 +1740,12 @@ detect_and_break_cycles() { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; } - + ((RenderState *)this)->remove_cache_pointers(); } } } - + //////////////////////////////////////////////////////////////////// // Function: RenderState::r_detect_cycles // Access: Private, Static @@ -1747,14 +1772,14 @@ r_detect_cycles(const RenderState *start_state, return (current_state == start_state && length > 2); } ((RenderState *)current_state)->_cycle_detect = this_seq; - + int i; int cache_size = current_state->_composition_cache.get_size(); for (i = 0; i < cache_size; ++i) { if (current_state->_composition_cache.has_element(i)) { const RenderState *result = current_state->_composition_cache.get_data(i)._result; if (result != (const RenderState *)NULL) { - if (r_detect_cycles(start_state, result, length + 1, + if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. if (cycle_desc != (CompositionCycleDesc *)NULL) { @@ -1826,7 +1851,7 @@ r_detect_reverse_cycles(const RenderState *start_state, const RenderState *result = other->_composition_cache.get_data(oi)._result; if (result != (const RenderState *)NULL) { - if (r_detect_reverse_cycles(start_state, result, length + 1, + if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. if (cycle_desc != (CompositionCycleDesc *)NULL) { @@ -1851,7 +1876,7 @@ r_detect_reverse_cycles(const RenderState *start_state, const RenderState *result = other->_invert_composition_cache.get_data(oi)._result; if (result != (const RenderState *)NULL) { - if (r_detect_reverse_cycles(start_state, result, length + 1, + if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. if (cycle_desc != (CompositionCycleDesc *)NULL) { @@ -1975,11 +2000,11 @@ remove_cache_pointers() { if (oi != -1) { // Hold a copy of the other composition result, too. Composition ocomp = other->_composition_cache.get_data(oi); - + other->_composition_cache.remove_element(oi); _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); - + // It's finally safe to let our held pointers go away. This may // have cascading effects as other RenderState objects are // destructed, but there will be no harm done if they destruct @@ -2071,7 +2096,7 @@ determine_bin_index() { } } } - + CullBinManager *bin_manager = CullBinManager::get_global_ptr(); _bin_index = bin_manager->find_bin(bin_name); if (_bin_index == -1) { @@ -2104,7 +2129,7 @@ determine_cull_callback() { _flags |= F_has_cull_callback; break; } - + mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); } @@ -2210,7 +2235,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { nassertv(attrib._attrib != (RenderAttrib *)NULL); manager->write_pointer(dg, attrib._attrib); dg.add_int32(attrib._override); - + mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); } @@ -2276,7 +2301,7 @@ change_this(TypedWritable *old_ptr, BamReader *manager) { pointer->ref(); manager->register_finalize(state); } - + // We have to cast the pointer back to non-const, because the bam // reader expects that. return (RenderState *)pointer.p(); diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 0100049c1c..9b87926045 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -67,6 +67,7 @@ public: PUBLISHED: int compare_to(const RenderState &other) const; int compare_sort(const RenderState &other) const; + int compare_mask(const RenderState &other, SlotMask compare_mask) const; INLINE size_t get_hash() const; INLINE bool is_empty() const; @@ -88,7 +89,7 @@ PUBLISHED: const RenderAttrib *attrib4, int override = 0); static CPT(RenderState) make(const RenderAttrib * const *attrib, int num_attribs, int override = 0); - + CPT(RenderState) compose(const RenderState *other) const; CPT(RenderState) invert_compose(const RenderState *other) const; @@ -152,10 +153,10 @@ PUBLISHED: INLINE int get_draw_order() const; INLINE int get_bin_index() const; int get_geom_rendering(int geom_rendering) const; - + public: static void bin_removed(int bin_index); - + INLINE static void flush_level(); private: @@ -339,7 +340,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/pgraph/stencilAttrib.I b/panda/src/pgraph/stencilAttrib.I index f1ef860cbf..39f3a7f026 100644 --- a/panda/src/pgraph/stencilAttrib.I +++ b/panda/src/pgraph/stencilAttrib.I @@ -18,6 +18,6 @@ // Description: Returns render state. //////////////////////////////////////////////////////////////////// INLINE unsigned int StencilAttrib:: -get_render_state(unsigned int render_state_identifier) const { - return _stencil_render_states [render_state_identifier]; +get_render_state(StencilRenderState render_state_identifier) const { + return _stencil_render_states[(int)render_state_identifier]; } diff --git a/panda/src/pgraph/stencilAttrib.cxx b/panda/src/pgraph/stencilAttrib.cxx index 584c809abe..07657fbf96 100644 --- a/panda/src/pgraph/stencilAttrib.cxx +++ b/panda/src/pgraph/stencilAttrib.cxx @@ -24,11 +24,8 @@ TypeHandle StencilAttrib::_type_handle; int StencilAttrib::_attrib_slot; const char *StencilAttrib:: -stencil_render_state_name_array [StencilAttrib::SRS_total] = +stencil_render_state_name_array[StencilAttrib::SRS_total] = { - "SRS_front_enable", - "SRS_back_enable", - "SRS_front_comparison_function", "SRS_front_stencil_fail_operation", "SRS_front_stencil_pass_z_fail_operation", @@ -55,11 +52,7 @@ stencil_render_state_name_array [StencilAttrib::SRS_total] = //////////////////////////////////////////////////////////////////// StencilAttrib:: StencilAttrib() { - - _stencil_render_states [SRS_front_enable] = 0; - _stencil_render_states [SRS_back_enable] = 0; - - _stencil_render_states [SRS_front_comparison_function] = SCF_always; + _stencil_render_states [SRS_front_comparison_function] = M_none; _stencil_render_states [SRS_front_stencil_fail_operation] = SO_keep; _stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = SO_keep; _stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = SO_keep; @@ -68,7 +61,7 @@ StencilAttrib() { _stencil_render_states [SRS_read_mask] = ~0; _stencil_render_states [SRS_write_mask] = ~0; - _stencil_render_states [SRS_back_comparison_function] = SCF_always; + _stencil_render_states [SRS_back_comparison_function] = M_none; _stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep; _stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep; _stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep; @@ -80,14 +73,12 @@ StencilAttrib() { //////////////////////////////////////////////////////////////////// // Function: StencilAttrib::make_off // Access: Published, Static -// Description: Constructs a StencilAttrib that has stenciling +// Description: Constructs a StencilAttrib that has stenciling // turned off. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) StencilAttrib:: -make_off() -{ +make_off() { StencilAttrib *attrib = new StencilAttrib; - return return_new(attrib); } @@ -110,19 +101,20 @@ make_default() { //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) StencilAttrib:: make( - unsigned int front_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask) { StencilAttrib *attrib = new StencilAttrib; - attrib->_stencil_render_states [SRS_front_enable] = front_enable; - attrib->_stencil_render_states [SRS_back_enable] = 0; + if (!front_enable) { + front_comparison_function = M_none; + } attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function; attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation; @@ -133,7 +125,7 @@ make( attrib->_stencil_render_states [SRS_read_mask] = read_mask; attrib->_stencil_render_states [SRS_write_mask] = write_mask; - attrib->_stencil_render_states [SRS_back_comparison_function] = SCF_always; + attrib->_stencil_render_states [SRS_back_comparison_function] = M_none; attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep; attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep; attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep; @@ -148,24 +140,29 @@ make( //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) StencilAttrib:: make_2_sided( - unsigned int front_enable, - unsigned int back_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + bool back_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask, - unsigned int back_comparison_function, - unsigned int back_stencil_fail_operation, - unsigned int back_stencil_pass_z_fail_operation, - unsigned int back_stencil_pass_z_pass_operation) + PandaCompareFunc back_comparison_function, + StencilOperation back_stencil_fail_operation, + StencilOperation back_stencil_pass_z_fail_operation, + StencilOperation back_stencil_pass_z_pass_operation) { StencilAttrib *attrib = new StencilAttrib; - attrib->_stencil_render_states [SRS_front_enable] = front_enable; - attrib->_stencil_render_states [SRS_back_enable] = back_enable; + if (!front_enable) { + front_comparison_function = M_none; + } + + if (!back_enable) { + back_comparison_function = M_none; + } attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function; attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation; @@ -191,21 +188,22 @@ make_2_sided( //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) StencilAttrib:: make_with_clear( - unsigned int front_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask, - unsigned int clear, + bool clear, unsigned int clear_value) { StencilAttrib *attrib = new StencilAttrib; - attrib->_stencil_render_states [SRS_front_enable] = front_enable; - attrib->_stencil_render_states [SRS_back_enable] = 0; + if (!front_enable) { + front_comparison_function = M_none; + } attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function; attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation; @@ -216,7 +214,7 @@ make_with_clear( attrib->_stencil_render_states [SRS_read_mask] = read_mask; attrib->_stencil_render_states [SRS_write_mask] = write_mask; - attrib->_stencil_render_states [SRS_back_comparison_function] = SCF_always; + attrib->_stencil_render_states [SRS_back_comparison_function] = M_none; attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep; attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep; attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep; @@ -234,26 +232,31 @@ make_with_clear( //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) StencilAttrib:: make_2_sided_with_clear( - unsigned int front_enable, - unsigned int back_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + bool back_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask, - unsigned int back_comparison_function, - unsigned int back_stencil_fail_operation, - unsigned int back_stencil_pass_z_fail_operation, - unsigned int back_stencil_pass_z_pass_operation, - unsigned int clear, + PandaCompareFunc back_comparison_function, + StencilOperation back_stencil_fail_operation, + StencilOperation back_stencil_pass_z_fail_operation, + StencilOperation back_stencil_pass_z_pass_operation, + bool clear, unsigned int clear_value) { StencilAttrib *attrib = new StencilAttrib; - attrib->_stencil_render_states [SRS_front_enable] = front_enable; - attrib->_stencil_render_states [SRS_back_enable] = back_enable; + if (!front_enable) { + front_comparison_function = M_none; + } + + if (!back_enable) { + back_comparison_function = M_none; + } attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function; attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation; @@ -316,9 +319,9 @@ compare_to_impl(const RenderAttrib *other) const { int index; int compare_result = 0; - for (index = 0; index < SRS_total; index++) { - a = (int) sa -> _stencil_render_states [index]; - b = (int) _stencil_render_states [index]; + for (index = 0; index < SRS_total; ++index) { + a = (int) sa -> _stencil_render_states[index]; + b = (int) _stencil_render_states[index]; compare_result = (a - b); if (compare_result) { break; @@ -368,9 +371,8 @@ void StencilAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); - int index; - for (index = 0; index < SRS_total; index++) { - dg.add_int32(_stencil_render_states [index]); + for (int index = 0; index < SRS_total; ++index) { + dg.add_uint32(_stencil_render_states[index]); } } @@ -405,8 +407,29 @@ void StencilAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); - int index; - for (index = 0; index < SRS_total; index++) { - _stencil_render_states [index] = scan.get_int32(); + if (manager->get_file_minor_ver() < 35) { + unsigned int front_enable, back_enable; + front_enable = scan.get_int32(); + back_enable = scan.get_int32(); + + for (int index = 0; index < SRS_total; ++index) { + _stencil_render_states[index] = scan.get_int32(); + } + + if (front_enable) { + _stencil_render_states[SRS_front_comparison_function]++; + } else { + _stencil_render_states[SRS_front_comparison_function] = M_none; + } + + if (back_enable) { + _stencil_render_states[SRS_back_comparison_function]++; + } else { + _stencil_render_states[SRS_back_comparison_function] = M_none; + } + } else { + for (int index = 0; index < SRS_total; ++index) { + _stencil_render_states[index] = scan.get_uint32(); + } } } diff --git a/panda/src/pgraph/stencilAttrib.h b/panda/src/pgraph/stencilAttrib.h index aa30985bd9..5e456b29d6 100644 --- a/panda/src/pgraph/stencilAttrib.h +++ b/panda/src/pgraph/stencilAttrib.h @@ -23,9 +23,9 @@ class FactoryParams; //////////////////////////////////////////////////////////////////// // Class : StencilAttrib // Description : A StencilAttrib is a collection of all stencil render -// states. The render states in a StencilAttrib are -// read-only. A StencilAttrib is created with make or -// make_2_sided. To determine if two sided stencil is +// states. The render states in a StencilAttrib are +// read-only. A StencilAttrib is created with make or +// make_2_sided. To determine if two sided stencil is // supported, call the function GraphicsStateGuardian:: // get_supports_two_sided_stencil. //////////////////////////////////////////////////////////////////// @@ -35,13 +35,8 @@ private: StencilAttrib(); PUBLISHED: - // enums are duplicated here from class StencilRenderStates for use in Python - enum StencilRenderState - { - SRS_front_enable, - SRS_back_enable, - + enum StencilRenderState { SRS_front_comparison_function, SRS_front_stencil_fail_operation, SRS_front_stencil_pass_z_fail_operation, @@ -58,26 +53,23 @@ PUBLISHED: SRS_clear, SRS_clear_value, - + SRS_total, - - SRS_first = 0, }; - enum StencilComparisonFunction - { - SCF_never, - SCF_less_than, - SCF_equal, - SCF_less_than_or_equal, - SCF_greater_than, - SCF_not_equal, - SCF_greater_than_or_equal, - SCF_always, + // Exists purely for backward compatibility. + enum StencilComparisonFunction { + SCF_never = M_never, + SCF_less_than = M_less, + SCF_equal = M_equal, + SCF_less_than_or_equal = M_less_equal, + SCF_greater_than = M_greater, + SCF_not_equal = M_not_equal, + SCF_greater_than_or_equal = M_greater_equal, + SCF_always = M_always, }; - enum StencilOperation - { + enum StencilOperation { SO_keep, SO_zero, SO_replace, @@ -88,73 +80,68 @@ PUBLISHED: SO_decrement_saturate, }; - enum StencilMask - { - SM_default = ~0, - }; - static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make_default(); static CPT(RenderAttrib) make( - unsigned int front_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask); static CPT(RenderAttrib) make_2_sided( - unsigned int front_enable, - unsigned int back_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + bool back_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask, - unsigned int back_comparison_function, - unsigned int back_stencil_fail_operation, - unsigned int back_stencil_pass_z_fail_operation, - unsigned int back_stencil_pass_z_pass_operation); + PandaCompareFunc back_comparison_function, + StencilOperation back_stencil_fail_operation, + StencilOperation back_stencil_pass_z_fail_operation, + StencilOperation back_stencil_pass_z_pass_operation); static CPT(RenderAttrib) make_with_clear( - unsigned int front_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask, - unsigned int clear, + bool clear, unsigned int clear_value); static CPT(RenderAttrib) make_2_sided_with_clear( - unsigned int front_enable, - unsigned int back_enable, - unsigned int front_comparison_function, - unsigned int stencil_fail_operation, - unsigned int stencil_pass_z_fail_operation, - unsigned int front_stencil_pass_z_pass_operation, + bool front_enable, + bool back_enable, + PandaCompareFunc front_comparison_function, + StencilOperation stencil_fail_operation, + StencilOperation stencil_pass_z_fail_operation, + StencilOperation front_stencil_pass_z_pass_operation, unsigned int reference, unsigned int read_mask, unsigned int write_mask, - unsigned int back_comparison_function, - unsigned int back_stencil_fail_operation, - unsigned int back_stencil_pass_z_fail_operation, - unsigned int back_stencil_pass_z_pass_operation, - unsigned int clear, + PandaCompareFunc back_comparison_function, + StencilOperation back_stencil_fail_operation, + StencilOperation back_stencil_pass_z_fail_operation, + StencilOperation back_stencil_pass_z_pass_operation, + bool clear, unsigned int clear_value); - INLINE unsigned int get_render_state (unsigned int render_state_identifier) const; + INLINE unsigned int get_render_state(StencilRenderState render_state_identifier) const; public: static const char *stencil_render_state_name_array [SRS_total]; - + virtual void output(ostream &out) const; protected: diff --git a/panda/src/pgraphnodes/computeNode.I b/panda/src/pgraphnodes/computeNode.I index f841af6309..726193e8b1 100644 --- a/panda/src/pgraphnodes/computeNode.I +++ b/panda/src/pgraphnodes/computeNode.I @@ -41,6 +41,17 @@ add_dispatch(int num_groups_x, int num_groups_y, int num_groups_z) { add_dispatch(num_groups); } +//////////////////////////////////////////////////////////////////// +// Function: ComputeNode::clear_dispatches +// Access: Published +// Description: Removes all dispatch commands. +//////////////////////////////////////////////////////////////////// +INLINE void ComputeNode:: +clear_dispatches() { + Dispatcher::CDWriter cdata(_dispatcher->_cycler); + cdata->_dispatches.clear(); +} + //////////////////////////////////////////////////////////////////// // Function: ComputeNode::get_num_dispatches // Access: Published diff --git a/panda/src/pgraphnodes/computeNode.h b/panda/src/pgraphnodes/computeNode.h index d6b835d6ce..94f2086c10 100644 --- a/panda/src/pgraphnodes/computeNode.h +++ b/panda/src/pgraphnodes/computeNode.h @@ -36,6 +36,8 @@ PUBLISHED: INLINE int get_num_dispatches() const; INLINE const LVecBase3i &get_dispatch(int i) const; + INLINE void clear_dispatches(); + MAKE_SEQ(get_dispatches, get_num_dispatches, get_dispatch); public: diff --git a/panda/src/putil/bam.h b/panda/src/putil/bam.h index cbc4e583f4..7930a7f62c 100644 --- a/panda/src/putil/bam.h +++ b/panda/src/putil/bam.h @@ -33,7 +33,7 @@ static const unsigned short _bam_major_ver = 6; // Bumped to major version 6 on 2/11/06 to factor out PandaNode::CData. static const unsigned short _bam_first_minor_ver = 14; -static const unsigned short _bam_minor_ver = 34; +static const unsigned short _bam_minor_ver = 35; // Bumped to minor version 14 on 12/19/07 to change default ColorAttrib. // Bumped to minor version 15 on 4/9/08 to add TextureAttrib::_implicit_sort. // Bumped to minor version 16 on 5/13/08 to add Texture::_quality_level. @@ -55,5 +55,6 @@ static const unsigned short _bam_minor_ver = 34; // Bumped to minor version 32 on 6/11/12 to add Texture::_has_read_mipmaps. // Bumped to minor version 33 on 8/17/13 to add UvScrollNode::_w_speed. // Bumped to minor version 34 on 9/16/14 to add ScissorAttrib::_off. +// Bumped to minor version 35 on 12/3/14 to change StencilAttrib. #endif diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index a0bcc99504..e89ce1fdb6 100755 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -28,7 +28,7 @@ bool wglGraphicsStateGuardian::_twindow_class_registered = false; //////////////////////////////////////////////////////////////////// wglGraphicsStateGuardian:: wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, - wglGraphicsStateGuardian *share_with) : + wglGraphicsStateGuardian *share_with) : GLGraphicsStateGuardian(engine, pipe), _share_with(share_with) { @@ -41,12 +41,12 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _pfnum = -1; _pfnum_supports_pbuffer = false; _pfnum_properties.clear(); - + _supports_pbuffer = false; _supports_pixel_format = false; _supports_wgl_multisample = false; _supports_wgl_render_texture = false; - + get_gamma_table(); atexit(atexit_function); } @@ -103,7 +103,7 @@ fail_pfnum() { //////////////////////////////////////////////////////////////////// void wglGraphicsStateGuardian:: get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { - + PIXELFORMATDESCRIPTOR pfd; ZeroMemory(&pfd,sizeof(PIXELFORMATDESCRIPTOR)); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); @@ -113,7 +113,7 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { properties.clear(); properties.set_all_specified(); - + if (((pfd.dwFlags & PFD_SUPPORT_OPENGL) == 0)|| ((pfd.dwFlags & PFD_DRAW_TO_WINDOW) == 0)) { // Return without setting either RGB or Indexed Color. @@ -123,8 +123,12 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { if (pfd.iPixelType == PFD_TYPE_COLORINDEX) { properties.set_indexed_color(1); + properties.set_color_bits(pfd.cColorBits); + properties.set_alpha_bits(pfd.cAlphaBits); } else { properties.set_rgb_color(1); + properties.set_rgba_bits(pfd.cRedBits, pfd.cGreenBits, + pfd.cBlueBits, pfd.cAlphaBits); } int mode = 0; @@ -139,13 +143,7 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { } else { properties.set_force_hardware(1); } - - if (pfd.cColorBits != 0) { - properties.set_color_bits(pfd.cColorBits); - } - if (pfd.cAlphaBits != 0) { - properties.set_alpha_bits(pfd.cAlphaBits); - } + if (pfd.cDepthBits != 0) { properties.set_depth_bits(pfd.cDepthBits); } @@ -164,23 +162,27 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { // extensions. //////////////////////////////////////////////////////////////////// bool wglGraphicsStateGuardian:: -get_properties_advanced(FrameBufferProperties &properties, +get_properties_advanced(FrameBufferProperties &properties, HDC window_dc, int pfnum) { - + static const int max_attrib_list = 32; int iattrib_list[max_attrib_list]; int ivalue_list[max_attrib_list]; int ni = 0; int acceleration_i, pixel_type_i, double_buffer_i, stereo_i, - color_bits_i, alpha_bits_i, accum_bits_i, depth_bits_i, - stencil_bits_i, multisamples_i, srgb_capable_i; + color_bits_i, red_bits_i, green_bits_i, blue_bits_i, alpha_bits_i, + accum_bits_i, depth_bits_i, stencil_bits_i, multisamples_i, + srgb_capable_i; iattrib_list[acceleration_i = ni++] = WGL_ACCELERATION_ARB; iattrib_list[pixel_type_i = ni++] = WGL_PIXEL_TYPE_ARB; iattrib_list[double_buffer_i = ni++] = WGL_DOUBLE_BUFFER_ARB; iattrib_list[stereo_i = ni++] = WGL_STEREO_ARB; iattrib_list[color_bits_i = ni++] = WGL_COLOR_BITS_ARB; + iattrib_list[red_bits_i = ni++] = WGL_RED_BITS_ARB; + iattrib_list[green_bits_i = ni++] = WGL_GREEN_BITS_ARB; + iattrib_list[blue_bits_i = ni++] = WGL_BLUE_BITS_ARB; iattrib_list[alpha_bits_i = ni++] = WGL_ALPHA_BITS_ARB; iattrib_list[accum_bits_i = ni++] = WGL_ACCUM_BITS_ARB; iattrib_list[depth_bits_i = ni++] = WGL_DEPTH_BITS_ARB; @@ -211,8 +213,14 @@ get_properties_advanced(FrameBufferProperties &properties, if (ivalue_list[pixel_type_i] == WGL_TYPE_COLORINDEX_ARB) { properties.set_indexed_color(true); + properties.set_color_bits(ivalue_list[color_bits_i]); + properties.set_alpha_bits(ivalue_list[alpha_bits_i]); } else { properties.set_rgb_color(true); + properties.set_rgba_bits(ivalue_list[red_bits_i], + ivalue_list[green_bits_i], + ivalue_list[blue_bits_i], + ivalue_list[alpha_bits_i]); } if (ivalue_list[double_buffer_i]) { @@ -227,10 +235,6 @@ get_properties_advanced(FrameBufferProperties &properties, properties.set_srgb_color(true); } - if (ivalue_list[alpha_bits_i] != 0) { - properties.set_alpha_bits(ivalue_list[alpha_bits_i]); - } - if (ivalue_list[accum_bits_i] != 0) { properties.set_accum_bits(ivalue_list[accum_bits_i]); } @@ -249,8 +253,6 @@ get_properties_advanced(FrameBufferProperties &properties, } } - properties.set_color_bits(ivalue_list[color_bits_i]); - return true; } @@ -271,22 +273,22 @@ choose_pixel_format(const FrameBufferProperties &properties, if (gl_force_pixfmt.has_value()) { wgldisplay_cat.info() - << "overriding pixfmt choice with gl-force-pixfmt(" + << "overriding pixfmt choice with gl-force-pixfmt(" << gl_force_pixfmt << ")\n"; _pfnum = gl_force_pixfmt; _pfnum_properties = properties; _pfnum_supports_pbuffer = true; return; } - + int best_pfnum = 0; int best_quality = 0; FrameBufferProperties best_prop; - + HDC hdc = GetDC(NULL); int max_pfnum = DescribePixelFormat(hdc, 1, 0, NULL); - + for (int pfnum = 0; pfnum 0) { if (need_pbuffer) { best_quality = 0; @@ -445,11 +447,11 @@ choose_pixel_format(const FrameBufferProperties &properties, if (wgldisplay_cat.is_debug()) { wgldisplay_cat.debug() - << "Selected advanced pixfmt #" << _pfnum << " = " + << "Selected advanced pixfmt #" << _pfnum << " = " << _pfnum_properties << "\n"; } } - + wglDeleteContext(twindow_ctx); release_twindow(); } @@ -467,7 +469,7 @@ reset() { _supports_swap_control = has_extension("WGL_EXT_swap_control"); if (_supports_swap_control) { - _wglSwapIntervalEXT = + _wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); if (_wglSwapIntervalEXT == NULL) { wgldisplay_cat.error() @@ -485,17 +487,17 @@ reset() { _supports_pbuffer = has_extension("WGL_ARB_pbuffer"); if (_supports_pbuffer) { - _wglCreatePbufferARB = + _wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB"); - _wglGetPbufferDCARB = + _wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB"); - _wglReleasePbufferDCARB = + _wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB"); - _wglDestroyPbufferARB = + _wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB"); - _wglQueryPbufferARB = + _wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)wglGetProcAddress("wglQueryPbufferARB"); - + if (_wglCreatePbufferARB == NULL || _wglGetPbufferDCARB == NULL || _wglReleasePbufferDCARB == NULL || @@ -531,11 +533,11 @@ reset() { _supports_wgl_render_texture = has_extension("WGL_ARB_render_texture"); if (_supports_wgl_render_texture) { - _wglBindTexImageARB = + _wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)wglGetProcAddress("wglBindTexImageARB"); - _wglReleaseTexImageARB = + _wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)wglGetProcAddress("wglReleaseTexImageARB"); - _wglSetPbufferAttribARB = + _wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC)wglGetProcAddress("wglSetPbufferAttribARB"); if (_wglBindTexImageARB == NULL || _wglReleaseTexImageARB == NULL || @@ -562,7 +564,7 @@ get_extra_extensions() { // Look for the ARB flavor first, which wants one parameter, the HDC // of the drawing context. - PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = + PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); if (wglGetExtensionsStringARB != NULL) { HDC hdc = wglGetCurrentDC(); @@ -574,7 +576,7 @@ get_extra_extensions() { // If that failed, look for the EXT flavor, which wants no // parameters. - PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = + PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT"); if (wglGetExtensionsStringEXT != NULL) { save_extensions((const char *)wglGetExtensionsStringEXT()); @@ -709,9 +711,9 @@ make_twindow() { register_twindow_class(); HINSTANCE hinstance = GetModuleHandle(NULL); - _twindow = CreateWindow(_twindow_class_name, "twindow", window_style, + _twindow = CreateWindow(_twindow_class_name, "twindow", window_style, 0, 0, 1, 1, NULL, NULL, hinstance, 0); - + if (!_twindow) { wgldisplay_cat.error() << "CreateWindow() failed!" << endl; @@ -775,7 +777,7 @@ register_twindow_class() { wc.lpfnWndProc = DefWindowProc; wc.hInstance = instance; wc.lpszClassName = _twindow_class_name; - + if (!RegisterClass(&wc)) { wgldisplay_cat.error() << "could not register window class!" << endl; @@ -797,8 +799,8 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, // avoid divide by zero and negative exponents gamma = 1.0; } - gamma_correction = 1.0 / (double) gamma; - + gamma_correction = 1.0 / (double) gamma; + for (i = 0; i < 256; i++) { double r; double g; @@ -809,11 +811,11 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, g = (double) original_green_table [i] / GAMMA_1; b = (double) original_blue_table [i] / GAMMA_1; } - else { + else { r = ((double) i / 255.0); g = r; b = r; - } + } r = pow (r, gamma_correction); g = pow (g, gamma_correction); @@ -829,14 +831,14 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, b = 1.0; } - r = r * GAMMA_1; - g = g * GAMMA_1; - b = b * GAMMA_1; + r = r * GAMMA_1; + g = g * GAMMA_1; + b = b * GAMMA_1; red_table [i] = r; green_table [i] = g; blue_table [i] = b; - } + } } //////////////////////////////////////////////////////////////////// @@ -846,13 +848,13 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, //////////////////////////////////////////////////////////////////// bool wglGraphicsStateGuardian:: get_gamma_table(void) { - bool get; + bool get; get = false; if (_gamma_table_initialized == false) { HDC hdc = GetDC(NULL); - if (hdc) { + if (hdc) { if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { _gamma_table_initialized = true; get = true; @@ -861,26 +863,26 @@ get_gamma_table(void) { ReleaseDC (NULL, hdc); } } - + return get; } //////////////////////////////////////////////////////////////////// // Function: wglGraphicsStateGuardian::static_set_gamma // Access: Public, Static -// Description: Static function for setting gamma which is needed +// Description: Static function for setting gamma which is needed // for atexit. //////////////////////////////////////////////////////////////////// bool wglGraphicsStateGuardian:: static_set_gamma(bool restore, PN_stdfloat gamma) { - bool set; + bool set; HDC hdc = GetDC(NULL); set = false; - if (hdc) { + if (hdc) { unsigned short ramp [256 * 3]; - if (restore && _gamma_table_initialized) { + if (restore && _gamma_table_initialized) { _create_gamma_table (gamma, &_orignial_gamma_table [0], &_orignial_gamma_table [256], &_orignial_gamma_table [512], &ramp [0], &ramp [256], &ramp [512]); } else { @@ -890,7 +892,7 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { if (SetDeviceGammaRamp (hdc, ramp)) { set = true; } - + ReleaseDC (NULL, hdc); } @@ -909,7 +911,7 @@ set_gamma(PN_stdfloat gamma) { set = static_set_gamma(false, gamma); if (set) { - _gamma = gamma; + _gamma = gamma; } return set; diff --git a/pandatool/.gitignore b/pandatool/.gitignore index 8a32c60a80..692e733aa2 100644 --- a/pandatool/.gitignore +++ b/pandatool/.gitignore @@ -1,3 +1,6 @@ -/built/ +# These are files that are generated within the source tree by the +# ppremake system. Makefile pp.dep +/built/ +Opt?-*