Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
DXGraphicsStateGuardian8 Class Reference

A GraphicsStateGuardian for rendering into DirectX8 contexts. More...

#include "dxGraphicsStateGuardian8.h"

Inheritance diagram for DXGraphicsStateGuardian8:
GraphicsStateGuardian GraphicsStateGuardianBase TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Public Member Functions

 DXGraphicsStateGuardian8 (GraphicsEngine *engine, GraphicsPipe *pipe)
virtual void apply_fog (Fog *fog)
bool apply_index_buffer (IndexBufferContext *ibc, const GeomPrimitivePipelineReader *reader, bool force)
 Updates the index buffer with the current data, and makes it the current index buffer for rendering.
void apply_texture (int i, TextureContext *tc)
 Makes the texture the currently available texture for rendering on the ith stage.
bool apply_vertex_buffer (VertexBufferContext *vbc, const GeomVertexArrayDataHandle *reader, bool force)
 Updates the vertex buffer with the current data, and makes it the current vertex buffer for rendering.
virtual bool begin_draw_primitives (const GeomPipelineReader *geom_reader, const GeomMunger *munger, const GeomVertexDataPipelineReader *data_reader, bool force)
 Called before a sequence of draw_primitive() functions are called, this should prepare the vertex data for rendering.
virtual bool begin_frame (Thread *current_thread)
 Called before each frame is rendered, to allow the GSG a chance to do any internal cleanup before beginning the frame.
virtual bool begin_scene ()
 Called between begin_frame() and end_frame() to mark the beginning of drawing commands for a "scene" (usually a particular DisplayRegion) within a frame.
virtual void bind_light (PointLight *light_obj, const NodePath &light, int light_id)
 Called the first time a particular light has been bound to a given id within a frame, this should set up the associated hardware light with the light's properties.
virtual void bind_light (DirectionalLight *light_obj, const NodePath &light, int light_id)
 Called the first time a particular light has been bound to a given id within a frame, this should set up the associated hardware light with the light's properties.
virtual void bind_light (Spotlight *light_obj, const NodePath &light, int light_id)
 Called the first time a particular light has been bound to a given id within a frame, this should set up the associated hardware light with the light's properties.
FrameBufferProperties calc_fb_properties (DWORD cformat, DWORD dformat, DWORD multisampletype)
 Convert DirectX framebuffer format ids into a FrameBufferProperties structure.
virtual void clear (DrawableRegion *region)
 Clears all of the indicated buffers to their assigned colors.
virtual CPT (TransformState) calc_projection_mat(const Lens *lens)
bool do_framebuffer_copy_to_ram (Texture *tex, int z, const DisplayRegion *dr, const RenderBuffer &rb, bool inverted)
 This is the implementation of framebuffer_copy_to_ram(); it adds one additional parameter, which should be true if the framebuffer is to be inverted during the copy (as in the same way it copies to texture memory).
virtual bool draw_lines (const GeomPrimitivePipelineReader *reader, bool force)
 Draws a series of disconnected line segments.
virtual bool draw_linestrips (const GeomPrimitivePipelineReader *reader, bool force)
 Draws a series of line strips.
virtual bool draw_points (const GeomPrimitivePipelineReader *reader, bool force)
 Draws a series of disconnected points.
virtual bool draw_triangles (const GeomPrimitivePipelineReader *reader, bool force)
 Draws a series of disconnected triangles.
virtual bool draw_trifans (const GeomPrimitivePipelineReader *reader, bool force)
 Draws a series of triangle fans.
virtual bool draw_tristrips (const GeomPrimitivePipelineReader *reader, bool force)
 Draws a series of triangle strips.
virtual void end_draw_primitives ()
 Called after a sequence of draw_primitive() functions are called, this should do whatever cleanup is appropriate.
virtual void end_frame (Thread *current_thread)
 Called after each frame is rendered, to allow the GSG a chance to do any internal cleanup after rendering the frame, and before the window flips.
virtual void end_scene ()
 Called between begin_frame() and end_frame() to mark the end of drawing commands for a "scene" (usually a particular DisplayRegion) within a frame.
virtual bool extract_texture_data (Texture *tex)
 This method should only be called by the GraphicsEngine.
virtual TypeHandle force_init_type ()
virtual bool framebuffer_copy_to_ram (Texture *tex, int z, const DisplayRegion *dr, const RenderBuffer &rb)
 Copy the pixels within the indicated display region from the framebuffer into system memory, not texture memory.
virtual bool framebuffer_copy_to_texture (Texture *tex, int z, const DisplayRegion *dr, const RenderBuffer &rb)
 Copy the pixels within the indicated display region from the framebuffer into texture memory.
LPDIRECT3DDEVICE8 get_d3d_device ()
bool get_supports_render_texture () const
 Returns true if this particular GSG can render from a wdxGraphicsBuffer8 directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.
virtual TypeHandle get_type () const
virtual void prepare_display_region (DisplayRegionPipelineReader *dr)
 Prepare a display region for rendering (set up scissor region and viewport)
virtual IndexBufferContextprepare_index_buffer (GeomPrimitive *data)
 Creates a new retained-mode representation of the given data, and returns a newly-allocated IndexBufferContext pointer to reference it.
virtual bool prepare_lens ()
 Makes the current lens (whichever lens was most recently specified with set_scene()) active, so that it will transform future rendered geometry.
