diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 1e1f37ffd8..7565de3d2e 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -436,7 +436,7 @@ set_inverted(bool inverted) { //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::set_sort -// Access: Published +// Access: Published, Virtual // Description: Adjusts the sorting order of this particular // GraphicsOutput, relative to other GraphicsOutputs. //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index bab85210b7..4936805256 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -23,6 +23,7 @@ #include "graphicsStateGuardian.h" #include "drawableRegion.h" #include "renderBuffer.h" +#include "graphicsOutputBase.h" #include "typedWritableReferenceCount.h" #include "pandaNode.h" @@ -58,7 +59,7 @@ class GraphicsEngine; // TypedWritableReferenceCount instead of // TypedReferenceCount for that convenience. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_DISPLAY GraphicsOutput : public TypedWritableReferenceCount, public DrawableRegion { +class EXPCL_PANDA_DISPLAY GraphicsOutput : public GraphicsOutputBase, public DrawableRegion { protected: GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -135,7 +136,7 @@ PUBLISHED: INLINE void clear_delete_flag(); INLINE bool get_delete_flag() const; - void set_sort(int sort); + virtual void set_sort(int sort); INLINE int get_sort() const; INLINE void set_child_sort(int child_sort); @@ -313,9 +314,9 @@ public: return _type_handle; } static void init_type() { - TypedWritableReferenceCount::init_type(); + GraphicsOutputBase::init_type(); register_type(_type_handle, "GraphicsOutput", - TypedWritableReferenceCount::get_class_type()); + GraphicsOutputBase::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index bfd1b5bdec..4453a558a6 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -1305,6 +1305,23 @@ clear_state_and_transform() { _state_mask.clear(); } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsStateGuardian::remove_window +// Access: Public, Virtual +// Description: This is simply a transparent call to +// GraphicsEngine::remove_window(). It exists primary +// to support removing a window from that compiles +// before the display module, and therefore has no +// knowledge of a GraphicsEngine object. +//////////////////////////////////////////////////////////////////// +void GraphicsStateGuardian:: +remove_window(GraphicsOutputBase *window) { + nassertv(_engine != (GraphicsEngine *)NULL); + GraphicsOutput *win; + DCAST_INTO_V(win, window); + _engine->remove_window(win); +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::prepare_lens // Access: Public, Virtual diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 660d6205a1..d4ba5d73e7 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -228,6 +228,8 @@ public: virtual void clear_before_callback(); virtual void clear_state_and_transform(); + virtual void remove_window(GraphicsOutputBase *window); + virtual CPT(TransformState) calc_projection_mat(const Lens *lens); virtual bool prepare_lens(); diff --git a/panda/src/gsgbase/Sources.pp b/panda/src/gsgbase/Sources.pp index e9772a9336..f16b02129b 100644 --- a/panda/src/gsgbase/Sources.pp +++ b/panda/src/gsgbase/Sources.pp @@ -11,15 +11,18 @@ #define SOURCES \ config_gsgbase.h \ displayRegionBase.I displayRegionBase.h \ + graphicsOutputBase.I graphicsOutputBase.h \ graphicsStateGuardianBase.h #define INCLUDED_SOURCES \ config_gsgbase.cxx \ displayRegionBase.cxx \ + graphicsOutputBase.cxx \ graphicsStateGuardianBase.cxx #define INSTALL_HEADERS \ displayRegionBase.I displayRegionBase.h \ + graphicsOutputBase.I graphicsOutputBase.h \ graphicsStateGuardianBase.h #define IGATESCAN all diff --git a/panda/src/gsgbase/config_gsgbase.cxx b/panda/src/gsgbase/config_gsgbase.cxx index 5ea6f4159f..1f87e8558d 100644 --- a/panda/src/gsgbase/config_gsgbase.cxx +++ b/panda/src/gsgbase/config_gsgbase.cxx @@ -14,6 +14,7 @@ #include "config_gsgbase.h" #include "displayRegionBase.h" +#include "graphicsOutputBase.h" #include "graphicsStateGuardianBase.h" #include "dconfig.h" @@ -22,5 +23,6 @@ Configure(config_gsgbase); ConfigureFn(config_gsgbase) { DisplayRegionBase::init_type(); + GraphicsOutputBase::init_type(); GraphicsStateGuardianBase::init_type(); } diff --git a/panda/src/gsgbase/graphicsOutputBase.I b/panda/src/gsgbase/graphicsOutputBase.I new file mode 100644 index 0000000000..9d3dce114d --- /dev/null +++ b/panda/src/gsgbase/graphicsOutputBase.I @@ -0,0 +1,14 @@ +// Filename: graphicsOutputBase.I +// Created by: drose (27May09) +// +//////////////////////////////////////////////////////////////////// +// +// 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." +// +//////////////////////////////////////////////////////////////////// + diff --git a/panda/src/gsgbase/graphicsOutputBase.cxx b/panda/src/gsgbase/graphicsOutputBase.cxx new file mode 100644 index 0000000000..0506295730 --- /dev/null +++ b/panda/src/gsgbase/graphicsOutputBase.cxx @@ -0,0 +1,17 @@ +// Filename: graphicsOutputBase.cxx +// Created by: drose (27May09) +// +//////////////////////////////////////////////////////////////////// +// +// 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 "graphicsOutputBase.h" + +TypeHandle GraphicsOutputBase::_type_handle; diff --git a/panda/src/gsgbase/graphicsOutputBase.h b/panda/src/gsgbase/graphicsOutputBase.h new file mode 100644 index 0000000000..40ade50dcc --- /dev/null +++ b/panda/src/gsgbase/graphicsOutputBase.h @@ -0,0 +1,54 @@ +// Filename: graphicsOutputBase.h +// Created by: drose (27May09) +// +//////////////////////////////////////////////////////////////////// +// +// 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 GRAPHICSOUTPUTBASE_H +#define GRAPHICSOUTPUTBASE_H + +#include "pandabase.h" +#include "typedWritableReferenceCount.h" + +//////////////////////////////////////////////////////////////////// +// Class : GraphicsOutputBase +// Description : An abstract base class for GraphicsOutput, for all +// the usual reasons. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA_GSGBASE GraphicsOutputBase : public TypedWritableReferenceCount { +PUBLISHED: + virtual void set_sort(int sort)=0; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedWritableReferenceCount::init_type(); + register_type(_type_handle, "GraphicsOutputBase", + TypedWritableReferenceCount::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; + + friend class GraphicsPipe; + friend class GraphicsEngine; + friend class DisplayRegion; +}; + +#include "graphicsOutputBase.I" + +#endif diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.h b/panda/src/gsgbase/graphicsStateGuardianBase.h index 88e02111bb..6fd7227b5d 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.h +++ b/panda/src/gsgbase/graphicsStateGuardianBase.h @@ -27,6 +27,7 @@ class Thread; class RenderBuffer; class GraphicsWindow; class NodePath; +class GraphicsOutputBase; class VertexBufferContext; class IndexBufferContext; @@ -131,6 +132,8 @@ public: virtual void clear_before_callback()=0; virtual void clear_state_and_transform()=0; + virtual void remove_window(GraphicsOutputBase *window)=0; + #ifndef CPPPARSER // We hide this from interrogate, so that it will be properly // exported from the GraphicsStateGuardian class, later. diff --git a/panda/src/gsgbase/gsgbase_composite1.cxx b/panda/src/gsgbase/gsgbase_composite1.cxx index 3b47c01195..5a6cec2b95 100644 --- a/panda/src/gsgbase/gsgbase_composite1.cxx +++ b/panda/src/gsgbase/gsgbase_composite1.cxx @@ -1,5 +1,6 @@ #include "config_gsgbase.cxx" #include "displayRegionBase.cxx" +#include "graphicsOutputBase.cxx" #include "graphicsStateGuardianBase.cxx" diff --git a/panda/src/pgraphnodes/lightLensNode.I b/panda/src/pgraphnodes/lightLensNode.I index 3aef9e33d3..d1f1d5cd60 100644 --- a/panda/src/pgraphnodes/lightLensNode.I +++ b/panda/src/pgraphnodes/lightLensNode.I @@ -61,14 +61,10 @@ set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int buffer_so _sb_xsize = buffer_xsize; _sb_ysize = buffer_ysize; if (buffer_sort != _sb_sort) { - // drose: Temporarily commenting out--can't call set_sort() on an - // undefined class. - /* ShadowBuffers::iterator it; for(it = _sbuffers.begin(); it != _sbuffers.end(); ++it) { - it->second->set_sort(buffer_sort); + (*it).second->set_sort(buffer_sort); } - */ _sb_sort = buffer_sort; } set_active(caster); diff --git a/panda/src/pgraphnodes/lightLensNode.cxx b/panda/src/pgraphnodes/lightLensNode.cxx index c1c64fd780..19c0e892f1 100644 --- a/panda/src/pgraphnodes/lightLensNode.cxx +++ b/panda/src/pgraphnodes/lightLensNode.cxx @@ -75,13 +75,9 @@ LightLensNode(const LightLensNode ©) : void LightLensNode:: clear_shadow_buffers() { ShadowBuffers::iterator it; - // drose: Temporarily commenting out--can't call get_engine() or - // remove_window() on an undefined class. - /* for(it = _sbuffers.begin(); it != _sbuffers.end(); ++it) { - it->first->get_engine()->remove_window(it->second); + (*it).first->remove_window((*it).second); } - */ _sbuffers.clear(); } diff --git a/panda/src/pgraphnodes/lightLensNode.h b/panda/src/pgraphnodes/lightLensNode.h index 0423e23d87..0951422dac 100644 --- a/panda/src/pgraphnodes/lightLensNode.h +++ b/panda/src/pgraphnodes/lightLensNode.h @@ -20,7 +20,7 @@ #include "light.h" #include "camera.h" #include "graphicsStateGuardianBase.h" -#include "typedWritableReferenceCount.h" +#include "graphicsOutputBase.h" class ShaderGenerator; @@ -49,10 +49,8 @@ protected: int _sb_xsize, _sb_ysize, _sb_sort; double _push_bias; - // drose: This is really a map of GSG -> GraphicsOutput. - // Temporarily changed it to TypedWritableReferenceCount to allow - // compilation without circular dependencies. - typedef pmap ShadowBuffers; + // This is really a map of GSG -> GraphicsOutput. + typedef pmap ShadowBuffers; ShadowBuffers _sbuffers; public: