From 03408cd09d1fcffaadbea23a2e0166484a6fc929 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 29 Dec 2004 02:31:45 +0000 Subject: [PATCH] robustify config for framebuffer etc. --- panda/src/display/config_display.cxx | 33 +++ panda/src/display/config_display.h | 8 + panda/src/display/displayRegion.cxx | 2 + panda/src/display/frameBufferProperties.I | 142 +++++++++- panda/src/display/frameBufferProperties.cxx | 117 ++++++++- panda/src/display/frameBufferProperties.h | 66 +++-- panda/src/display/graphicsEngine.cxx | 10 +- panda/src/display/graphicsStateGuardian.cxx | 2 +- panda/src/dxgsg7/config_dxgsg7.cxx | 11 - panda/src/dxgsg7/config_dxgsg7.h | 4 - panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx | 14 - panda/src/dxgsg7/dxGraphicsStateGuardian7.h | 2 - panda/src/dxgsg7/wdxGraphicsWindow7.cxx | 30 ++- panda/src/dxgsg8/config_dxgsg8.cxx | 11 - panda/src/dxgsg8/config_dxgsg8.h | 2 - panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 243 +---------------- panda/src/dxgsg8/dxGraphicsStateGuardian8.h | 2 - panda/src/dxgsg9/config_dxgsg9.cxx | 11 - panda/src/dxgsg9/config_dxgsg9.h | 2 - panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 244 +----------------- panda/src/dxgsg9/dxGraphicsStateGuardian9.h | 2 - .../glstuff/glGraphicsStateGuardian_src.cxx | 24 +- .../src/glstuff/glGraphicsStateGuardian_src.h | 2 - panda/src/glstuff/glmisc_src.cxx | 5 - panda/src/glstuff/glmisc_src.h | 1 - panda/src/wgldisplay/wglGraphicsPipe.cxx | 127 ++++++--- panda/src/wgldisplay/wglGraphicsPipe.h | 6 +- panda/src/windisplay/config_windisplay.cxx | 5 - panda/src/windisplay/config_windisplay.h | 2 - 29 files changed, 466 insertions(+), 664 deletions(-) diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 547a31f878..50f9131438 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -119,6 +119,14 @@ ConfigVariableBool window_inverted "they will render upside-down and backwards. Normally this is useful only " "for debugging.")); +ConfigVariableBool depth_offset_decals +("depth-offset-decals", false, + PRC_DESC("Set this true to allow decals to be implemented via the advanced " + "depth offset feature, if supported, instead of via the traditional " + "(and slower) two-pass approach. This is false by default " + "because it appears that many graphics drivers have issues with " + "their depth offset implementation.")); + ConfigVariableInt win_size ("win-size", "640 480", PRC_DESC("This is the default size at which to open a new window. This " @@ -162,6 +170,31 @@ ConfigVariableEnum z_order ConfigVariableString window_title ("window-title", "Panda"); +ConfigVariableString framebuffer_mode +("framebuffer-mode", "rgba double-buffer depth multisample hardware", + PRC_DESC("A space-separated list of keywords that describe the default " + "framebuffer properties requested for a window.")); +ConfigVariableInt depth_bits +("depth-bits", 1, + PRC_DESC("The minimum number of depth bits requested if the depth keyword " + "is present in framebuffer-mode.")); +ConfigVariableInt color_bits +("color-bits", 1, + PRC_DESC("The minimum number of color bits requested in the default " + "framebuffer properties (sum of all three color channels).")); +ConfigVariableInt alpha_bits +("alpha-bits", 1, + PRC_DESC("The minimum number of alpha bits requested if the alpha or rgba " + "keyword is present in framebuffer-mode.")); +ConfigVariableInt stencil_bits +("stencil-bits", 1, + PRC_DESC("The minimum number of stencil bits requested if the stencil keyword " + "is present in framebuffer-mode.")); +ConfigVariableInt multisample_bits +("multisample-bits", 1, + PRC_DESC("The minimum number of multisample bits requested if the multisample keyword " + "is present in framebuffer-mode.")); + ConfigVariableDouble background_color ("background-color", "0.41 0.41 0.41", PRC_DESC("Specifies the rgb(a) value of the default background color for a " diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index f51c44b272..b81eae2e35 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -53,6 +53,7 @@ extern ConfigVariableBool prefer_single_buffer; extern ConfigVariableBool copy_texture_inverted; extern ConfigVariableBool window_inverted; +extern ConfigVariableBool depth_offset_decals; extern ConfigVariableInt win_size; extern ConfigVariableInt win_origin; @@ -68,6 +69,13 @@ extern ConfigVariableFilename cursor_filename; extern ConfigVariableEnum z_order; extern ConfigVariableString window_title; +extern ConfigVariableString framebuffer_mode; +extern ConfigVariableInt depth_bits; +extern ConfigVariableInt color_bits; +extern ConfigVariableInt alpha_bits; +extern ConfigVariableInt stencil_bits; +extern ConfigVariableInt multisample_bits; + extern ConfigVariableDouble background_color; diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index 046b8033a1..9e2253298e 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -38,6 +38,7 @@ DisplayRegion(GraphicsOutput *window) : _active(true), _sort(0) { + _draw_buffer_type = window->get_draw_buffer_type(); compute_pixels(); } @@ -55,6 +56,7 @@ DisplayRegion(GraphicsOutput *window, const float l, _active(true), _sort(0) { + _draw_buffer_type = window->get_draw_buffer_type(); compute_pixels(); } diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index 408ed54f88..fb541d7779 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -164,7 +164,7 @@ has_depth_bits() const { INLINE void FrameBufferProperties:: clear_depth_bits() { _specified &= ~S_depth_bits; - _depth_bits = 0; + _depth_bits = 1; } //////////////////////////////////////////////////////////////////// @@ -212,7 +212,145 @@ has_color_bits() const { INLINE void FrameBufferProperties:: clear_color_bits() { _specified &= ~S_color_bits; - _color_bits = 0; + _color_bits = 1; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_alpha_bits +// Access: Published +// Description: Specifies the minimum number of bits that are +// required of the alpha buffer. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_alpha_bits(int alpha_bits) { + _alpha_bits = alpha_bits; + _specified |= S_alpha_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_alpha_bits +// Access: Published +// Description: Returns the number of bits specified for the alpha +// buffer. +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_alpha_bits() const { + return _alpha_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::has_alpha_bits +// Access: Published +// Description: Returns true if the number of bits for the alpha +// buffer has been specified, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +has_alpha_bits() const { + return ((_specified & S_alpha_bits) != 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::clear_alpha_bits +// Access: Published +// Description: Removes the alpha_bits specification from the +// properties. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +clear_alpha_bits() { + _specified &= ~S_alpha_bits; + _alpha_bits = 1; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_stencil_bits +// Access: Published +// Description: Specifies the minimum number of bits that are +// required for the stencil buffer. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_stencil_bits(int stencil_bits) { + _stencil_bits = stencil_bits; + _specified |= S_stencil_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_stencil_bits +// Access: Published +// Description: Returns the number of bits specified for the stencil +// buffer. +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_stencil_bits() const { + return _stencil_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::has_stencil_bits +// Access: Published +// Description: Returns true if the number of bits for the stencil +// buffer has been specified, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +has_stencil_bits() const { + return ((_specified & S_stencil_bits) != 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::clear_stencil_bits +// Access: Published +// Description: Removes the stencil_bits specification from the +// properties. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +clear_stencil_bits() { + _specified &= ~S_stencil_bits; + _stencil_bits = 1; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_multisample_bits +// Access: Published +// Description: Specifies the minimum number of bits that are +// required for the multisample buffer. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_multisample_bits(int multisample_bits) { + _multisample_bits = multisample_bits; + _specified |= S_multisample_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_multisample_bits +// Access: Published +// Description: Returns the number of bits specified for the multisample +// buffer. +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_multisample_bits() const { + return _multisample_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::has_multisample_bits +// Access: Published +// Description: Returns true if the number of bits for the multisample +// buffer has been specified, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +has_multisample_bits() const { + return ((_specified & S_multisample_bits) != 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::clear_multisample_bits +// Access: Published +// Description: Removes the multisample_bits specification from the +// properties. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +clear_multisample_bits() { + _specified &= ~S_multisample_bits; + _multisample_bits = 1; } INLINE ostream & diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index a24b87b894..f013972260 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "frameBufferProperties.h" +#include "string_utils.h" //////////////////////////////////////////////////////////////////// @@ -41,6 +42,85 @@ operator = (const FrameBufferProperties ©) { _frame_buffer_mode = copy._frame_buffer_mode; _depth_bits = copy._depth_bits; _color_bits = copy._color_bits; + _alpha_bits = copy._alpha_bits; + _stencil_bits = copy._stencil_bits; + _multisample_bits = copy._multisample_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_default +// Access: Published, Static +// Description: Returns a FrameBufferProperties structure with all of +// the default values filled in according to the user's +// config file. +//////////////////////////////////////////////////////////////////// +FrameBufferProperties FrameBufferProperties:: +get_default() { + FrameBufferProperties props; + + int mode = 0; + int num_words = framebuffer_mode.get_num_words(); + for (int i = 0; i < num_words; i++) { + string word = framebuffer_mode.get_word(i); + if (cmp_nocase_uh(word, "rgb") == 0) { + mode |= FM_rgb; + + } else if (cmp_nocase_uh(word, "index") == 0) { + mode |= FM_index; + + } else if (cmp_nocase_uh(word, "single") == 0 || + cmp_nocase_uh(word, "single-buffer") == 0) { + mode |= FM_single_buffer; + + } else if (cmp_nocase_uh(word, "double") == 0 || + cmp_nocase_uh(word, "double-buffer") == 0) { + mode |= FM_double_buffer; + + } else if (cmp_nocase_uh(word, "triple") == 0 || + cmp_nocase_uh(word, "triple-buffer") == 0) { + mode |= FM_triple_buffer; + + } else if (cmp_nocase_uh(word, "accum") == 0) { + mode |= FM_accum; + + } else if (cmp_nocase_uh(word, "alpha") == 0) { + mode |= FM_alpha; + + } else if (cmp_nocase_uh(word, "rgba") == 0) { + mode |= FM_rgba; + + } else if (cmp_nocase_uh(word, "depth") == 0) { + mode |= FM_depth; + + } else if (cmp_nocase_uh(word, "stencil") == 0) { + mode |= FM_stencil; + + } else if (cmp_nocase_uh(word, "multisample") == 0) { + mode |= FM_multisample; + + } else if (cmp_nocase_uh(word, "stereo") == 0) { + mode |= FM_stereo; + + } else if (cmp_nocase_uh(word, "software") == 0) { + mode |= FM_software; + + } else if (cmp_nocase_uh(word, "hardware") == 0) { + mode |= FM_hardware; + + } else { + display_cat.warning() + << "Unknown framebuffer keyword: " << word << "\n"; + } + } + + props.set_frame_buffer_mode(mode); + props.set_depth_bits(depth_bits); + props.set_color_bits(color_bits); + props.set_alpha_bits(alpha_bits); + props.set_stencil_bits(stencil_bits); + props.set_multisample_bits(multisample_bits); + + return props; } //////////////////////////////////////////////////////////////////// @@ -54,7 +134,10 @@ operator == (const FrameBufferProperties &other) const { _flags == other._flags && _frame_buffer_mode == other._frame_buffer_mode && _depth_bits == other._depth_bits && - _color_bits == other._color_bits); + _color_bits == other._color_bits && + _alpha_bits == other._alpha_bits && + _stencil_bits == other._stencil_bits && + _multisample_bits == other._multisample_bits); } //////////////////////////////////////////////////////////////////// @@ -69,8 +152,11 @@ clear() { _specified = 0; _flags = 0; _frame_buffer_mode = 0; - _depth_bits = 0; - _color_bits = 0; + _depth_bits = 1; + _color_bits = 1; + _alpha_bits = 1; + _stencil_bits = 1; + _multisample_bits = 1; } //////////////////////////////////////////////////////////////////// @@ -91,6 +177,15 @@ add_properties(const FrameBufferProperties &other) { if (other.has_color_bits()) { set_color_bits(other.get_color_bits()); } + if (other.has_alpha_bits()) { + set_alpha_bits(other.get_alpha_bits()); + } + if (other.has_stencil_bits()) { + set_stencil_bits(other.get_stencil_bits()); + } + if (other.has_multisample_bits()) { + set_multisample_bits(other.get_multisample_bits()); + } } //////////////////////////////////////////////////////////////////// @@ -137,8 +232,11 @@ output(ostream &out) const { if ((frameBuffer_mode & FM_stereo) != 0) { out << "|FM_stereo"; } - if ((frameBuffer_mode & FM_luminance) != 0) { - out << "|FM_luminance"; + if ((frameBuffer_mode & FM_software) != 0) { + out << "|FM_software"; + } + if ((frameBuffer_mode & FM_hardware) != 0) { + out << "|FM_hardware"; } out << " "; } @@ -148,4 +246,13 @@ output(ostream &out) const { if (has_color_bits()) { out << "color_bits=" << get_color_bits() << " "; } + if (has_alpha_bits()) { + out << "alpha_bits=" << get_alpha_bits() << " "; + } + if (has_stencil_bits()) { + out << "stencil_bits=" << get_stencil_bits() << " "; + } + if (has_multisample_bits()) { + out << "multisample_bits=" << get_multisample_bits() << " "; + } } diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h index cde8492394..07d4085504 100644 --- a/panda/src/display/frameBufferProperties.h +++ b/panda/src/display/frameBufferProperties.h @@ -34,24 +34,27 @@ PUBLISHED: void operator = (const FrameBufferProperties ©); INLINE ~FrameBufferProperties(); + static FrameBufferProperties get_default(); + bool operator == (const FrameBufferProperties &other) const; INLINE bool operator != (const FrameBufferProperties &other) const; enum FrameBufferMode { - FM_rgb = 0x0000, - FM_index = 0x0001, - FM_single_buffer = 0x0000, - FM_double_buffer = 0x0002, - FM_triple_buffer = 0x0004, - FM_buffer = 0x0006, // == (FM_single_buffer | FM_double_buffer | FM_triple_buffer) - FM_accum = 0x0008, - FM_alpha = 0x0010, - FM_rgba = 0x0010, // == (FM_rgb | FM_alpha) - FM_depth = 0x0020, - FM_stencil = 0x0040, - FM_multisample = 0x0080, - FM_stereo = 0x0100, - FM_luminance = 0x0200, + FM_rgb = 0x0000, + FM_index = 0x0001, + FM_single_buffer = 0x0000, + FM_double_buffer = 0x0002, + FM_triple_buffer = 0x0004, + FM_buffer = 0x0006, // == (FM_single_buffer | FM_double_buffer | FM_triple_buffer) + FM_accum = 0x0008, + FM_alpha = 0x0010, + FM_rgba = 0x0010, // == (FM_rgb | FM_alpha) + FM_depth = 0x0020, + FM_stencil = 0x0040, + FM_multisample = 0x0080, + FM_stereo = 0x0100, + FM_software = 0x0200, + FM_hardware = 0x0400, }; void clear(); @@ -74,6 +77,21 @@ PUBLISHED: INLINE bool has_color_bits() const; INLINE void clear_color_bits(); + INLINE void set_alpha_bits(int alpha_bits); + INLINE int get_alpha_bits() const; + INLINE bool has_alpha_bits() const; + INLINE void clear_alpha_bits(); + + INLINE void set_stencil_bits(int stencil_bits); + INLINE int get_stencil_bits() const; + INLINE bool has_stencil_bits() const; + INLINE void clear_stencil_bits(); + + INLINE void set_multisample_bits(int multisample_bits); + INLINE int get_multisample_bits() const; + INLINE bool has_multisample_bits() const; + INLINE void clear_multisample_bits(); + void add_properties(const FrameBufferProperties &other); void output(ostream &out) const; @@ -83,24 +101,22 @@ private: // structure have been filled in by the user, and which remain // unspecified. enum Specified { - S_frame_buffer_mode = 0x0200, - S_depth_bits = 0x0400, - S_color_bits = 0x0800, + S_frame_buffer_mode = 0x0001, + S_depth_bits = 0x0002, + S_color_bits = 0x0004, + S_alpha_bits = 0x0008, + S_stencil_bits = 0x0010, + S_multisample_bits = 0x0020, }; - // This bitmask represents the true/false settings for various - // boolean flags (assuming the corresponding S_* bit has been set, - // above). - /* - enum Flags { - }; - */ - int _specified; int _flags; int _frame_buffer_mode; int _depth_bits; int _color_bits; + int _alpha_bits; + int _stencil_bits; + int _multisample_bits; }; INLINE ostream &operator << (ostream &out, const FrameBufferProperties &properties); diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index a8d4bcc56e..cbcfd695ce 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -73,13 +73,7 @@ GraphicsEngine(Pipeline *pipeline) : _windows_sorted = true; // Default frame buffer properties. - _frame_buffer_properties.set_depth_bits(1); - _frame_buffer_properties.set_color_bits(1); - _frame_buffer_properties.set_frame_buffer_mode - (FrameBufferProperties::FM_rgba | - FrameBufferProperties::FM_double_buffer | - FrameBufferProperties::FM_multisample | - FrameBufferProperties::FM_depth); + _frame_buffer_properties = FrameBufferProperties::get_default(); set_threading_model(GraphicsThreadingModel(threading_model)); if (!_threading_model.is_default()) { @@ -1084,7 +1078,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, CullTraverser trav; trav.set_cull_handler(cull_handler); - trav.set_depth_offset_decals(gsg->depth_offset_decals()); + trav.set_depth_offset_decals(depth_offset_decals && gsg->depth_offset_decals()); trav.set_scene(scene_setup); if (view_frustum_cull) { diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 65afb95c85..afefa87a95 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -486,7 +486,7 @@ wants_colors() const { //////////////////////////////////////////////////////////////////// bool GraphicsStateGuardian:: depth_offset_decals() { - return false; + return true; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/dxgsg7/config_dxgsg7.cxx b/panda/src/dxgsg7/config_dxgsg7.cxx index 5ae42a5954..0d0e5c966d 100644 --- a/panda/src/dxgsg7/config_dxgsg7.cxx +++ b/panda/src/dxgsg7/config_dxgsg7.cxx @@ -59,11 +59,6 @@ ConfigVariableBool dx_no_vertex_fog ConfigVariableBool dx_auto_normalize_lighting ("auto-normalize-lighting", true); -ConfigVariableBool dx_allow_software_renderer -("dx-allow-software-renderer", false); -ConfigVariableBool dx_force_software_renderer -("dx-force-software-renderer", false); - #ifndef NDEBUG // debugging flag // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW @@ -96,12 +91,6 @@ ConfigVariableBool dx_do_vidmemsize_check ConfigVariableBool dx_preserve_fpu_state ("dx-preserve-fpu-state", true); -// Configure this true to try to implement decals using a -// DepthOffsetAttrib, false to do them with the more reliable 3-pass -// rendering method instead. -ConfigVariableBool dx_depth_offset_decals -("depth-offset-decals", false); - #ifdef _DEBUG ConfigVariableDouble dx_global_miplevel_bias ("dx-global-miplevel-bias", 0.0); diff --git a/panda/src/dxgsg7/config_dxgsg7.h b/panda/src/dxgsg7/config_dxgsg7.h index ec7963ea3c..fcd2d30b02 100644 --- a/panda/src/dxgsg7/config_dxgsg7.h +++ b/panda/src/dxgsg7/config_dxgsg7.h @@ -34,8 +34,6 @@ extern ConfigVariableBool dx_no_vertex_fog; extern ConfigVariableBool dx_full_screen_antialiasing; extern ConfigVariableBool dx_auto_normalize_lighting; extern ConfigVariableBool dx_use_rangebased_fog; -extern ConfigVariableBool dx_allow_software_renderer; -extern ConfigVariableBool dx_force_software_renderer; extern ConfigVariableBool link_tristrips; // debug flags we might want to use in full optimized build @@ -47,8 +45,6 @@ extern ConfigVariableBool dx_force_16bpp_zbuffer; extern ConfigVariableBool dx_do_vidmemsize_check; extern ConfigVariableBool dx_preserve_fpu_state; -extern ConfigVariableBool dx_depth_offset_decals; - #ifndef NDEBUG extern ConfigVariableInt dx_force_backface_culling; #endif diff --git a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx index 25c215afff..5e21367613 100644 --- a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx +++ b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx @@ -4267,20 +4267,6 @@ wants_texcoords() const { return _texturing_enabled; } - -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian7::depth_offset_decals -// Access: Public, Virtual -// Description: Returns true if this GSG can implement decals using a -// DepthOffsetAttrib, or false if that is unreliable -// and the three-step rendering process should be used -// instead. -//////////////////////////////////////////////////////////////////// -bool DXGraphicsStateGuardian7:: -depth_offset_decals() { - return dx_depth_offset_decals; -} - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian7::compute_distance_to // Access: Public, Virtual diff --git a/panda/src/dxgsg7/dxGraphicsStateGuardian7.h b/panda/src/dxgsg7/dxGraphicsStateGuardian7.h index 03ee0cd309..5d618a81ed 100644 --- a/panda/src/dxgsg7/dxGraphicsStateGuardian7.h +++ b/panda/src/dxgsg7/dxGraphicsStateGuardian7.h @@ -131,8 +131,6 @@ public: virtual bool wants_texcoords(void) const; - virtual bool depth_offset_decals(); - INLINE float compute_distance_to(const LPoint3f &point) const; virtual void set_color_clear_value(const Colorf& value); diff --git a/panda/src/dxgsg7/wdxGraphicsWindow7.cxx b/panda/src/dxgsg7/wdxGraphicsWindow7.cxx index 4ca72d5b98..b3615f167d 100644 --- a/panda/src/dxgsg7/wdxGraphicsWindow7.cxx +++ b/panda/src/dxgsg7/wdxGraphicsWindow7.cxx @@ -1013,8 +1013,22 @@ choose_device(int devnum, DXDeviceInfo *pDevinfo) { wdxGraphicsPipe7 *dxpipe; DCAST_INTO_R(dxpipe, _pipe, false); - DWORD dwRenderWidth = get_properties().get_x_size(); - DWORD dwRenderHeight = get_properties().get_y_size(); + WindowProperties properties = get_properties(); + FrameBufferProperties fbprops = _dxgsg->get_properties(); + + int mode = fbprops.get_frame_buffer_mode(); + bool hardware = ((mode & FrameBufferProperties::FM_hardware) != 0); + bool software = ((mode & FrameBufferProperties::FM_software) != 0); + + // If the user specified neither hardware nor software frame buffer, + // he gets either one. + if (!hardware && !software) { + hardware = true; + software = true; + } + + DWORD dwRenderWidth = properties.get_x_size(); + DWORD dwRenderHeight = properties.get_y_size(); LPDIRECTDRAW7 pDD=NULL; HRESULT hr; @@ -1111,22 +1125,18 @@ choose_device(int devnum, DXDeviceInfo *pDevinfo) { WORD DeviceIdx; // select TNL if present - if (d3ddevs[TNLHALIDX].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION) { + if (hardware && (d3ddevs[TNLHALIDX].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION)) { DeviceIdx = TNLHALIDX; - } else if (d3ddevs[REGHALIDX].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION) { + } else if (hardware && (d3ddevs[REGHALIDX].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION)) { DeviceIdx = REGHALIDX; - } else if (dx_allow_software_renderer || dx_force_software_renderer) { + } else if (software) { DeviceIdx = SWRASTIDX; } else { wdxdisplay7_cat.error() - << "No 3D HW present on device #" << devnum << ", skipping it... (" + << "No 3D graphics present on device #" << devnum << ", skipping it... (" << _wcontext.DXDeviceID.szDescription<<")\n"; goto error_exit; } - - if (dx_force_software_renderer) { - DeviceIdx = SWRASTIDX; - } memcpy(&_wcontext.D3DDevDesc, &d3ddevs[DeviceIdx], sizeof(D3DDEVICEDESC7)); diff --git a/panda/src/dxgsg8/config_dxgsg8.cxx b/panda/src/dxgsg8/config_dxgsg8.cxx index 6224a0d193..7918061649 100644 --- a/panda/src/dxgsg8/config_dxgsg8.cxx +++ b/panda/src/dxgsg8/config_dxgsg8.cxx @@ -37,11 +37,6 @@ NotifyCategoryDef(wdxdisplay8, "windisplay"); ConfigVariableBool dx_show_transforms ("dx-show-transforms", false); -// Configure this to TRUE if you want DirectX to control the entire screen, -// If false, it will just blit into a window. -ConfigVariableBool dx_full_screen -("dx-full-screen", false); - // Configure this true to force the rendering to sync to the video // refresh, or false to let your frame rate go as high as it can, // irrespective of the video refresh. @@ -52,12 +47,6 @@ ConfigVariableBool dx_sync_video ConfigVariableInt dx_multisample_antialiasing_level ("dx-multisample-antialiasing-level", 0); -// Configure this true to perform a cull traversal over the geometry -// by default, false otherwise. The cull traversal provides support -// for state-sorting, z-sorting, and binning. -ConfigVariableBool dx_cull_traversal -("dx-cull-traversal", true); - // if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability ConfigVariableBool dx_no_vertex_fog ("dx-no-vertex-fog", false); diff --git a/panda/src/dxgsg8/config_dxgsg8.h b/panda/src/dxgsg8/config_dxgsg8.h index 909a8a62f0..8100e0f4d0 100644 --- a/panda/src/dxgsg8/config_dxgsg8.h +++ b/panda/src/dxgsg8/config_dxgsg8.h @@ -29,9 +29,7 @@ NotifyCategoryDecl(dxgsg8, EXPCL_PANDADX, EXPTP_PANDADX); NotifyCategoryDecl(wdxdisplay8, EXPCL_PANDADX, EXPTP_PANDADX); -extern ConfigVariableBool dx_full_screen; extern ConfigVariableBool dx_sync_video; -extern ConfigVariableBool dx_cull_traversal; extern ConfigVariableBool dx_no_vertex_fog; extern ConfigVariableBool dx_show_cursor_watermark; extern ConfigVariableBool dx_full_screen_antialiasing; diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index d62162334c..fd6a82428b 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -74,10 +74,6 @@ // for sprites, 1000 prims, 6 verts/prim, 24 bytes/vert const int VERT_BUFFER_SIZE = (32*6*1024L); -// if defined, pandadx only handles 1 panda display region -// note multiple region code doesnt work now (see prepare_display_region,set_clipper) -#define NO_MULTIPLE_DISPLAY_REGIONS - TypeHandle DXGraphicsStateGuardian8::_type_handle; // bit masks used for drawing primitives @@ -576,34 +572,6 @@ dx_init(void) { void DXGraphicsStateGuardian8:: support_overlay_window(bool flag) { // How is this supposed to be done in DX8? - //_bDXisReady = !flag; - //dxgsg8_cat.debug() << "Set DxReady to " << _bDXisReady << "\n"; - /* - if (_overlay_windows_supported && !flag) { - // Disable support for overlay windows. - _overlay_windows_supported = false; - - if (dx_full_screen) { - _pScrn->pddsPrimary->SetClipper(NULL); - } - - } else if (!_overlay_windows_supported && flag) { - // Enable support for overlay windows. - _overlay_windows_supported = true; - - if (dx_full_screen) { - // Create a Clipper object to blt the whole screen. - LPDIRECTDRAWCLIPPER Clipper; - - if (_pScrn->pDD->CreateClipper(0, &Clipper, NULL) == DD_OK) { - Clipper->SetHWnd(0, _pScrn->hWnd); - _pScrn->pddsPrimary->SetClipper(Clipper); - } - _pScrn->pDD->FlipToGDISurface(); - Clipper->Release(); - } - } - */ } //////////////////////////////////////////////////////////////////// @@ -755,54 +723,6 @@ prepare_lens() { return SUCCEEDED(hr); } -#ifndef NO_MULTIPLE_DISPLAY_REGIONS -//////////////////////////////////////////////////////////////////// -// Function: set_clipper -// Access: -// Description: Useless in DX at the present time -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian8::set_clipper(RECT cliprect) { - - LPDIRECTDRAWCLIPPER Clipper; - HRESULT result; - - // For windowed mode, the clip region is associated with the window, - // and DirectX does not allow you to create clip regions. - if (dx_full_screen) return; - - /* The cliprect we receive is normalized so that (0,0) means the upper left of - the client portion of the window. - At least, I think that's true, and the following code assumes that. - So we must adjust the clip region by offsetting it to the origin of the - view rectangle. - */ - clip_rect = cliprect; // store the normalized clip rect - cliprect.left += _view_rect.left; - cliprect.right += _view_rect.left; - cliprect.top += _view_rect.top; - cliprect.bottom += _view_rect.top; - RGNDATA *rgn_data = (RGNDATA *)malloc(sizeof(RGNDATAHEADER) + sizeof(RECT)); - HRGN hrgn = CreateRectRgn(cliprect.left, cliprect.top, cliprect.right, cliprect.bottom); - GetRegionData(hrgn, sizeof(RGNDATAHEADER) + sizeof(RECT), rgn_data); - - if (_pD3DDevicesPrimary->GetClipper(&Clipper) != DD_OK) { - result = _pD3DDevice->CreateClipper(0, &Clipper, NULL); - result = Clipper->SetClipList(rgn_data, 0); - result = _pD3DDevicesPrimary->SetClipper(Clipper); - } else { - result = Clipper->SetClipList(rgn_data, 0 ); - if (result == DDERR_CLIPPERISUSINGHWND) { - result = _pD3DDevicesPrimary->SetClipper(NULL); - result = _pD3DDevice->CreateClipper(0, &Clipper, NULL); - result = Clipper->SetClipList(rgn_data, 0 ) ; - result = _pD3DDevicesPrimary->SetClipper(Clipper); - } - } - free(rgn_data); - DeleteObject(hrgn); -} -#endif - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian8::get_blend_func // Access: Protected, Static @@ -3774,20 +3694,6 @@ end_frame() { GraphicsStateGuardian::end_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian8::depth_offset_decals -// Access: Public, Virtual -// Description: Returns true if this GSG can implement decals using a -// DepthOffsetAttrib, or false if that is unreliable -// and the three-step rendering process should be used -// instead. -//////////////////////////////////////////////////////////////////// -bool DXGraphicsStateGuardian8:: -depth_offset_decals() { - // False for now. - return false; -} - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian8::set_draw_buffer // Access: Protected @@ -4391,13 +4297,11 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *pPresParams, DXScreenData **pScrn) { ReleaseAllDeviceObjects(); - if(!dx_full_screen) { - // for windowed make sure out format matches the desktop fmt, in case the - // desktop mode has been changed + // for windowed mode make sure our format matches the desktop fmt, + // in case the desktop mode has been changed + _pScrn->pD3D8->GetAdapterDisplayMode(_pScrn->CardIDNum, &_pScrn->DisplayMode); + pPresParams->BackBufferFormat = _pScrn->DisplayMode.Format; - _pScrn->pD3D8->GetAdapterDisplayMode(_pScrn->CardIDNum, &_pScrn->DisplayMode); - pPresParams->BackBufferFormat = _pScrn->DisplayMode.Format; - } // here we have to look at the _PresReset frame buffer dimension // if current window's dimension is bigger than _PresReset // we have to reset the device before creating new swapchain. @@ -4510,145 +4414,6 @@ CheckCooperativeLevel(bool bDoReactivateWindow) { return SUCCEEDED(hr); } -/* -//////////////////////////////////////////////////////////////////// -// Function: adjust_view_rect -// Access: -// Description: we receive the new x and y position of the client -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian8::adjust_view_rect(int x, int y) { - if (_pScrn->view_rect.left != x || _pScrn->view_rect.top != y) { - - _pScrn->view_rect.right = x + RECT_XSIZE(_pScrn->view_rect); - _pScrn->view_rect.left = x; - _pScrn->view_rect.bottom = y + RECT_YSIZE(_pScrn->view_rect); - _pScrn->view_rect.top = y; - -// set_clipper(clip_rect); - } -} -*/ - -#if 0 - -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::save_mipmap_images -// Access: Protected -// Description: Saves out each mipmap level of the indicated texture -// (which must also be the currently active texture in -// the GL state) as a separate image file to disk. -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian8::read_mipmap_images(Texture *tex) { - Filename filename = tex->get_name(); - string name; - if (filename.empty()) { - static index = 0; - name = "texture" + format_string(index); - index++; - } else { - name = filename.get_basename_wo_extension(); - } - - PixelBuffer *pb = tex->get_ram_image(); - nassertv(pb != (PixelBuffer *)NULL); - - GLenum external_format = get_external_image_format(pb->get_format()); - GLenum type = get_image_type(pb->get_image_type()); - - int xsize = pb->get_xsize(); - int ysize = pb->get_ysize(); - - // Specify byte-alignment for the pixels on output. - glPixelStorei(GL_PACK_ALIGNMENT, 1); - - int mipmap_level = 0; - do { - xsize = max(xsize, 1); - ysize = max(ysize, 1); - - PT(PixelBuffer) mpb = - new PixelBuffer(xsize, ysize, pb->get_num_components(), - pb->get_component_width(), pb->get_image_type(), - pb->get_format()); - glGetTexImage(GL_TEXTURE_2D, mipmap_level, external_format, - type, mpb->_image); - Filename mipmap_filename = name + "_" + format_string(mipmap_level) + ".pnm"; - nout << "Writing mipmap level " << mipmap_level - << " (" << xsize << " by " << ysize << ") " - << mipmap_filename << "\n"; - mpb->write(mipmap_filename); - - xsize >>= 1; - ysize >>= 1; - mipmap_level++; - } while (xsize > 0 && ysize > 0); -} -#endif - - -#if 0 -//----------------------------------------------------------------------------- -// Name: SetViewMatrix() -// Desc: Given an eye point, a lookat point, and an up vector, this -// function builds a 4x4 view matrix. -//----------------------------------------------------------------------------- -HRESULT SetViewMatrix( D3DMATRIX& mat, D3DXVECTOR3& vFrom, D3DXVECTOR3& vAt, - D3DXVECTOR3& vWorldUp ) { - // Get the z basis vector, which points straight ahead. This is the - // difference from the eyepoint to the lookat point. - D3DXVECTOR3 vView = vAt - vFrom; - - float fLength = Magnitude( vView ); - if (fLength < 1e-6f) - return E_INVALIDARG; - - // Normalize the z basis vector - vView /= fLength; - - // Get the dot product, and calculate the projection of the z basis - // vector onto the up vector. The projection is the y basis vector. - float fDotProduct = DotProduct( vWorldUp, vView ); - - D3DXVECTOR3 vUp = vWorldUp - fDotProduct * vView; - - // If this vector has near-zero length because the input specified a - // bogus up vector, let's try a default up vector - if (1e-6f > ( fLength = Magnitude( vUp ) )) { - vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) - vView.y * vView; - - // If we still have near-zero length, resort to a different axis. - if (1e-6f > ( fLength = Magnitude( vUp ) )) { - vUp = D3DXVECTOR3( 0.0f, 0.0f, 1.0f ) - vView.z * vView; - - if (1e-6f > ( fLength = Magnitude( vUp ) )) - return E_INVALIDARG; - } - } - - // Normalize the y basis vector - vUp /= fLength; - - // The x basis vector is found simply with the cross product of the y - // and z basis vectors - D3DXVECTOR3 vRight = CrossProduct( vUp, vView ); - - // Start building the matrix. The first three rows contains the basis - // vectors used to rotate the view to point at the lookat point - mat._11 = vRight.x; mat._12 = vUp.x; mat._13 = vView.x; mat._14 = 0.0f; - mat._21 = vRight.y; mat._22 = vUp.y; mat._23 = vView.y; mat._24 = 0.0f; - mat._31 = vRight.z; mat._32 = vUp.z; mat._33 = vView.z; mat._34 = 0.0f; - - // Do the translation values (rotations are still about the eyepoint) - mat._41 = - DotProduct( vFrom, vRight ); - mat._42 = - DotProduct( vFrom, vUp ); - mat._43 = - DotProduct( vFrom, vView ); - mat._44 = 1.0f; - - return S_OK; -} - -#endif - HRESULT CreateDX8Cursor(LPDIRECT3DDEVICE8 pd3dDevice, HCURSOR hCursor,BOOL bAddWatermark) { // copied directly from dxsdk SetDeviceCursor HRESULT hr = E_FAIL; diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.h b/panda/src/dxgsg8/dxGraphicsStateGuardian8.h index 1894f941fb..840d59ffb4 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.h +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.h @@ -135,8 +135,6 @@ public: virtual bool wants_texcoords(void) const; - virtual bool depth_offset_decals(); - INLINE float compute_distance_to(const LPoint3f &point) const; virtual void set_color_clear_value(const Colorf& value); diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index aacdd32003..02f7e7876a 100755 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -37,11 +37,6 @@ NotifyCategoryDef(wdxdisplay9, "windisplay"); ConfigVariableBool dx_show_transforms ("dx-show-transforms", false); -// Configure this to TRUE if you want DirectX to control the entire screen, -// If false, it will just blit into a window. -ConfigVariableBool dx_full_screen -("dx-full-screen", false); - // Configure this true to force the rendering to sync to the video // refresh, or false to let your frame rate go as high as it can, // irrespective of the video refresh. @@ -52,12 +47,6 @@ ConfigVariableBool dx_sync_video ConfigVariableInt dx_multisample_antialiasing_level ("dx-multisample-antialiasing-level", 0); -// Configure this true to perform a cull traversal over the geometry -// by default, false otherwise. The cull traversal provides support -// for state-sorting, z-sorting, and binning. -ConfigVariableBool dx_cull_traversal -("dx-cull-traversal", true); - // if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability ConfigVariableBool dx_no_vertex_fog ("dx-no-vertex-fog", false); diff --git a/panda/src/dxgsg9/config_dxgsg9.h b/panda/src/dxgsg9/config_dxgsg9.h index a313d2e0a8..c10eec4644 100755 --- a/panda/src/dxgsg9/config_dxgsg9.h +++ b/panda/src/dxgsg9/config_dxgsg9.h @@ -29,9 +29,7 @@ NotifyCategoryDecl(dxgsg9, EXPCL_PANDADX, EXPTP_PANDADX); NotifyCategoryDecl(wdxdisplay9, EXPCL_PANDADX, EXPTP_PANDADX); -extern ConfigVariableBool dx_full_screen; extern ConfigVariableBool dx_sync_video; -extern ConfigVariableBool dx_cull_traversal; extern ConfigVariableBool dx_no_vertex_fog; extern ConfigVariableBool dx_show_cursor_watermark; extern ConfigVariableBool dx_full_screen_antialiasing; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index a2b5dcf923..da7783fde2 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -73,10 +73,6 @@ // for sprites, 1000 prims, 6 verts/prim, 24 bytes/vert const int VERT_BUFFER_SIZE = (32*6*1024L); -// if defined, pandadx only handles 1 panda display region -// note multiple region code doesnt work now (see prepare_display_region,set_clipper) -#define NO_MULTIPLE_DISPLAY_REGIONS - TypeHandle DXGraphicsStateGuardian9::_type_handle; // bit masks used for drawing primitives @@ -574,33 +570,6 @@ dx_init(void) { void DXGraphicsStateGuardian9:: support_overlay_window(bool flag) { // How is this supposed to be done in DX9? - - /* - if (_overlay_windows_supported && !flag) { - // Disable support for overlay windows. - _overlay_windows_supported = false; - - if (dx_full_screen) { - _pD3DDevicesPrimary->SetClipper(NULL); - } - - } else if (!_overlay_windows_supported && flag) { - // Enable support for overlay windows. - _overlay_windows_supported = true; - - if (dx_full_screen) { - // Create a Clipper object to blt the whole screen. - LPDIRECTDRAWCLIPPER Clipper; - - if (_pScrn->pDD->CreateClipper(0, &Clipper, NULL) == DD_OK) { - Clipper->SetHWnd(0, _pScrn->hWnd); - _pScrn->pddsPrimary->SetClipper(Clipper); - } - _pScrn->pDD->FlipToGDISurface(); - Clipper->Release(); - } - } - */ } //////////////////////////////////////////////////////////////////// @@ -732,54 +701,6 @@ prepare_lens() { return SUCCEEDED(hr); } -#ifndef NO_MULTIPLE_DISPLAY_REGIONS -//////////////////////////////////////////////////////////////////// -// Function: set_clipper -// Access: -// Description: Useless in DX at the present time -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian9::set_clipper(RECT cliprect) { - - LPDIRECTDRAWCLIPPER Clipper; - HRESULT result; - - // For windowed mode, the clip region is associated with the window, - // and DirectX does not allow you to create clip regions. - if (dx_full_screen) return; - - /* The cliprect we receive is normalized so that (0,0) means the upper left of - the client portion of the window. - At least, I think that's true, and the following code assumes that. - So we must adjust the clip region by offsetting it to the origin of the - view rectangle. - */ - clip_rect = cliprect; // store the normalized clip rect - cliprect.left += _view_rect.left; - cliprect.right += _view_rect.left; - cliprect.top += _view_rect.top; - cliprect.bottom += _view_rect.top; - RGNDATA *rgn_data = (RGNDATA *)malloc(sizeof(RGNDATAHEADER) + sizeof(RECT)); - HRGN hrgn = CreateRectRgn(cliprect.left, cliprect.top, cliprect.right, cliprect.bottom); - GetRegionData(hrgn, sizeof(RGNDATAHEADER) + sizeof(RECT), rgn_data); - - if (_pD3DDevicesPrimary->GetClipper(&Clipper) != DD_OK) { - result = _pD3DDevice->CreateClipper(0, &Clipper, NULL); - result = Clipper->SetClipList(rgn_data, 0); - result = _pD3DDevicesPrimary->SetClipper(Clipper); - } else { - result = Clipper->SetClipList(rgn_data, 0 ); - if (result == DDERR_CLIPPERISUSINGHWND) { - result = _pD3DDevicesPrimary->SetClipper(NULL); - result = _pD3DDevice->CreateClipper(0, &Clipper, NULL); - result = Clipper->SetClipList(rgn_data, 0 ) ; - result = _pD3DDevicesPrimary->SetClipper(Clipper); - } - } - free(rgn_data); - DeleteObject(hrgn); -} -#endif - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian9::get_blend_func // Access: Protected, Static @@ -3761,20 +3682,6 @@ end_frame() { GraphicsStateGuardian::end_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::depth_offset_decals -// Access: Public, Virtual -// Description: Returns true if this GSG can implement decals using a -// DepthOffsetAttrib, or false if that is unreliable -// and the three-step rendering process should be used -// instead. -//////////////////////////////////////////////////////////////////// -bool DXGraphicsStateGuardian9:: -depth_offset_decals() { - // False for now. - return false; -} - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian9::set_draw_buffer // Access: Protected @@ -4380,13 +4287,12 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *pPresParams, DXScreenData **pScrn) { ReleaseAllDeviceObjects(); - if(!dx_full_screen) { - // for windowed make sure out format matches the desktop fmt, in case the - // desktop mode has been changed + // for windowed mode make sure our format matches the desktop fmt, + // in case the desktop mode has been changed + + _pScrn->pD3D9->GetAdapterDisplayMode(_pScrn->CardIDNum, &_pScrn->DisplayMode); + pPresParams->BackBufferFormat = _pScrn->DisplayMode.Format; - _pScrn->pD3D9->GetAdapterDisplayMode(_pScrn->CardIDNum, &_pScrn->DisplayMode); - pPresParams->BackBufferFormat = _pScrn->DisplayMode.Format; - } // here we have to look at the _PresReset frame buffer dimension // if current window's dimension is bigger than _PresReset // we have to reset the device before creating new swapchain. @@ -4499,146 +4405,6 @@ CheckCooperativeLevel(bool bDoReactivateWindow) { return SUCCEEDED(hr); } -/* -//////////////////////////////////////////////////////////////////// -// Function: adjust_view_rect -// Access: -// Description: we receive the new x and y position of the client -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian9::adjust_view_rect(int x, int y) { - if (_pScrn->view_rect.left != x || _pScrn->view_rect.top != y) { - - _pScrn->view_rect.right = x + RECT_XSIZE(_pScrn->view_rect); - _pScrn->view_rect.left = x; - _pScrn->view_rect.bottom = y + RECT_YSIZE(_pScrn->view_rect); - _pScrn->view_rect.top = y; - -// set_clipper(clip_rect); - } -} -*/ - -#if 0 - -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::save_mipmap_images -// Access: Protected -// Description: Saves out each mipmap level of the indicated texture -// (which must also be the currently active texture in -// the GL state) as a separate image file to disk. -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian9::read_mipmap_images(Texture *tex) { - Filename filename = tex->get_name(); - string name; - if (filename.empty()) { - static index = 0; - name = "texture" + format_string(index); - index++; - } else { - name = filename.get_basename_wo_extension(); - } - - PixelBuffer *pb = tex->get_ram_image(); - nassertv(pb != (PixelBuffer *)NULL); - - GLenum external_format = get_external_image_format(pb->get_format()); - GLenum type = get_image_type(pb->get_image_type()); - - int xsize = pb->get_xsize(); - int ysize = pb->get_ysize(); - - // Specify byte-alignment for the pixels on output. - glPixelStorei(GL_PACK_ALIGNMENT, 1); - - int mipmap_level = 0; - do { - xsize = max(xsize, 1); - ysize = max(ysize, 1); - - PT(PixelBuffer) mpb = - new PixelBuffer(xsize, ysize, pb->get_num_components(), - pb->get_component_width(), pb->get_image_type(), - pb->get_format()); - glGetTexImage(GL_TEXTURE_2D, mipmap_level, external_format, - type, mpb->_image); - Filename mipmap_filename = name + "_" + format_string(mipmap_level) + ".pnm"; - nout << "Writing mipmap level " << mipmap_level - << " (" << xsize << " by " << ysize << ") " - << mipmap_filename << "\n"; - mpb->write(mipmap_filename); - - xsize >>= 1; - ysize >>= 1; - mipmap_level++; - } while (xsize > 0 && ysize > 0); -} -#endif - - -#if 0 -//----------------------------------------------------------------------------- -// Name: SetViewMatrix() -// Desc: Given an eye point, a lookat point, and an up vector, this -// function builds a 4x4 view matrix. -//----------------------------------------------------------------------------- -HRESULT SetViewMatrix( D3DMATRIX& mat, D3DXVECTOR3& vFrom, D3DXVECTOR3& vAt, - D3DXVECTOR3& vWorldUp ) { - // Get the z basis vector, which points straight ahead. This is the - // difference from the eyepoint to the lookat point. - D3DXVECTOR3 vView = vAt - vFrom; - - float fLength = Magnitude( vView ); - if (fLength < 1e-6f) - return E_INVALIDARG; - - // Normalize the z basis vector - vView /= fLength; - - // Get the dot product, and calculate the projection of the z basis - // vector onto the up vector. The projection is the y basis vector. - float fDotProduct = DotProduct( vWorldUp, vView ); - - D3DXVECTOR3 vUp = vWorldUp - fDotProduct * vView; - - // If this vector has near-zero length because the input specified a - // bogus up vector, let's try a default up vector - if (1e-6f > ( fLength = Magnitude( vUp ) )) { - vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) - vView.y * vView; - - // If we still have near-zero length, resort to a different axis. - if (1e-6f > ( fLength = Magnitude( vUp ) )) { - vUp = D3DXVECTOR3( 0.0f, 0.0f, 1.0f ) - vView.z * vView; - - if (1e-6f > ( fLength = Magnitude( vUp ) )) - return E_INVALIDARG; - } - } - - // Normalize the y basis vector - vUp /= fLength; - - // The x basis vector is found simply with the cross product of the y - // and z basis vectors - D3DXVECTOR3 vRight = CrossProduct( vUp, vView ); - - // Start building the matrix. The first three rows contains the basis - // vectors used to rotate the view to point at the lookat point - mat._11 = vRight.x; mat._12 = vUp.x; mat._13 = vView.x; mat._14 = 0.0f; - mat._21 = vRight.y; mat._22 = vUp.y; mat._23 = vView.y; mat._24 = 0.0f; - mat._31 = vRight.z; mat._32 = vUp.z; mat._33 = vView.z; mat._34 = 0.0f; - - // Do the translation values (rotations are still about the eyepoint) - mat._41 = - DotProduct( vFrom, vRight ); - mat._42 = - DotProduct( vFrom, vUp ); - mat._43 = - DotProduct( vFrom, vView ); - mat._44 = 1.0f; - - return S_OK; -} - -#endif - - HRESULT CreateDX9Cursor(LPDIRECT3DDEVICE9 pd3dDevice, HCURSOR hCursor,BOOL bAddWatermark) { // copied directly from dxsdk SetDeviceCursor HRESULT hr = E_FAIL; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index f48facb3b2..f9c8e0d490 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -136,8 +136,6 @@ public: virtual bool wants_texcoords(void) const; - virtual bool depth_offset_decals(); - INLINE float compute_distance_to(const LPoint3f &point) const; virtual void set_color_clear_value(const Colorf& value); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index ea44976659..906d5402e1 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -414,19 +414,14 @@ reset() { report_my_gl_errors(); - _buffer_mask = 0; - - // All GL implementations have the following buffers. (?) + // All GL implementations have the following buffers. _buffer_mask = (RenderBuffer::T_color | RenderBuffer::T_depth | RenderBuffer::T_stencil | RenderBuffer::T_accum); - // Check to see if we have double-buffering. - - // This isn't completely right. Instead of just clearing this bit - // and disallowing writes to T_back, we need to set T_front on - // operations that might have had T_back set otherwise. + // If we don't have double-buffering, don't attempt to write to the + // back buffer. GLboolean has_back; GLP(GetBooleanv)(GL_DOUBLEBUFFER, &has_back); if (!has_back) { @@ -2831,19 +2826,6 @@ wants_texcoords() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::depth_offset_decals -// Access: Public, Virtual -// Description: Returns true if this GSG can implement decals using a -// DepthOffsetAttrib, or false if that is unreliable -// and the three-step rendering process should be used -// instead. -//////////////////////////////////////////////////////////////////// -bool CLP(GraphicsStateGuardian):: -depth_offset_decals() { - return CLP(depth_offset_decals); -} - //////////////////////////////////////////////////////////////////// // Function: CLP(GraphicsStateGuardian)::compute_distance_to // Access: Public, Virtual diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 173b0b103e..920e053cdb 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -132,8 +132,6 @@ public: virtual bool wants_texcoords(void) const; - virtual bool depth_offset_decals(); - virtual float compute_distance_to(const LPoint3f &point) const; void print_gfx_visual(); diff --git a/panda/src/glstuff/glmisc_src.cxx b/panda/src/glstuff/glmisc_src.cxx index c883e5f822..340df594bd 100644 --- a/panda/src/glstuff/glmisc_src.cxx +++ b/panda/src/glstuff/glmisc_src.cxx @@ -52,11 +52,6 @@ bool CLP(save_mipmaps) = CONFIGOBJ.GetBool("gl-save-mipmaps", false); // variable. bool CLP(auto_normalize_lighting) = CONFIGOBJ.GetBool("auto-normalize-lighting", true); -// Configure this true to try to implement decals using a -// DepthOffsetAttrib, false to do them with the more reliable 3-pass -// rendering method instead. -bool CLP(depth_offset_decals) = CONFIGOBJ.GetBool("depth-offset-decals", false); - // Configure this false if your GL's implementation of GLP(ColorMask)() // is broken (some are). This will force the use of a (presumably) // more expensive blending operation instead. diff --git a/panda/src/glstuff/glmisc_src.h b/panda/src/glstuff/glmisc_src.h index 89fc96966b..545c415876 100644 --- a/panda/src/glstuff/glmisc_src.h +++ b/panda/src/glstuff/glmisc_src.h @@ -28,7 +28,6 @@ extern bool CLP(force_mipmaps); extern bool CLP(show_mipmaps); extern bool CLP(save_mipmaps); extern bool CLP(auto_normalize_lighting); -extern bool CLP(depth_offset_decals); extern bool CLP(color_mask); extern EXPCL_GL void CLP(init_classes)(); diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index 6cedd483a1..9a2773a880 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -100,15 +100,10 @@ make_gsg(const FrameBufferProperties &properties, DCAST_INTO_R(share_gsg, share_with, NULL); } - // Make a copy of the supplied properties so we can possibly modify - // them to suit our available properties. - FrameBufferProperties new_properties = properties; - // We need a DC to examine the available pixel formats. We'll use // the screen DC. HDC hdc = GetDC(NULL); - int pfnum = choose_pfnum(new_properties, hdc); - ReleaseDC(NULL, hdc); + int pfnum = choose_pfnum(properties, hdc); if (gl_force_pixfmt != 0) { wgldisplay_cat.info() @@ -117,13 +112,18 @@ make_gsg(const FrameBufferProperties &properties, pfnum = gl_force_pixfmt; } + FrameBufferProperties new_properties; + get_properties(new_properties, hdc, pfnum); + ReleaseDC(NULL, hdc); + if (wgldisplay_cat.is_debug()) { wgldisplay_cat.debug() - << "config() - picking pixfmt #" << pfnum <