virtual TextureContextprepare_texture (Texture *tex, int view)
 Creates a new retained-mode representation of the given texture, and returns a newly-allocated TextureContext pointer to reference it.
virtual VertexBufferContextprepare_vertex_buffer (GeomVertexArrayData *data)
 Creates a new retained-mode representation of the given data, and returns a newly-allocated VertexBufferContext pointer to reference it.
virtual PT (GeomMunger) make_geom_munger(const RenderState *state
virtual void release_index_buffer (IndexBufferContext *ibc)
 Frees the GL resources previously allocated for the data.
virtual void release_texture (TextureContext *tc)
 Frees the GL resources previously allocated for the texture.
virtual void release_vertex_buffer (VertexBufferContext *vbc)
 Frees the GL resources previously allocated for the data.
virtual void reset ()
 Resets all internal state as if the gsg were newly created.
void restore_gamma ()
 Restore original gamma.
bool set_gamma (PN_stdfloat gamma)
 Non static version of setting gamma.
virtual void set_state_and_transform (const RenderState *state, const TransformState *transform)
 Simultaneously resets the render state and the transform state.
virtual bool update_texture (TextureContext *tc, bool force)
 Ensures that the current Texture data is refreshed onto the GSG.
bool upload_texture (DXTextureContext8 *dtc, bool force)
 Creates a texture surface on the graphics card and fills it with its pixel data.

Static Public Member Functions

static void atexit_function (void)
 This function is passed to the atexit function.
static TypeHandle get_class_type ()
static bool get_gamma_table (void)
 Static function for getting the original gamma.
static D3DFORMAT get_index_type (Geom::NumericType numeric_type)
 Maps from the Geom's internal numeric type symbols to DirectX's.
static void init_type ()
static DWORD LColor_to_D3DCOLOR (const LColor &cLColor)
 Converts Panda's floating-point LColor structure to DirectX's D3DCOLOR packed structure.
static bool static_set_gamma (bool restore, PN_stdfloat gamma)
 Static function for setting gamma which is needed for atexit.

Public Attributes

virtual Threadcurrent_thread

Protected Types

typedef pmap< NodePath, D3DLIGHT8 > DirectionalLights
enum  DxgsgFogType { None, PerVertexFog = D3DRS_FOGVERTEXMODE, PerPixelFog = D3DRS_FOGTABLEMODE }

Protected Member Functions

virtual void bind_clip_plane (const NodePath &plane, int plane_id)
 Called the first time a particular clip_plane has been bound to a given id within a frame, this should set up the associated hardware clip_plane with the clip_plane's properties.
bool check_cooperative_level ()
virtual void close_gsg ()
 This is called by the associated GraphicsWindow when close_window() is called.
void copy_pres_reset (DXScreenData *new_context)
 copies the PresReset from passed DXScreenData
 CPT (TransformState) _scissor_mat
bool create_swap_chain (DXScreenData *new_context)
void do_auto_rescale_normal ()
 Issues the appropriate GL commands to either rescale or normalize the normals according to the current transform.
void do_issue_alpha_test ()
void do_issue_blending ()
 Called after any of the things that might change blending state have changed, this function is responsible for setting the appropriate color blending mode based on the current properties.
void do_issue_color_write ()
void do_issue_cull_face ()
void do_issue_depth_offset ()
void do_issue_depth_test ()
void do_issue_depth_write ()
void do_issue_fog ()
void do_issue_material ()
void do_issue_render_mode ()
void do_issue_rescale_normal ()
void do_issue_scissor ()
void do_issue_shade_model ()
void do_issue_stencil ()
 Set stencil render states.
void do_issue_tex_gen ()
void do_issue_texture ()
void do_issue_transform ()
 Sends the indicated transform matrix to the graphics API to be applied to future vertices.
void draw_indexed_primitive_up (D3DPRIMITIVETYPE primitive_type, unsigned int min_index, unsigned int max_index, unsigned int num_primitives, const unsigned char *index_data, D3DFORMAT index_type, const unsigned char *buffer, size_t stride)
 Issues the DrawIndexedPrimitiveUP call to draw the indicated primitive_type from the given buffer.
void draw_primitive_up (D3DPRIMITIVETYPE primitive_type, unsigned int primitive_count, unsigned int first_vertex, unsigned int num_vertices, const unsigned char *buffer, size_t stride)
 Issues the DrawPrimitiveUP call to draw the indicated primitive_type from the given buffer.
void dx_cleanup ()
 Clean up the DirectX environment, accounting for exit()
virtual void enable_clip_plane (int plane_id, bool enable)
 Intended to be overridden by a derived class to enable the indicated clip_plane id.
virtual void enable_light (int light_id, bool enable)
 Intended to be overridden by a derived class to enable the indicated light id.
virtual void enable_lighting (bool enable)
 Intended to be overridden by a derived class to enable or disable the use of lighting overall.
void free_d3d_device ()
 setup for re-calling dx_init(), this is not the final exit cleanup routine (see dx_cleanup)
void free_nondx_resources ()
 Frees some memory that was explicitly allocated within the dxgsg.
const D3DCOLORVALUE & get_light_color (Light *light) const
 Returns the array of four floats that should be issued as the light's color, as scaled by the current value of _light_color_scale, in the case of color_scale_via_lighting.
virtual void reissue_transforms ()
 Called by clear_state_and_transform() to ensure that the current modelview and projection matrices are properly loaded in the graphics state, after a callback might have mucked them up.
bool release_swap_chain (DXScreenData *new_context)
 Release the swap chain on this DXScreenData.
void report_texmgr_stats ()
 Reports the DX texture manager's activity to PStats.
HRESULT reset_d3d_device (D3DPRESENT_PARAMETERS *p_presentation_params, DXScreenData **screen=NULL)
 This function checks current device's framebuffer dimension against passed p_presentation_params backbuffer dimension to determine a device reset if there is only one window or it is the main window or fullscreen mode then, it resets the device.
virtual void set_ambient_light (const LColor &color)
 Intended to be overridden by a derived class to indicate the color of the ambient light that should be in effect.
void set_context (DXScreenData *new_context)
void set_draw_buffer (const RenderBuffer &rb)
 Sets up the glDrawBuffer to render into the buffer indicated by the RenderBuffer object.
void set_read_buffer (const RenderBuffer &rb)
 Vestigial analog of glReadBuffer.
void set_render_target ()
 Set render target to the backbuffer of current swap chain.
void set_scissor (PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
 Sets up the scissor region, as a set of coordinates relative to the current viewport.
void set_texture_blend_mode (int i, const TextureStage *stage)
void show_frame ()
 redraw primary buffer

Static Protected Member Functions

static D3DBLEND get_blend_func (ColorBlendAttrib::Operand operand)
 Maps from ColorBlendAttrib::Operand to D3DBLEND value.
static D3DTEXTUREFILTERTYPE get_d3d_min_type (Texture::FilterType filter_type)
static D3DTEXTUREFILTERTYPE get_d3d_mip_type (Texture::FilterType filter_type)
static D3DFOGMODE get_fog_mode_type (Fog::Mode m)
 Maps from the fog types to gl version.
static unsigned char * get_safe_buffer_start ()
 Returns the address of a 64K buffer that is allocated at the beginning of a 64K block.
static D3DTRANSFORMSTATETYPE get_tex_mat_sym (int stage_index)
 Returns the nth D3DTS_TEXTURE(n) constant.
static DWORD get_texture_argument (TextureStage::CombineSource source, TextureStage::CombineOperand operand)
 Returns the D3DTA value corresponding to the indicated TextureStage::CombineSource and TextureStage::CombineOperand enumerated types.
static DWORD get_texture_argument_modifier (TextureStage::CombineOperand operand)
 Returns the extra bits that modify the D3DTA argument, according to the indicated TextureStage::CombineOperand enumerated type.
static D3DTEXTUREOP get_texture_operation (TextureStage::CombineMode mode, int scale)
 Returns the D3DTEXTUREOP value corresponding to the indicated TextureStage::CombineMode enumerated type.
static D3DTEXTUREADDRESS get_texture_wrap_mode (Texture::WrapMode wm)
 Maps from the Texture's internal wrap mode symbols to GL's.

Protected Attributes

const DXIndexBufferContext8_active_ibuffer
const DXVertexBufferContext8_active_vbuffer
bool _auto_rescale_normal
DWORD _clip_plane_bits
CullFaceAttrib::Mode _cull_face_mode
RenderBuffer::Type _cur_read_pixel_buffer
RenderModeAttrib::Mode _current_fill_mode
D3DVIEWPORT8 _current_viewport
LPDIRECT3DDEVICE8 _d3d_device
DirectionalLights _dlights
DxgsgFogType _do_fog_type
bool _dx_is_ready
list< wdxGraphicsBuffer8 ** > _graphics_buffer_list
HRESULT _last_testcooplevel_result
PN_stdfloat _material_ambient
PN_stdfloat _material_diffuse
PN_stdfloat _material_emission
PN_stdfloat _material_shininess
PN_stdfloat _material_specular
int _num_active_texture_stages
bool _overlay_windows_supported
D3DPRESENT_PARAMETERS _presentation_reset
DXScreenData_screen
bool _supports_render_texture
IDirect3DSwapChain8 * _swap_chain
bool _tex_stats_retrieval_impossible
bool _vertex_blending_enabled

Static Protected Attributes

static D3DMATRIX _d3d_ident_mat
static unsigned char * _safe_buffer_start = NULL
static unsigned char * _temp_buffer = NULL

Friends

class DXTextureContext8
class wdxGraphicsBuffer8
class wdxGraphicsPipe8
class wdxGraphicsWindow8
class wdxGraphicsWindowGroup8

Detailed Description

A GraphicsStateGuardian for rendering into DirectX8 contexts.

Definition at line 44 of file dxGraphicsStateGuardian8.h.


Member Function Documentation

This function is passed to the atexit function.

Definition at line 4742 of file dxGraphicsStateGuardian8.cxx.

References static_set_gamma().

bool DXGraphicsStateGuardian8::begin_draw_primitives ( const GeomPipelineReader geom_reader,
const GeomMunger munger,
const GeomVertexDataPipelineReader data_reader,
bool  force 
) [virtual]
bool DXGraphicsStateGuardian8::begin_frame ( Thread current_thread) [virtual]

Called before each frame is rendered, to allow the GSG a chance to do any internal cleanup before beginning the frame.

The return value is true if successful (in which case the frame will be drawn and end_frame() will be called later), or false if unsuccessful (in which case nothing will be drawn and end_frame() will not be called).

Reimplemented from GraphicsStateGuardian.

Definition at line 749 of file dxGraphicsStateGuardian8.cxx.

References GraphicsStateGuardian::begin_frame().

Called between begin_frame() and end_frame() to mark the beginning of drawing commands for a "scene" (usually a particular DisplayRegion) within a frame.

All 3-D drawing commands, except the clear operation, must be enclosed within begin_scene() .. end_scene().

The return value is true if successful (in which case the scene will be drawn and end_scene() will be called later), or false if unsuccessful (in which case nothing will be drawn and end_scene() will not be called).

Reimplemented from GraphicsStateGuardian.

Definition at line 779 of file dxGraphicsStateGuardian8.cxx.

References GraphicsStateGuardian::begin_scene().

void DXGraphicsStateGuardian8::bind_clip_plane ( const NodePath plane,
int  plane_id 
) [protected, virtual]

Called the first time a particular clip_plane has been bound to a given id within a frame, this should set up the associated hardware clip_plane with the clip_plane's properties.

Reimplemented from GraphicsStateGuardian.

Definition at line 3134 of file dxGraphicsStateGuardian8.cxx.

References LMatrix4f::convert_mat(), TransformState::get_mat(), PlaneNode::get_plane(), NodePath::get_transform(), and NodePath::node().

void DXGraphicsStateGuardian8::bind_light ( PointLight light_obj,
const NodePath light,
int  light_id 
) [virtual]

Called the first time a particular light has been bound to a given id within a frame, this should set up the associated hardware light with the light's properties.

Reimplemented from GraphicsStateGuardian.

Definition at line 2590 of file dxGraphicsStateGuardian8.cxx.

References LMatrix4f::convert_mat(), PointLight::get_attenuation(), LVecBase3f::get_data(), LVecBase4f::get_data(), get_light_color(), PointLight::get_point(), PointLight::get_specular_color(), and NodePath::get_transform().

void DXGraphicsStateGuardian8::bind_light ( DirectionalLight light_obj,
const NodePath light,
int  light_id 
) [virtual]

Called the first time a particular light has been bound to a given id within a frame, this should set up the associated hardware light with the light's properties.

Reimplemented from GraphicsStateGuardian.

Definition at line 2637 of file dxGraphicsStateGuardian8.cxx.

References LMatrix4f::convert_mat(), LVecBase3f::get_data(), LVecBase4f::get_data(), DirectionalLight::get_direction(), get_light_color(), DirectionalLight::get_specular_color(), and NodePath::get_transform().

void DXGraphicsStateGuardian8::bind_light ( Spotlight light_obj,
const NodePath light,
int  light_id 
) [virtual]

Called the first time a particular light has been bound to a given id within a frame, this should set up the associated hardware light with the light's properties.

Reimplemented from GraphicsStateGuardian.

Definition at line 2694 of file dxGraphicsStateGuardian8.cxx.

References LMatrix4f::convert_mat(), Spotlight::get_attenuation(), LVecBase3f::get_data(), LVecBase4f::get_data(), Spotlight::get_exponent(), Lens::get_hfov(), LensNode::get_lens(), get_light_color(), Lens::get_nodal_point(), Spotlight::get_specular_color(), NodePath::get_transform(), and Lens::get_view_vector().

FrameBufferProperties DXGraphicsStateGuardian8::calc_fb_properties ( DWORD  cformat,
DWORD  dformat,
DWORD  multisampletype 
)

Convert DirectX framebuffer format ids into a FrameBufferProperties structure.

Definition at line 4550 of file dxGraphicsStateGuardian8.cxx.

void DXGraphicsStateGuardian8::clear ( DrawableRegion region) [virtual]

Clears all of the indicated buffers to their assigned colors.

Reimplemented from GraphicsStateGuardian.

Definition at line 574 of file dxGraphicsStateGuardian8.cxx.

void DXGraphicsStateGuardian8::close_gsg ( ) [protected, virtual]

This is called by the associated GraphicsWindow when close_window() is called.

It should null out the _win pointer and possibly free any open resources associated with the GSG.

Reimplemented from GraphicsStateGuardian.

Definition at line 3261 of file dxGraphicsStateGuardian8.cxx.

References Thread::get_current_thread(), and GraphicsStateGuardian::release_all().

void DXGraphicsStateGuardian8::copy_pres_reset ( DXScreenData new_context) [protected]

copies the PresReset from passed DXScreenData

Definition at line 4025 of file dxGraphicsStateGuardian8.cxx.

Referenced by wdxGraphicsWindow8::open_window().

Issues the appropriate GL commands to either rescale or normalize the normals according to the current transform.

Definition at line 3356 of file dxGraphicsStateGuardian8.cxx.

Referenced by do_issue_transform().

bool DXGraphicsStateGuardian8::do_framebuffer_copy_to_ram ( Texture tex,
int  z,
const DisplayRegion dr,
const RenderBuffer rb,
bool  inverted 
)

This is the implementation of framebuffer_copy_to_ram(); it adds one additional parameter, which should be true if the framebuffer is to be inverted during the copy (as in the same way it copies to texture memory).

Definition at line 1640 of file dxGraphicsStateGuardian8.cxx.

References DXTextureContext8::d3d_surface_to_texture(), Texture::get_component_type(), Texture::get_format(), DisplayRegion::get_region_pixels_i(), Texture::get_texture_type(), Texture::get_x_size(), Texture::get_y_size(), Texture::get_z_size(), Texture::has_ram_image(), set_read_buffer(), and Texture::setup_texture().

Referenced by framebuffer_copy_to_ram(), and framebuffer_copy_to_texture().

Called after any of the things that might change blending state have changed, this function is responsible for setting the appropriate color blending mode based on the current properties.

Definition at line 3162 of file dxGraphicsStateGuardian8.cxx.

References get_blend_func(), ColorWriteAttrib::get_channels(), TransparencyAttrib::get_mode(), ColorBlendAttrib::get_mode(), ColorBlendAttrib::get_operand_a(), and ColorBlendAttrib::get_operand_b().

Referenced by set_state_and_transform().

Set stencil render states.

Definition at line 4421 of file dxGraphicsStateGuardian8.cxx.

Referenced by set_state_and_transform().

Sends the indicated transform matrix to the graphics API to be applied to future vertices.

This transform is the internal_transform, already converted into the GSG's internal coordinate system.

Definition at line 2139 of file dxGraphicsStateGuardian8.cxx.

References do_auto_rescale_normal(), and TransformState::get_mat().

Referenced by reissue_transforms(), and set_state_and_transform().

void DXGraphicsStateGuardian8::draw_indexed_primitive_up ( D3DPRIMITIVETYPE  primitive_type,
unsigned int  min_index,
unsigned int  max_index,
unsigned int  num_primitives,
const unsigned char *  index_data,
D3DFORMAT  index_type,
const unsigned char *  buffer,
size_t  stride 
) [protected]

Issues the DrawIndexedPrimitiveUP call to draw the indicated primitive_type from the given buffer.

As in draw_primitive_up(), above, the parameter list is not exactly one-for-one with the DrawIndexedPrimitiveUP() call, but it's similar (in particular, we pass max_index instead of NumVertices, which always seemed ambiguous to me).

Definition at line 4271 of file dxGraphicsStateGuardian8.cxx.

References get_safe_buffer_start().

Referenced by draw_lines(), draw_triangles(), draw_trifans(), and draw_tristrips().

bool DXGraphicsStateGuardian8::draw_lines ( const GeomPrimitivePipelineReader reader,
bool  force 
) [virtual]
bool DXGraphicsStateGuardian8::draw_linestrips ( const GeomPrimitivePipelineReader reader,
bool  force 
) [virtual]

Draws a series of line strips.

Reimplemented from GraphicsStateGuardian.

Definition at line 1418 of file dxGraphicsStateGuardian8.cxx.

bool DXGraphicsStateGuardian8::draw_points ( const GeomPrimitivePipelineReader reader,
bool  force 
) [virtual]
void DXGraphicsStateGuardian8::draw_primitive_up ( D3DPRIMITIVETYPE  primitive_type,
unsigned int  primitive_count,
unsigned int  first_vertex,
unsigned int  num_vertices,
const unsigned char *  buffer,
size_t  stride 
) [protected]

Issues the DrawPrimitiveUP call to draw the indicated primitive_type from the given buffer.

We add the num_vertices parameter, so we can determine the size of the buffer.

Definition at line 4221 of file dxGraphicsStateGuardian8.cxx.

References get_safe_buffer_start().

Referenced by draw_lines(), draw_points(), draw_triangles(), draw_trifans(), and draw_tristrips().

bool DXGraphicsStateGuardian8::draw_triangles ( const GeomPrimitivePipelineReader reader,
bool  force 
) [virtual]
bool DXGraphicsStateGuardian8::draw_trifans ( const GeomPrimitivePipelineReader reader,
bool  force 
) [virtual]
bool DXGraphicsStateGuardian8::draw_tristrips ( const GeomPrimitivePipelineReader reader,
bool  force 
) [virtual]

Clean up the DirectX environment, accounting for exit()

Definition at line 3743 of file dxGraphicsStateGuardian8.cxx.

References free_nondx_resources().

Referenced by wdxGraphicsWindow8::open_window().

void DXGraphicsStateGuardian8::enable_clip_plane ( int  plane_id,
bool  enable 
) [protected, virtual]

Intended to be overridden by a derived class to enable the indicated clip_plane id.

A specific PlaneNode will already have been bound to this id via bind_clip_plane().

Reimplemented from GraphicsStateGuardian.

Definition at line 3116 of file dxGraphicsStateGuardian8.cxx.

void DXGraphicsStateGuardian8::enable_light ( int  light_id,
bool  enable 
) [protected, virtual]

Intended to be overridden by a derived class to enable the indicated light id.

A specific Light will already have been bound to this id via bind_light().

Reimplemented from GraphicsStateGuardian.

Definition at line 3097 of file dxGraphicsStateGuardian8.cxx.

void DXGraphicsStateGuardian8::enable_lighting ( bool  enable) [protected, virtual]

Intended to be overridden by a derived class to enable or disable the use of lighting overall.

This is called by issue_light() according to whether any lights are in use or not.

Reimplemented from GraphicsStateGuardian.

Definition at line 3066 of file dxGraphicsStateGuardian8.cxx.

Called after a sequence of draw_primitive() functions are called, this should do whatever cleanup is appropriate.

Reimplemented from GraphicsStateGuardian.

Definition at line 1467 of file dxGraphicsStateGuardian8.cxx.

References LMatrix4f::get_data().

void DXGraphicsStateGuardian8::end_frame ( Thread current_thread) [virtual]

Called after each frame is rendered, to allow the GSG a chance to do any internal cleanup after rendering the frame, and before the window flips.

Reimplemented from GraphicsStateGuardian.

Definition at line 848 of file dxGraphicsStateGuardian8.cxx.

References report_texmgr_stats().

Called between begin_frame() and end_frame() to mark the end of drawing commands for a "scene" (usually a particular DisplayRegion) within a frame.

All 3-D drawing commands, except the clear operation, must be enclosed within begin_scene() .. end_scene().

Reimplemented from GraphicsStateGuardian.

Definition at line 817 of file dxGraphicsStateGuardian8.cxx.

This method should only be called by the GraphicsEngine.

Do not call it directly; call GraphicsEngine::extract_texture_data() instead.

This method will be called in the draw thread to download the texture memory's image into its ram_image value. It returns true on success, false otherwise.

Reimplemented from GraphicsStateGuardian.

Definition at line 353 of file dxGraphicsStateGuardian8.cxx.

References DXTextureContext8::extract_texture_data(), GraphicsStateGuardian::get_prepared_objects(), and Texture::prepare_now().

bool DXGraphicsStateGuardian8::framebuffer_copy_to_ram ( Texture tex,
int  z,
const DisplayRegion dr,
const RenderBuffer rb 
) [virtual]

Copy the pixels within the indicated display region from the framebuffer into system memory, not texture memory.

Returns true on success, false on failure.

This completely redefines the ram image of the indicated texture.

Reimplemented from GraphicsStateGuardian.

Definition at line 1626 of file dxGraphicsStateGuardian8.cxx.

References do_framebuffer_copy_to_ram().

Referenced by framebuffer_copy_to_texture().

bool DXGraphicsStateGuardian8::framebuffer_copy_to_texture ( Texture tex,
int  z,
const DisplayRegion dr,
const RenderBuffer rb 
) [virtual]

setup for re-calling dx_init(), this is not the final exit cleanup routine (see dx_cleanup)

Definition at line 3294 of file dxGraphicsStateGuardian8.cxx.

References BitMask< WType, nbits >::clear(), free_nondx_resources(), and GraphicsStateGuardian::release_all().

Frees some memory that was explicitly allocated within the dxgsg.

Definition at line 3284 of file dxGraphicsStateGuardian8.cxx.

Referenced by dx_cleanup(), and free_d3d_device().

D3DBLEND DXGraphicsStateGuardian8::get_blend_func ( ColorBlendAttrib::Operand  operand) [static, protected]

Maps from ColorBlendAttrib::Operand to D3DBLEND value.

Definition at line 3393 of file dxGraphicsStateGuardian8.cxx.

Referenced by do_issue_blending().

D3DFOGMODE DXGraphicsStateGuardian8::get_fog_mode_type ( Fog::Mode  m) [inline, static, protected]

Maps from the fog types to gl version.

Definition at line 105 of file dxGraphicsStateGuardian8.I.

Static function for getting the original gamma.

Definition at line 4656 of file dxGraphicsStateGuardian8.cxx.

D3DFORMAT DXGraphicsStateGuardian8::get_index_type ( Geom::NumericType  numeric_type) [static]

Maps from the Geom's internal numeric type symbols to DirectX's.

Definition at line 2754 of file dxGraphicsStateGuardian8.cxx.

Referenced by DXIndexBufferContext8::create_ibuffer(), draw_lines(), draw_triangles(), draw_trifans(), and draw_tristrips().

const D3DCOLORVALUE & DXGraphicsStateGuardian8::get_light_color ( Light light) const [protected]

Returns the array of four floats that should be issued as the light's color, as scaled by the current value of _light_color_scale, in the case of color_scale_via_lighting.

Definition at line 3376 of file dxGraphicsStateGuardian8.cxx.

References Light::get_color(), and LVecBase4f::get_data().

Referenced by bind_light().

unsigned char * DXGraphicsStateGuardian8::get_safe_buffer_start ( ) [inline, static, protected]

Returns the address of a 64K buffer that is allocated at the beginning of a 64K block.

Definition at line 135 of file dxGraphicsStateGuardian8.I.

Referenced by draw_indexed_primitive_up(), and draw_primitive_up().

Returns true if this particular GSG can render from a wdxGraphicsBuffer8 directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.

Definition at line 157 of file dxGraphicsStateGuardian8.I.

D3DTRANSFORMSTATETYPE DXGraphicsStateGuardian8::get_tex_mat_sym ( int  stage_index) [inline, static, protected]

Returns the nth D3DTS_TEXTURE(n) constant.

Definition at line 124 of file dxGraphicsStateGuardian8.I.

DWORD DXGraphicsStateGuardian8::get_texture_argument ( TextureStage::CombineSource  source,
TextureStage::CombineOperand  operand 
) [static, protected]

Returns the D3DTA value corresponding to the indicated TextureStage::CombineSource and TextureStage::CombineOperand enumerated types.

Definition at line 4157 of file dxGraphicsStateGuardian8.cxx.

References get_texture_argument_modifier().

DWORD DXGraphicsStateGuardian8::get_texture_argument_modifier ( TextureStage::CombineOperand  operand) [static, protected]

Returns the extra bits that modify the D3DTA argument, according to the indicated TextureStage::CombineOperand enumerated type.

Definition at line 4190 of file dxGraphicsStateGuardian8.cxx.

Referenced by get_texture_argument().

D3DTEXTUREOP DXGraphicsStateGuardian8::get_texture_operation ( TextureStage::CombineMode  mode,
int  scale 
) [static, protected]

Returns the D3DTEXTUREOP value corresponding to the indicated TextureStage::CombineMode enumerated type.

Definition at line 4108 of file dxGraphicsStateGuardian8.cxx.

D3DTEXTUREADDRESS DXGraphicsStateGuardian8::get_texture_wrap_mode ( Texture::WrapMode  wm) [inline, static, protected]

Maps from the Texture's internal wrap mode symbols to GL's.

Definition at line 82 of file dxGraphicsStateGuardian8.I.

Referenced by apply_texture().

DWORD DXGraphicsStateGuardian8::LColor_to_D3DCOLOR ( const LColor cLColor) [inline, static]

Converts Panda's floating-point LColor structure to DirectX's D3DCOLOR packed structure.

Definition at line 23 of file dxGraphicsStateGuardian8.I.

Referenced by apply_texture(), and set_ambient_light().

Prepare a display region for rendering (set up scissor region and viewport)

Reimplemented from GraphicsStateGuardian.

Definition at line 652 of file dxGraphicsStateGuardian8.cxx.

References DisplayRegionPipelineReader::get_region_pixels_i(), and set_scissor().

Creates a new retained-mode representation of the given data, and returns a newly-allocated IndexBufferContext pointer to reference it.

It is the responsibility of the calling function to later call release_index_buffer() with this same pointer (which will also delete the pointer).

This function should not be called directly to prepare a buffer. Instead, call Geom::prepare().

Reimplemented from GraphicsStateGuardian.

Definition at line 479 of file dxGraphicsStateGuardian8.cxx.

Makes the current lens (whichever lens was most recently specified with set_scene()) active, so that it will transform future rendered geometry.

Normally this is only called from the draw process, and usually it is called by set_scene().

The return value is true if the lens is acceptable, false if it is not.

Reimplemented from GraphicsStateGuardian.

Definition at line 726 of file dxGraphicsStateGuardian8.cxx.

References LMatrix4f::get_data().

Referenced by reissue_transforms(), and set_scissor().

TextureContext * DXGraphicsStateGuardian8::prepare_texture ( Texture tex,
int  view 
) [virtual]

Creates a new retained-mode representation of the given texture, and returns a newly-allocated TextureContext pointer to reference it.

It is the responsibility of the calling function to later call release_texture() with this same pointer (which will also delete the pointer).

This function should not be called directly to prepare a texture. Instead, call Texture::prepare().

Implements GraphicsStateGuardianBase.

Definition at line 159 of file dxGraphicsStateGuardian8.cxx.

References Texture::get_ram_image_compression(), GraphicsStateGuardian::get_supports_compressed_texture_format(), and TextureContext::get_texture().

Creates a new retained-mode representation of the given data, and returns a newly-allocated VertexBufferContext pointer to reference it.

It is the responsibility of the calling function to later call release_vertex_buffer() with this same pointer (which will also delete the pointer).

This function should not be called directly to prepare a buffer. Instead, call Geom::prepare().

Reimplemented from GraphicsStateGuardian.

Definition at line 375 of file dxGraphicsStateGuardian8.cxx.

void DXGraphicsStateGuardian8::reissue_transforms ( ) [protected, virtual]

Called by clear_state_and_transform() to ensure that the current modelview and projection matrices are properly loaded in the graphics state, after a callback might have mucked them up.

Reimplemented from GraphicsStateGuardian.

Definition at line 3052 of file dxGraphicsStateGuardian8.cxx.

References do_issue_transform(), and prepare_lens().

Frees the GL resources previously allocated for the data.

This function should never be called directly; instead, call Data::release() (or simply let the Data destruct).

Reimplemented from GraphicsStateGuardian.

Definition at line 550 of file dxGraphicsStateGuardian8.cxx.

bool DXGraphicsStateGuardian8::release_swap_chain ( DXScreenData new_context) [protected]

Release the swap chain on this DXScreenData.

Definition at line 4005 of file dxGraphicsStateGuardian8.cxx.

Referenced by wdxGraphicsWindow8::close_window(), and wdxGraphicsWindow8::reset_window().

Frees the GL resources previously allocated for the texture.

Reimplemented from GraphicsStateGuardian.

Definition at line 335 of file dxGraphicsStateGuardian8.cxx.

Frees the GL resources previously allocated for the data.

This function should never be called directly; instead, call Data::release() (or simply let the Data destruct).

Reimplemented from GraphicsStateGuardian.

Definition at line 460 of file dxGraphicsStateGuardian8.cxx.

Reports the DX texture manager's activity to PStats.

Definition at line 3456 of file dxGraphicsStateGuardian8.cxx.

Referenced by end_frame().

void DXGraphicsStateGuardian8::reset ( ) [virtual]

Resets all internal state as if the gsg were newly created.

The GraphicsWindow pointer represents a typical window that might be used for this context; it may be required to set up the frame buffer properly the first time.

Reimplemented from GraphicsStateGuardian.

Definition at line 1800 of file dxGraphicsStateGuardian8.cxx.

References GraphicsStateGuardianBase::add_gsg().

HRESULT DXGraphicsStateGuardian8::reset_d3d_device ( D3DPRESENT_PARAMETERS *  presentation_params,
DXScreenData **  screen = NULL 
) [protected]

This function checks current device's framebuffer dimension against passed p_presentation_params backbuffer dimension to determine a device reset if there is only one window or it is the main window or fullscreen mode then, it resets the device.

Finally it returns the new DXScreenData through parameter screen

Definition at line 3771 of file dxGraphicsStateGuardian8.cxx.

References Thread::get_current_thread(), GraphicsStateGuardian::get_engine(), GraphicsStateGuardian::mark_new(), GraphicsStateGuardian::release_all(), GraphicsStateGuardian::release_all_index_buffers(), GraphicsStateGuardian::release_all_vertex_buffers(), and GraphicsEngine::reset_all_windows().

Restore original gamma.

Reimplemented from GraphicsStateGuardian.

Definition at line 4732 of file dxGraphicsStateGuardian8.cxx.

References static_set_gamma().

void DXGraphicsStateGuardian8::set_ambient_light ( const LColor color) [protected, virtual]

Intended to be overridden by a derived class to indicate the color of the ambient light that should be in effect.

This is called by issue_light() after all other lights have been enabled or disabled.

Reimplemented from GraphicsStateGuardian.

Definition at line 3079 of file dxGraphicsStateGuardian8.cxx.

References LColor_to_D3DCOLOR().

void DXGraphicsStateGuardian8::set_draw_buffer ( const RenderBuffer rb) [protected]

Sets up the glDrawBuffer to render into the buffer indicated by the RenderBuffer object.

This only sets up the color bits; it does not affect the depth, stencil, accum layers.

Definition at line 3326 of file dxGraphicsStateGuardian8.cxx.

bool DXGraphicsStateGuardian8::set_gamma ( PN_stdfloat  gamma) [virtual]

Non static version of setting gamma.

Returns true on success.

Reimplemented from GraphicsStateGuardian.

Definition at line 4715 of file dxGraphicsStateGuardian8.cxx.

References static_set_gamma().

void DXGraphicsStateGuardian8::set_read_buffer ( const RenderBuffer rb) [protected]

Vestigial analog of glReadBuffer.

Definition at line 3337 of file dxGraphicsStateGuardian8.cxx.

Referenced by do_framebuffer_copy_to_ram(), and framebuffer_copy_to_texture().

Set render target to the backbuffer of current swap chain.

Definition at line 3545 of file dxGraphicsStateGuardian8.cxx.

Referenced by wdxGraphicsWindow8::begin_frame().

void DXGraphicsStateGuardian8::set_scissor ( PN_stdfloat  left,
PN_stdfloat  right,
PN_stdfloat  bottom,
PN_stdfloat  top 
) [protected]

Sets up the scissor region, as a set of coordinates relative to the current viewport.

Definition at line 4491 of file dxGraphicsStateGuardian8.cxx.

References prepare_lens().

Referenced by prepare_display_region().

void DXGraphicsStateGuardian8::set_state_and_transform ( const RenderState target,
const TransformState transform 
) [virtual]

Simultaneously resets the render state and the transform state.

This transform specified is the "internal" net transform, already converted into the GSG's internal coordinate space by composing it to get_cs_transform(). (Previously, this used to be the "external" net transform, with the assumption that that GSG would convert it internally, but that is no longer the case.)

Special case: if (state==NULL), then the target state is already stored in _target.

Reimplemented from GraphicsStateGuardian.

Definition at line 2386 of file dxGraphicsStateGuardian8.cxx.

References GraphicsStateGuardian::determine_target_texture(), do_issue_blending(), GraphicsStateGuardian::do_issue_clip_plane(), GraphicsStateGuardian::do_issue_color(), GraphicsStateGuardian::do_issue_light(), do_issue_stencil(), do_issue_transform(), BitMask< WType, nbits >::get_bit(), and BitMask< WType, nbits >::set_bit().

redraw primary buffer

Definition at line 3952 of file dxGraphicsStateGuardian8.cxx.

Referenced by wdxGraphicsWindow8::end_flip().

bool DXGraphicsStateGuardian8::static_set_gamma ( bool  restore,
PN_stdfloat  gamma 
) [static]

Static function for setting gamma which is needed for atexit.

Definition at line 4683 of file dxGraphicsStateGuardian8.cxx.

Referenced by atexit_function(), restore_gamma(), and set_gamma().

bool DXGraphicsStateGuardian8::update_texture ( TextureContext tc,
bool  force 
) [virtual]

Ensures that the current Texture data is refreshed onto the GSG.

This means updating the texture properties and/or re-uploading the texture image, if necessary. This should only be called within the draw thread.

If force is true, this function will not return until the texture has been fully uploaded. If force is false, the function may choose to upload a simple version of the texture instead, if the texture is not fully resident (and if get_incomplete_render() is true).

Reimplemented from GraphicsStateGuardian.

Definition at line 267 of file dxGraphicsStateGuardian8.cxx.

References AdaptiveLruPage::enqueue_lru(), TextureContext::get_texture(), upload_texture(), and TextureContext::was_modified().

Referenced by apply_texture().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations