Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/gsgbase/graphicsStateGuardianBase.h

Go to the documentation of this file.
00001 // Filename: graphicsStateGuardianBase.h
00002 // Created by:  drose (06Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef GRAPHICSSTATEGUARDIANBASE_H
00020 #define GRAPHICSSTATEGUARDIANBASE_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "typedReferenceCount.h"
00025 #include "luse.h"
00026 
00027 // A handful of forward references.
00028 
00029 class RenderBuffer;
00030 class GraphicsWindow;
00031 
00032 class GeomContext;
00033 class GeomNodeContext;
00034 class GeomNode;
00035 class Geom;
00036 class GeomPoint;
00037 class GeomLine;
00038 class GeomLinestrip;
00039 class GeomSprite;
00040 class GeomPolygon;
00041 class GeomQuad;
00042 class GeomTri;
00043 class GeomTristrip;
00044 class GeomTrifan;
00045 class GeomSphere;
00046 
00047 class TextureContext;
00048 class Texture;
00049 class PixelBuffer;
00050 class RenderState;
00051 class TransformState;
00052 
00053 class Material;
00054 
00055 class ColorScaleAttrib;
00056 class TexMatrixAttrib;
00057 class ColorAttrib;
00058 class TextureAttrib;
00059 class LightAttrib;
00060 class MaterialAttrib;
00061 class RenderModeAttrib;
00062 class ColorBlendAttrib;
00063 class TextureApplyAttrib;
00064 class ColorWriteAttrib;
00065 class AlphaTestAttrib;
00066 class DepthTestAttrib;
00067 class DepthWriteAttrib;
00068 class TexGenAttrib;
00069 class CullFaceAttrib;
00070 class StencilAttrib;
00071 class ClipPlaneAttrib;
00072 class TransparencyAttrib;
00073 class FogAttrib;
00074 class LinesmoothAttrib;
00075 class PointShapeAttrib;
00076 class DepthOffsetAttrib;
00077 
00078 class PointLight;
00079 class DirectionalLight;
00080 class Spotlight;
00081 class AmbientLight;
00082 
00083 class DisplayRegion;
00084 class Lens;
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //       Class : GraphicsStateGuardianBase
00088 // Description : This is a base class for the GraphicsStateGuardian
00089 //               class, which is itself a base class for the various
00090 //               GSG's for different platforms.  This class contains
00091 //               all the function prototypes to support the
00092 //               double-dispatch of GSG to geoms, transitions, etc.  It
00093 //               lives in a separate class in its own package so we
00094 //               can avoid circular build dependency problems.
00095 ////////////////////////////////////////////////////////////////////
00096 class EXPCL_PANDA GraphicsStateGuardianBase : public TypedReferenceCount {
00097 public:
00098   // These functions will be queried by the GeomIssuer to determine if
00099   // it should issue normals, texcoords, and/or colors, based on the
00100   // GSG's current state.
00101   virtual bool wants_normals(void) const=0;
00102   virtual bool wants_texcoords(void) const=0;
00103   virtual bool wants_colors(void) const=0;
00104 
00105   // These are some general interface functions; they're defined here
00106   // mainly to make it easy to call these from code in some directory
00107   // that display depends on.
00108   virtual TextureContext *prepare_texture(Texture *tex)=0;
00109   virtual void apply_texture(TextureContext *tc)=0;
00110   virtual void release_texture(TextureContext *tc)=0;
00111 
00112   virtual GeomNodeContext *prepare_geom_node(GeomNode *node)=0;
00113   virtual void draw_geom_node(GeomNode *node, const RenderState *state,
00114                               GeomNodeContext *gnc)=0;
00115   virtual void release_geom_node(GeomNodeContext *gnc)=0;
00116 
00117   virtual GeomContext *prepare_geom(Geom *geom)=0;
00118   virtual void release_geom(GeomContext *gc)=0;
00119 
00120   virtual void set_state_and_transform(const RenderState *state,
00121                                        const TransformState *transform)=0;
00122 
00123   // This function may only be called during a render traversal; it
00124   // will compute the distance to the indicated point, assumed to be
00125   // in modelview coordinates, from the camera plane.  This is a
00126   // virtual function because different GSG's may define the modelview
00127   // coordinate space differently.
00128   virtual float compute_distance_to(const LPoint3f &point) const=0;
00129 
00130   // These are used to implement decals.  If depth_offset_decals()
00131   // returns true, none of the remaining functions will be called,
00132   // since depth offsets can be used to implement decals fully (and
00133   // usually faster).
00134   virtual bool depth_offset_decals()=0;
00135   virtual CPT(RenderState) begin_decal_base_first()=0;
00136   virtual CPT(RenderState) begin_decal_nested()=0;
00137   virtual CPT(RenderState) begin_decal_base_second()=0;
00138   virtual void finish_decal()=0;
00139 
00140   // Defined here are some internal interface functions for the
00141   // GraphicsStateGuardian.  These are here to support
00142   // double-dispatching from Geoms and NodeTransitions, and are
00143   // intended to be invoked only directly by the appropriate Geom and
00144   // NodeTransition types.  They're public only because it would be too
00145   // inconvenient to declare each of those types to be friends of this
00146   // class.
00147 
00148   virtual void draw_point(GeomPoint *geom, GeomContext *gc)=0;
00149   virtual void draw_line(GeomLine *geom, GeomContext *gc)=0;
00150   virtual void draw_linestrip(GeomLinestrip *geom, GeomContext *gc)=0;
00151   virtual void draw_sprite(GeomSprite *geom, GeomContext *gc)=0;
00152   virtual void draw_polygon(GeomPolygon *geom, GeomContext *gc)=0;
00153   virtual void draw_quad(GeomQuad *geom, GeomContext *gc)=0;
00154   virtual void draw_tri(GeomTri *geom, GeomContext *gc)=0;
00155   virtual void draw_tristrip(GeomTristrip *geom, GeomContext *gc)=0;
00156   virtual void draw_trifan(GeomTrifan *geom, GeomContext *gc)=0;
00157   virtual void draw_sphere(GeomSphere *geom, GeomContext *gc)=0;
00158 
00159   virtual void copy_texture(TextureContext *tc, const DisplayRegion *dr)=0;
00160   virtual void copy_texture(TextureContext *tc, const DisplayRegion *dr,
00161                             const RenderBuffer &rb)=0;
00162 
00163   virtual void texture_to_pixel_buffer(TextureContext *tc, PixelBuffer *pb)=0;
00164   virtual void texture_to_pixel_buffer(TextureContext *tc, PixelBuffer *pb,
00165                                 const DisplayRegion *dr)=0;
00166 
00167   virtual void copy_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr)=0;
00168   virtual void copy_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr,
00169                                  const RenderBuffer &rb)=0;
00170 
00171   virtual void apply_material(const Material *material)=0;
00172 
00173   virtual void issue_transform(const TransformState *) { }
00174   virtual void issue_alpha_test(const AlphaTestAttrib *) { }
00175   virtual void issue_color_scale(const ColorScaleAttrib *) { }
00176   virtual void issue_color(const ColorAttrib *) { }
00177   virtual void issue_tex_matrix(const TexMatrixAttrib *) { }
00178   virtual void issue_texture(const TextureAttrib *) { }
00179   virtual void issue_light(const LightAttrib *) { }
00180   virtual void issue_material(const MaterialAttrib *) { }
00181   virtual void issue_render_mode(const RenderModeAttrib *) { }
00182   virtual void issue_texture_apply(const TextureApplyAttrib *) { }
00183   virtual void issue_color_write(const ColorWriteAttrib *) { }
00184   virtual void issue_depth_test(const DepthTestAttrib *) { }
00185   virtual void issue_depth_write(const DepthWriteAttrib *) { }
00186   virtual void issue_cull_face(const CullFaceAttrib *) { }
00187   virtual void issue_transparency(const TransparencyAttrib *) { }
00188   virtual void issue_fog(const FogAttrib *) { }
00189   virtual void issue_depth_offset(const DepthOffsetAttrib *) { }
00190   virtual void issue_color_blend(const ColorBlendAttrib *) { }
00191   virtual void issue_tex_gen(const TexGenAttrib *) { }
00192   virtual void issue_stencil(const StencilAttrib *) { }
00193   virtual void issue_clip_plane(const ClipPlaneAttrib *) { }
00194 
00195   virtual void bind_light(PointLight *light, int light_id) { }
00196   virtual void bind_light(DirectionalLight *light, int light_id) { }
00197   virtual void bind_light(Spotlight *light, int light_id) { }
00198 
00199 PUBLISHED:
00200   static TypeHandle get_class_type() {
00201     return _type_handle;
00202   }
00203 
00204 public:
00205   static void init_type() {
00206     TypedReferenceCount::init_type();
00207     register_type(_type_handle, "GraphicsStateGuardianBase",
00208                   TypedReferenceCount::get_class_type());
00209   }
00210   virtual TypeHandle get_type() const {
00211     return get_class_type();
00212   }
00213   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00214 
00215 private:
00216   static TypeHandle _type_handle;
00217 };
00218 
00219 #endif

Generated on Fri May 2 00:39:47 2003 for Panda by doxygen1.3