GraphicsOutputBase

This commit is contained in:
David Rose 2009-05-28 00:42:53 +00:00
parent 040dcfc333
commit 8d234769ab
14 changed files with 124 additions and 20 deletions

View File

@ -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.
////////////////////////////////////////////////////////////////////

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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();
}

View File

@ -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."
//
////////////////////////////////////////////////////////////////////

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -1,5 +1,6 @@
#include "config_gsgbase.cxx"
#include "displayRegionBase.cxx"
#include "graphicsOutputBase.cxx"
#include "graphicsStateGuardianBase.cxx"

View File

@ -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);

View File

@ -75,13 +75,9 @@ LightLensNode(const LightLensNode &copy) :
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();
}

View File

@ -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<CPT(GraphicsStateGuardianBase), PT(TypedWritableReferenceCount) > ShadowBuffers;
// This is really a map of GSG -> GraphicsOutput.
typedef pmap<PT(GraphicsStateGuardianBase), PT(GraphicsOutputBase) > ShadowBuffers;
ShadowBuffers _sbuffers;
public: