mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
dxgsg to pgraph
This commit is contained in:
parent
88963dedb5
commit
85b45520e3
@ -263,9 +263,11 @@ setup_scene(const qpNodePath &camera, GraphicsStateGuardian *gsg) {
|
||||
}
|
||||
|
||||
scene_setup->set_scene_root(scene_root);
|
||||
scene_setup->set_camera(camera_node);
|
||||
scene_setup->set_camera_path(camera);
|
||||
scene_setup->set_camera_node(camera_node);
|
||||
scene_setup->set_lens(lens);
|
||||
scene_setup->set_camera_transform(camera_transform);
|
||||
scene_setup->set_world_transform(world_transform);
|
||||
scene_setup->set_render_transform(render_transform);
|
||||
|
||||
return scene_setup;
|
||||
@ -286,7 +288,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
|
||||
trav.set_cull_handler(cull_handler);
|
||||
trav.set_depth_offset_decals(gsg->depth_offset_decals());
|
||||
trav.set_scene(scene_setup);
|
||||
trav.set_camera_mask(scene_setup->get_camera()->get_camera_mask());
|
||||
trav.set_camera_mask(scene_setup->get_camera_node()->get_camera_mask());
|
||||
|
||||
if (qpview_frustum_cull) {
|
||||
// If we're to be performing view-frustum culling, determine the
|
||||
|
@ -158,7 +158,7 @@ reset() {
|
||||
_transparency_mode = TransparencyAttrib::M_none;
|
||||
|
||||
_has_scene_graph_color = false;
|
||||
_issued_color_stale = false;
|
||||
_scene_graph_color_stale = false;
|
||||
_vertex_colors_enabled = true;
|
||||
_lighting_enabled = false;
|
||||
|
||||
@ -1120,7 +1120,7 @@ issue_color_scale(const ColorScaleAttrib *attrib) {
|
||||
_alpha_transform_enabled = true;
|
||||
}
|
||||
|
||||
_issued_color_stale = _has_scene_graph_color;
|
||||
_scene_graph_color_stale = _has_scene_graph_color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -1145,14 +1145,14 @@ issue_color(const ColorAttrib *attrib) {
|
||||
_scene_graph_color = attrib->get_color();
|
||||
_has_scene_graph_color = true;
|
||||
_vertex_colors_enabled = false;
|
||||
_issued_color_stale = true;
|
||||
_scene_graph_color_stale = true;
|
||||
break;
|
||||
|
||||
case ColorAttrib::T_off:
|
||||
// Color attribute off: it specifies that no scene graph color is
|
||||
// in effect, and vertex color is not important either.
|
||||
_has_scene_graph_color = false;
|
||||
_issued_color_stale = false;
|
||||
_scene_graph_color_stale = false;
|
||||
_vertex_colors_enabled = false;
|
||||
break;
|
||||
|
||||
@ -1160,7 +1160,7 @@ issue_color(const ColorAttrib *attrib) {
|
||||
// Color attribute vertex: it specifies that vertex color should
|
||||
// be revealed.
|
||||
_has_scene_graph_color = false;
|
||||
_issued_color_stale = false;
|
||||
_scene_graph_color_stale = false;
|
||||
_vertex_colors_enabled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ protected:
|
||||
|
||||
Colorf _scene_graph_color;
|
||||
bool _has_scene_graph_color;
|
||||
bool _issued_color_stale;
|
||||
bool _scene_graph_color_stale;
|
||||
bool _vertex_colors_enabled;
|
||||
bool _lighting_enabled;
|
||||
|
||||
|
@ -80,6 +80,11 @@ bool dx_use_rangebased_fog = config_dxgsg.GetBool("dx-use-rangebased-fog", false
|
||||
bool dx_force_16bpptextures = config_dxgsg.GetBool("dx-force-16bpptextures", false);
|
||||
bool dx_no_dithering = config_dxgsg.GetBool("dx-no-dithering", false);
|
||||
|
||||
// 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 dx_depth_offset_decals = config_dxgsg.GetBool("depth-offset-decals", false);
|
||||
|
||||
#ifdef _DEBUG
|
||||
float dx_global_miplevel_bias = config_dxgsg.GetFloat("dx-global-miplevel-bias", 0.0);
|
||||
bool dx_debug_view_mipmaps = config_dxgsg.GetBool("dx-debug-view-mipmaps", false);
|
||||
|
@ -44,6 +44,8 @@ extern bool dx_show_transforms;
|
||||
extern bool dx_force_16bpptextures;
|
||||
extern bool dx_no_dithering;
|
||||
|
||||
extern bool dx_depth_offset_decals;
|
||||
|
||||
#ifndef NDEBUG
|
||||
extern int dx_force_backface_culling;
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,23 +20,26 @@
|
||||
#define DXGRAPHICSSTATEGUARDIAN_H
|
||||
|
||||
#include "dxgsgbase.h"
|
||||
#include <graphicsStateGuardian.h>
|
||||
#include <geomprimitives.h>
|
||||
#include <texture.h>
|
||||
#include <pixelBuffer.h>
|
||||
#include <displayRegion.h>
|
||||
#include <material.h>
|
||||
#include <textureApplyProperty.h>
|
||||
#include <depthTestProperty.h>
|
||||
#include <stencilProperty.h>
|
||||
#include <fog.h>
|
||||
#include <renderModeProperty.h>
|
||||
#include <colorMatrixTransition.h>
|
||||
#include <alphaTransformTransition.h>
|
||||
#include <pointerToArray.h>
|
||||
#include <planeNode.h>
|
||||
#include "graphicsStateGuardian.h"
|
||||
#include "geomprimitives.h"
|
||||
#include "texture.h"
|
||||
#include "pixelBuffer.h"
|
||||
#include "displayRegion.h"
|
||||
#include "material.h"
|
||||
#include "textureApplyProperty.h"
|
||||
#include "depthTestProperty.h"
|
||||
#include "depthTestAttrib.h"
|
||||
#include "stencilProperty.h"
|
||||
#include "fog.h"
|
||||
#include "qpfog.h"
|
||||
#include "renderModeProperty.h"
|
||||
#include "colorMatrixTransition.h"
|
||||
#include "alphaTransformTransition.h"
|
||||
#include "pointerToArray.h"
|
||||
#include "planeNode.h"
|
||||
#include "dxGeomNodeContext.h"
|
||||
#include "dxTextureContext.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class PlaneNode;
|
||||
@ -77,6 +80,7 @@ public:
|
||||
virtual void clear(const RenderBuffer &buffer, const DisplayRegion* region);
|
||||
|
||||
virtual void prepare_display_region();
|
||||
virtual bool prepare_lens();
|
||||
|
||||
virtual void render_frame();
|
||||
virtual void render_scene(Node *root, LensNode *projnode);
|
||||
@ -129,6 +133,7 @@ public:
|
||||
|
||||
virtual void apply_material(const Material *material);
|
||||
virtual void apply_fog(Fog *fog);
|
||||
virtual void apply_fog(qpFog *fog);
|
||||
|
||||
virtual void issue_transform(const TransformTransition *attrib);
|
||||
virtual void issue_tex_matrix(const TexMatrixTransition *attrib);
|
||||
@ -151,13 +156,34 @@ public:
|
||||
virtual void issue_fog(const FogTransition *attrib);
|
||||
virtual void issue_linesmooth(const LinesmoothTransition *attrib);
|
||||
|
||||
virtual void issue_transform(const TransformState *transform);
|
||||
virtual void issue_tex_matrix(const TexMatrixAttrib *attrib);
|
||||
virtual void issue_texture(const TextureAttrib *attrib);
|
||||
virtual void issue_material(const MaterialAttrib *attrib);
|
||||
virtual void issue_render_mode(const RenderModeAttrib *attrib);
|
||||
virtual void issue_texture_apply(const TextureApplyAttrib *attrib);
|
||||
virtual void issue_depth_test(const DepthTestAttrib *attrib);
|
||||
virtual void issue_depth_write(const DepthWriteAttrib *attrib);
|
||||
virtual void issue_cull_face(const CullFaceAttrib *attrib);
|
||||
virtual void issue_fog(const FogAttrib *attrib);
|
||||
virtual void issue_depth_offset(const DepthOffsetAttrib *attrib);
|
||||
|
||||
virtual void bind_light(PointLight *light, int light_id);
|
||||
virtual void bind_light(DirectionalLight *light, int light_id);
|
||||
virtual void bind_light(Spotlight *light, int light_id);
|
||||
|
||||
virtual void begin_frame();
|
||||
virtual void end_frame();
|
||||
|
||||
virtual bool wants_normals(void) const;
|
||||
virtual bool wants_texcoords(void) const;
|
||||
virtual bool wants_colors(void) const;
|
||||
|
||||
virtual void begin_decal(GeomNode *base_geom, AllTransitionsWrapper &attrib);
|
||||
virtual void end_decal(GeomNode *base_geom);
|
||||
|
||||
virtual bool depth_offset_decals();
|
||||
|
||||
virtual CoordinateSystem get_internal_coordinate_system() const;
|
||||
INLINE float compute_distance_to(const LPoint3f &point) const;
|
||||
virtual void set_color_clear_value(const Colorf& value);
|
||||
|
||||
@ -172,8 +198,13 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void enable_lighting(bool enable);
|
||||
virtual void set_ambient_light(const Colorf &color);
|
||||
virtual void enable_light(int light_id, bool enable);
|
||||
|
||||
virtual void set_blend_mode(ColorWriteAttrib::Mode color_write_mode,
|
||||
ColorBlendAttrib::Mode color_blend_mode,
|
||||
TransparencyAttrib::Mode transparency_mode);
|
||||
|
||||
void free_pointers(); // free local internal buffers
|
||||
void free_dxgsg_objects(void); // free the DirectX objects we create
|
||||
virtual PT(SavedFrameBuffer) save_frame_buffer(const RenderBuffer &buffer,
|
||||
@ -224,7 +255,9 @@ protected:
|
||||
|
||||
INLINE D3DTEXTUREADDRESS get_texture_wrap_mode(Texture::WrapMode wm) const;
|
||||
INLINE D3DCMPFUNC get_depth_func_type(DepthTestProperty::Mode m) const;
|
||||
INLINE D3DCMPFUNC get_depth_func_type(DepthTestAttrib::Mode m) const;
|
||||
INLINE D3DFOGMODE get_fog_mode_type(Fog::Mode m) const;
|
||||
INLINE D3DFOGMODE get_fog_mode_type(qpFog::Mode m) const;
|
||||
|
||||
INLINE D3DCMPFUNC get_stencil_func_type(StencilProperty::Mode m) const;
|
||||
INLINE D3DSTENCILOP get_stencil_action_type(StencilProperty::Action a) const;
|
||||
@ -254,10 +287,7 @@ protected:
|
||||
DWORD _curFVFflags;
|
||||
DWORD _perPrim,_perVertex,_perComp; // these hold DrawLoopFlags bitmask values
|
||||
|
||||
bool _issued_color_enabled; // WBD ADDED
|
||||
bool _enable_all_color;
|
||||
Colorf _issued_color; // WBD ADDED
|
||||
D3DCOLOR _issued_color_D3DCOLOR; // WBD ADDED
|
||||
D3DCOLOR _scene_graph_color_D3DCOLOR;
|
||||
D3DCOLOR _d3dcolor_clear_value;
|
||||
D3DSHADEMODE _CurShadeMode;
|
||||
|
||||
@ -342,12 +372,7 @@ protected:
|
||||
|
||||
// Color/Alpha Matrix Transition stuff
|
||||
INLINE void transform_color(Colorf &InColor,D3DCOLOR &OutColor);
|
||||
bool _color_transform_required; // _color_transform_enabled || _alpha_transform_enabled
|
||||
bool _color_transform_enabled;
|
||||
bool _alpha_transform_enabled;
|
||||
LMatrix4f _current_color_mat;
|
||||
float _current_alpha_offset;
|
||||
float _current_alpha_scale;
|
||||
|
||||
bool _overlay_windows_supported;
|
||||
|
||||
// vars for frames/sec meter
|
||||
|
@ -1088,9 +1088,9 @@ get_clip_plane_id(int index) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GLGraphicsStateGuardian::
|
||||
issue_scene_graph_color() {
|
||||
if (_issued_color_stale) {
|
||||
if (_scene_graph_color_stale) {
|
||||
issue_transformed_color(_scene_graph_color);
|
||||
_issued_color_stale = false;
|
||||
_scene_graph_color_stale = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2506,7 +2506,7 @@ issue_color_transform(const ColorMatrixTransition *attrib) {
|
||||
_color_transform_enabled = true;
|
||||
}
|
||||
|
||||
_issued_color_stale = _has_scene_graph_color;
|
||||
_scene_graph_color_stale = _has_scene_graph_color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -2525,7 +2525,7 @@ issue_alpha_transform(const AlphaTransformTransition *attrib) {
|
||||
_alpha_transform_enabled = true;
|
||||
}
|
||||
|
||||
_issued_color_stale = _has_scene_graph_color;
|
||||
_scene_graph_color_stale = _has_scene_graph_color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -2559,21 +2559,21 @@ issue_color(const ColorTransition *attrib) {
|
||||
_scene_graph_color = attrib->get_color();
|
||||
_has_scene_graph_color = true;
|
||||
_vertex_colors_enabled = false;
|
||||
_issued_color_stale = true;
|
||||
_scene_graph_color_stale = true;
|
||||
|
||||
} else {
|
||||
// The color attribute is "on" but not "real": it specifies that
|
||||
// no scene graph color is in effect, but vertex color is not
|
||||
// important either.
|
||||
_has_scene_graph_color = false;
|
||||
_issued_color_stale = false;
|
||||
_scene_graph_color_stale = false;
|
||||
_vertex_colors_enabled = false;
|
||||
}
|
||||
} else {
|
||||
// The color attribute is "off": it specifies that vertex color
|
||||
// should be revealed.
|
||||
_has_scene_graph_color = false;
|
||||
_issued_color_stale = false;
|
||||
_scene_graph_color_stale = false;
|
||||
_vertex_colors_enabled = true;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
INLINE SceneSetup::
|
||||
SceneSetup() {
|
||||
_camera_transform = TransformState::make_identity();
|
||||
_world_transform = TransformState::make_identity();
|
||||
_render_transform = TransformState::make_identity();
|
||||
}
|
||||
|
||||
@ -49,23 +50,43 @@ get_scene_root() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneSetup::set_camera
|
||||
// Function: SceneSetup::set_camera_path
|
||||
// Access: Public
|
||||
// Description: Specifies the NodePath to the camera.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void SceneSetup::
|
||||
set_camera_path(const qpNodePath &camera_path) {
|
||||
_camera_path = camera_path;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneSetup::get_camera_path
|
||||
// Access: Public
|
||||
// Description: Returns the NodePath to the camera.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const qpNodePath &SceneSetup::
|
||||
get_camera_path() const {
|
||||
return _camera_path;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneSetup::set_camera_node
|
||||
// Access: Public
|
||||
// Description: Specifies the camera used to render the scene.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void SceneSetup::
|
||||
set_camera(const qpCamera *camera) {
|
||||
_camera = camera;
|
||||
set_camera_node(const qpCamera *camera_node) {
|
||||
_camera_node = camera_node;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneSetup::get_camera
|
||||
// Function: SceneSetup::get_camera_node
|
||||
// Access: Public
|
||||
// Description: Returns the camera used to render the scene.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const qpCamera *SceneSetup::
|
||||
get_camera() const {
|
||||
return _camera;
|
||||
get_camera_node() const {
|
||||
return _camera_node;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -114,12 +135,37 @@ get_camera_transform() const {
|
||||
return _camera_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneSetup::set_world_transform
|
||||
// Access: Public
|
||||
// Description: Specifies the position of the starting node relative
|
||||
// to the camera. This is the inverse of the camera
|
||||
// transform.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void SceneSetup::
|
||||
set_world_transform(const TransformState *world_transform) {
|
||||
_world_transform = world_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneSetup::get_world_transform
|
||||
// Access: Public
|
||||
// Description: Returns the position of the starting node relative
|
||||
// to the camera. This is the inverse of the camera
|
||||
// transform.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const TransformState *SceneSetup::
|
||||
get_world_transform() const {
|
||||
return _world_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneSetup::set_render_transform
|
||||
// Access: Public
|
||||
// Description: Specifies the position of the starting node relative
|
||||
// to the camera, pretransformed as appropriate for
|
||||
// rendering.
|
||||
// rendering. This is the same as the world transform,
|
||||
// with a possible coordinate-system conversion applied.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void SceneSetup::
|
||||
set_render_transform(const TransformState *render_transform) {
|
||||
@ -131,7 +177,8 @@ set_render_transform(const TransformState *render_transform) {
|
||||
// Access: Public
|
||||
// Description: Returns the position of the starting node relative
|
||||
// to the camera, pretransformed as appropriate for
|
||||
// rendering.
|
||||
// rendering. This is the same as the world transform,
|
||||
// with a possible coordinate-system conversion applied.
|
||||
//
|
||||
// Note that this value is always the position of the
|
||||
// starting node, not the current node, even if it is
|
||||
|
@ -41,8 +41,11 @@ public:
|
||||
INLINE void set_scene_root(const qpNodePath &scene_root);
|
||||
INLINE const qpNodePath &get_scene_root() const;
|
||||
|
||||
INLINE void set_camera(const qpCamera *camera);
|
||||
INLINE const qpCamera *get_camera() const;
|
||||
INLINE void set_camera_path(const qpNodePath &camera_path);
|
||||
INLINE const qpNodePath &get_camera_path() const;
|
||||
|
||||
INLINE void set_camera_node(const qpCamera *camera_node);
|
||||
INLINE const qpCamera *get_camera_node() const;
|
||||
|
||||
INLINE void set_lens(const Lens *lens);
|
||||
INLINE const Lens *get_lens() const;
|
||||
@ -50,14 +53,19 @@ public:
|
||||
INLINE void set_camera_transform(const TransformState *camera_transform);
|
||||
INLINE const TransformState *get_camera_transform() const;
|
||||
|
||||
INLINE void set_world_transform(const TransformState *world_transform);
|
||||
INLINE const TransformState *get_world_transform() const;
|
||||
|
||||
INLINE void set_render_transform(const TransformState *render_transform);
|
||||
INLINE const TransformState *get_render_transform() const;
|
||||
|
||||
private:
|
||||
qpNodePath _scene_root;
|
||||
CPT(qpCamera) _camera;
|
||||
qpNodePath _camera_path;
|
||||
CPT(qpCamera) _camera_node;
|
||||
CPT(Lens) _lens;
|
||||
CPT(TransformState) _camera_transform;
|
||||
CPT(TransformState) _world_transform;
|
||||
CPT(TransformState) _render_transform;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user