new window code

This commit is contained in:
David Rose 2003-01-09 20:35:54 +00:00
parent b38c84c55c
commit ea59108287
177 changed files with 14125 additions and 16870 deletions

View File

@ -25,10 +25,12 @@
#include "get_config_path.h"
#include "camera.h"
// Don't define this unless you have drose's new GraphicsWindow code,
// which is currently a work in progress. You probably won't have it
// unless you are drose.
//#define NEW_WINDOW_CODE 1
// You should define this unless you don't have the new GraphicsWindow
// code yet. drose checked this in to Panda at around 12:30pm on
// Thursday, Jan 9; if you haven't updated your Panda since then you
// should either go update it (and prepare for a long build) or just
// comment this out to run for the short term with the old code.
#define NEW_WINDOW_CODE 1
#ifdef NEW_WINDOW_CODE
#include "graphicsPipeSelection.h"

View File

@ -7,7 +7,7 @@
; release dlls
libpanda 0x0000000060000000 0x004b0000
libpandadx 0x0000000061000000 0x00090000
libpandadx8 0x0000000061000000 0x00090000
libpandadx7 0x0000000061000000 0x00050000
libpandagl 0x0000000061000000 0x00040000
libpandaexpress 0x00000000605d0000 0x00140000
@ -25,7 +25,7 @@ libframework 0x0000000060a50000 0x00020000
; debug dlls
libpanda_d 0x0000000060000000 0x007c0000
libpandadx_d 0x00000000607c0000 0x000f0000
libpandadx8_d 0x00000000607c0000 0x000f0000
libpandadx7_d 0x00000000608b0000 0x00070000
libpandagl_d 0x0000000060920000 0x00050000
libpandaexpress_d 0x0000000060970000 0x00210000

View File

@ -1,23 +0,0 @@
#define BUILD_DIRECTORY $[HAVE_DX]
// DIR_TYPE "metalib" indicates we are building a shared library that
// consists mostly of references to other shared libraries. Under
// Windows, this directly produces a DLL (as opposed to the regular
// src libraries, which don't produce anything but a pile of OBJ files
// under Windows).
#define DIR_TYPE metalib
#define BUILDING_DLL BUILDING_PANDADX
#define COMPONENT_LIBS \
dxgsg wdxdisplay
#define LOCAL_LIBS gsgbase display express
#define OTHER_LIBS dtoolconfig dtool
#begin metalib_target
#define TARGET pandadx7
#define SOURCES pandadx.cxx
#define WIN_SYS_LIBS \
ddraw.lib dxguid.lib winmm.lib \
kernel32.lib gdi32.lib user32.lib $[WIN_SYS_LIBS]
#end metalib_target

View File

@ -1,23 +0,0 @@
// Filename: pandadx.cxx
// Created by: drose (15May00)
//
////////////////////////////////////////////////////////////////////
#include "pandadx.h"
#include <config_dxgsg.h>
#include <config_wdxdisplay.h>
////////////////////////////////////////////////////////////////////
// Function: init_libpandadx
// Description: Initializes the library. This must be called at
// least once before any of the functions or classes in
// this library can be used. Normally it will be
// called by the static initializers and need not be
// called explicitly, but special cases exist.
////////////////////////////////////////////////////////////////////
void
init_libpandadx() {
init_libdxgsg();
init_libwdxdisplay();
}

View File

@ -1,13 +0,0 @@
// Filename: pandadx.h
// Created by: drose (2Jan01)
//
////////////////////////////////////////////////////////////////////
#ifndef PANDADX_H
#define PANDADX_H
#include <pandabase.h>
EXPCL_PANDADX void init_libpandadx();
#endif

View File

@ -10,12 +10,12 @@
#define BUILDING_DLL BUILDING_PANDADX
#define COMPONENT_LIBS \
dxgsg8 wdxdisplay8
dxgsg8
#define LOCAL_LIBS gsgbase display express gobj
#define OTHER_LIBS dtoolconfig dtool
#begin metalib_target
#define TARGET pandadx
#define TARGET pandadx8
#define SOURCES pandadx8.cxx
#define WIN_SYS_LIBS \
ddraw.lib dxguid.lib winmm.lib \

View File

@ -5,8 +5,7 @@
#include "pandadx8.h"
#include <config_dxgsg8.h>
#include <config_wdxdisplay8.h>
#include "config_dxgsg8.h"
////////////////////////////////////////////////////////////////////
// Function: init_libpandadx
@ -19,5 +18,4 @@
void
init_libpandadx8() {
init_libdxgsg8();
init_libwdxdisplay8();
}

View File

@ -12,8 +12,9 @@
// We don't have any components if we're linking the GL library
// directly into Panda.
#define COMPONENT_LIBS \
glgsg glxdisplay wgldisplay glutdisplay \
sgidisplay sgiglxdisplay sgiglutdisplay
glgsg glxdisplay \
sgidisplay sgiglxdisplay \
wgldisplay
#endif
#define LOCAL_LIBS gsgbase display express

View File

@ -7,9 +7,12 @@
#ifndef LINK_IN_GL
#include <config_glgsg.h>
// Temporarily commented out for development on wgldisplay
/*
#ifdef HAVE_WGL
#include <config_wgldisplay.h>
#endif
*/
#endif
////////////////////////////////////////////////////////////////////
@ -24,8 +27,11 @@ void
init_libpandagl() {
#ifndef LINK_IN_GL
init_libglgsg();
// Temporarily commented out for development on wgldisplay
/*
#ifdef HAVE_WGL
init_libwgldisplay();
#endif
*/
#endif
}

View File

@ -19,6 +19,8 @@
#include "chancfg.h"
#include "notify.h"
#include "displayRegion.h"
#include "graphicsPipe.h"
#include "graphicsEngine.h"
#include "graphicsChannel.h"
#include "hardwareChannel.h"
#include "camera.h"
@ -335,7 +337,8 @@ void ChanConfig::chan_eval(GraphicsWindow* win, WindowItem& W, LayoutItem& L,
return;
}
ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &render,
ChanConfig::ChanConfig(GraphicsEngine *engine, GraphicsPipe* pipe,
std::string cfg, const NodePath &render,
ChanCfgOverrides& overrides) {
ReadChanConfigData();
// check to make sure we know everything we need to
@ -400,9 +403,9 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
origY = overrides.defined(ChanCfgOverrides::OrigY) ?
overrides.getInt(ChanCfgOverrides::OrigY) : origY;
bool border = !chanconfig.GetBool("no-border", !W.getBorder());
bool undecorated = chanconfig.GetBool("undecorated", !W.getBorder());
bool fullscreen = chanconfig.GetBool("fullscreen", false);
bool use_cursor = chanconfig.GetBool("cursor-visible", W.getCursor());
bool use_cursor = !chanconfig.GetBool("cursor-hidden", !W.getCursor());
int want_depth_bits = chanconfig.GetInt("want-depth-bits", 1);
int want_color_bits = chanconfig.GetInt("want-color-bits", 1);
@ -411,28 +414,27 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
float win_background_b = chanconfig.GetFloat("win-background-b", 0.41);
// visual? nope, that's handled with the mode.
uint mask = 0x0; // ?! this really should come from the win config
mask = overrides.defined(ChanCfgOverrides::Mask) ?
overrides.getUInt(ChanCfgOverrides::Mask) : mask;
int framebuffer_mode =
WindowProperties::FM_rgba |
WindowProperties::FM_double_buffer |
WindowProperties::FM_depth;
framebuffer_mode = overrides.defined(ChanCfgOverrides::Mask) ?
overrides.getUInt(ChanCfgOverrides::Mask) : framebuffer_mode;
std::string title = cfg;
title = overrides.defined(ChanCfgOverrides::Title) ?
overrides.getString(ChanCfgOverrides::Title) : title;
GraphicsWindow::Properties props;
props._xorg = origX;
props._yorg = origY;
props._xsize = sizeX;
props._ysize = sizeY;
props._title = title;
props._mask = mask;
props._border = border;
props._fullscreen = fullscreen;
props._want_depth_bits = want_depth_bits;
props._want_color_bits = want_color_bits;
props._bCursorIsVisible = use_cursor;
props.set_clear_color(Colorf(win_background_r, win_background_g,
win_background_b, 1.0f));
WindowProperties props;
props.set_open(true);
props.set_origin(origX, origY);
props.set_size(sizeX, sizeY);
props.set_title(title);
props.set_framebuffer_mode(framebuffer_mode);
props.set_undecorated(undecorated);
props.set_fullscreen(fullscreen);
props.set_depth_bits(want_depth_bits);
props.set_color_bits(want_color_bits);
props.set_cursor_hidden(!use_cursor);
// stereo prep?
@ -442,13 +444,17 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
overrides.getBool(ChanCfgOverrides::Cameras) : true;
// open that sucker
PT(GraphicsWindow) win = pipe->make_window(props);
PT(GraphicsWindow) win = engine->make_window(pipe);
if(win == (GraphicsWindow *)NULL) {
chancfg_cat.error() << "Could not create window" << endl;
_graphics_window = (GraphicsWindow *)NULL;
return;
}
win->request_properties(props);
win->set_clear_color(Colorf(win_background_r, win_background_g,
win_background_b, 1.0f));
// make channels and display regions
ChanViewport V(0.0f, 1.0f, 0.0f, 1.0f);
chan_eval(win, W, L, S, V, W.getChanOffset()+1, sizeX, sizeY,
@ -459,9 +465,7 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
// sanity check
if (config_sanity_check) {
nout << "ChanConfig Sanity check:" << endl
<< "window - " << (void*)win << endl
<< " width = " << win->get_width() << " height = " << win->get_height() << endl
<< " xorig = " << win->get_xorg() << " yorig = " << win->get_yorg()<< endl;
<< "window - " << (void*)win << endl;
int max_channel_index = win->get_max_channel_index();
for (int c = 0; c < max_channel_index; c++) {

View File

@ -26,13 +26,15 @@
#include "chanwindow.h"
#include "chanshare.h"
#include "graphicsPipe.h"
#include "graphicsWindow.h"
#include "pandaNode.h"
#include "nodePath.h"
#include "pmap.h"
class GraphicsEngine;
class GraphicsPipe;
class EXPCL_PANDA ChanCfgOverrides {
public:
enum Field { OrigX, OrigY, SizeX, SizeY, Title, Mask, Cameras };
@ -114,8 +116,9 @@ private:
SVec& S, ChanViewport& V, int hw_offset,
int xsize, int ysize, const NodePath &render, bool want_cameras);
PUBLISHED:
ChanConfig(GraphicsPipe*, std::string, const NodePath &render,
ChanCfgOverrides& = ChanOverrideNone);
ChanConfig(GraphicsEngine *engine, GraphicsPipe *pipe,
std::string cfg, const NodePath &render,
ChanCfgOverrides& = ChanOverrideNone);
INLINE PandaNode *get_group_node(const int node_index) const;
INLINE int get_group_membership(const int dr_index) const;
INLINE int get_num_groups(void) const;

View File

@ -78,8 +78,9 @@ do_transmit_data(const DataNodeTransmit &, DataNodeTransmit &output) {
_pixel_xy->set_value(LPoint2f(mdata._xpos, mdata._ypos));
output.set_data(_pixel_xy_output, EventParameter(_pixel_xy));
int w = _window->get_width();
int h = _window->get_height();
WindowProperties properties = _window->get_properties();
int w = properties.get_x_size();
int h = properties.get_y_size();
// Normalize pixel motion to range [-1,1].
float xf = (float)(2 * mdata._xpos) / (float)w - 1.0f;

View File

@ -10,39 +10,41 @@
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
#define SOURCES \
config_display.h \
clearableRegion.I clearableRegion.h \
displayRegion.I displayRegion.h \
displayRegionStack.I \
displayRegionStack.h \
frameBufferStack.I frameBufferStack.h \
geomContext.I geomContext.h geomNodeContext.I geomNodeContext.h \
graphicsChannel.I graphicsChannel.h \
graphicsEngine.I graphicsEngine.h \
graphicsLayer.I \
graphicsLayer.h graphicsPipe.I graphicsPipe.N graphicsPipe.h \
graphicsStateGuardian.I graphicsStateGuardian.N \
graphicsStateGuardian.h graphicsWindow.I graphicsWindow.N \
graphicsWindow.h graphicsWindowInputDevice.I \
graphicsWindowInputDevice.h hardwareChannel.I \
hardwareChannel.h interactiveGraphicsPipe.I \
interactiveGraphicsPipe.h \
lensStack.I lensStack.h \
noninteractiveGraphicsPipe.I \
noninteractiveGraphicsPipe.h pipeSpec.I pipeSpec.h \
savedFrameBuffer.I savedFrameBuffer.h
config_display.h \
clearableRegion.I clearableRegion.h \
displayRegion.I displayRegion.h \
displayRegionStack.I \
displayRegionStack.h \
frameBufferStack.I frameBufferStack.h \
geomContext.I geomContext.h geomNodeContext.I geomNodeContext.h \
graphicsChannel.I graphicsChannel.h \
graphicsEngine.I graphicsEngine.h \
graphicsLayer.I \
graphicsLayer.h graphicsPipe.I graphicsPipe.h \
graphicsPipeSelection.I graphicsPipeSelection.h \
graphicsStateGuardian.I \
graphicsStateGuardian.h graphicsWindow.I \
graphicsWindow.h graphicsWindowInputDevice.I \
graphicsWindowInputDevice.h \
windowProperties.I windowProperties.h \
hardwareChannel.I \
hardwareChannel.h \
lensStack.I lensStack.h \
savedFrameBuffer.I savedFrameBuffer.h
#define INCLUDED_SOURCES \
config_display.cxx \
clearableRegion.cxx \
displayRegion.cxx \
geomContext.cxx geomNodeContext.cxx graphicsChannel.cxx \
graphicsEngine.cxx \
graphicsLayer.cxx graphicsPipe.cxx graphicsStateGuardian.cxx \
graphicsWindow.cxx graphicsWindowInputDevice.cxx \
hardwareChannel.cxx interactiveGraphicsPipe.cxx \
noninteractiveGraphicsPipe.cxx pipeSpec.cxx \
savedFrameBuffer.cxx
config_display.cxx \
clearableRegion.cxx \
displayRegion.cxx \
geomContext.cxx geomNodeContext.cxx graphicsChannel.cxx \
graphicsEngine.cxx \
graphicsLayer.cxx graphicsPipe.cxx \
graphicsPipeSelection.cxx \
graphicsStateGuardian.cxx \
graphicsWindow.cxx graphicsWindowInputDevice.cxx \
windowProperties.cxx \
hardwareChannel.cxx \
savedFrameBuffer.cxx
#define INSTALL_HEADERS \
config_display.h \
@ -54,14 +56,15 @@
graphicsChannel.I graphicsChannel.h \
graphicsEngine.I graphicsEngine.h \
graphicsLayer.I graphicsLayer.h \
graphicsPipe.I graphicsPipe.h graphicsStateGuardian.I \
graphicsPipe.I graphicsPipe.h \
graphicsPipeSelection.I graphicsPipeSelection.h \
graphicsStateGuardian.I \
graphicsStateGuardian.h graphicsWindow.I graphicsWindow.h \
graphicsWindowInputDevice.I graphicsWindowInputDevice.h \
hardwareChannel.I hardwareChannel.h interactiveGraphicsPipe.I \
interactiveGraphicsPipe.h \
windowProperties.I windowProperties.h \
hardwareChannel.I hardwareChannel.h \
lensStack.I lensStack.h \
noninteractiveGraphicsPipe.I \
noninteractiveGraphicsPipe.h pipeSpec.I pipeSpec.h renderBuffer.h \
renderBuffer.h \
savedFrameBuffer.I savedFrameBuffer.h
#define IGATESCAN all

View File

@ -53,6 +53,7 @@ PUBLISHED:
INLINE bool is_any_clear_active() const;
private:
// This data needs to be cycled.
enum Flags {
F_clear_color_active = 0x0001,
F_clear_depth_active = 0x0002,

View File

@ -21,8 +21,6 @@
#include "graphicsStateGuardian.h"
#include "savedFrameBuffer.h"
#include "graphicsPipe.h"
#include "interactiveGraphicsPipe.h"
#include "noninteractiveGraphicsPipe.h"
#include "graphicsWindow.h"
#include "graphicsChannel.h"
#include "graphicsLayer.h"
@ -36,28 +34,11 @@ NotifyCategoryDef(display, "");
NotifyCategoryDef(gsg, display_cat);
static Config::ConfigTable::Symbol *disp;
static Config::ConfigTable::Symbol *guard;
static Config::ConfigTable::Symbol *preferred_pipe;
static Config::ConfigTable::Symbol *preferred_window;
static Config::ConfigTable::Symbol *preferred_gsg;
ConfigureFn(config_display) {
init_libdisplay();
}
const string pipe_spec_machine = config_display.GetString("pipe-machine", "");
const string pipe_spec_filename = config_display.GetString("pipe-filename",
"outfile-%03f.rib");
const int pipe_spec_pipe_number = config_display.GetInt("pipe-number", -1);
const bool pipe_spec_is_file = config_display.Defined("pipe-filename")
|| config_display.GetBool("pipe-file", false);
const bool pipe_spec_is_remote = config_display.Defined("pipe-machine")
|| config_display.GetBool("pipe-remote",
false);
const bool compare_state_by_pointer =
config_display.GetBool("compare-state-by-pointer", true);
// This is normally true; set it false to disable view-frustum culling
// (primarily useful for debugging).
const bool view_frustum_cull = config_display.GetBool("view-frustum-cull", true);
@ -67,59 +48,32 @@ const bool view_frustum_cull = config_display.GetBool("view-frustum-cull", true)
// of per-frame overhead to count these things up.
const bool pstats_unused_states = config_display.GetBool("pstats-unused-states", false);
// This is the default threading model to use when the GraphicsEngine
// is created, e.g. app-cull-draw or appculldraw or some such. (See
// GraphicsEngine::set_threading_model()).
// This is the default threading model to use for new windows. Use
// empty string for single-threaded, or something like "cull/draw" for
// a 3-stage pipeline. See GraphicsEngine::set_threading_model().
// Warning! The code that uses this is currently experimental and
// incomplete, and will almost certainly crash! Do not set
// threading-model to anything other than its default of a
// single-threaded model unless you are developing Panda's threading
// system!
const string threading_model = config_display.GetString("threading-model", "appculldraw");
const string threading_model = config_display.GetString("threading-model", "");
// Use this to specify a particular pipe you prefer to use, when more
// than one GraphicsPipe is available (for instance, if both GL and DX
// are linked in). This should be the name of the type preferred, or
// a substring unique to the type name.
const string preferred_pipe = config_display.GetString("preferred-pipe", "");
Config::ConfigTable::Symbol::iterator pipe_modules_begin(void) {
Config::ConfigTable::Symbol::iterator display_modules_begin(void) {
return disp->begin();
}
Config::ConfigTable::Symbol::iterator pipe_modules_end(void) {
Config::ConfigTable::Symbol::iterator display_modules_end(void) {
return disp->end();
}
Config::ConfigTable::Symbol::iterator gsg_modules_begin(void) {
return guard->begin();
}
Config::ConfigTable::Symbol::iterator gsg_modules_end(void) {
return guard->end();
}
Config::ConfigTable::Symbol::iterator preferred_pipe_begin(void) {
return preferred_pipe->begin();
}
Config::ConfigTable::Symbol::iterator preferred_pipe_end(void) {
return preferred_pipe->end();
}
Config::ConfigTable::Symbol::iterator preferred_window_begin(void) {
return preferred_window->begin();
}
Config::ConfigTable::Symbol::iterator preferred_window_end(void) {
return preferred_window->end();
}
Config::ConfigTable::Symbol::iterator preferred_gsg_begin(void) {
return preferred_gsg->begin();
}
Config::ConfigTable::Symbol::iterator preferred_gsg_end(void) {
return preferred_gsg->end();
}
////////////////////////////////////////////////////////////////////
// Function: init_libdisplay
// Description: Initializes the library. This must be called at
@ -141,14 +95,7 @@ init_libdisplay() {
GraphicsStateGuardian::GsgWindow::init_type();
SavedFrameBuffer::init_type();
GraphicsPipe::init_type();
GraphicsPipe::PipeParam::init_type();
GraphicsPipe::PipeSpec::init_type();
InteractiveGraphicsPipe::init_type();
NoninteractiveGraphicsPipe::init_type();
GraphicsWindow::init_type();
GraphicsWindow::WindowParam::init_type();
GraphicsWindow::WindowProps::init_type();
GraphicsWindow::WindowPipe::init_type();
GraphicsChannel::init_type();
GraphicsLayer::init_type();
HardwareChannel::init_type();
@ -157,15 +104,5 @@ init_libdisplay() {
GeomContext::init_type();
disp = new Config::ConfigTable::Symbol;
guard = new Config::ConfigTable::Symbol;
preferred_pipe = new Config::ConfigTable::Symbol;
preferred_window = new Config::ConfigTable::Symbol;
preferred_gsg = new Config::ConfigTable::Symbol;
config_display.GetAll("load-display", *disp);
config_display.GetAll("load-gsg", *guard);
config_display.GetAll("preferred-pipe", *preferred_pipe);
config_display.GetAll("preferred-window", *preferred_window);
config_display.GetAll("preferred-gsg", *preferred_gsg);
}

View File

@ -29,29 +29,14 @@
NotifyCategoryDecl(display, EXPCL_PANDA, EXPTP_PANDA);
NotifyCategoryDecl(gsg, EXPCL_PANDA, EXPTP_PANDA);
extern const string pipe_spec_machine;
extern const string pipe_spec_filename;
extern const int pipe_spec_pipe_number;
extern const bool pipe_spec_is_file;
extern const bool pipe_spec_is_remote;
extern const bool compare_state_by_pointer;
extern const bool view_frustum_cull;
extern const bool pstats_unused_states;
extern const string threading_model;
extern const string preferred_pipe;
extern Config::ConfigTable::Symbol::iterator pipe_modules_begin(void);
extern Config::ConfigTable::Symbol::iterator pipe_modules_end(void);
extern Config::ConfigTable::Symbol::iterator gsg_modules_begin(void);
extern Config::ConfigTable::Symbol::iterator gsg_modules_end(void);
extern Config::ConfigTable::Symbol::iterator preferred_pipe_begin();
extern Config::ConfigTable::Symbol::iterator preferred_pipe_end();
extern Config::ConfigTable::Symbol::iterator preferred_window_begin();
extern Config::ConfigTable::Symbol::iterator preferred_window_end();
extern Config::ConfigTable::Symbol::iterator preferred_gsg_begin();
extern Config::ConfigTable::Symbol::iterator preferred_gsg_end();
extern Config::ConfigTable::Symbol::iterator display_modules_begin(void);
extern Config::ConfigTable::Symbol::iterator display_modules_end(void);
extern EXPCL_PANDA void init_libdisplay();

View File

@ -16,110 +16,10 @@
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_dimensions
// Access: Public
// Description: Retrieves the coordinates of the DisplayRegion's
// rectangle within its GraphicsLayer. These numbers
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
INLINE void DisplayRegion::
get_dimensions(float &l, float &r, float &b, float &t) const {
l = _l;
r = _r;
b = _b;
t = _t;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_left
// Access: Public
// Description: Retrieves the x coordinate of the left edge of the
// rectangle within its GraphicsLayer. This number
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
INLINE float DisplayRegion::
get_left() const {
return _l;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_right
// Access: Public
// Description: Retrieves the x coordinate of the right edge of the
// rectangle within its GraphicsLayer. This number
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
INLINE float DisplayRegion::
get_right() const {
return _r;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_bottom
// Access: Public
// Description: Retrieves the y coordinate of the bottom edge of
// the rectangle within its GraphicsLayer. This
// number will be in the range [0..1].
////////////////////////////////////////////////////////////////////
INLINE float DisplayRegion::
get_bottom() const {
return _b;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_top
// Access: Public
// Description: Retrieves the y coordinate of the top edge of the
// rectangle within its GraphicsLayer. This number
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
INLINE float DisplayRegion::
get_top() const {
return _t;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_layer
// Access: Public
// Description: Returns the layer associated with this particular
// DisplayRegion, or NULL if no layer is associated
// (or if the layer was deleted).
////////////////////////////////////////////////////////////////////
INLINE GraphicsLayer *DisplayRegion::
get_layer() const {
return _layer;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_camera
// Access: Public
// Description: Returns the camera associated with this
// DisplayRegion, or NULL if no camera is associated.
////////////////////////////////////////////////////////////////////
INLINE const NodePath &DisplayRegion::
get_camera() const {
return _camera;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::set_active
// Access: Public
// Description: Sets the active flag associated with the
// DisplayRegion. If the DisplayRegion is marked
// inactive, nothing is rendered.
////////////////////////////////////////////////////////////////////
INLINE void DisplayRegion::
set_active(bool active) {
if (active != _active) {
_active = active;
win_display_regions_changed();
}
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::is_active
// Access: Public
// Access: Published
// Description: Returns the active flag associated with the
// DisplayRegion.
////////////////////////////////////////////////////////////////////
@ -129,67 +29,17 @@ is_active() const {
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::compute_pixels
// Access: Public
// Description: Computes the pixel locations of the DisplayRegion
// within its layer, given the size of the layer in
// pixels.
// Function: DisplayRegion::do_compute_pixels
// Access: Private
// Description: The private implementation of compute_pixels, this
// assumes that we already have the lock.
////////////////////////////////////////////////////////////////////
INLINE void DisplayRegion::
compute_pixels(const int x, const int y) {
_pl = int((_l * x) + 0.5);
_pr = int((_r * x) + 0.5);
_pb = int((_b * y) + 0.5);
_pt = int((_t * y) + 0.5);
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_pixels
// Access: Public
// Description: Retrieves the coordinates of the DisplayRegion within
// its layer, in pixels.
////////////////////////////////////////////////////////////////////
INLINE void DisplayRegion::
get_pixels(int &pl, int &pr, int &pb, int &pt) const {
pl = _pl;
pr = _pr;
pb = _pb;
pt = _pt;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_region_pixels
// Access: Public
// Description: Retrieves the coordinates of the DisplayRegion within
// its layer, as the pixel location of its bottom-left
// corner, along with a pixel width and height.
////////////////////////////////////////////////////////////////////
INLINE void DisplayRegion::
get_region_pixels(int &xo, int &yo, int &w, int &h) const {
xo = _pl;
yo = _pb;
w = _pr - _pl;
h = _pt - _pb;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_pixel_width
// Access: Public
// Description: Returns the width of the DisplayRegion in pixels.
////////////////////////////////////////////////////////////////////
INLINE int DisplayRegion::
get_pixel_width() const {
return _pr - _pl;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_pixel_height
// Access: Public
// Description: Returns the height of the DisplayRegion in pixels.
////////////////////////////////////////////////////////////////////
INLINE int DisplayRegion::
get_pixel_height() const {
return _pt - _pb;
do_compute_pixels(int x_size, int y_size) {
_pl = int((_l * x_size) + 0.5);
_pr = int((_r * x_size) + 0.5);
_pb = int((_b * y_size) + 0.5);
_pt = int((_t * y_size) + 0.5);
}

View File

@ -24,6 +24,7 @@
#include "displayRegion.h"
#include "camera.h"
#include "dcast.h"
#include "mutexHolder.h"
////////////////////////////////////////////////////////////////////
@ -38,6 +39,7 @@ DisplayRegion(GraphicsLayer *layer) :
_camera_node((Camera *)NULL),
_active(true)
{
compute_pixels();
}
////////////////////////////////////////////////////////////////////
@ -53,6 +55,7 @@ DisplayRegion(GraphicsLayer *layer, const float l,
_camera_node((Camera *)NULL),
_active(true)
{
compute_pixels();
}
////////////////////////////////////////////////////////////////////
@ -102,9 +105,77 @@ DisplayRegion::
set_camera(NodePath());
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_dimensions
// Access: Published
// Description: Retrieves the coordinates of the DisplayRegion's
// rectangle within its GraphicsLayer. These numbers
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
void DisplayRegion::
get_dimensions(float &l, float &r, float &b, float &t) const {
MutexHolder holder(_lock);
l = _l;
r = _r;
b = _b;
t = _t;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_left
// Access: Published
// Description: Retrieves the x coordinate of the left edge of the
// rectangle within its GraphicsLayer. This number
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
float DisplayRegion::
get_left() const {
MutexHolder holder(_lock);
return _l;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_right
// Access: Published
// Description: Retrieves the x coordinate of the right edge of the
// rectangle within its GraphicsLayer. This number
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
float DisplayRegion::
get_right() const {
MutexHolder holder(_lock);
return _r;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_bottom
// Access: Published
// Description: Retrieves the y coordinate of the bottom edge of
// the rectangle within its GraphicsLayer. This
// number will be in the range [0..1].
////////////////////////////////////////////////////////////////////
float DisplayRegion::
get_bottom() const {
MutexHolder holder(_lock);
return _b;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_top
// Access: Published
// Description: Retrieves the y coordinate of the top edge of the
// rectangle within its GraphicsLayer. This number
// will be in the range [0..1].
////////////////////////////////////////////////////////////////////
float DisplayRegion::
get_top() const {
MutexHolder holder(_lock);
return _t;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::set_dimensions
// Access: Public
// Access: Published
// Description: Changes the portion of the framebuffer this
// DisplayRegion corresponds to. The parameters range
// from 0 to 1, where 0,0 is the lower left corner and
@ -113,6 +184,7 @@ DisplayRegion::
////////////////////////////////////////////////////////////////////
void DisplayRegion::
set_dimensions(float l, float r, float b, float t) {
MutexHolder holder(_lock);
_l = l;
_r = r;
_b = b;
@ -120,49 +192,68 @@ set_dimensions(float l, float r, float b, float t) {
const GraphicsWindow *win = get_window();
if (win != (GraphicsWindow *)NULL) {
compute_pixels(win->get_width(), win->get_height());
WindowProperties properties = win->get_properties();
if (properties.has_size()) {
do_compute_pixels(properties.get_x_size(), properties.get_y_size());
}
}
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_layer
// Access: Published
// Description: Returns the layer associated with this particular
// DisplayRegion, or NULL if no layer is associated
// (or if the layer was deleted).
////////////////////////////////////////////////////////////////////
GraphicsLayer *DisplayRegion::
get_layer() const {
MutexHolder holder(_lock);
return _layer;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_channel
// Access: Public
// Access: Published
// Description: Returns the GraphicsChannel that this DisplayRegion is
// ultimately associated with, or NULL if no channel is
// associated.
////////////////////////////////////////////////////////////////////
GraphicsChannel *DisplayRegion::
get_channel() const {
MutexHolder holder(_lock);
return (_layer != (GraphicsLayer *)NULL) ? _layer->get_channel() : NULL;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_window
// Access: Public
// Access: Published
// Description: Returns the GraphicsWindow that this DisplayRegion is
// ultimately associated with, or NULL if no window is
// associated.
////////////////////////////////////////////////////////////////////
GraphicsWindow *DisplayRegion::
get_window() const {
MutexHolder holder(_lock);
return (_layer != (GraphicsLayer *)NULL) ? _layer->get_window() : NULL;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_pipe
// Access: Public
// Access: Published
// Description: Returns the GraphicsPipe that this DisplayRegion is
// ultimately associated with, or NULL if no pipe is
// associated.
////////////////////////////////////////////////////////////////////
GraphicsPipe *DisplayRegion::
get_pipe() const {
MutexHolder holder(_lock);
return (_layer != (GraphicsLayer *)NULL) ? _layer->get_pipe() : NULL;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::set_camera
// Access: Public
// Access: Published
// Description: Sets the camera that is associated with this
// DisplayRegion. There is a one-to-one association
// between cameras and DisplayRegions; if this camera
@ -175,6 +266,7 @@ get_pipe() const {
////////////////////////////////////////////////////////////////////
void DisplayRegion::
set_camera(const NodePath &camera) {
MutexHolder holder(_lock);
Camera *camera_node = (Camera *)NULL;
if (!camera.is_empty()) {
DCAST_INTO_V(camera_node, camera.node());
@ -195,13 +287,135 @@ set_camera(const NodePath &camera) {
_camera = camera;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_camera
// Access: Published
// Description: Returns the camera associated with this
// DisplayRegion, or NULL if no camera is associated.
////////////////////////////////////////////////////////////////////
const NodePath &DisplayRegion::
get_camera() const {
MutexHolder holder(_lock);
return _camera;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::set_active
// Access: Published
// Description: Sets the active flag associated with the
// DisplayRegion. If the DisplayRegion is marked
// inactive, nothing is rendered.
////////////////////////////////////////////////////////////////////
void DisplayRegion::
set_active(bool active) {
MutexHolder holder(_lock);
if (active != _active) {
_active = active;
win_display_regions_changed();
}
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::compute_pixels
// Access: Published
// Description: Computes the pixel locations of the DisplayRegion
// within its layer. The DisplayRegion will request the
// size from the window.
////////////////////////////////////////////////////////////////////
void DisplayRegion::
compute_pixels() {
const GraphicsWindow *win = get_window();
if (win != (GraphicsWindow *)NULL) {
MutexHolder holder(_lock);
WindowProperties properties = win->get_properties();
if (!properties.has_size()) {
// If the window doesn't know its size yet, maybe it will
// eventually be given the size it's requesting.
properties = win->get_requested_properties();
}
if (properties.has_size()) {
do_compute_pixels(properties.get_x_size(), properties.get_y_size());
} else {
do_compute_pixels(0, 0);
}
}
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::compute_pixels
// Access: Published
// Description: Computes the pixel locations of the DisplayRegion
// within its layer, given the size of the layer in
// pixels.
////////////////////////////////////////////////////////////////////
void DisplayRegion::
compute_pixels(int x_size, int y_size) {
MutexHolder holder(_lock);
do_compute_pixels(x_size, y_size);
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_pixels
// Access: Published
// Description: Retrieves the coordinates of the DisplayRegion within
// its layer, in pixels.
////////////////////////////////////////////////////////////////////
void DisplayRegion::
get_pixels(int &pl, int &pr, int &pb, int &pt) const {
MutexHolder holder(_lock);
pl = _pl;
pr = _pr;
pb = _pb;
pt = _pt;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_region_pixels
// Access: Published
// Description: Retrieves the coordinates of the DisplayRegion within
// its layer, as the pixel location of its bottom-left
// corner, along with a pixel width and height.
////////////////////////////////////////////////////////////////////
void DisplayRegion::
get_region_pixels(int &xo, int &yo, int &w, int &h) const {
MutexHolder holder(_lock);
xo = _pl;
yo = _pb;
w = _pr - _pl;
h = _pt - _pb;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_pixel_width
// Access: Published
// Description: Returns the width of the DisplayRegion in pixels.
////////////////////////////////////////////////////////////////////
int DisplayRegion::
get_pixel_width() const {
MutexHolder holder(_lock);
return _pr - _pl;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::get_pixel_height
// Access: Published
// Description: Returns the height of the DisplayRegion in pixels.
////////////////////////////////////////////////////////////////////
int DisplayRegion::
get_pixel_height() const {
MutexHolder holder(_lock);
return _pt - _pb;
}
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::output
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
void DisplayRegion::
output(ostream &out) const {
MutexHolder holder(_lock);
out << "DisplayRegion(" << _l << " " << _r << " " << _b << " " << _t
<< ")=pixels(" << _pl << " " << _pr << " " << _pb << " " << _pt
<< ")";
@ -209,11 +423,12 @@ output(ostream &out) const {
////////////////////////////////////////////////////////////////////
// Function: DisplayRegion::win_display_regions_changed
// Access: Public
// Access: Private
// Description: Intended to be called when the active state on a
// nested channel or layer or display region changes,
// forcing the window to recompute its list of active
// display regions.
// display regions. It is assumed the lock is already
// held.
////////////////////////////////////////////////////////////////////
void DisplayRegion::
win_display_regions_changed() {

View File

@ -25,6 +25,7 @@
#include "nodePath.h"
#include "cullResult.h"
#include "pointerTo.h"
#include "mutex.h"
#include "plist.h"
@ -41,50 +42,51 @@ class Camera;
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA DisplayRegion : public ReferenceCount, public ClearableRegion {
public:
DisplayRegion(GraphicsLayer *);
DisplayRegion(GraphicsLayer *,
DisplayRegion(GraphicsLayer *layer);
DisplayRegion(GraphicsLayer *layer,
const float l, const float r,
const float b, const float t);
DisplayRegion(int xsize, int ysize);
private:
DisplayRegion(const DisplayRegion &);
void operator = (const DisplayRegion &);
DisplayRegion(const DisplayRegion &copy);
void operator = (const DisplayRegion &copy);
public:
~DisplayRegion();
PUBLISHED:
INLINE void get_dimensions(float &l, float &r, float &b, float &t) const;
INLINE float get_left() const;
INLINE float get_right() const;
INLINE float get_bottom() const;
INLINE float get_top() const;
void get_dimensions(float &l, float &r, float &b, float &t) const;
float get_left() const;
float get_right() const;
float get_bottom() const;
float get_top() const;
void set_dimensions(float l, float r, float b, float t);
INLINE GraphicsLayer *get_layer() const;
GraphicsLayer *get_layer() const;
GraphicsChannel *get_channel() const;
GraphicsWindow *get_window() const;
GraphicsPipe *get_pipe() const;
void set_camera(const NodePath &camera);
INLINE const NodePath &get_camera() const;
const NodePath &get_camera() const;
INLINE void set_active(bool active);
void set_active(bool active);
INLINE bool is_active() const;
INLINE void compute_pixels(const int x, const int y);
INLINE void get_pixels(int &pl, int &pr, int &pb, int &pt) const;
INLINE void get_region_pixels(int &xo, int &yo, int &w, int &h) const;
void compute_pixels();
void compute_pixels(int x_size, int y_size);
void get_pixels(int &pl, int &pr, int &pb, int &pt) const;
void get_region_pixels(int &xo, int &yo, int &w, int &h) const;
INLINE int get_pixel_width() const;
INLINE int get_pixel_height() const;
int get_pixel_width() const;
int get_pixel_height() const;
void output(ostream &out) const;
public:
private:
void win_display_regions_changed();
protected:
INLINE void do_compute_pixels(int x_size, int y_size);
Mutex _lock;
float _l;
float _r;

View File

@ -1,6 +1,5 @@
#include "config_display.cxx"
#include "graphicsPipeSelection.cxx"
#include "hardwareChannel.cxx"
#include "interactiveGraphicsPipe.cxx"
#include "noninteractiveGraphicsPipe.cxx"
#include "pipeSpec.cxx"
#include "savedFrameBuffer.cxx"
#include "windowProperties.cxx"

View File

@ -17,20 +17,6 @@
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::set_active
// Access: Public
// Description: Sets the active flag on the channel. If the channel
// is marked as inactive, nothing will be rendered.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsChannel::
set_active(bool active) {
if (active != _is_active) {
_is_active = active;
win_display_regions_changed();
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::is_active
// Access: Public

View File

@ -18,18 +18,17 @@
#include "graphicsChannel.h"
#include "graphicsWindow.h"
#include "graphicsLayer.h"
#include "config_display.h"
#include "mutexHolder.h"
#include "pmap.h"
////////////////////////////////////////////////////////////////////
// Static variables
////////////////////////////////////////////////////////////////////
TypeHandle GraphicsChannel::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::Constructor
// Access: Public
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
GraphicsChannel::
@ -41,7 +40,9 @@ GraphicsChannel() {
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::Constructor
// Access: Public
// Description:
// Description: This is public just so derived window types can
// easily call it. Don't call it directly; instead, use
// GraphicsWindow::get_channel() to get a channel.
////////////////////////////////////////////////////////////////////
GraphicsChannel::
GraphicsChannel(GraphicsWindow *window)
@ -56,9 +57,8 @@ GraphicsChannel(GraphicsWindow *window)
// Description:
////////////////////////////////////////////////////////////////////
INLINE GraphicsChannel::
GraphicsChannel(const GraphicsChannel&) {
display_cat.error()
<< "GraphicsChannels should never be copied" << endl;
GraphicsChannel(const GraphicsChannel &) {
nassertv(false);
}
////////////////////////////////////////////////////////////////////
@ -66,16 +66,14 @@ GraphicsChannel(const GraphicsChannel&) {
// Access: Private
// Description:
////////////////////////////////////////////////////////////////////
INLINE GraphicsChannel &GraphicsChannel::
operator=(const GraphicsChannel&) {
display_cat.error()
<< "GraphicsChannels should never be assigned" << endl;
return *this;
INLINE void GraphicsChannel::
operator = (const GraphicsChannel &) {
nassertv(false);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::Destructor
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
GraphicsChannel::
@ -88,7 +86,9 @@ GraphicsChannel::
for (li = _layers.begin();
li != _layers.end();
++li) {
(*li)->_channel = NULL;
GraphicsLayer *layer = (*li);
MutexHolder holder(layer->_lock);
layer->_channel = NULL;
}
// We don't need to remove ourself from the windows's list of
@ -98,7 +98,7 @@ GraphicsChannel::
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::make_layer
// Access: Public
// Access: Published
// Description: Creates a new GraphicsLayer, associated with the
// window, at the indicated index position. If the
// index position negative or past the end of the array,
@ -108,6 +108,7 @@ GraphicsChannel::
////////////////////////////////////////////////////////////////////
GraphicsLayer *GraphicsChannel::
make_layer(int index) {
MutexHolder holder(_lock);
PT(GraphicsLayer) layer = new GraphicsLayer(this);
if (index < 0 || index >= (int)_layers.size()) {
_layers.push_back(layer);
@ -119,29 +120,33 @@ make_layer(int index) {
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::get_num_layers
// Access: Public
// Access: Published
// Description: Returns the number of layers currently associated
// with the channel.
////////////////////////////////////////////////////////////////////
int GraphicsChannel::
get_num_layers() const {
MutexHolder holder(_lock);
return _layers.size();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::get_layer
// Access: Public
// Access: Published
// Description: Returns the nth layer associated with the channel.
////////////////////////////////////////////////////////////////////
GraphicsLayer *GraphicsChannel::
get_layer(int index) const {
nassertr(index >= 0 && index < (int)_layers.size(), NULL);
return _layers[index];
MutexHolder holder(_lock);
if (index >= 0 && index < (int)_layers.size()) {
return _layers[index];
}
return NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::move_layer
// Access: Public
// Access: Published
// Description: Changes the ordering of the layers so that the
// indicated layer will move to the indicated position.
// If to_index is negative or past the end of the array,
@ -149,6 +154,7 @@ get_layer(int index) const {
////////////////////////////////////////////////////////////////////
void GraphicsChannel::
move_layer(int from_index, int to_index) {
MutexHolder holder(_lock);
nassertv(from_index >= 0 && from_index < (int)_layers.size());
PT(GraphicsLayer) layer = _layers[from_index];
@ -170,19 +176,20 @@ move_layer(int from_index, int to_index) {
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::remove_layer
// Access: Public
// Access: Published
// Description: Removes the nth layer. This changes the numbers of
// all subsequent layers.
////////////////////////////////////////////////////////////////////
void GraphicsChannel::
remove_layer(int index) {
MutexHolder holder(_lock);
nassertv(index >= 0 && index < (int)_layers.size());
_layers.erase(_layers.begin() + index);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::get_window
// Access: Public
// Access: Published
// Description: Returns the GraphicsWindow that this channel is
// associated with. It is possible that the
// GraphicsWindow might have been deleted while an
@ -192,21 +199,38 @@ remove_layer(int index) {
////////////////////////////////////////////////////////////////////
GraphicsWindow *GraphicsChannel::
get_window() const {
MutexHolder holder(_lock);
return _window;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::get_pipe
// Access: Public
// Access: Published
// Description: Returns the GraphicsPipe that this channel is
// ultimately associated with, or NULL if no pipe is
// associated.
////////////////////////////////////////////////////////////////////
GraphicsPipe *GraphicsChannel::
get_pipe() const {
MutexHolder holder(_lock);
return (_window != (GraphicsWindow *)NULL) ? _window->get_pipe() : NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::set_active
// Access: Published
// Description: Sets the active flag on the channel. If the channel
// is marked as inactive, nothing will be rendered.
////////////////////////////////////////////////////////////////////
void GraphicsChannel::
set_active(bool active) {
MutexHolder holder(_lock);
if (active != _is_active) {
_is_active = active;
win_display_regions_changed();
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::window_resized
// Access: Public, Virtual
@ -215,25 +239,27 @@ get_pipe() const {
// adjust the channel to account for it.
////////////////////////////////////////////////////////////////////
void GraphicsChannel::
window_resized(int x, int y) {
window_resized(int x_size, int y_size) {
// By default, a normal GraphicsChannel fills the whole window, and
// so when the window resizes so does the channel, by the same
// amount.
MutexHolder holder(_lock);
GraphicsLayers::iterator li;
for (li = _layers.begin();
li != _layers.end();
++li) {
(*li)->channel_resized(x, y);
(*li)->channel_resized(x_size, y_size);
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsChannel::win_display_regions_changed
// Access: Public
// Access: Private
// Description: Intended to be called when the active state on a
// nested channel or layer or display region changes,
// forcing the window to recompute its list of active
// display regions.
// display regions. It is assumed the lock is already
// held.
////////////////////////////////////////////////////////////////////
void GraphicsChannel::
win_display_regions_changed() {

View File

@ -17,22 +17,14 @@
////////////////////////////////////////////////////////////////////
#ifndef GRAPHICSCHANNEL_H
#define GRAPHICSCHANNEL_H
//
////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////
#include <pandabase.h>
#include "pandabase.h"
#include "graphicsLayer.h"
#include <typedReferenceCount.h>
#include <pointerTo.h>
#include "typedReferenceCount.h"
#include "pointerTo.h"
#include "mutex.h"
#include "pvector.h"
////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////
class GraphicsChannel;
class GraphicsPipe;
class GraphicsWindow;
@ -48,14 +40,17 @@ class CullHandler;
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsChannel : public TypedReferenceCount {
protected:
GraphicsChannel();
public:
GraphicsChannel(GraphicsWindow *);
virtual ~GraphicsChannel();
GraphicsChannel(GraphicsWindow *window);
private:
GraphicsChannel(const GraphicsChannel &copy);
void operator = (const GraphicsChannel &copy);
PUBLISHED:
virtual ~GraphicsChannel();
GraphicsLayer *make_layer(int index = -1);
int get_num_layers() const;
GraphicsLayer *get_layer(int index) const;
@ -65,28 +60,23 @@ PUBLISHED:
GraphicsWindow *get_window() const;
GraphicsPipe *get_pipe() const;
public:
virtual void window_resized(int x, int y);
void win_display_regions_changed();
PUBLISHED:
INLINE void set_active(bool active);
void set_active(bool active);
INLINE bool is_active() const;
public:
virtual void window_resized(int x_size, int y_size);
private:
void win_display_regions_changed();
protected:
Mutex _lock;
GraphicsWindow *_window;
bool _is_active;
typedef pvector< PT(GraphicsLayer) > GraphicsLayers;
GraphicsLayers _layers;
private:
GraphicsChannel(const GraphicsChannel&);
GraphicsChannel& operator=(const GraphicsChannel&);
public:
static TypeHandle get_class_type() {
return _type_handle;
@ -105,6 +95,7 @@ private:
static TypeHandle _type_handle;
friend class GraphicsWindow;
friend class GraphicsLayer;
};
#include "graphicsChannel.I"

View File

@ -18,28 +18,17 @@
////////////////////////////////////////////////////////////////////
// Function: GraphicsEngine::get_threading_model
// Function: GraphicsEngine::make_window
// Access: Published
// Description: Returns the current threading model in use; see
// set_threading_model().
// Description: Creates a new window using the indicated GraphicsPipe
// and returns it. The GraphicsEngine becomes the owner
// of the window; it will persist at least until
// remove_window() is called later.
//
// This flavor of make_window() uses the default
// threading model, specified via set_threading_model().
////////////////////////////////////////////////////////////////////
INLINE GraphicsEngine::ThreadingModel GraphicsEngine::
get_threading_model() const {
return _threading_model;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsEngine::start_cull
// Access: Private
// Description: Starts the cull stage for the current frame. This
// may or may not execute within a sub-thread, according
// to the current threading model.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsEngine::
start_cull() {
if (_cull_sorting) {
cull_bin_draw();
} else {
cull_and_draw_together();
}
INLINE GraphicsWindow *GraphicsEngine::
make_window(GraphicsPipe *pipe) {
return make_window(pipe, get_threading_model());
}

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,7 @@
class Pipeline;
class DisplayRegion;
class GraphicsPipe;
////////////////////////////////////////////////////////////////////
// Class : GraphicsEngine
@ -43,44 +44,40 @@ class DisplayRegion;
// required.
//
// The GraphicsEngine is responsible for managing the
// cull and draw processes. The application simply
// calls engine->render_frame() and considers it done.
// various cull and draw threads. The application
// simply calls engine->render_frame() and considers it
// done.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsEngine : public Namable {
class EXPCL_PANDA GraphicsEngine {
PUBLISHED:
GraphicsEngine(Pipeline *pipeline = NULL);
~GraphicsEngine();
void add_window(GraphicsWindow *window);
void set_threading_model(const string &threading_model);
string get_threading_model() const;
INLINE GraphicsWindow *make_window(GraphicsPipe *pipe);
GraphicsWindow *make_window(GraphicsPipe *pipe,
const string &threading_model);
bool remove_window(GraphicsWindow *window);
void remove_all_windows();
void render_frame();
void render_subframe(GraphicsStateGuardian *gsg, DisplayRegion *dr);
enum ThreadingModel {
TM_invalid,
TM_appculldraw,
TM_appcull_draw,
TM_app_culldraw,
TM_app_cull_draw,
TM_appcdraw,
TM_app_cdraw,
};
void set_threading_model(ThreadingModel threading_model);
INLINE ThreadingModel get_threading_model() const;
public:
static ThreadingModel string_threading_model(const string &string);
void render_subframe(GraphicsStateGuardian *gsg, DisplayRegion *dr,
bool cull_sorting);
private:
INLINE void start_cull();
void cull_and_draw_together();
typedef pset< PT(GraphicsWindow) > Windows;
void cull_and_draw_together(const Windows &wlist);
void cull_and_draw_together(GraphicsStateGuardian *gsg, DisplayRegion *dr);
void cull_bin_draw();
void cull_bin_draw(const Windows &wlist);
void cull_bin_draw(GraphicsStateGuardian *gsg, DisplayRegion *dr);
void process_events(const GraphicsEngine::Windows &wlist);
void flip_windows(const GraphicsEngine::Windows &wlist);
PT(SceneSetup) setup_scene(const NodePath &camera,
GraphicsStateGuardian *gsg);
void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
@ -90,17 +87,42 @@ private:
bool setup_gsg(GraphicsStateGuardian *gsg, SceneSetup *scene_setup);
void do_remove_window(GraphicsWindow *window);
void terminate_threads();
// The WindowRenderer class records the stages of the pipeline that
// each thread (including the main thread, a.k.a. "app") should
// process, and the list of windows for each stage.
class WindowRenderer {
public:
void add_window(Windows &wlist, GraphicsWindow *window);
void remove_window(GraphicsWindow *window);
void do_frame(GraphicsEngine *engine);
void do_flip(GraphicsEngine *engine);
void do_release(GraphicsEngine *engine);
void do_close(GraphicsEngine *engine);
void do_pending(GraphicsEngine *engine);
Windows _cull; // cull stage
Windows _cdraw; // cull-and-draw-together stage
Windows _draw; // draw stage
Windows _window; // window stage, i.e. process windowing events
Windows _pending_release; // moved from _draw, pending release_gsg.
Windows _pending_close; // moved from _window, pending close.
Mutex _wl_lock;
};
enum ThreadState {
TS_wait,
TS_do_frame,
TS_do_flip,
TS_do_release,
TS_terminate
};
class CullThread : public Thread {
class RenderThread : public Thread, public WindowRenderer {
public:
CullThread(const string &name, GraphicsEngine *engine);
RenderThread(const string &name, GraphicsEngine *engine);
virtual void thread_main();
GraphicsEngine *_engine;
@ -109,37 +131,23 @@ private:
ThreadState _thread_state;
};
class DrawThread : public Thread {
public:
DrawThread(const string &name, GraphicsEngine *engine);
virtual void thread_main();
GraphicsEngine *_engine;
Mutex _cv_mutex;
ConditionVar _cv;
ThreadState _thread_state;
};
WindowRenderer *get_window_renderer(const string &name);
Pipeline *_pipeline;
typedef pset<PT(GraphicsWindow)> Windows;
Windows _windows;
ThreadingModel _threading_model;
bool _cull_sorting;
WindowRenderer _app;
typedef pmap<string, PT(RenderThread) > Threads;
Threads _threads;
string _threading_model;
PT(CullThread) _cull_thread;
PT(DrawThread) _draw_thread;
Mutex _lock;
static PStatCollector _cull_pcollector;
static PStatCollector _draw_pcollector;
friend class CullThread;
friend class WindowRenderer;
};
ostream &
operator << (ostream &out, GraphicsEngine::ThreadingModel threading_model);
#include "graphicsEngine.I"
#endif

View File

@ -16,34 +16,6 @@
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::get_channel
// Access: Published
// Description: Returns the GraphicsChannel that this layer is
// associated with. It is possible that the
// GraphicsChannel might have been deleted while an
// outstanding PT(GraphicsLayer) prevented all of its
// children layers from also being deleted; in this
// unlikely case, get_channel() may return NULL.
////////////////////////////////////////////////////////////////////
INLINE GraphicsChannel *GraphicsLayer::
get_channel() const {
return _channel;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::set_active
// Access: Published
// Description: Sets the active flag on the layer. If the layer
// is marked as inactive, nothing will be rendered.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsLayer::
set_active(bool active) {
if (active != _is_active) {
_is_active = active;
win_display_regions_changed();
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::is_active
@ -54,4 +26,3 @@ INLINE bool GraphicsLayer::
is_active() const {
return _is_active;
}

View File

@ -20,20 +20,19 @@
#include "graphicsChannel.h"
#include "graphicsWindow.h"
#include "config_display.h"
#include "notify.h"
#include "mutexHolder.h"
#include <algorithm>
#include <notify.h>
////////////////////////////////////////////////////////////////////
// Static variables
////////////////////////////////////////////////////////////////////
TypeHandle GraphicsLayer::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::Constructor
// Access: Public
// Description:
// Access: Private
// Description: Use GraphicsChannel::make_layer() to make a new
// layer.
////////////////////////////////////////////////////////////////////
GraphicsLayer::
GraphicsLayer() {
@ -44,7 +43,8 @@ GraphicsLayer() {
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::Constructor
// Access: Public
// Description:
// Description: Use GraphicsChannel::make_layer() to make a new
// layer.
////////////////////////////////////////////////////////////////////
GraphicsLayer::
GraphicsLayer(GraphicsChannel *channel)
@ -58,10 +58,9 @@ GraphicsLayer(GraphicsChannel *channel)
// Access: Private
// Description:
////////////////////////////////////////////////////////////////////
INLINE GraphicsLayer::
GraphicsLayer(const GraphicsLayer&) {
display_cat.error()
<< "GraphicsLayers should never be copied" << endl;
GraphicsLayer::
GraphicsLayer(const GraphicsLayer &) {
nassertv(false);
}
////////////////////////////////////////////////////////////////////
@ -69,16 +68,14 @@ GraphicsLayer(const GraphicsLayer&) {
// Access: Private
// Description:
////////////////////////////////////////////////////////////////////
INLINE GraphicsLayer &GraphicsLayer::
operator=(const GraphicsLayer&) {
display_cat.error()
<< "GraphicsLayers should never be assigned" << endl;
return *this;
void GraphicsLayer::
operator = (const GraphicsLayer &) {
nassertv(false);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::Destructor
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
GraphicsLayer::
@ -91,7 +88,9 @@ GraphicsLayer::
for (dri = _display_regions.begin();
dri != _display_regions.end();
++dri) {
(*dri)->_layer = NULL;
DisplayRegion *dr = (*dri);
MutexHolder holder(dr->_lock);
dr->_layer = NULL;
}
win_display_regions_changed();
@ -102,17 +101,15 @@ GraphicsLayer::
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::make_display_region
// Access: Public
// Access: Published
// Description: Creates a new DisplayRegion that covers the entire
// layer.
////////////////////////////////////////////////////////////////////
DisplayRegion *GraphicsLayer::
make_display_region() {
PT(DisplayRegion) dr = new DisplayRegion(this);
const GraphicsWindow *win = get_window();
if (win != (GraphicsWindow *)NULL) {
dr->compute_pixels(win->get_width(), win->get_height());
}
MutexHolder holder(_lock);
_display_regions.push_back(dr);
win_display_regions_changed();
return dr;
@ -120,7 +117,7 @@ make_display_region() {
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::make_display_region
// Access: Public
// Access: Published
// Description: Creates a new DisplayRegion that covers the indicated
// sub-rectangle within the layer.
////////////////////////////////////////////////////////////////////
@ -128,10 +125,8 @@ DisplayRegion *GraphicsLayer::
make_display_region(float l, float r, float b, float t) {
nassertr(this != (GraphicsLayer *)NULL, NULL);
PT(DisplayRegion) dr = new DisplayRegion(this, l, r, b, t);
const GraphicsWindow *win = get_window();
if (win != (GraphicsWindow *)NULL) {
dr->compute_pixels(win->get_width(), win->get_height());
}
MutexHolder holder(_lock);
_display_regions.push_back(dr);
win_display_regions_changed();
return dr;
@ -139,36 +134,43 @@ make_display_region(float l, float r, float b, float t) {
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::get_num_drs
// Access: Public
// Access: Published
// Description: Returns the number of DisplayRegions associated with
// the layer.
////////////////////////////////////////////////////////////////////
int GraphicsLayer::
get_num_drs() const {
MutexHolder holder(_lock);
return _display_regions.size();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::get_dr
// Access: Public
// Access: Published
// Description: Returns the nth DisplayRegion associated with the
// layer.
// layer. This might return NULL if another thread has
// recently removed a DisplayRegion.
////////////////////////////////////////////////////////////////////
DisplayRegion *GraphicsLayer::
get_dr(int index) const {
nassertr(index >= 0 && index < (int)_display_regions.size(), NULL);
return _display_regions[index];
MutexHolder holder(_lock);
if (index >= 0 && index < (int)_display_regions.size()) {
return _display_regions[index];
} else {
return NULL;
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::remove_dr
// Access: Public
// Access: Published
// Description: Removes (and possibly deletes) the nth DisplayRegion
// associated with the layer. All subsequent index
// numbers will shift down one.
////////////////////////////////////////////////////////////////////
void GraphicsLayer::
remove_dr(int index) {
MutexHolder holder(_lock);
nassertv(index >= 0 && index < (int)_display_regions.size());
_display_regions[index]->_layer = NULL;
_display_regions.erase(_display_regions.begin() + index);
@ -177,7 +179,7 @@ remove_dr(int index) {
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::remove_dr
// Access: Public
// Access: Published
// Description: Removes (and possibly deletes) the indicated
// DisplayRegion associated with the layer. All
// subsequent index numbers will shift down one.
@ -186,8 +188,7 @@ remove_dr(int index) {
////////////////////////////////////////////////////////////////////
bool GraphicsLayer::
remove_dr(DisplayRegion *display_region) {
// For whatever reason, VC++ considers == ambiguous unless we
// compare it to a PT(DisplayRegion) instead of a DisplayRegion*.
MutexHolder holder(_lock);
PT(DisplayRegion) ptdr = display_region;
DisplayRegions::iterator dri =
find(_display_regions.begin(), _display_regions.end(), ptdr);
@ -200,40 +201,73 @@ remove_dr(DisplayRegion *display_region) {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::get_channel
// Access: Published
// Description: Returns the GraphicsChannel that this layer is
// associated with. It is possible that the
// GraphicsChannel might have been deleted while an
// outstanding PT(GraphicsLayer) prevented all of its
// children layers from also being deleted; in this
// unlikely case, get_channel() may return NULL.
////////////////////////////////////////////////////////////////////
GraphicsChannel *GraphicsLayer::
get_channel() const {
MutexHolder holder(_lock);
return _channel;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::get_window
// Access: Public
// Access: Published
// Description: Returns the GraphicsWindow that this layer is
// ultimately associated with, or NULL if no window is
// associated.
////////////////////////////////////////////////////////////////////
GraphicsWindow *GraphicsLayer::
get_window() const {
nassertr(this != (GraphicsLayer *)NULL, NULL);
MutexHolder holder(_lock);
return (_channel != (GraphicsChannel *)NULL) ? _channel->get_window() : NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::get_pipe
// Access: Public
// Access: Published
// Description: Returns the GraphicsPipe that this layer is
// ultimately associated with, or NULL if no pipe is
// associated.
////////////////////////////////////////////////////////////////////
GraphicsPipe *GraphicsLayer::
get_pipe() const {
MutexHolder holder(_lock);
return (_channel != (GraphicsChannel *)NULL) ? _channel->get_pipe() : NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::set_active
// Access: Published
// Description: Sets the active flag on the layer. If the layer
// is marked as inactive, nothing will be rendered.
////////////////////////////////////////////////////////////////////
void GraphicsLayer::
set_active(bool active) {
MutexHolder holder(_lock);
if (active != _is_active) {
_is_active = active;
win_display_regions_changed();
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::channel_resized
// Access: Public, Virtual
// Access: Public
// Description: This is called whenever the parent channel has been
// resized; it should do whatever needs to be done to
// adjust the layer to account for it.
////////////////////////////////////////////////////////////////////
void GraphicsLayer::
channel_resized(int x, int y) {
MutexHolder holder(_lock);
// Since a layer always fills the whole channel, when the channel
// resizes so does the layer, by the same amount.
DisplayRegions::iterator dri;
@ -246,11 +280,12 @@ channel_resized(int x, int y) {
////////////////////////////////////////////////////////////////////
// Function: GraphicsLayer::win_display_regions_changed
// Access: Public
// Access: Private
// Description: Intended to be called when the active state on a
// nested channel or layer or display region changes,
// forcing the window to recompute its list of active
// display regions.
// display regions. It is assumed the lock is already
// held.
////////////////////////////////////////////////////////////////////
void GraphicsLayer::
win_display_regions_changed() {

View File

@ -19,21 +19,14 @@
#ifndef GRAPHICSLAYER_H
#define GRAPHICSLAYER_H
////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////
#include <pandabase.h>
#include "pandabase.h"
#include "displayRegion.h"
#include <typedReferenceCount.h>
#include <pointerTo.h>
#include "typedReferenceCount.h"
#include "pointerTo.h"
#include "mutex.h"
#include "pvector.h"
////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////
class GraphicsChannel;
class GraphicsWindow;
class GraphicsPipe;
@ -50,15 +43,17 @@ class CullHandler;
// without clearing the framebuffer between layers.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsLayer : public TypedReferenceCount {
protected:
private:
GraphicsLayer();
GraphicsLayer(GraphicsChannel *);
GraphicsLayer(GraphicsChannel *channel);
public:
virtual ~GraphicsLayer();
private:
GraphicsLayer(const GraphicsLayer &copy);
void operator = (const GraphicsLayer &copy);
PUBLISHED:
virtual ~GraphicsLayer();
DisplayRegion *make_display_region();
DisplayRegion *make_display_region(float l, float r,
float b, float t);
@ -68,31 +63,26 @@ PUBLISHED:
void remove_dr(int index);
bool remove_dr(DisplayRegion *display_region);
INLINE GraphicsChannel *get_channel() const;
GraphicsChannel *get_channel() const;
GraphicsWindow *get_window() const;
GraphicsPipe *get_pipe() const;
void set_active(bool active);
INLINE bool is_active() const;
public:
void channel_resized(int x, int y);
private:
void win_display_regions_changed();
PUBLISHED:
INLINE void set_active(bool active);
INLINE bool is_active() const;
private:
Mutex _lock;
GraphicsChannel *_channel;
bool _is_active;
typedef pvector< PT(DisplayRegion) > DisplayRegions;
DisplayRegions _display_regions;
private:
GraphicsLayer(const GraphicsLayer&);
GraphicsLayer& operator=(const GraphicsLayer&);
public:
static TypeHandle get_class_type() {
@ -113,6 +103,7 @@ private:
friend class GraphicsChannel;
friend class GraphicsWindow;
friend class DisplayRegion;
};
#include "graphicsLayer.I"

View File

@ -16,21 +16,3 @@
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_all_pipes
// Access: Private, Static
// Description: Returns a reference to the static _all_pipes
// container. This wrapper function allows us to
// guarantee creation of the container before we attempt
// to reference it.
////////////////////////////////////////////////////////////////////
INLINE GraphicsPipe::Pipes &GraphicsPipe::
get_all_pipes() {
if (_all_pipes == NULL) {
_all_pipes = new Pipes;
}
return *_all_pipes;
}

View File

@ -18,251 +18,93 @@
#include "graphicsPipe.h"
#include "config_display.h"
#include "mutexHolder.h"
#include "load_dso.h"
#include "filename.h"
#include "pset.h"
#include <algorithm>
// Static variables
////////////////////////////////////////////////////////////////////
TypeHandle GraphicsPipe::_type_handle;
TypeHandle GraphicsPipe::PipeSpec::_type_handle;
// These static members are pointers rather than concrete objects so
// we can guarantee order of creation at static init time.
GraphicsPipe::PipeFactory *GraphicsPipe::_factory = NULL;
GraphicsPipe::Pipes *GraphicsPipe::_all_pipes = NULL;
GraphicsPipe::PipeSpec::~PipeSpec(void) {}
TypeHandle GraphicsPipe::PipeSpec::get_class_type(void) {
return _type_handle;
}
void GraphicsPipe::PipeSpec::init_type(void) {
PipeParam::init_type();
register_type(_type_handle, "GraphicsPipe::PipeSpec",
PipeParam::get_class_type());
}
TypeHandle GraphicsPipe::PipeSpec::get_type(void) const {
return get_class_type();
}
TypeHandle GraphicsPipe::PipeSpec::force_init_type(void) {
init_type();
return get_class_type();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
GraphicsPipe::
GraphicsPipe(const PipeSpecifier &spec) :
Namable(spec.get_name())
{
// Add ourself to the global list of pipes.
get_all_pipes().push_back(this);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::Default Constructor
// Access: Private
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
GraphicsPipe::
GraphicsPipe() {
display_cat.error()
<< "GraphicsPipes should not be called with default constructor" << endl;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::Copy Constructor
// Access: Private
// Description:
// Description: Don't try to copy GraphicsPipes.
////////////////////////////////////////////////////////////////////
GraphicsPipe::
GraphicsPipe(const GraphicsPipe&) {
display_cat.error()
<< "GraphicsPipes should not be copied" << endl;
GraphicsPipe(const GraphicsPipe &) {
nassertv(false);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::Copy Assignment Operator
// Access: Private
// Description:
// Description: Don't try to copy GraphicsPipes.
////////////////////////////////////////////////////////////////////
GraphicsPipe &GraphicsPipe::
operator=(const GraphicsPipe&) {
display_cat.error()
<< "GraphicsPipes should not be assigned" << endl;
return *this;
void GraphicsPipe::
operator = (const GraphicsPipe &) {
nassertv(false);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::Destructor
// Access: Public
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
GraphicsPipe::
~GraphicsPipe() {
// We don't have to destruct our child windows explicitly, since
// they are all reference-counted and will go away when their
// pointers do. However, we do need to zero out their pointers to
// us.
Windows::const_iterator wi;
// On destruction, we need to clean up our references to all of the
// windows.
Windows::iterator wi;
for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
(*wi)->_pipe = NULL;
}
// Remove ourself from the global list.
Pipes &all_pipes = get_all_pipes();
Pipes::iterator pi =
find(all_pipes.begin(), all_pipes.end(), this);
if (pi != all_pipes.end()) {
all_pipes.erase(pi);
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::make_window
// Access: Public
// Description: Creates and returns a new window on the pipe. The
// window will automatically be added to the pipe's
// reference-countling list of windows; it must later be
// explicitly removed to destroy it (you should not
// attempt to delete it).
////////////////////////////////////////////////////////////////////
GraphicsWindow *GraphicsPipe::
make_window() {
FactoryParams params;
params.add_param(new GraphicsWindow::WindowPipe(this));
GraphicsWindow *win = GraphicsWindow::get_factory().
make_instance(get_window_type(), params);
nassertr(win != (GraphicsWindow *)NULL, NULL);
add_window(win);
return win;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::make_window
// Access: Public
// Description: Creates and returns a new window on the pipe. The
// window will automatically be added to the pipe's
// reference-countling list of windows; it must later be
// explicitly removed to destroy it (you should not
// attempt to delete it).
////////////////////////////////////////////////////////////////////
GraphicsWindow *GraphicsPipe::
make_window(const GraphicsWindow::Properties &props) {
FactoryParams params;
params.add_param(new GraphicsWindow::WindowPipe(this));
params.add_param(new GraphicsWindow::WindowProps(props));
GraphicsWindow *win = GraphicsWindow::get_factory().
make_instance(get_window_type(), params);
nassertr(win != (GraphicsWindow *)NULL, NULL);
add_window(win);
return win;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::remove_window
// Access: Public
// Description: Deletes a previously-created window by removing it
// from the reference-counting list of windows owned by
// the pipe. Note that the window will not actually be
// deleted until all pointers to it (for instance, on
// mouse objects, etc.) are cleared.
////////////////////////////////////////////////////////////////////
void GraphicsPipe::
remove_window(GraphicsWindow *window) {
// For whatever reason, VC++ considers == ambiguous unless we
// compare it to a PT(GraphicsWindow) instead of a GraphicsWindow*.
PT(GraphicsWindow) ptwin = window;
Windows::iterator wi =
find(_windows.begin(), _windows.end(), ptwin);
if (wi != _windows.end()) {
_windows.erase(wi);
GraphicsWindow *window = (*wi);
window->_pipe = NULL;
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_num_windows
// Access: Public
// Access: Published
// Description: Returns the number of windows that have been created
// on this pipe.
////////////////////////////////////////////////////////////////////
int GraphicsPipe::
get_num_windows() const {
return _windows.size();
int result;
{
MutexHolder holder(_lock);
result = _windows.size();
}
return result;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_window
// Access: Public
// Description: Returns the nth window associated with this pipe. n
// must be between 0 and get_num_windows().
// Access: Published
// Description: Returns the nth window that has been created
// on this pipe. It is possible for this to return NULL
// due to a window being removed in another thread.
////////////////////////////////////////////////////////////////////
GraphicsWindow *GraphicsPipe::
PT(GraphicsWindow) GraphicsPipe::
get_window(int n) const {
nassertr(n >= 0 && n < get_num_windows(), NULL);
return _windows[n];
PT(GraphicsWindow) result;
{
MutexHolder holder(_lock);
if (n >= 0 && n < (int)_windows.size()) {
result = _windows[n];
}
}
return result;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_num_pipes
// Access: Public, Static
// Description: Returns the total number of pipes in the universe.
////////////////////////////////////////////////////////////////////
int GraphicsPipe::
get_num_pipes() {
return get_all_pipes().size();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_pipe
// Access: Public, Static
// Description: Returns the nth pipe in the universe. n must be
// between 0 and get_num_pipes().
////////////////////////////////////////////////////////////////////
GraphicsPipe *GraphicsPipe::
get_pipe(int n) {
nassertr(n >= 0 && n < get_num_pipes(), NULL);
return get_all_pipes()[n];
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_glx_display
// Access: Public, Virtual
// Description: Returns the glxDisplay information associated with
// this pipe, if any. This allows us to define several
// kinds of GraphicsPipe objects that manage some
// glx-specific stuff, without having them all inherit
// from a common glx base class. This allows the
// glxGraphicsWindow to ask questions about the
// glx-specific stuff without knowing what kind of
// glxGraphicsPipe it has. Non-glx pipes will simply
// return NULL for this function.
////////////////////////////////////////////////////////////////////
glxDisplay *GraphicsPipe::
get_glx_display() {
return (glxDisplay *)NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_num_hw_channels
// Access: Protected, Virtual
// Access: Public, Virtual
// Description: Returns the number of hardware channels available for
// pipes of this type. See get_hw_channel().
////////////////////////////////////////////////////////////////////
@ -271,7 +113,6 @@ get_num_hw_channels() {
return 0;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_hw_channel
// Access: Public, Virtual
@ -287,92 +128,44 @@ get_num_hw_channels() {
// always return NULL.
////////////////////////////////////////////////////////////////////
HardwareChannel *GraphicsPipe::
get_hw_channel(GraphicsWindow*, int) {
get_hw_channel(GraphicsWindow *, int) {
return (HardwareChannel*)0L;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::add_window
// Access: Protected
// Description: Adds a newly-created window to the set of windows
// owned by the pipe. This function is intended to be
// called from a derived class' make_window() function.
// Description: This is intended to be called by the derived
// make_window() function to add the newly-created
// window to the list of windows owned by this pipe.
////////////////////////////////////////////////////////////////////
void GraphicsPipe::
add_window(GraphicsWindow *win) {
_windows.push_back(win);
}
void GraphicsPipe::read_priorities(void) {
PipeFactory &factory = get_factory();
if (factory.get_num_preferred() == 0) {
Config::ConfigTable::Symbol::iterator i;
for (i = preferred_pipe_begin(); i != preferred_pipe_end(); ++i) {
ConfigString type_name = (*i).Val();
TypeHandle type = TypeRegistry::ptr()->find_type(type_name);
if (type == TypeHandle::none()) {
display_cat.warning()
<< "Unknown type requested for pipe preference: " << type_name
<< "\n";
} else {
display_cat.debug()
<< "Specifying type " << type << " for pipe preference.\n";
factory.add_preferred(type);
}
}
}
add_window(GraphicsWindow *window) {
nassertv(window->_pipe == this);
MutexHolder holder(_lock);
_windows.push_back(window);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::get_factory
// Access: Public, Static
// Description: Returns the factory object that can be used to
// register new kinds of GraphicsPipe objects that may
// be created.
// Function: GraphicsPipe::remove_window
// Access: Protected
// Description: This is intended to be called by the GraphicsEngine
// when a window is to be removed. It returns true if
// the window is removed, or false if it was not found.
////////////////////////////////////////////////////////////////////
GraphicsPipe::PipeFactory &GraphicsPipe::
get_factory() {
if (_factory == (PipeFactory *)NULL) {
_factory = new PipeFactory;
}
return (*_factory);
}
void GraphicsPipe::resolve_modules(void) {
Config::ConfigTable::Symbol::iterator i;
// Build up a set of the modules we've already loaded as we go, so
// we don't attempt to load a given module more than once.
pset<string> already_loaded;
for (i=pipe_modules_begin(); i!=pipe_modules_end(); ++i) {
string name = (*i).Val();
if (already_loaded.insert(name).second) {
Filename dlname = Filename::dso_filename("lib" + name + ".so");
display_cat.info()
<< "loading display module: " << dlname.to_os_specific() << endl;
void *tmp = load_dso(dlname);
if (tmp == (void*)0L) {
display_cat.info()
<< "Unable to load: " << load_dso_error() << endl;
}
}
}
for (i=gsg_modules_begin(); i!=gsg_modules_end(); ++i) {
string name = (*i).Val();
if (already_loaded.insert(name).second) {
Filename dlname = Filename::dso_filename("lib" + name + ".so");
display_cat.info()
<< "loading GSG module: " << dlname.to_os_specific() << endl;
void *tmp = load_dso(dlname);
if (tmp == (void*)0L) {
display_cat.info()
<< "Unable to load: " << load_dso_error() << endl;
}
bool GraphicsPipe::
remove_window(GraphicsWindow *window) {
bool removed = false;
{
MutexHolder holder(_lock);
PT(GraphicsWindow) ptwin = window;
window->_pipe = NULL;
Windows::iterator wi = find(_windows.begin(), _windows.end(), ptwin);
if (wi != _windows.end()) {
_windows.erase(wi);
removed = true;
}
}
read_priorities();
GraphicsWindow::read_priorities();
GraphicsPipe::read_priorities();
return removed;
}

View File

@ -15,114 +15,64 @@
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef GRAPHICSPIPE_H
#define GRAPHICSPIPE_H
//
////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////
#include <pandabase.h>
#include "graphicsWindow.h"
#include "hardwareChannel.h"
#include "pipeSpec.h"
#include "pandabase.h"
#include <typedReferenceCount.h>
#include <namable.h>
#include <factory.h>
#include <factoryParam.h>
#include <string>
#include "typedReferenceCount.h"
#include "pointerTo.h"
#include "mutex.h"
#include "pvector.h"
////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////
class GraphicsPipe;
class glxDisplay;
class HardwareChannel;
class GraphicsWindow;
////////////////////////////////////////////////////////////////////
// Class : GraphicsPipe
// Description :
// Description : An object to create GraphicsWindows that share a
// particular 3-D API. Normally, there will only be one
// GraphicsPipe in an application, although it is
// possible to have multiple of these at once if there
// are multiple different API's available in the same
// machine.
//
// Often, the GraphicsPipe corresponds to a physical
// output device, hence the term "pipe", but this is not
// necessarily the case.
//
// The GraphicsPipe is used by the GraphicsEngine object
// to create and destroy windows; it keeps ownership of
// the windows it creates.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsPipe : public TypedReferenceCount, public Namable {
class EXPCL_PANDA GraphicsPipe : public TypedReferenceCount {
protected:
GraphicsPipe();
private:
GraphicsPipe(const GraphicsPipe &copy);
void operator = (const GraphicsPipe &copy);
PUBLISHED:
GraphicsPipe(const PipeSpecifier &spec);
virtual ~GraphicsPipe();
GraphicsWindow *make_window();
GraphicsWindow *make_window(const GraphicsWindow::Properties&);
void remove_window(GraphicsWindow *window);
virtual TypeHandle get_window_type() const=0;
// Functions for obtaining the set of windows associated with this
// pipe, and the set of all GraphicsPipes in the world.
int get_num_windows() const;
GraphicsWindow *get_window(int n) const;
static int get_num_pipes();
static GraphicsPipe *get_pipe(int n);
PT(GraphicsWindow) get_window(int n) const;
public:
// This function's interface must be defined here even though we
// know nothing about glx displays at this point.
virtual glxDisplay *get_glx_display();
protected:
virtual int get_num_hw_channels();
virtual HardwareChannel *get_hw_channel(GraphicsWindow *, int);
void add_window(GraphicsWindow *win);
public:
// Factory stuff
typedef Factory<GraphicsPipe> PipeFactory;
typedef FactoryParam PipeParam;
// Make a factory parameter type for the pipe specifier
class EXPCL_PANDA PipeSpec : public PipeParam {
public:
INLINE PipeSpec(void) : PipeParam() {}
INLINE PipeSpec(PipeSpecifier& p) : PipeParam(), _p(p) {}
virtual ~PipeSpec(void);
INLINE const PipeSpecifier &get_specifier(void) { return _p; }
public:
static TypeHandle get_class_type(void);
static void init_type(void);
virtual TypeHandle get_type(void) const;
virtual TypeHandle force_init_type(void);
private:
PipeSpecifier _p;
static TypeHandle _type_handle;
};
static PipeFactory &get_factory();
static void resolve_modules(void);
private:
static void read_priorities(void);
virtual HardwareChannel *get_hw_channel(GraphicsWindow *window, int index);
protected:
virtual PT(GraphicsWindow) make_window()=0;
GraphicsPipe();
GraphicsPipe(const GraphicsPipe &copy);
GraphicsPipe &operator = (const GraphicsPipe &copy);
void add_window(GraphicsWindow *window);
bool remove_window(GraphicsWindow *window);
private:
// Some private type declarations. These must be declared here so
// we can declare the public iterator types, below.
typedef pvector< PT(GraphicsWindow) > Windows;
typedef pvector<GraphicsPipe *> Pipes;
Windows _windows;
Mutex _lock;
static PipeFactory *_factory;
static Pipes *_all_pipes;
INLINE static Pipes &get_all_pipes();
public:
static TypeHandle get_class_type() {
@ -130,10 +80,8 @@ public:
}
static void init_type() {
TypedReferenceCount::init_type();
Namable::init_type();
register_type(_type_handle, "GraphicsPipe",
TypedReferenceCount::get_class_type(),
Namable::get_class_type());
TypedReferenceCount::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
@ -142,9 +90,7 @@ public:
private:
static TypeHandle _type_handle;
// this is so it can call get_hw_channel
friend class GraphicsWindow;
friend class GraphicsEngine;
};
#include "graphicsPipe.I"

View File

@ -0,0 +1,57 @@
// Filename: graphicsPipeSelection.I
// Created by: drose (15Aug02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::resolve_modules
// Access: Published
// Description: Conditionally calls do_resolve_modules(), if it has
// not been called before.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsPipeSelection::
resolve_modules() const {
if (!_resolved_modules) {
((GraphicsPipeSelection *)this)->do_resolve_modules();
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::get_global_ptr
// Access: Published, Static
// Description: Returns a pointer to the one global
// GraphicsPipeSelection object.
////////////////////////////////////////////////////////////////////
INLINE GraphicsPipeSelection *GraphicsPipeSelection::
get_global_ptr() {
if (_global_ptr == (GraphicsPipeSelection *)NULL) {
_global_ptr = new GraphicsPipeSelection;
}
return _global_ptr;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::PipeType::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE GraphicsPipeSelection::PipeType::
PipeType(TypeHandle type, PipeConstructorFunc *constructor) :
_type(type),
_constructor(constructor)
{
}

View File

@ -0,0 +1,251 @@
// Filename: graphicsPipeSelection.cxx
// Created by: drose (15Aug02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "graphicsPipeSelection.h"
#include "mutexHolder.h"
#include "string_utils.h"
#include "filename.h"
#include "load_dso.h"
#include "config_display.h"
GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = NULL;
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::Constructor
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
GraphicsPipeSelection::
GraphicsPipeSelection() {
_resolved_modules = false;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::Destructor
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
GraphicsPipeSelection::
~GraphicsPipeSelection() {
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::get_num_pipe_types
// Access: Published
// Description: Returns the number of different types of
// GraphicsPipes that are available to create through
// this interface.
////////////////////////////////////////////////////////////////////
int GraphicsPipeSelection::
get_num_pipe_types() const {
resolve_modules();
int result;
{
MutexHolder holder(_lock);
result = _pipe_types.size();
}
return result;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::get_pipe_type
// Access: Published
// Description: Returns the nth type of GraphicsPipe available
// through this interface.
////////////////////////////////////////////////////////////////////
TypeHandle GraphicsPipeSelection::
get_pipe_type(int n) const {
resolve_modules();
TypeHandle result;
{
MutexHolder holder(_lock);
if (n >= 0 && n < (int)_pipe_types.size()) {
result = _pipe_types[n]._type;
}
}
return result;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::make_pipe
// Access: Published
// Description: Creates a new GraphicsPipe of the indicated type (or
// a type more specific than the indicated type, if
// necessary) and returns it. Returns NULL if the type
// cannot be matched.
////////////////////////////////////////////////////////////////////
PT(GraphicsPipe) GraphicsPipeSelection::
make_pipe(TypeHandle type) {
resolve_modules();
MutexHolder holder(_lock);
PipeTypes::const_iterator ti;
// First, look for an exact match of the requested type.
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
const PipeType &ptype = (*ti);
if (ptype._type == type) {
// Here's an exact match.
PT(GraphicsPipe) pipe = (*ptype._constructor)();
if (pipe != (GraphicsPipe *)NULL) {
return pipe;
}
}
}
// Now look for a more-specific type.
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
const PipeType &ptype = (*ti);
if (ptype._type.is_derived_from(type)) {
// Here's an approximate match.
PT(GraphicsPipe) pipe = (*ptype._constructor)();
if (pipe != (GraphicsPipe *)NULL) {
return pipe;
}
}
}
// Couldn't find a matching pipe type.
return NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::make_default_pipe
// Access: Published
// Description: Creates a new GraphicsPipe of some arbitrary type.
// The user may specify a preference using the Configrc
// file; otherwise, one will be chosen arbitrarily.
////////////////////////////////////////////////////////////////////
PT(GraphicsPipe) GraphicsPipeSelection::
make_default_pipe() {
resolve_modules();
MutexHolder holder(_lock);
PipeTypes::const_iterator ti;
// First, look for an exact match of the requested type (excepting
// case and hyphen/underscore).
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
const PipeType &ptype = (*ti);
if (cmp_nocase_uh(ptype._type.get_name(), preferred_pipe) == 0) {
// Here's an exact match.
PT(GraphicsPipe) pipe = (*ptype._constructor)();
if (pipe != (GraphicsPipe *)NULL) {
return pipe;
}
}
}
// No match; look for a substring match.
string preferred_name = downcase(preferred_pipe);
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
const PipeType &ptype = (*ti);
string ptype_name = downcase(ptype._type.get_name());
if (ptype_name.find(preferred_name) != string::npos) {
// Here's a substring match.
PT(GraphicsPipe) pipe = (*ptype._constructor)();
if (pipe != (GraphicsPipe *)NULL) {
return pipe;
}
}
}
// Couldn't find a matching pipe type; choose one arbitrarily.
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
const PipeType &ptype = (*ti);
PT(GraphicsPipe) pipe = (*ptype._constructor)();
if (pipe != (GraphicsPipe *)NULL) {
return pipe;
}
}
// Nothing. Probably the list was empty.
return NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::add_pipe_type
// Access: Public
// Description: Adds a new kind of GraphicsPipe to the list of
// available pipes for creation. Normally, this is
// called at static init type by the various shared
// libraries as they are linked in. Returns true on
// success, false on failure.
////////////////////////////////////////////////////////////////////
bool GraphicsPipeSelection::
add_pipe_type(TypeHandle type, PipeConstructorFunc *func) {
if (!type.is_derived_from(GraphicsPipe::get_class_type())) {
display_cat.warning()
<< "Attempt to register " << type << " as a GraphicsPipe type.\n";
return false;
}
// First, make sure we don't already have a GraphicsPipe of this
// type.
MutexHolder holder(_lock);
PipeTypes::const_iterator ti;
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
const PipeType &ptype = (*ti);
if (ptype._type == type) {
display_cat.warning()
<< "Attempt to register GraphicsPipe type " << type
<< " more than once.\n";
return false;
}
}
// Ok, now add a new entry.
_pipe_types.push_back(PipeType(type, func));
return true;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipeSelection::do_resolve_modules
// Access: Private
// Description: Loads the shared objects listed in the load-display
// Configrc variable, which should make all of the
// dynamic GraphicsPipes available.
////////////////////////////////////////////////////////////////////
void GraphicsPipeSelection::
do_resolve_modules() {
Config::ConfigTable::Symbol::iterator ci;
// Build up a set of the modules we've already loaded as we go, so
// we don't attempt to load a given module more than once.
pset<string> already_loaded;
for (ci = display_modules_begin(); ci != display_modules_end(); ++ci) {
string name = (*ci).Val();
if (already_loaded.insert(name).second) {
Filename dlname = Filename::dso_filename("lib" + name + ".so");
display_cat.info()
<< "loading display module: " << dlname.to_os_specific() << endl;
void *tmp = load_dso(dlname);
if (tmp == (void *)NULL) {
display_cat.info()
<< "Unable to load: " << load_dso_error() << endl;
}
}
}
_resolved_modules = true;
}

View File

@ -0,0 +1,86 @@
// Filename: graphicsPipeSelection.h
// Created by: drose (15Aug02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef GRAPHICSPIPESELECTION_H
#define GRAPHICSPIPESELECTION_H
#include "pandabase.h"
#include "graphicsPipe.h"
#include "pointerTo.h"
#include "typeHandle.h"
#include "mutex.h"
class HardwareChannel;
class GraphicsWindow;
////////////////////////////////////////////////////////////////////
// Class : GraphicsPipeSelection
// Description : This maintains a list of GraphicsPipes by type that
// are available for creation. Normally there is one
// default interactive GraphicsPipe, and possibly other
// types available as well.
//
// This is used to manage creation of a GraphicsPipe
// when you don't particularly care what kind of pipe
// you create; you just want to render to the screen.
// If your application does have a preference, you can
// of course invoke the appropriate GraphicsPipe
// constructor yourself.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsPipeSelection {
protected:
GraphicsPipeSelection();
~GraphicsPipeSelection();
PUBLISHED:
int get_num_pipe_types() const;
TypeHandle get_pipe_type(int n) const;
PT(GraphicsPipe) make_pipe(TypeHandle type);
PT(GraphicsPipe) make_default_pipe();
INLINE void resolve_modules() const;
INLINE static GraphicsPipeSelection *get_global_ptr();
public:
typedef PT(GraphicsPipe) PipeConstructorFunc();
bool add_pipe_type(TypeHandle type, PipeConstructorFunc *func);
private:
void do_resolve_modules();
class PipeType {
public:
INLINE PipeType(TypeHandle type, PipeConstructorFunc *constructor);
TypeHandle _type;
PipeConstructorFunc *_constructor;
};
typedef pvector<PipeType> PipeTypes;
PipeTypes _pipe_types;
bool _resolved_modules;
Mutex _lock;
static GraphicsPipeSelection *_global_ptr;
};
#include "graphicsPipeSelection.I"
#endif

View File

@ -417,8 +417,14 @@ prepare_lens() {
// Description: 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).
////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian::
bool GraphicsStateGuardian::
begin_frame() {
// Undo any lighting we had enabled last frame, to force the lights
// to be reissued, in case their parameters or positions have
@ -466,6 +472,40 @@ begin_frame() {
// measurably expensive.
modify_state(get_untextured_state());
#endif
return true;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::begin_scene
// Access: Public, Virtual
// Description: 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).
////////////////////////////////////////////////////////////////////
bool GraphicsStateGuardian::
begin_scene() {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::end_scene
// Access: Public, Virtual
// Description: 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().
////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian::
end_scene() {
}
////////////////////////////////////////////////////////////////////
@ -1338,6 +1378,16 @@ unmark_prepared_geom_node(GeomNodeContext *gnc) {
return removed;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::free_pointers
// Access: Protected, Virtual
// Description: Frees some memory that was explicitly allocated
// within the glgsg.
////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian::
free_pointers() {
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::close_gsg
// Access: Protected, Virtual
@ -1348,6 +1398,10 @@ unmark_prepared_geom_node(GeomNodeContext *gnc) {
////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian::
close_gsg() {
free_pointers();
release_all_textures();
release_all_geoms();
_win = (GraphicsWindow *)NULL;
}
@ -1535,31 +1589,3 @@ get_factory() {
}
return (*_factory);
}
void GraphicsStateGuardian::
read_priorities(void) {
GsgFactory &factory = get_factory();
if (factory.get_num_preferred() == 0) {
Config::ConfigTable::Symbol::iterator i;
for (i = preferred_gsg_begin(); i != preferred_gsg_end(); ++i) {
ConfigString type_name = (*i).Val();
TypeHandle type = TypeRegistry::ptr()->find_type(type_name);
if (type == TypeHandle::none()) {
gsg_cat.warning()
<< "Unknown type requested for GSG preference: " << type_name
<< "\n";
} else {
gsg_cat.debug()
<< "Specifying type " << type << " for GSG preference.\n";
factory.add_preferred(type);
}
}
}
}
void GraphicsStateGuardian::start_rendering(void) {
}
void GraphicsStateGuardian::finish_rendering(void) {
}

View File

@ -101,12 +101,11 @@ public:
INLINE void enable_normals(bool val) { _normals_enabled = val; }
virtual void begin_frame();
virtual bool begin_frame();
virtual bool begin_scene();
virtual void end_scene();
virtual void end_frame();
virtual void start_rendering(void);
virtual void finish_rendering(void);
// These functions will be queried by the GeomIssuer to determine if
// it should issue normals, texcoords, and/or colors, based on the
// GSG's current state.
@ -190,6 +189,7 @@ protected:
bool mark_prepared_geom_node(GeomNodeContext *gnc);
bool unmark_prepared_geom_node(GeomNodeContext *gnc);
virtual void free_pointers();
virtual void close_gsg();
#ifdef DO_PSTATS
@ -353,7 +353,6 @@ public:
static GsgFactory &get_factory();
private:
static void read_priorities(void);
static GsgFactory *_factory;
public:

View File

@ -16,190 +16,44 @@
//
////////////////////////////////////////////////////////////////////
#include <notify.h>
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::Copy Constructor
// Function: GraphicsWindow::is_closed
// Access: Published
// Description:
// Description: Returns true if the window has not yet been opened,
// or has been fully closed, false if it is open. The
// window is not opened immediately after
// GraphicsEngine::make_window() is called; nor is it
// closed immediately after
// GraphicsEngine::remove_window() is called. Either
// operation may take a frame or two.
////////////////////////////////////////////////////////////////////
INLINE GraphicsWindow::Properties::
Properties(const Properties &copy) {
(*this) = copy;
INLINE bool GraphicsWindow::
is_closed() const {
return !_properties.get_open();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::Copy Assignment Operator
// Function: GraphicsWindow::is_active
// Access: Published
// Description:
// Description: Returns true if the window is ready to be rendered
// into, false otherwise.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
operator = (const Properties &copy) {
ClearableRegion::operator = (copy);
_xorg = copy._xorg;
_yorg = copy._yorg;
_xsize = copy._xsize;
_ysize = copy._ysize;
_title = copy._title;
_border = copy._border;
_fullscreen = copy._fullscreen;
_mask = copy._mask;
_want_depth_bits = copy._want_depth_bits;
_want_color_bits = copy._want_color_bits;
_bCursorIsVisible = copy._bCursorIsVisible;
INLINE bool GraphicsWindow::
is_active() const {
// Make this smarter?
return _properties.get_open() && !_properties.get_minimized();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::Destructor
// Function: GraphicsWindow::is_fullscreen
// Access: Published
// Description:
// Description: Returns true if the window has been opened as a
// fullscreen window, false otherwise.
////////////////////////////////////////////////////////////////////
INLINE GraphicsWindow::Properties::
~Properties() {
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::set_origin
// Access: Published
// Description: Specifies the origin on the screen (in pixels,
// relative to the top-left corner) at which the window
// should appear. This is the origin of the top-left
// corner of the useful part of the window, not
// including decorations.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
set_origin(int xorg, int yorg) {
_xorg = xorg;
_yorg = yorg;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::set_size
// Access: Published
// Description: Specifies the requested size of the window, in
// pixels. This is the size of the useful part of the
// window, not including decorations.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
set_size(int xsize, int ysize) {
_xsize = xsize;
_ysize = ysize;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::set_title
// Access: Published
// Description: Specifies the title that should be assigned to the
// window.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
set_title(const string &title) {
_title = title;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::set_border
// Access: Published
// Description: Specifies whether the window should be created with a
// border (true, the default) or not (false).
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
set_border(bool border) {
_border = border;
}
/*
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::set_cursor_visible
// Access: Published
// Description: Specifies if mouse cursor is visible
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
set_cursor_visible(bool IsVisible) {
_bCursorIsVisible=IsVisible; // note: gsg should override to implement
}
*/
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::set_mask
// Access: Published
// Description: Specifies the set of graphics properties that are
// required for the context associated with the window.
// This should be the union of the appropriate bits
// defined in WindowModeType.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
set_mask(uint mask) {
_mask = mask;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::Properties::set_bit_depth
// Access: Published
// Description: Specifies the minimum number of bits that are
// required for the depth buffer and color buffer,
// respectively.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::Properties::
set_bit_depth(int want_depth_bits, int want_color_bits) {
_want_depth_bits = want_depth_bits;
_want_color_bits = want_color_bits;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_properties
// Access: Published
// Description: Returns the full Properties structure that describes
// the window.
////////////////////////////////////////////////////////////////////
INLINE const GraphicsWindow::Properties &GraphicsWindow::
get_properties() const {
return _props;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_width
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE int GraphicsWindow::
get_width() const {
return (_props._xsize);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_height
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE int GraphicsWindow::
get_height() const {
return (_props._ysize);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_xorg
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE int GraphicsWindow::
get_xorg() const {
return (_props._xorg);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_yorg
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE int GraphicsWindow::
get_yorg() const {
return (_props._yorg);
}
INLINE bool GraphicsWindow::
is_fullscreen() const {
return (_props._fullscreen);
return _properties.get_fullscreen();
}
////////////////////////////////////////////////////////////////////
@ -209,13 +63,13 @@ is_fullscreen() const {
// There is a one-to-one association between windows and
// GSG's.
//
// It is invalid to call this if the window has been
// closed; that is, if is_closed() returns true. In
// this case the GSG has been closed as well.
// This may return NULL if the graphics context has not
// yet been created for the window, e.g. before the
// first frame has rendered; or after the window has
// been closed.
////////////////////////////////////////////////////////////////////
INLINE GraphicsStateGuardian *GraphicsWindow::
get_gsg() const {
nassertr(!is_closed(), NULL);
return _gsg;
}
@ -234,207 +88,6 @@ get_pipe() const {
return _pipe;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::close_window
// Access: Published
// Description: Closes the window and frees all resources associated
// with it, including the GSG. The window may not be
// opened again.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::
close_window() {
if (!is_closed()) {
do_close_window();
release_gsg();
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::is_closed
// Access: Published
// Description: Returns true if close_window() has been called on
// this window, false otherwise. If the window has been
// closed, most of its interface is no longer valid.
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsWindow::
is_closed() const {
return (_gsg == (GraphicsStateGuardian *)NULL);
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::set_frame_number
// Access: Published
// Description: Sets the current frame number of the window. This
// affects the frame numbers written for %f in a RIB or
// image filename template. The frame number is
// initially zero, and it increments at each call to
// end_frame().
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::
set_frame_number(const int f) {
_frame_number = f;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_frame_number
// Access: Published
// Description: Returns the current frame number of the window. See
// set_frame_number().
////////////////////////////////////////////////////////////////////
INLINE int GraphicsWindow::
get_frame_number() const {
return _frame_number;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::set_draw_callback
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::
set_draw_callback(Callback *c) {
_draw_callback = c;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::set_idle_callback
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::
set_idle_callback(Callback *c) {
_idle_callback = c;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::call_draw_callback
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::
call_draw_callback(bool force_redraw) {
if (_draw_callback) {
_draw_callback->draw(force_redraw);
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::call_idle_callback
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::
call_idle_callback() {
if (_idle_callback) {
_idle_callback->idle();
}
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_num_input_devices
// Access: Published
// Description: Returns the number of separate input devices
// associated with the window. Typically, a window will
// have exactly one input device: the keyboard/mouse
// pair. However, some windows may have no input
// devices, and others may add additional devices, for
// instance for a joystick.
////////////////////////////////////////////////////////////////////
INLINE int GraphicsWindow::
get_num_input_devices() const {
return _input_devices.size();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_input_device_name
// Access: Published
// Description: Returns the name of the nth input device.
////////////////////////////////////////////////////////////////////
INLINE string GraphicsWindow::
get_input_device_name(int device) const {
nassertr(device >= 0 && device < (int)_input_devices.size(), "");
return _input_devices[device].get_name();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::has_pointer
// Access: Published
// Description: Returns true if the nth input device has a
// screen-space pointer (for instance, a mouse), false
// otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsWindow::
has_pointer(int device) const {
nassertr(device >= 0 && device < (int)_input_devices.size(), false);
return _input_devices[device].has_pointer();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::has_keyboard
// Access: Published
// Description: Returns true if the nth input device has a keyboard,
// false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsWindow::
has_keyboard(int device) const {
nassertr(device >= 0 && device < (int)_input_devices.size(), false);
return _input_devices[device].has_keyboard();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_mouse_data
// Access: Published
// Description: Returns the MouseData associated with the nth input
// device.
////////////////////////////////////////////////////////////////////
INLINE const MouseData &GraphicsWindow::
get_mouse_data(int device) const {
nassertr(device >= 0 && device < (int)_input_devices.size(),
*(new MouseData));
return _input_devices[device].get_mouse_data();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::has_button_event
// Access: Published
// Description: Returns true if the indicated device has a pending
// button event (a mouse button or keyboard button
// down/up), false otherwise. If this returns true, the
// particular event may be extracted via
// get_button_event().
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsWindow::
has_button_event(int device) const {
nassertr(device >= 0 && device < (int)_input_devices.size(), false);
return _input_devices[device].has_button_event();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_button_event
// Access: Published
// Description: Assuming a previous call to has_button_event()
// returned true, this returns the pending button event.
////////////////////////////////////////////////////////////////////
INLINE ButtonEvent GraphicsWindow::
get_button_event(int device) {
nassertr(has_button_event(device), ButtonEvent());
return _input_devices[device].get_button_event();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_window_active
// Access: Public
// Description: Returns true if the window is currently active and
// ready to be rendered into, or false otherwise. This
// state is normally updated only by the GSG, or by the
// window itself.
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsWindow::
get_window_active() const {
return _window_active;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::win_display_regions_changed
// Access: Public
@ -448,56 +101,6 @@ win_display_regions_changed() {
_display_regions_stale = true;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::set_sync
// Access: Public
// Description: Sets flag for whether the buffer swap is done
// implicitely at the end of each frame, or done
// explicitely for the purpose of synchronization.
////////////////////////////////////////////////////////////////////
INLINE void GraphicsWindow::
set_sync(const bool b) {
_is_synced = b;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_sync
// Access: Public
// Description: Returns whether buffer swap is done explicitely by
// call to swap() method.
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsWindow::
get_sync() const {
return _is_synced;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_num_display_regions
// Access: Published
// Description: Returns the number of active DisplayRegions that have
// been created within the various layers and channels
// of the window.
////////////////////////////////////////////////////////////////////
INLINE int GraphicsWindow::
get_num_display_regions() const {
determine_display_regions();
return _display_regions.size();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::get_display_region
// Access: Published
// Description: Returns the nth active DisplayRegion of those that
// have been created within the various layers and
// channels of the window.
////////////////////////////////////////////////////////////////////
INLINE DisplayRegion *GraphicsWindow::
get_display_region(int n) const {
determine_display_regions();
nassertr(n >= 0 && n < (int)_display_regions.size(), NULL);
return _display_regions[n];
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::determine_display_regions

File diff suppressed because it is too large Load Diff

View File

@ -21,244 +21,154 @@
#include "pandabase.h"
#include "graphicsWindowInputDevice.h"
#include "windowProperties.h"
#include "graphicsChannel.h"
#include "graphicsPipe.h"
#include "displayRegion.h"
#include "graphicsStateGuardian.h"
#include "clearableRegion.h"
#include "typedef.h"
#include "configurable.h"
#include "referenceCount.h"
#include "typedReferenceCount.h"
#include "mouseData.h"
#include "modifierButtons.h"
#include "buttonEvent.h"
#include "iterator_types.h"
#include "factory.h"
#include "pStatCollector.h"
#include "notify.h"
#include "mutex.h"
#include "pvector.h"
#include "pdeque.h"
////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////
enum WindowModeType
{
W_RGBA = 0,
W_RGB = 0,
W_INDEX = 1,
W_SINGLE = 0,
W_DOUBLE = 2,
W_ACCUM = 4,
W_ALPHA = 8,
W_DEPTH = 16,
W_STENCIL = 32,
W_MULTISAMPLE = 128,
W_STEREO = 256,
W_LUMINANCE = 512
};
class GraphicsPipe;
class GraphicsWindow;
class CullHandler;
////////////////////////////////////////////////////////////////////
// Class : GraphicsWindow
// Description :
// Description : An output medium for receiving the results of
// rendering. Typically this is a window on the
// computer desktop, but it may also be the entire
// desktop or console screen (i.e. a fullscreen window),
// or a window on another machine, or even a disk file.
//
// The GraphicsWindow class handles all of the details
// about creating a window and its framebuffer, and
// managing the properties associated with the windowing
// system, such as position and size and keyboard/mouse
// input. The actual rendering, and anything associated
// with the graphics context itself, is managed by the
// window's GraphicsStateGuardian.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsWindow : public Configurable, public ReferenceCount, public ClearableRegion {
class EXPCL_PANDA GraphicsWindow : public TypedReferenceCount, public ClearableRegion {
protected:
GraphicsWindow(GraphicsPipe *pipe);
private:
GraphicsWindow(const GraphicsWindow &copy);
void operator = (const GraphicsWindow &copy);
PUBLISHED:
class EXPCL_PANDA Properties : public ClearableRegion {
PUBLISHED:
Properties();
INLINE Properties(const Properties &copy);
INLINE void operator = (const Properties &copy);
INLINE ~Properties();
// all these methods essentially do nothing since they do not get passed down to the gsg
// and maybe should be removed or commented out until they do, since
// they modify parameters that usually require re-creation of the window
// except for set_size(), which is superseded by resize(), which actually works.
INLINE void set_origin(int xorg, int yorg);
INLINE void set_size(int xsize, int ysize);
INLINE void set_title(const string &title);
INLINE void set_border(bool border);
INLINE void set_mask(uint mask);
INLINE void set_bit_depth(int want_depth_bits, int want_color_bits);
public:
int _xorg;
int _yorg;
int _xsize;
int _ysize;
string _title;
bool _border;
bool _fullscreen;
bool _bCursorIsVisible;
uint _mask;
int _want_depth_bits;
int _want_color_bits;
};
public:
class EXPCL_PANDA Callback {
public:
virtual void draw(bool);
virtual void idle();
};
typedef void (*vfn)();
typedef void (*vfnii)(int, int);
public:
GraphicsWindow(GraphicsPipe *pipe, const Properties &props = Properties());
virtual ~GraphicsWindow();
INLINE const Properties& get_properties() const;
virtual void get_framebuffer_format(PixelBuffer::Type &fb_type, PixelBuffer::Format &fb_format);
PUBLISHED:
INLINE int get_width() const;
INLINE int get_height() const;
INLINE int get_xorg() const;
INLINE int get_yorg() const;
WindowProperties get_properties() const;
WindowProperties get_requested_properties() const;
void request_properties(const WindowProperties &requested_properties);
INLINE bool is_closed() const;
INLINE bool is_active() const;
INLINE bool is_fullscreen() const;
// # of z bits/pixel. purpose is to adjust camera near plane if have fewer z bits
virtual int get_depth_bitwidth(void);
void set_window_event(const string &window_event);
string get_window_event() const;
INLINE GraphicsStateGuardian *get_gsg() const;
INLINE GraphicsPipe *get_pipe() const;
INLINE void close_window();
INLINE bool is_closed() const;
INLINE void set_frame_number(const int);
INLINE int get_frame_number() const;
INLINE void set_sync(const bool);
INLINE bool get_sync() const;
// since this requires gsg modification, dont worry about implementing it yet
// since init control is good enough
// virtual void set_cursor_visible(bool bIsVisible); // should be overridden by gsg to implement
// resize the window to the given size
virtual bool resize(unsigned int xsize,unsigned int ysize);
virtual void swap();
public:
virtual void resized(const unsigned int, const unsigned int);
// see if window sizes are supported (i.e. in fullscrn mode)
//
// note: it might be better to implement some sort of query
// interface that returns an array of supported sizes,
// but this way is somewhat simpler and will do the job
// on most cards, assuming they handle the std sizes the app
// knows about.
virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
INLINE virtual void set_draw_callback(Callback *c);
INLINE virtual void set_idle_callback(Callback *c);
INLINE void call_draw_callback(bool force_redraw);
INLINE void call_idle_callback();
PT(DisplayRegion) make_scratch_display_region(int xsize,
int ysize) const;
virtual TypeHandle get_gsg_type() const=0;
public:
// context setting
virtual void make_current();
virtual void unmake_current();
PUBLISHED:
// Mouse and keyboard routines
INLINE int get_num_input_devices() const;
INLINE string get_input_device_name(int device) const;
INLINE bool has_pointer(int device) const;
INLINE bool has_keyboard(int device) const;
public:
INLINE const MouseData &get_mouse_data(int device) const;
INLINE bool has_button_event(int device) const;
INLINE ButtonEvent get_button_event(int device);
PUBLISHED:
// GUI glue methods
virtual void flag_redisplay();
virtual void register_draw_function(GraphicsWindow::vfn);
virtual void register_idle_function(GraphicsWindow::vfn);
public:
virtual void begin_frame(bool bStartRendering = true);
void clear();
virtual void end_frame();
virtual void process_events();
INLINE bool get_window_active() const;
virtual void deactivate_window();
virtual void reactivate_window();
INLINE void win_display_regions_changed();
// Statistics
static PStatCollector _app_pcollector;
static PStatCollector _show_code_pcollector;
static PStatCollector _swap_pcollector; // dxgsg needs access so this is public
static PStatCollector _clear_pcollector;
static PStatCollector _show_fps_pcollector;
static PStatCollector _make_current_pcollector;
protected:
void make_gsg();
void release_gsg();
virtual void do_close_window();
typedef vector_GraphicsWindowInputDevice InputDevices;
InputDevices _input_devices;
PT(GraphicsStateGuardian) _gsg;
Properties _props;
GraphicsPipe *_pipe;
vfn _draw_function;
vfn _idle_function;
vfnii _resize_function;
int _frame_number;
bool _is_synced;
bool _window_active;
protected:
Callback *_draw_callback;
Callback *_idle_callback;
PUBLISHED:
virtual GraphicsChannel *get_channel(int index);
GraphicsChannel *get_channel(int index);
void remove_channel(int index);
int get_max_channel_index() const;
bool is_channel_defined(int index) const;
INLINE int get_num_display_regions() const;
INLINE DisplayRegion *get_display_region(int n) const;
int get_num_display_regions() const;
DisplayRegion *get_display_region(int n) const;
// Mouse and keyboard routines
int get_num_input_devices() const;
string get_input_device_name(int device) const;
bool has_pointer(int device) const;
bool has_keyboard(int device) const;
public:
// No need to publish these.
MouseData get_mouse_data(int device) const;
bool has_button_event(int device) const;
ButtonEvent get_button_event(int device);
virtual void get_framebuffer_format(PixelBuffer::Type &fb_type, PixelBuffer::Format &fb_format);
public:
virtual int verify_window_sizes(int numsizes, int *dimen);
PT(DisplayRegion) make_scratch_display_region(int x_size, int y_size) const;
INLINE void win_display_regions_changed();
public:
// It is an error to call any of the following methods from any
// thread other than the draw thread. These methods are normally
// called by the GraphicsEngine.
virtual bool begin_frame();
void clear();
virtual void end_frame();
virtual void make_gsg();
virtual void release_gsg();
// This method is called in the draw thread prior to issuing any
// drawing commands for the window.
virtual void make_current();
// These methods will be called within the app (main) thread.
virtual void begin_flip();
virtual void end_flip();
// It is an error to call any of the following methods from any
// thread other than the window thread. These methods are normally
// called by the GraphicsEngine.
virtual void process_events();
virtual void set_properties_now(WindowProperties &properties);
protected:
virtual void close_window();
virtual bool open_window();
virtual bool do_reshape_request(int x_origin, int y_origin,
int x_size, int y_size);
void declare_channel(int index, GraphicsChannel *chan);
// It is an error to call any of the following methods from any
// thread other than the window thread.
void system_changed_properties(const WindowProperties &properties);
void system_changed_size(int x_size, int y_size);
protected:
typedef vector_GraphicsWindowInputDevice InputDevices;
InputDevices _input_devices;
Mutex _input_lock;
PT(GraphicsStateGuardian) _gsg;
GraphicsPipe *_pipe;
private:
INLINE void determine_display_regions() const;
void do_determine_display_regions();
protected:
WindowProperties _properties;
private:
Mutex _lock;
// protects _channels, _display_regions, and _requested_properties.
typedef pvector< PT(GraphicsChannel) > Channels;
Channels _channels;
@ -266,67 +176,17 @@ private:
DisplayRegions _display_regions;
bool _display_regions_stale;
public:
// factory stuff
typedef Factory<GraphicsWindow> WindowFactory;
typedef FactoryParam WindowParam;
// make a factory parameter type for the window properties
class EXPCL_PANDA WindowProps : public FactoryParam {
public:
INLINE WindowProps(void) : WindowParam() {}
INLINE WindowProps(const Properties& p) : WindowParam(), _p(p) {}
virtual ~WindowProps(void);
INLINE Properties get_properties(void) { return _p; }
public:
static TypeHandle get_class_type(void);
static void init_type(void);
virtual TypeHandle get_type(void) const;
virtual TypeHandle force_init_type(void);
private:
Properties _p;
static TypeHandle _type_handle;
};
// make a factory parameter type for the GraphicsPipe*
class EXPCL_PANDA WindowPipe : public FactoryParam {
public:
INLINE WindowPipe(GraphicsPipe* p) : WindowParam(), _p(p) {}
virtual ~WindowPipe(void);
INLINE GraphicsPipe* get_pipe(void) { return _p; }
public:
static TypeHandle get_class_type(void);
static void init_type(void);
virtual TypeHandle get_type(void) const;
virtual TypeHandle force_init_type(void);
private:
GraphicsPipe* _p;
static TypeHandle _type_handle;
INLINE WindowPipe(void) : WindowParam() {}
};
static WindowFactory &get_factory();
private:
static void read_priorities(void);
GraphicsWindow(const GraphicsWindow&);
GraphicsWindow &operator=(const GraphicsWindow&);
static WindowFactory *_factory;
WindowProperties _requested_properties;
string _window_event;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
Configurable::init_type();
ReferenceCount::init_type();
TypedReferenceCount::init_type();
register_type(_type_handle, "GraphicsWindow",
Configurable::get_class_type(),
ReferenceCount::get_class_type());
TypedReferenceCount::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
@ -337,6 +197,7 @@ private:
static TypeHandle _type_handle;
friend class GraphicsPipe;
friend class GraphicsEngine;
};
#include "graphicsWindow.I"

View File

@ -18,15 +18,15 @@
#include "graphicsWindowInputDevice.h"
#include <mouseButton.h>
#include <keyboardButton.h>
#include "mouseButton.h"
#include "keyboardButton.h"
#define EXPCL EXPCL_PANDA
#define EXPTP EXPTP_PANDA
#define TYPE GraphicsWindowInputDevice
#define NAME vector_GraphicsWindowInputDevice
#include <vector_src.cxx>
#include "vector_src.cxx"
// Tell GCC that we'll take care of the instantiation explicitly here.
#ifdef __GNUC__

View File

@ -19,10 +19,10 @@
#ifndef GRAPHICSWINDOWINPUTDEVICE_H
#define GRAPHICSWINDOWINPUTDEVICE_H
#include <pandabase.h>
#include "pandabase.h"
#include <buttonEvent.h>
#include <mouseData.h>
#include "buttonEvent.h"
#include "mouseData.h"
#include "pdeque.h"
#include "pvector.h"

View File

@ -1,73 +0,0 @@
// Filename: interactiveGraphicsPipe.cxx
// Created by: cary (10Mar99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "interactiveGraphicsPipe.h"
#include "config_display.h"
////////////////////////////////////////////////////////////////////
// Static variables
////////////////////////////////////////////////////////////////////
TypeHandle InteractiveGraphicsPipe::_type_handle;
InteractiveGraphicsPipe::
InteractiveGraphicsPipe(const PipeSpecifier& spec) :
GraphicsPipe(spec)
{
}
InteractiveGraphicsPipe::
~InteractiveGraphicsPipe() {
}
TypeHandle InteractiveGraphicsPipe::
get_class_type(void) {
return _type_handle;
}
void InteractiveGraphicsPipe::
init_type(void) {
GraphicsPipe::init_type();
register_type(_type_handle, "InteractiveGraphicsPipe",
GraphicsPipe::get_class_type());
}
TypeHandle InteractiveGraphicsPipe::
get_type(void) const {
return get_class_type();
}
InteractiveGraphicsPipe::
InteractiveGraphicsPipe(void) {
display_cat.error()
<< "InteractiveGraphicsPipe should not be created with default constructor" << endl;
}
InteractiveGraphicsPipe::
InteractiveGraphicsPipe(const InteractiveGraphicsPipe&) {
display_cat.error()
<< "InteractiveGraphicsPipes should not be copied" << endl;
}
InteractiveGraphicsPipe &InteractiveGraphicsPipe::
operator=(const InteractiveGraphicsPipe&) {
display_cat.error()
<< "InteractiveGraphicsPipes should not be assigned" << endl;
return *this;
}

View File

@ -1,51 +0,0 @@
// Filename: interactiveGraphicsPipe.h
// Created by: cary (10Mar99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef __INTERACTIVEGRAPHICSPIPE_H__
#define __INTERACTIVEGRAPHICSPIPE_H__
#include <pandabase.h>
#include "graphicsPipe.h"
class EXPCL_PANDA InteractiveGraphicsPipe : public GraphicsPipe {
PUBLISHED:
InteractiveGraphicsPipe( const PipeSpecifier& );
virtual ~InteractiveGraphicsPipe(void);
public:
static TypeHandle get_class_type(void);
static void init_type(void);
virtual TypeHandle get_type(void) const;
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
protected:
InteractiveGraphicsPipe(void);
InteractiveGraphicsPipe(const InteractiveGraphicsPipe&);
InteractiveGraphicsPipe& operator=(const InteractiveGraphicsPipe&);
};
#include "interactiveGraphicsPipe.I"
#endif /* __INTERACTIVEGRAPHICSPIPE_H__ */

View File

@ -1,61 +0,0 @@
// Filename: noninteractiveGraphicsPipe.cxx
// Created by: cary (10Mar99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "noninteractiveGraphicsPipe.h"
#include "config_display.h"
////////////////////////////////////////////////////////////////////
// Static variables
////////////////////////////////////////////////////////////////////
TypeHandle NoninteractiveGraphicsPipe::_type_handle;
NoninteractiveGraphicsPipe::NoninteractiveGraphicsPipe(const PipeSpecifier& spec)
: GraphicsPipe(spec) {}
NoninteractiveGraphicsPipe::~NoninteractiveGraphicsPipe(void) {}
NoninteractiveGraphicsPipe::NoninteractiveGraphicsPipe(void) {
display_cat.error()
<< "NoninteractiveGraphicsPipe should not be created with default constructor" << endl;
}
NoninteractiveGraphicsPipe::NoninteractiveGraphicsPipe(const NoninteractiveGraphicsPipe&) {
display_cat.error()
<< "NoninteractiveGraphicsPipes should not be copied" << endl;
}
NoninteractiveGraphicsPipe& NoninteractiveGraphicsPipe::operator=(const NoninteractiveGraphicsPipe&) {
display_cat.error()
<< "NoninteractiveGraphicsPipes should not be assigned" << endl;
return *this;
}
TypeHandle NoninteractiveGraphicsPipe::get_class_type(void) {
return _type_handle;
}
void NoninteractiveGraphicsPipe::init_type(void) {
GraphicsPipe::init_type();
register_type(_type_handle, "NoninteractiveGraphicsPipe",
GraphicsPipe::get_class_type());
}
TypeHandle NoninteractiveGraphicsPipe::get_type(void) const {
return get_class_type();
}

View File

@ -1,52 +0,0 @@
// Filename: noninteractiveGraphicsPipe.h
// Created by: cary (10Mar99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef __NONINTERACTIVEGRAPHICSPIPE_H__
#define __NONINTERACTIVEGRAPHICSPIPE_H__
#include <pandabase.h>
#include "graphicsPipe.h"
class EXPCL_PANDA NoninteractiveGraphicsPipe : public GraphicsPipe {
public:
NoninteractiveGraphicsPipe( const PipeSpecifier& );
virtual ~NoninteractiveGraphicsPipe(void) = 0;
public:
static TypeHandle get_class_type(void);
static void init_type(void);
virtual TypeHandle get_type(void) const;
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
protected:
NoninteractiveGraphicsPipe(void);
NoninteractiveGraphicsPipe(const NoninteractiveGraphicsPipe&);
NoninteractiveGraphicsPipe& operator=(const NoninteractiveGraphicsPipe&);
};
#include "noninteractiveGraphicsPipe.I"
#endif /* __NONINTERACTIVEGRAPHICSPIPE_H__ */

View File

@ -1,78 +0,0 @@
// Filename: pipeSpec.I
// Created by: frang (07Mar99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
INLINE void PipeSpecifier::set_name(const std::string& name) {
_name = name;
}
INLINE std::string PipeSpecifier::get_name(void) const {
return _name;
}
INLINE void PipeSpecifier::unset_machine(void) {
if (!_is_file) {
_is_file = true;
_machine = "";
_is_remote = false;
}
}
INLINE void PipeSpecifier::unset_file(void) {
if (_is_file) {
_is_file = false;
_filename = "";
}
}
INLINE void PipeSpecifier::set_machine_name(const std::string& name) {
_machine = name;
if (_machine.empty())
_is_remote = false;
else
_is_remote = true;
unset_file();
}
INLINE std::string PipeSpecifier::get_machine_name(void) const {
return _machine;
}
INLINE void PipeSpecifier::set_file_name(const std::string& name) {
_filename = name;
unset_machine();
}
INLINE std::string PipeSpecifier::get_file_name(void) const {
return _filename;
}
INLINE void PipeSpecifier::set_pipe_number(const int p) {
_pipe_number = p;
}
INLINE int PipeSpecifier::get_pipe_number(void) const {
return _pipe_number;
}
INLINE bool PipeSpecifier::is_file(void) const {
return _is_file;
}
INLINE bool PipeSpecifier::is_remote(void) const {
return _is_remote;
}

View File

@ -1,55 +0,0 @@
// Filename: pipeSpec.cxx
// Created by: frang (07Mar99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "config_display.h"
#include "pipeSpec.h"
PipeSpecifier::PipeSpecifier(void)
: _machine(pipe_spec_machine),
_filename(pipe_spec_filename),
_pipe_number(pipe_spec_pipe_number),
_is_file(pipe_spec_is_file),
_is_remote(pipe_spec_is_remote) {}
PipeSpecifier::PipeSpecifier(const PipeSpecifier& c)
: _name(c._name), _machine(c._machine), _filename(c._filename),
_pipe_number(c._pipe_number), _is_file(c._is_file),
_is_remote(c._is_remote) {}
PipeSpecifier::~PipeSpecifier(void) {}
std::string PipeSpecifier::get_X_specifier(void) const {
std::string ret;
if (!_is_file) {
if (_machine.empty()) {
if (getenv("DISPLAY")) {
ret = getenv("DISPLAY");
}
}
if (ret.empty()) {
ostringstream ss;
ss << _machine << ":" << ((_pipe_number<0)?0:_pipe_number) << ".0";
ret = ss.str();
}
}
return ret;
}

View File

@ -1,60 +0,0 @@
// Filename: pipeSpec.h
// Created by: frang (07Mar99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef __PIPESPEC_H__
#define __PIPESPEC_H__
#include <pandabase.h>
#include <string>
class EXPCL_PANDA PipeSpecifier {
PUBLISHED:
PipeSpecifier(void);
PipeSpecifier(const PipeSpecifier&);
~PipeSpecifier(void);
INLINE void set_name(const std::string&);
INLINE std::string get_name(void) const;
INLINE void set_machine_name(const std::string&);
INLINE std::string get_machine_name(void) const;
INLINE void set_file_name(const std::string&);
INLINE std::string get_file_name(void) const;
INLINE void set_pipe_number(const int);
INLINE int get_pipe_number(void) const;
INLINE bool is_file(void) const;
INLINE bool is_remote(void) const;
std::string get_X_specifier(void) const;
private:
std::string _name;
std::string _machine;
std::string _filename;
int _pipe_number;
bool _is_file;
bool _is_remote;
INLINE void unset_machine(void);
INLINE void unset_file(void);
};
#include "pipeSpec.I"
#endif /* __PIPESPEC_H__ */

View File

@ -19,6 +19,7 @@
#ifndef RENDERBUFFER_H
#define RENDERBUFFER_H
#include "pandabase.h"
class GraphicsStateGuardian;

View File

@ -0,0 +1,664 @@
// Filename: windowProperties.I
// Created by: drose (13Aug02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE WindowProperties::
WindowProperties(const WindowProperties &copy) {
(*this) = copy;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::Destructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE WindowProperties::
~WindowProperties() {
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::operator !=
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
operator != (const WindowProperties &other) const {
return !operator == (other);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::is_any_specified
// Access: Published
// Description: Returns true if any properties have been specified,
// false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
is_any_specified() const {
return (_specified != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_origin
// Access: Published
// Description: Specifies the origin on the screen (in pixels,
// relative to the top-left corner) at which the window
// should appear. This is the origin of the top-left
// corner of the useful part of the window, not
// including decorations.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_origin(int x_origin, int y_origin) {
_x_origin = x_origin;
_y_origin = y_origin;
_specified |= S_origin;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_x_origin
// Access: Published
// Description: Returns the x coordinate of the window's top-left
// corner, not including decorations.
////////////////////////////////////////////////////////////////////
INLINE int WindowProperties::
get_x_origin() const {
nassertr(has_origin(), 0);
return _x_origin;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_y_origin
// Access: Published
// Description: Returns the y coordinate of the window's top-left
// corner, not including decorations.
////////////////////////////////////////////////////////////////////
INLINE int WindowProperties::
get_y_origin() const {
nassertr(has_origin(), 0);
return _y_origin;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_origin
// Access: Published
// Description: Returns true if the window origin has been specified,
// false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_origin() const {
return ((_specified & S_origin) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_origin
// Access: Published
// Description: Removes the origin specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_origin() {
_specified &= ~S_origin;
_x_origin = 0;
_y_origin = 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_size
// Access: Published
// Description: Specifies the requested size of the window, in
// pixels. This is the size of the useful part of the
// window, not including decorations.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_size(int x_size, int y_size) {
_x_size = x_size;
_y_size = y_size;
_specified |= S_size;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_x_size
// Access: Published
// Description: Returns size in pixels in the x dimension of the
// useful part of the window, not including decorations.
// That is, this is the window's width.
////////////////////////////////////////////////////////////////////
INLINE int WindowProperties::
get_x_size() const {
nassertr(has_size(), 0);
return _x_size;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_y_size
// Access: Published
// Description: Returns size in pixels in the y dimension of the
// useful part of the window, not including decorations.
// That is, this is the window's height.
////////////////////////////////////////////////////////////////////
INLINE int WindowProperties::
get_y_size() const {
nassertr(has_size(), 0);
return _y_size;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_size
// Access: Published
// Description: Returns true if the window size has been specified,
// false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_size() const {
return ((_specified & S_size) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_size
// Access: Published
// Description: Removes the size specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_size() {
_specified &= ~S_size;
_x_size = 0;
_y_size = 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_title
// Access: Published
// Description: Specifies the title that should be assigned to the
// window.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_title(const string &title) {
_title = title;
_specified |= S_title;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_title
// Access: Published
// Description: Returns the window's title.
////////////////////////////////////////////////////////////////////
INLINE const string &WindowProperties::
get_title() const {
nassertr(has_title(), _title);
return _title;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_title
// Access: Published
// Description: Returns true if the window title has been specified,
// false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_title() const {
return ((_specified & S_title) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_title
// Access: Published
// Description: Removes the title specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_title() {
_specified &= ~S_title;
_title = string();
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_undecorated
// Access: Published
// Description: Specifies whether the window should be created with a
// visible title and border (false, the default) or not
// (true).
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_undecorated(bool undecorated) {
if (undecorated) {
_flags |= F_undecorated;
} else {
_flags &= ~F_undecorated;
}
_specified |= S_undecorated;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_undecorated
// Access: Published
// Description: Returns true if the window has no border.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
get_undecorated() const {
return (_flags & F_undecorated) != 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_undecorated
// Access: Published
// Description: Returns true if set_undecorated() has been specified.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_undecorated() const {
return ((_specified & S_undecorated) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_undecorated
// Access: Published
// Description: Removes the undecorated specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_undecorated() {
_specified &= ~S_undecorated;
_flags &= ~F_undecorated;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_fullscreen
// Access: Published
// Description: Specifies whether the window should be opened in
// fullscreen mode (true) or normal windowed mode
// (false, the default).
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_fullscreen(bool fullscreen) {
if (fullscreen) {
_flags |= F_fullscreen;
} else {
_flags &= ~F_fullscreen;
}
_specified |= S_fullscreen;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_fullscreen
// Access: Published
// Description: Returns true if the window is in fullscreen mode.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
get_fullscreen() const {
return (_flags & F_fullscreen) != 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_fullscreen
// Access: Published
// Description: Returns true if set_fullscreen() has been specified.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_fullscreen() const {
return ((_specified & S_fullscreen) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_fullscreen
// Access: Published
// Description: Removes the fullscreen specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_fullscreen() {
_specified &= ~S_fullscreen;
_flags &= ~F_fullscreen;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_foreground
// Access: Published
// Description: Specifies whether the window should be opened in
// the foreground (true), or left in the background
// (false).
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_foreground(bool foreground) {
if (foreground) {
_flags |= F_foreground;
} else {
_flags &= ~F_foreground;
}
_specified |= S_foreground;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_foreground
// Access: Published
// Description: Returns true if the window is in the foreground.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
get_foreground() const {
return (_flags & F_foreground) != 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_foreground
// Access: Published
// Description: Returns true if set_foreground() has been specified.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_foreground() const {
return ((_specified & S_foreground) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_foreground
// Access: Published
// Description: Removes the foreground specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_foreground() {
_specified &= ~S_foreground;
_flags &= ~F_foreground;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_minimized
// Access: Published
// Description: Specifies whether the window should be created
// minimized (true), or normal (false).
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_minimized(bool minimized) {
if (minimized) {
_flags |= F_minimized;
} else {
_flags &= ~F_minimized;
}
_specified |= S_minimized;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_minimized
// Access: Published
// Description: Returns true if the window is minimized.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
get_minimized() const {
return (_flags & F_minimized) != 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_minimized
// Access: Published
// Description: Returns true if set_minimized() has been specified.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_minimized() const {
return ((_specified & S_minimized) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_minimized
// Access: Published
// Description: Removes the minimized specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_minimized() {
_specified &= ~S_minimized;
_flags &= ~F_minimized;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_open
// Access: Published
// Description: Specifies whether the window should be open. It is
// legal to create a GraphicsWindow in the closed state,
// and later request it to open by changing this flag.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_open(bool open) {
if (open) {
_flags |= F_open;
} else {
_flags &= ~F_open;
}
_specified |= S_open;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_open
// Access: Published
// Description: Returns true if the window is open.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
get_open() const {
return (_flags & F_open) != 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_open
// Access: Published
// Description: Returns true if set_open() has been specified.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_open() const {
return ((_specified & S_open) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_open
// Access: Published
// Description: Removes the open specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_open() {
_specified &= ~S_open;
_flags &= ~F_open;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_cursor_hidden
// Access: Published
// Description: Specifies whether the mouse cursor should be visible.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_cursor_hidden(bool cursor_hidden) {
if (cursor_hidden) {
_flags |= F_cursor_hidden;
} else {
_flags &= ~F_cursor_hidden;
}
_specified |= S_cursor_hidden;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_cursor_hidden
// Access: Published
// Description: Returns true if the mouse cursor is invisible.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
get_cursor_hidden() const {
return (_flags & F_cursor_hidden) != 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_cursor_hidden
// Access: Published
// Description: Returns true if set_cursor_hidden() has been specified.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_cursor_hidden() const {
return ((_specified & S_cursor_hidden) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_cursor_hidden
// Access: Published
// Description: Removes the cursor_hidden specification from the properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_cursor_hidden() {
_specified &= ~S_cursor_hidden;
_flags &= ~F_cursor_hidden;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_framebuffer_mode
// Access: Published
// Description: Specifies the set of graphics properties that are
// required for the context associated with the window.
// This should be the union of the appropriate bits
// defined in FramebufferMode.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_framebuffer_mode(int framebuffer_mode) {
_framebuffer_mode = framebuffer_mode;
_specified |= S_framebuffer_mode;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_framebuffer_mode
// Access: Published
// Description: Returns the set of graphics properties that are
// in effect for the window. This will be the union of
// the corresponding bits from FramebufferMode.
////////////////////////////////////////////////////////////////////
INLINE int WindowProperties::
get_framebuffer_mode() const {
nassertr(has_framebuffer_mode(), false);
return _framebuffer_mode;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_framebuffer_mode
// Access: Published
// Description: Returns true if the framebuffer mode has been
// specified, false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_framebuffer_mode() const {
return ((_specified & S_framebuffer_mode) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_framebuffer_mode
// Access: Published
// Description: Removes the framebuffer_mode specification from the
// properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_framebuffer_mode() {
_specified &= ~S_framebuffer_mode;
_framebuffer_mode = 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_depth_bits
// Access: Published
// Description: Specifies the minimum number of bits that are
// required for the depth buffer.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_depth_bits(int depth_bits) {
_depth_bits = depth_bits;
_specified |= S_depth_bits;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_depth_bits
// Access: Published
// Description: Returns the number of bits specified for the depth
// buffer.
////////////////////////////////////////////////////////////////////
INLINE int WindowProperties::
get_depth_bits() const {
return _depth_bits;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_depth_bits
// Access: Published
// Description: Returns true if the number of bits for the depth
// buffer has been specified, false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_depth_bits() const {
return ((_specified & S_depth_bits) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_depth_bits
// Access: Published
// Description: Removes the depth_bits specification from the
// properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_depth_bits() {
_specified &= ~S_depth_bits;
_depth_bits = 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_color_bits
// Access: Published
// Description: Specifies the minimum number of bits that are
// required for all three channels of the color buffer.
// That is, this is the per-channel color requirement
// times three.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_color_bits(int color_bits) {
_color_bits = color_bits;
_specified |= S_color_bits;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_color_bits
// Access: Published
// Description: Returns the number of bits specified for the color
// buffer.
////////////////////////////////////////////////////////////////////
INLINE int WindowProperties::
get_color_bits() const {
return _color_bits;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::has_color_bits
// Access: Published
// Description: Returns true if the number of bits for the color
// buffer has been specified, false otherwise.
////////////////////////////////////////////////////////////////////
INLINE bool WindowProperties::
has_color_bits() const {
return ((_specified & S_color_bits) != 0);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_color_bits
// Access: Published
// Description: Removes the color_bits specification from the
// properties.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
clear_color_bits() {
_specified &= ~S_color_bits;
_color_bits = 0;
}
INLINE ostream &
operator << (ostream &out, const WindowProperties &properties) {
properties.output(out);
return out;
}

View File

@ -0,0 +1,220 @@
// Filename: windowProperties.cxx
// Created by: drose (13Aug02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "windowProperties.h"
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
WindowProperties::
WindowProperties() {
clear();
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
void WindowProperties::
operator = (const WindowProperties &copy) {
_specified = copy._specified;
_x_origin = copy._x_origin;
_y_origin = copy._y_origin;
_x_size = copy._x_size;
_y_size = copy._y_size;
_title = copy._title;
_flags = copy._flags;
_framebuffer_mode = copy._framebuffer_mode;
_depth_bits = copy._depth_bits;
_color_bits = copy._color_bits;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::operator ==
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
bool WindowProperties::
operator == (const WindowProperties &other) const {
return (_specified == other._specified &&
_flags == other._flags &&
_x_origin == other._x_origin &&
_y_origin == other._y_origin &&
_x_size == other._x_size &&
_y_size == other._y_size &&
_title == other._title &&
_framebuffer_mode == other._framebuffer_mode &&
_depth_bits == other._depth_bits &&
_color_bits == other._color_bits);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear
// Access: Published
// Description: Unsets all properties that have been specified so
// far, and resets the WindowProperties structure to its
// initial empty state.
////////////////////////////////////////////////////////////////////
void WindowProperties::
clear() {
_specified = 0;
_x_origin = 0;
_y_origin = 0;
_x_size = 0;
_y_size = 0;
_title = string();
_flags = 0;
_framebuffer_mode = 0;
_depth_bits = 0;
_color_bits = 0;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::add_properties
// Access: Published
// Description: Sets any properties that are explicitly specified in
// other on this object. Leaves other properties
// unchanged.
////////////////////////////////////////////////////////////////////
void WindowProperties::
add_properties(const WindowProperties &other) {
if (other.has_origin()) {
set_origin(other.get_x_origin(), other.get_y_origin());
}
if (other.has_size()) {
set_size(other.get_x_size(), other.get_y_size());
}
if (other.has_title()) {
set_title(other.get_title());
}
if (other.has_undecorated()) {
set_undecorated(other.get_undecorated());
}
if (other.has_fullscreen()) {
set_fullscreen(other.get_fullscreen());
}
if (other.has_foreground()) {
set_foreground(other.get_foreground());
}
if (other.has_minimized()) {
set_minimized(other.get_minimized());
}
if (other.has_open()) {
set_open(other.get_open());
}
if (other.has_cursor_hidden()) {
set_cursor_hidden(other.get_cursor_hidden());
}
if (other.has_framebuffer_mode()) {
set_framebuffer_mode(other.get_framebuffer_mode());
}
if (other.has_depth_bits()) {
set_depth_bits(other.get_depth_bits());
}
if (other.has_color_bits()) {
set_color_bits(other.get_color_bits());
}
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::output
// Access: Published
// Description: Sets any properties that are explicitly specified in
// other on this object. Leaves other properties
// unchanged.
////////////////////////////////////////////////////////////////////
void WindowProperties::
output(ostream &out) const {
if (has_origin()) {
out << "origin=(" << get_x_origin() << ", " << get_y_origin() << ") ";
}
if (has_size()) {
out << "size=(" << get_x_size() << ", " << get_y_size() << ") ";
}
if (has_title()) {
out << "title=\"" << get_title() << "\"" << " ";
}
if (has_undecorated()) {
out << (get_undecorated() ? "undecorated " : "!undecorated ");
}
if (has_fullscreen()) {
out << (get_fullscreen() ? "fullscreen " : "!fullscreen ");
}
if (has_foreground()) {
out << (get_foreground() ? "foreground " : "!foreground ");
}
if (has_minimized()) {
out << (get_minimized() ? "minimized " : "!minimized ");
}
if (has_open()) {
out << (get_open() ? "open " : "!open ");
}
if (has_cursor_hidden()) {
out << (get_cursor_hidden() ? "cursor_hidden " : "!cursor_hidden ");
}
if (has_framebuffer_mode()) {
out << "framebuffer_mode=";
int framebuffer_mode = get_framebuffer_mode();
if ((framebuffer_mode & FM_index) != 0) {
out << "FM_index";
} else {
out << "FM_rgb";
}
if ((framebuffer_mode & FM_triple_buffer) != 0) {
out << "|FM_triple_buffer";
} else if ((framebuffer_mode & FM_double_buffer) != 0) {
out << "|FM_double_buffer";
} else {
out << "|FM_single_buffer";
}
if ((framebuffer_mode & FM_accum) != 0) {
out << "|FM_accum";
}
if ((framebuffer_mode & FM_alpha) != 0) {
out << "|FM_alpha";
}
if ((framebuffer_mode & FM_depth) != 0) {
out << "|FM_depth";
}
if ((framebuffer_mode & FM_stencil) != 0) {
out << "|FM_stencil";
}
if ((framebuffer_mode & FM_multisample) != 0) {
out << "|FM_multisample";
}
if ((framebuffer_mode & FM_stereo) != 0) {
out << "|FM_stereo";
}
if ((framebuffer_mode & FM_luminance) != 0) {
out << "|FM_luminance";
}
out << " ";
}
if (has_depth_bits()) {
out << "depth_bits=" << get_depth_bits() << " ";
}
if (has_color_bits()) {
out << "color_bits=" << get_color_bits() << " ";
}
}

View File

@ -0,0 +1,173 @@
// Filename: windowProperties.h
// Created by: drose (13Aug02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef WINDOWPROPERTIES_H
#define WINDOWPROPERTIES_H
#include "pandabase.h"
////////////////////////////////////////////////////////////////////
// Class : WindowProperties
// Description : A container for the various kinds of properties we
// might ask to have on a graphics window before we open
// it. This also serves to hold the current properties
// for a window after it has been opened.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA WindowProperties {
PUBLISHED:
WindowProperties();
INLINE WindowProperties(const WindowProperties &copy);
void operator = (const WindowProperties &copy);
INLINE ~WindowProperties();
bool operator == (const WindowProperties &other) const;
INLINE bool operator != (const WindowProperties &other) const;
enum FramebufferMode {
FM_rgba = 0x0000,
FM_rgb = 0x0000,
FM_index = 0x0001,
FM_single_buffer = 0x0000,
FM_double_buffer = 0x0002,
FM_triple_buffer = 0x0004,
FM_accum = 0x0008,
FM_alpha = 0x0010,
FM_depth = 0x0020,
FM_stencil = 0x0040,
FM_multisample = 0x0080,
FM_stereo = 0x0100,
FM_luminance = 0x0200,
};
void clear();
INLINE bool is_any_specified() const;
INLINE void set_origin(int x_origin, int y_origin);
INLINE int get_x_origin() const;
INLINE int get_y_origin() const;
INLINE bool has_origin() const;
INLINE void clear_origin();
INLINE void set_size(int x_size, int y_size);
INLINE int get_x_size() const;
INLINE int get_y_size() const;
INLINE bool has_size() const;
INLINE void clear_size();
INLINE void set_title(const string &title);
INLINE const string &get_title() const;
INLINE bool has_title() const;
INLINE void clear_title();
INLINE void set_undecorated(bool undecorated);
INLINE bool get_undecorated() const;
INLINE bool has_undecorated() const;
INLINE void clear_undecorated();
INLINE void set_fullscreen(bool fullscreen);
INLINE bool get_fullscreen() const;
INLINE bool has_fullscreen() const;
INLINE void clear_fullscreen();
INLINE void set_foreground(bool foreground);
INLINE bool get_foreground() const;
INLINE bool has_foreground() const;
INLINE void clear_foreground();
INLINE void set_minimized(bool minimized);
INLINE bool get_minimized() const;
INLINE bool has_minimized() const;
INLINE void clear_minimized();
INLINE void set_open(bool open);
INLINE bool get_open() const;
INLINE bool has_open() const;
INLINE void clear_open();
INLINE void set_cursor_hidden(bool cursor_hidden);
INLINE bool get_cursor_hidden() const;
INLINE bool has_cursor_hidden() const;
INLINE void clear_cursor_hidden();
INLINE void set_framebuffer_mode(int framebuffer_mode);
INLINE int get_framebuffer_mode() const;
INLINE bool has_framebuffer_mode() const;
INLINE void clear_framebuffer_mode();
INLINE void set_depth_bits(int depth_bits);
INLINE int get_depth_bits() const;
INLINE bool has_depth_bits() const;
INLINE void clear_depth_bits();
INLINE void set_color_bits(int color_bits);
INLINE int get_color_bits() const;
INLINE bool has_color_bits() const;
INLINE void clear_color_bits();
void add_properties(const WindowProperties &other);
void output(ostream &out) const;
private:
// This bitmask indicates which of the parameters in the properties
// structure have been filled in by the user, and which remain
// unspecified.
enum Specified {
S_origin = 0x0001,
S_size = 0x0002,
S_title = 0x0004,
S_undecorated = 0x0008,
S_fullscreen = 0x0010,
S_foreground = 0x0020,
S_minimized = 0x0040,
S_open = 0x0080,
S_cursor_hidden = 0x0100,
S_framebuffer_mode = 0x0200,
S_depth_bits = 0x0400,
S_color_bits = 0x0800,
};
// This bitmask represents the true/false settings for various
// boolean flags (assuming the corresponding S_* bit has been set,
// above).
enum Flags {
F_undecorated = S_undecorated,
F_fullscreen = S_fullscreen,
F_foreground = S_foreground,
F_minimized = S_minimized,
F_open = S_open,
F_cursor_hidden = S_cursor_hidden,
};
int _specified;
int _x_origin;
int _y_origin;
int _x_size;
int _y_size;
string _title;
int _flags;
int _framebuffer_mode;
int _depth_bits;
int _color_bits;
};
INLINE ostream &operator << (ostream &out, const WindowProperties &properties);
#include "windowProperties.I"
#endif

View File

@ -601,7 +601,7 @@ render_screen(GraphicsEngine *engine, NonlinearImager::Screen &screen) {
PT(DisplayRegion) scratch_region =
_gsg->get_window()->make_scratch_display_region(screen._tex_width, screen._tex_height);
scratch_region->set_camera(screen._source_camera);
engine->render_subframe(_gsg, scratch_region);
engine->render_subframe(_gsg, scratch_region, true);
// Copy the results of the render from the frame buffer into the
// screen's texture.

View File

@ -1,29 +0,0 @@
#define BUILD_DIRECTORY $[HAVE_DX]
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
dtoolutil:c dtoolbase:c dtool:m
#define USE_PACKAGES dx
#begin lib_target
#define TARGET dxgsg
#define LOCAL_LIBS \
gsgmisc gsgbase gobj display \
putil linmath mathutil pnmimage event
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
// need to install these due to external projects that link directly with libpandadx (bartop)
#define INSTALL_HEADERS \
config_dxgsg.h dxGraphicsStateGuardian.I dxGraphicsStateGuardian.h \
dxTextureContext.h dxGeomNodeContext.h dxGeomNodeContext.I dxgsgbase.h
// build dxGraphicsStateGuardian separately since its so big
#define SOURCES \
dxGraphicsStateGuardian.cxx dxSavedFrameBuffer.I dxSavedFrameBuffer.h $[INSTALL_HEADERS]
#define INCLUDED_SOURCES \
config_dxgsg.cxx dxSavedFrameBuffer.cxx dxTextureContext.cxx dxGeomNodeContext.cxx
#end lib_target

View File

@ -1,4 +0,0 @@
#include "config_dxgsg.cxx"
#include "dxSavedFrameBuffer.cxx"
#include "dxTextureContext.cxx"
#include "dxGeomNodeContext.cxx"

View File

@ -0,0 +1,36 @@
#define BUILD_DIRECTORY $[HAVE_DX]
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
dtoolutil:c dtoolbase:c dtool:m
#define USE_PACKAGES dx
#begin lib_target
#define TARGET dxgsg7
#define LOCAL_LIBS \
gsgmisc gsgbase gobj display windisplay \
putil linmath mathutil pnmimage event
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
// need to install these due to external projects that link directly with libpandadx (bartop)
#define INSTALL_HEADERS \
config_dxgsg7.h dxGraphicsStateGuardian7.I dxGraphicsStateGuardian7.h \
dxTextureContext7.h dxGeomNodeContext7.h dxGeomNodeContext7.I dxgsg7base.h
// build dxGraphicsStateGuardian separately since its so big
#define SOURCES \
dxGraphicsStateGuardian7.cxx dxSavedFrameBuffer7.I dxSavedFrameBuffer7.h \
wdxGraphicsPipe7.I wdxGraphicsPipe7.h \
wdxGraphicsWindow7.I wdxGraphicsWindow7.h \
$[INSTALL_HEADERS]
#define INCLUDED_SOURCES \
config_dxgsg7.cxx \
dxgsg7base.cxx \
dxSavedFrameBuffer7.cxx dxTextureContext7.cxx \
dxGeomNodeContext7.cxx \
wdxGraphicsPipe7.cxx wdxGraphicsWindow7.cxx
#end lib_target

View File

@ -16,41 +16,45 @@
//
////////////////////////////////////////////////////////////////////
#include "config_dxgsg.h"
#include "dxGraphicsStateGuardian.h"
#include "dxSavedFrameBuffer.h"
#include "dxTextureContext.h"
#include "config_dxgsg7.h"
#include "dxGraphicsStateGuardian7.h"
#include "dxSavedFrameBuffer7.h"
#include "dxTextureContext7.h"
#include "wdxGraphicsPipe7.h"
#include "wdxGraphicsWindow7.h"
#include "graphicsPipeSelection.h"
#include <dconfig.h>
#include "dconfig.h"
Configure(config_dxgsg);
NotifyCategoryDef(dxgsg, ":display:gsg");
Configure(config_dxgsg7);
NotifyCategoryDef(dxgsg7, ":display:gsg");
NotifyCategoryDef(wdxdisplay7, "windisplay");
// Configure this variable true to cause the DXGSG to show each
// transform space it renders by drawing a little unit axis. This
// cannot be enabled when the player is compiled in NDEBUG mode.
bool dx_show_transforms = config_dxgsg.GetBool("dx-show-transforms", false);
bool dx_show_transforms = config_dxgsg7.GetBool("dx-show-transforms", false);
// Configure this to TRUE if you want DirectX to control the entire screen,
// If false, it will just blit into a window.
bool dx_full_screen = config_dxgsg.GetBool("dx-full-screen", false);
bool dx_full_screen = config_dxgsg7.GetBool("dx-full-screen", false);
// Configure this true to force the rendering to sync to the video
// refresh, or false to let your frame rate go as high as it can,
// irrespective of the video refresh.
bool dx_sync_video = config_dxgsg.GetBool("sync-video", true);
bool dx_sync_video = config_dxgsg7.GetBool("sync-video", true);
// enable this to turn on full-screen anti-aliasing, if the HW supports it
// this var is also used in wdxGraphicsWindows.cxx
bool dx_full_screen_antialiasing = config_dxgsg.GetBool("dx-antialias", false);
bool dx_full_screen_antialiasing = config_dxgsg7.GetBool("dx-antialias", false);
// Configure this true to perform a cull traversal over the geometry
// by default, false otherwise. The cull traversal provides support
// for state-sorting, z-sorting, and binning.
bool dx_cull_traversal = config_dxgsg.GetBool("dx-cull-traversal", true);
bool dx_cull_traversal = config_dxgsg7.GetBool("dx-cull-traversal", true);
// if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
bool dx_no_vertex_fog = config_dxgsg.GetBool("dx-no-vertex-fog", false);
bool dx_no_vertex_fog = config_dxgsg7.GetBool("dx-no-vertex-fog", false);
// Configure this true to cause all lighting normals to automatically
// be normalized by the CPU before rendering. This is
@ -58,43 +62,43 @@ bool dx_no_vertex_fog = config_dxgsg.GetBool("dx-no-vertex-fog", false);
// expect lighting to work correctly. Maybe one day there will be
// another way to set this at runtime, instead of only as a configure
// variable
bool dx_auto_normalize_lighting = config_dxgsg.GetBool("auto-normalize-lighting", false);
bool dx_auto_normalize_lighting = config_dxgsg7.GetBool("auto-normalize-lighting", false);
bool dx_allow_software_renderer = config_dxgsg.GetBool("dx-allow-software-renderer", false);
bool dx_force_software_renderer = config_dxgsg.GetBool("dx-force-software-renderer", false);
bool dx_show_fps_meter = config_dxgsg.GetBool("show-fps-meter", false);
float dx_fps_meter_update_interval = max(0.5,config_dxgsg.GetFloat("fps-meter-update-interval", 1.7));
bool dx_allow_software_renderer = config_dxgsg7.GetBool("dx-allow-software-renderer", false);
bool dx_force_software_renderer = config_dxgsg7.GetBool("dx-force-software-renderer", false);
#ifndef NDEBUG
// debugging flag
// values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
int dx_force_backface_culling = config_dxgsg.GetInt("dx-force-backface-culling", 0);
int dx_force_backface_culling = config_dxgsg7.GetInt("dx-force-backface-culling", 0);
#endif
bool dx_mipmap_everything = config_dxgsg.GetBool("dx-mipmap-everything", false);
bool dx_ignore_mipmaps = config_dxgsg.GetBool("dx-ignore-mipmaps", false);
bool dx_mipmap_everything = config_dxgsg7.GetBool("dx-mipmap-everything", false);
bool dx_ignore_mipmaps = config_dxgsg7.GetBool("dx-ignore-mipmaps", false);
// if this is set, more accurate but more expensive fog computations are performed
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);
bool dx_use_rangebased_fog = config_dxgsg7.GetBool("dx-use-rangebased-fog", false);
bool dx_force_16bpptextures = config_dxgsg7.GetBool("dx-force-16bpptextures", false);
bool dx_no_dithering = config_dxgsg7.GetBool("dx-no-dithering", false);
bool dx_force_16bpp_zbuffer = config_dxgsg7.GetBool("dx-force-16bpp-zbuffer", false);
bool dx_do_vidmemsize_check = config_dxgsg7.GetBool("do-vidmemsize-check", true);
bool dx_preserve_fpu_state = config_dxgsg7.GetBool("dx-preserve-fpu-state", 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);
bool dx_depth_offset_decals = config_dxgsg7.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);
bool dx_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
//int dx_print_texstats = config_dxgsg.GetBool("dx-print-texstats", 0);
float dx_global_miplevel_bias = config_dxgsg7.GetFloat("dx-global-miplevel-bias", 0.0);
bool dx_debug_view_mipmaps = config_dxgsg7.GetBool("dx-debug-view-mipmaps", false);
bool dx_force_anisotropic_filtering = config_dxgsg7.GetBool("dx-force-anisotropic-filtering", false);
//int dx_print_texstats = config_dxgsg7.GetBool("dx-print-texstats", 0);
#endif
// set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom
// together using degenerate tris
const bool link_tristrips = config_dxgsg.GetBool("link-tristrips", false);
const bool link_tristrips = config_dxgsg7.GetBool("link-tristrips", false);
// note: offset currently disabled since it wasnt working properly
DXDecalType dx_decal_type = GDT_blend;
@ -108,16 +112,16 @@ parse_decal_type(const string &type) {
} else if (type == "offset") {
return GDT_offset;
}
dxgsg_cat.error() << "Invalid dx-decal-type: " << type << "\n";
dxgsg7_cat.error() << "Invalid dx-decal-type: " << type << "\n";
return GDT_blend;
}
ConfigureFn(config_dxgsg) {
init_libdxgsg();
ConfigureFn(config_dxgsg7) {
init_libdxgsg7();
}
////////////////////////////////////////////////////////////////////
// Function: init_libdxgsg
// Function: init_libdxgsg7
// Description: Initializes the library. This must be called at
// least once before any of the functions or classes in
// this library can be used. Normally it will be
@ -125,24 +129,27 @@ ConfigureFn(config_dxgsg) {
// called explicitly, but special cases exist.
////////////////////////////////////////////////////////////////////
void
init_libdxgsg() {
init_libdxgsg7() {
static bool initialized = false;
if (initialized) {
return;
}
initialized = true;
string decal_type = config_dxgsg.GetString("dx-decal-type", "");
string decal_type = config_dxgsg7.GetString("dx-decal-type", "");
if (!decal_type.empty()) {
dx_decal_type = parse_decal_type(decal_type);
}
DXGraphicsStateGuardian::init_type();
DXSavedFrameBuffer::init_type();
DXTextureContext::init_type();
DXGeomNodeContext::init_type();
DXGraphicsStateGuardian7::init_type();
DXSavedFrameBuffer7::init_type();
DXTextureContext7::init_type();
DXGeomNodeContext7::init_type();
GraphicsStateGuardian::get_factory().register_factory
(DXGraphicsStateGuardian::get_class_type(),
DXGraphicsStateGuardian::make_DXGraphicsStateGuardian);
wdxGraphicsPipe7::init_type();
wdxGraphicsWindow7::init_type();
GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
selection->add_pipe_type(wdxGraphicsPipe7::get_class_type(),
wdxGraphicsPipe7::pipe_constructor);
}

View File

@ -1,4 +1,4 @@
// Filename: config_dxgsg.h
// Filename: config_dxgsg7.h
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -16,21 +16,20 @@
//
////////////////////////////////////////////////////////////////////
#ifndef CONFIG_DXGSG_H
#define CONFIG_DXGSG_H
#ifndef CONFIG_DXGSG7_H
#define CONFIG_DXGSG7_H
#include <pandabase.h>
#include <notifyCategoryProxy.h>
NotifyCategoryDecl(dxgsg, EXPCL_PANDADX, EXPTP_PANDADX);
NotifyCategoryDecl(dxgsg7, EXPCL_PANDADX, EXPTP_PANDADX);
NotifyCategoryDecl(wdxdisplay7, EXPCL_PANDADX, EXPTP_PANDADX);
extern bool dx_full_screen;
extern bool dx_sync_video;
extern bool dx_cull_traversal;
extern bool dx_show_fps_meter;
extern bool dx_no_vertex_fog;
extern bool dx_full_screen_antialiasing;
extern float dx_fps_meter_update_interval;
extern bool dx_auto_normalize_lighting;
extern bool dx_use_rangebased_fog;
extern bool dx_allow_software_renderer;
@ -43,6 +42,9 @@ extern bool dx_mipmap_everything;
extern bool dx_show_transforms;
extern bool dx_force_16bpptextures;
extern bool dx_no_dithering;
extern bool dx_force_16bpp_zbuffer;
extern bool dx_do_vidmemsize_check;
extern bool dx_preserve_fpu_state;
extern bool dx_depth_offset_decals;
@ -64,6 +66,6 @@ enum DXDecalType {
};
extern DXDecalType dx_decal_type;
extern EXPCL_PANDADX void init_libdxgsg();
extern EXPCL_PANDADX void init_libdxgsg7();
#endif

View File

@ -1,4 +1,4 @@
// Filename: dxGeomNodeContext.I
// Filename: dxGeomNodeContext7.I
// Created by: drose (12Jun01)
//
////////////////////////////////////////////////////////////////////
@ -18,12 +18,12 @@
////////////////////////////////////////////////////////////////////
// Function: dxGeomNodeContext::Constructor
// Function: DXGeomNodeContext7::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE DXGeomNodeContext::
DXGeomNodeContext(GeomNode *node) : GeomNodeContext(node)
INLINE DXGeomNodeContext7::
DXGeomNodeContext7(GeomNode *node) : GeomNodeContext(node)
{
_num_verts = 0;
_pVB = NULL;

View File

@ -1,4 +1,4 @@
// Filename: dxGeomNodeContext.cxx
// Filename: dxGeomNodeContext7.cxx
// Created by: drose (12Jun01)
//
////////////////////////////////////////////////////////////////////
@ -16,11 +16,11 @@
//
////////////////////////////////////////////////////////////////////
#include "dxGeomNodeContext.h"
#include "DXGeomNodeContext7.h"
TypeHandle DXGeomNodeContext::_type_handle;
TypeHandle DXGeomNodeContext7::_type_handle;
DXGeomNodeContext::~DXGeomNodeContext()
DXGeomNodeContext7::~DXGeomNodeContext7()
{
if(_pXformed_VB!=NULL)
_pXformed_VB->Release();

View File

@ -1,4 +1,4 @@
// Filename: dxGeomNodeContext.h
// Filename: dxGeomNodeContext7.h
// Created by: drose (12Jun01)
//
////////////////////////////////////////////////////////////////////
@ -16,10 +16,10 @@
//
////////////////////////////////////////////////////////////////////
#ifndef DXGEOMNODECONTEXT_H
#define DXGEOMNODECONTEXT_H
#ifndef DXGEOMNODECONTEXT7_H
#define DXGEOMNODECONTEXT7_H
#include "dxgsgbase.h"
#include "dxgsg7base.h"
#include "geomNodeContext.h"
#include "geomNode.h"
@ -31,13 +31,13 @@ typedef struct {
} DPInfo;
////////////////////////////////////////////////////////////////////
// Class : DXGeomNodeContext
// Class : DXGeomNodeContext7
// Description :
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXGeomNodeContext : public GeomNodeContext {
class EXPCL_PANDADX DXGeomNodeContext7 : public GeomNodeContext {
public:
INLINE DXGeomNodeContext(GeomNode *node);
~DXGeomNodeContext();
INLINE DXGeomNodeContext7(GeomNode *node);
~DXGeomNodeContext7();
// A list of the dynamic Geoms within the GeomNode; these aren't
// part of the above display list and must be drawn separately
@ -66,7 +66,7 @@ public:
}
static void init_type() {
GeomNodeContext::init_type();
register_type(_type_handle, "DXGeomNodeContext",
register_type(_type_handle, "DXGeomNodeContext7",
GeomNodeContext::get_class_type());
}
virtual TypeHandle get_type() const {
@ -78,7 +78,7 @@ private:
static TypeHandle _type_handle;
};
#include "dxGeomNodeContext.I"
#include "dxGeomNodeContext7.I"
#endif

View File

@ -1,4 +1,4 @@
// Filename: dxGraphicsStateGuardian.I
// Filename: dxGraphicsStateGuardian7.I
// Created by: mike (02Feb99)
//
////////////////////////////////////////////////////////////////////
@ -16,22 +16,22 @@
//
////////////////////////////////////////////////////////////////////
#include "config_dxgsg.h"
#include "config_dxgsg7.h"
#include <graphicsWindow.h>
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_line_smooth
// Function: DXGraphicsStateGuardian7::enable_line_smooth
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_line_smooth(bool val) {
if(_line_smooth_enabled != val) {
_line_smooth_enabled = val;
#ifdef NDEBUG
{
if(val && (scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
dxgsg_cat.error() << "no HW support for line smoothing!!\n";
dxgsg7_cat.error() << "no HW support for line smoothing!!\n";
}
#endif
@ -40,18 +40,18 @@ enable_line_smooth(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_dither
// Function: DXGraphicsStateGuardian7::enable_dither
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_dither(bool val) {
if (_dither_enabled != val) {
#ifdef _DEBUG
{
if(val && !(scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
dxgsg_cat.error() << "no HW support for color dithering!!\n";
dxgsg7_cat.error() << "no HW support for color dithering!!\n";
return;
}
#endif
@ -62,11 +62,11 @@ enable_dither(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_stencil_test
// Function: DXGraphicsStateGuardian7::enable_stencil_test
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_stencil_test(bool val) {
if (_stencil_test_enabled != val) {
_stencil_test_enabled = val;
@ -75,11 +75,11 @@ enable_stencil_test(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_color_material
// Function: DXGraphicsStateGuardian7::enable_color_material
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_color_material(bool val) {
if (_color_material_enabled != val) {
_color_material_enabled = val;
@ -87,11 +87,11 @@ enable_color_material(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_blend
// Function: DXGraphicsStateGuardian7::enable_blend
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_blend(bool val) {
if (_blend_enabled != val) {
_blend_enabled = val;
@ -100,11 +100,11 @@ enable_blend(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_blend
// Function: DXGraphicsStateGuardian7::enable_blend
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
set_shademode(D3DSHADEMODE val) {
if (_CurShadeMode != val) {
_CurShadeMode = val;
@ -112,7 +112,7 @@ set_shademode(D3DSHADEMODE val) {
}
}
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_primitive_clipping(bool val) {
if (_clipping_enabled != val) {
_clipping_enabled = val;
@ -121,11 +121,11 @@ enable_primitive_clipping(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_fog
// Function: DXGraphicsStateGuardian7::enable_fog
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_fog(bool val) {
if ((_fog_enabled != val) && (_doFogType!=None)) {
_fog_enabled = val;
@ -134,11 +134,11 @@ enable_fog(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_alpha_test
// Function: DXGraphicsStateGuardian7::enable_alpha_test
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_alpha_test(bool val )
{
if (_alpha_test_enabled != val) {
@ -148,17 +148,17 @@ enable_alpha_test(bool val )
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::call_dxLightModelAmbient
// Function: DXGraphicsStateGuardian7::call_dxLightModelAmbient
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
call_dxLightModelAmbient( const Colorf& color)
{
if (_lmodel_ambient != color) {
_lmodel_ambient = color;
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
dxgsg7_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
#endif
scrn.pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
D3DRGBA(color[0], color[1], color[2], color[3]));
@ -166,43 +166,47 @@ call_dxLightModelAmbient( const Colorf& color)
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::call_dxAlphaFunc
// Function: DXGraphicsStateGuardian7::call_dxAlphaFunc
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
if (_alpha_func != func) {
_alpha_func = func;
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxAlphaFunc(";
dxgsg7_cat.debug() << "dxAlphaFunc(";
switch (func) {
case D3DCMP_NEVER:
dxgsg_cat.debug(false) << "D3DCMP_NEVER";
dxgsg7_cat.debug(false) << "D3DCMP_NEVER";
break;
case D3DCMP_LESS:
dxgsg_cat.debug(false) << "D3DCMP_LESS";
dxgsg7_cat.debug(false) << "D3DCMP_LESS";
break;
case D3DCMP_EQUAL:
dxgsg_cat.debug(false) << "D3DCMP_EQUAL";
dxgsg7_cat.debug(false) << "D3DCMP_EQUAL";
break;
#ifdef D3DCMP_LEQUAL
case D3DCMP_LEQUAL:
dxgsg_cat.debug(false) << "D3DCMP_LEQUAL";
dxgsg7_cat.debug(false) << "D3DCMP_LEQUAL";
break;
#endif
case D3DCMP_GREATER:
dxgsg_cat.debug(false) << "D3DCMP_GREATER";
dxgsg7_cat.debug(false) << "D3DCMP_GREATER";
break;
case D3DCMP_NOTEQUAL:
dxgsg_cat.debug(false) << "D3DCMP_NOTEQUAL";
dxgsg7_cat.debug(false) << "D3DCMP_NOTEQUAL";
break;
#ifdef D3DCMP_GEQUAL
case D3DCMP_GEQUAL:
dxgsg_cat.debug(false) << "D3DCMP_GEQUAL";
dxgsg7_cat.debug(false) << "D3DCMP_GEQUAL";
break;
#endif
case D3DCMP_ALWAYS:
dxgsg_cat.debug(false) << "D3DCMP_ALWAYS";
dxgsg7_cat.debug(false) << "D3DCMP_ALWAYS";
break;
}
dxgsg_cat.debug() << " , " << reference_alpha << ")" << endl;
dxgsg7_cat.debug() << " , " << reference_alpha << ")" << endl;
#endif
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
}
@ -213,7 +217,7 @@ call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
}
}
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
{
if (_blend_source_func != sfunc)
@ -221,41 +225,41 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
_blend_source_func = sfunc;
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxSrcBlendFunc(";
dxgsg7_cat.debug() << "dxSrcBlendFunc(";
switch (sfunc)
{
case D3DBLEND_ZERO:
dxgsg_cat.debug(false) << "ZERO, ";
dxgsg7_cat.debug(false) << "ZERO, ";
break;
case D3DBLEND_ONE:
dxgsg_cat.debug(false) << "ONE, ";
dxgsg7_cat.debug(false) << "ONE, ";
break;
case D3DBLEND_DESTCOLOR:
dxgsg_cat.debug(false) << "DESTCOLOR, ";
dxgsg7_cat.debug(false) << "DESTCOLOR, ";
break;
case D3DBLEND_INVDESTCOLOR:
dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
break;
case D3DBLEND_SRCALPHA:
dxgsg_cat.debug(false) << "SRCALPHA, ";
dxgsg7_cat.debug(false) << "SRCALPHA, ";
break;
case D3DBLEND_INVSRCALPHA:
dxgsg_cat.debug(false) << "INVSRCALPHA, ";
dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
break;
case D3DBLEND_DESTALPHA:
dxgsg_cat.debug(false) << "DESTALPHA, ";
dxgsg7_cat.debug(false) << "DESTALPHA, ";
break;
case D3DBLEND_INVDESTALPHA:
dxgsg_cat.debug(false) << "INVDESTALPHA, ";
dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
break;
case D3DBLEND_SRCALPHASAT:
dxgsg_cat.debug(false) << "SRCALPHASAT, ";
dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
break;
default:
dxgsg_cat.debug(false) << "unknown, ";
dxgsg7_cat.debug(false) << "unknown, ";
break;
}
dxgsg_cat.debug(false) << endl;
dxgsg7_cat.debug(false) << endl;
#endif
}
if ( _blend_dest_func != dfunc)
@ -263,43 +267,43 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
_blend_dest_func = dfunc;
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxDstBlendFunc(";
dxgsg7_cat.debug() << "dxDstBlendFunc(";
switch (dfunc)
{
case D3DBLEND_ZERO:
dxgsg_cat.debug(false) << "ZERO, ";
dxgsg7_cat.debug(false) << "ZERO, ";
break;
case D3DBLEND_ONE:
dxgsg_cat.debug(false) << "ONE, ";
dxgsg7_cat.debug(false) << "ONE, ";
break;
case D3DBLEND_DESTCOLOR:
dxgsg_cat.debug(false) << "DESTCOLOR, ";
dxgsg7_cat.debug(false) << "DESTCOLOR, ";
break;
case D3DBLEND_INVDESTCOLOR:
dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
break;
case D3DBLEND_SRCALPHA:
dxgsg_cat.debug(false) << "SRCALPHA, ";
dxgsg7_cat.debug(false) << "SRCALPHA, ";
break;
case D3DBLEND_INVSRCALPHA:
dxgsg_cat.debug(false) << "INVSRCALPHA, ";
dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
break;
case D3DBLEND_DESTALPHA:
dxgsg_cat.debug(false) << "DESTALPHA, ";
dxgsg7_cat.debug(false) << "DESTALPHA, ";
break;
case D3DBLEND_INVDESTALPHA:
dxgsg_cat.debug(false) << "INVDESTALPHA, ";
dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
break;
case D3DBLEND_SRCALPHASAT:
dxgsg_cat.debug(false) << "SRCALPHASAT, ";
dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
break;
}
dxgsg_cat.debug(false) << endl;
dxgsg7_cat.debug(false) << endl;
#endif
}
}
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_zwritemask(bool val) {
if (_depth_write_enabled != val) {
_depth_write_enabled = val;
@ -310,24 +314,24 @@ enable_zwritemask(bool val) {
/** unimplemented
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_multisample
// Function: DXGraphicsStateGuardian7::enable_multisample
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_multisample(bool val) {
_multisample_enabled = val;
#ifdef NDEBUG
dxgsg_cat.error() << "dx multisample unimplemented!!\n";
dxgsg7_cat.error() << "dx multisample unimplemented!!\n";
#endif
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_one
// Function: DXGraphicsStateGuardian7::enable_multisample_alpha_one
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_multisample_alpha_one(bool val) {
if (_multisample_alpha_one_enabled != val) {
_multisample_alpha_one_enabled = val;
@ -335,11 +339,11 @@ enable_multisample_alpha_one(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_mask
// Function: DXGraphicsStateGuardian7::enable_multisample_alpha_mask
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_multisample_alpha_mask(bool val) {
if (_multisample_alpha_mask_enabled != val) {
_multisample_alpha_mask_enabled = val;
@ -347,16 +351,16 @@ enable_multisample_alpha_mask(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_point_smooth
// Function: DXGraphicsStateGuardian7::enable_point_smooth
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian7::
enable_point_smooth(bool val) {
// _point_smooth_enabled = val;
#ifdef NDEBUG
dxgsg_cat.error() << "dx point smoothing unimplemented!!\n";
dxgsg7_cat.error() << "dx point smoothing unimplemented!!\n";
#endif
}
*/

View File

@ -1,4 +1,4 @@
// Filename: dxGraphicsStateGuardian.h
// Filename: dxGraphicsStateGuardian7.h
// Created by: mike (02Feb99)
//
////////////////////////////////////////////////////////////////////
@ -16,12 +16,14 @@
//
////////////////////////////////////////////////////////////////////
#ifndef DXGRAPHICSSTATEGUARDIAN_H
#define DXGRAPHICSSTATEGUARDIAN_H
#ifndef DXGRAPHICSSTATEGUARDIAN7_H
#define DXGRAPHICSSTATEGUARDIAN7_H
#include "dxgsgbase.h"
#include "dxGeomNodeContext.h"
#include "dxTextureContext.h"
//#define GSG_VERBOSE 1
#include "dxgsg7base.h"
#include "dxGeomNodeContext7.h"
#include "dxTextureContext7.h"
#include "graphicsStateGuardian.h"
#include "geomprimitives.h"
@ -51,20 +53,20 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
#endif
////////////////////////////////////////////////////////////////////
// Class : DXGraphicsStateGuardian
// Class : DXGraphicsStateGuardian7
// Description : A GraphicsStateGuardian specialized for rendering
// into DX. There should be no DX calls
// outside of this object.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
friend class wdxGraphicsWindow;
friend class wdxGraphicsPipe;
friend class wdxGraphicsWindowGroup;
friend class DXTextureContext;
class EXPCL_PANDADX DXGraphicsStateGuardian7 : public GraphicsStateGuardian {
friend class wdxGraphicsWindow7;
friend class wdxGraphicsPipe7;
friend class wdxGraphicsWindow7Group;
friend class DXTextureContext7;
public:
DXGraphicsStateGuardian(GraphicsWindow *win);
~DXGraphicsStateGuardian();
DXGraphicsStateGuardian7(GraphicsWindow *win);
~DXGraphicsStateGuardian7();
virtual void reset();
@ -126,12 +128,11 @@ public:
virtual void bind_light(DirectionalLight *light, int light_id);
virtual void bind_light(Spotlight *light, int light_id);
// default gsg begin_frame() used
virtual bool begin_frame();
virtual bool begin_scene();
virtual void end_scene();
virtual void end_frame();
virtual void start_rendering();
virtual void finish_rendering();
virtual bool wants_normals(void) const;
virtual bool wants_texcoords(void) const;
@ -180,10 +181,8 @@ protected:
bool _dx_ready;
HRESULT _last_testcooplevel_result;
bool _bShowFPSMeter;
HDC _front_hdc;
DXTextureContext *_pCurTexContext;
DXTextureContext7 *_pCurTexContext;
bool _bTransformIssued; // decaling needs to tell when a transform has been issued
D3DMATRIX _SavedTransform;
@ -243,7 +242,7 @@ protected:
D3DSHADEMODE _CurShadeMode;
bool _bDrawPrimDoSetupVertexBuffer; // if true, draw methods just copy vertex data into pCurrentGeomContext
DXGeomNodeContext *_pCurrentGeomContext; // used in vertex buffer setup
DXGeomNodeContext7 *_pCurrentGeomContext; // used in vertex buffer setup
// iterators for primitives
Geom::VertexIterator vi;
@ -322,19 +321,6 @@ protected:
bool _overlay_windows_supported;
// vars for frames/sec meter
DWORD _start_time;
DWORD _start_frame_count;
DWORD _cur_frame_count;
float _current_fps;
DWORD *_fpsmeter_verts;
DWORD _fpsmeter_fvfflags;
LPDIRECTDRAWSURFACE7 _fpsmeter_font_surf;
float _fps_u_usedwidth,_fps_v_usedheight; // fraction of fps font texture actually used
DWORD _fps_vertexsize; // size of verts used to render fps meter
void SetFPSMeterPosition(RECT &view_rect);
void FillFPSMeterTexture(void);
public:
static GraphicsStateGuardian*
make_DXGraphicsStateGuardian(const FactoryParams &params);
@ -353,7 +339,7 @@ public:
void adjust_view_rect(int x, int y);
INLINE void SetDXReady(bool stat) { _dx_ready = stat; }
INLINE bool GetDXReady(void) { return _dx_ready;}
void DXGraphicsStateGuardian::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
void DXGraphicsStateGuardian7::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
void dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled);
@ -383,7 +369,7 @@ private:
static TypeHandle _type_handle;
};
#include "dxGraphicsStateGuardian.I"
#include "dxGraphicsStateGuardian7.I"
#endif

View File

@ -1,4 +1,4 @@
// Filename: dxSavedFrameBuffer.I
// Filename: dxSavedFrameBuffer7.I
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -18,22 +18,22 @@
////////////////////////////////////////////////////////////////////
// Function: DXSavedFrameBuffer::Constructor
// Function: DXSavedFrameBuffer7::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE DXSavedFrameBuffer::
DXSavedFrameBuffer(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
INLINE DXSavedFrameBuffer7::
DXSavedFrameBuffer7(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
SavedFrameBuffer(buffer, dr)
{
}
////////////////////////////////////////////////////////////////////
// Function: DXSavedFrameBuffer::Destructor
// Function: DXSavedFrameBuffer7::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE DXSavedFrameBuffer::
~DXSavedFrameBuffer() {
INLINE DXSavedFrameBuffer7::
~DXSavedFrameBuffer7() {
}

View File

@ -1,4 +1,4 @@
// Filename: dxSavedFrameBuffer.cxx
// Filename: dxSavedFrameBuffer7.cxx
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -16,6 +16,6 @@
//
////////////////////////////////////////////////////////////////////
#include "dxSavedFrameBuffer.h"
#include "dxSavedFrameBuffer7.h"
TypeHandle DXSavedFrameBuffer::_type_handle;
TypeHandle DXSavedFrameBuffer7::_type_handle;

View File

@ -1,4 +1,4 @@
// Filename: dxSavedFrameBuffer.h
// Filename: dxSavedFrameBuffer7.h
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -16,8 +16,8 @@
//
////////////////////////////////////////////////////////////////////
#ifndef DXSAVEDFRAMEBUFFER_H
#define DXSAVEDFRAMEBUFFER_H
#ifndef DXSAVEDFRAMEBUFFER7_H
#define DXSAVEDFRAMEBUFFER7_H
#include <pandabase.h>
@ -28,14 +28,14 @@
////////////////////////////////////////////////////////////////////
// Class : DXSavedFrameBuffer
// Class : DXSavedFrameBuffer7
// Description :
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXSavedFrameBuffer : public SavedFrameBuffer {
class EXPCL_PANDADX DXSavedFrameBuffer7 : public SavedFrameBuffer {
public:
INLINE DXSavedFrameBuffer(const RenderBuffer &buffer,
INLINE DXSavedFrameBuffer7(const RenderBuffer &buffer,
CPT(DisplayRegion) dr);
INLINE ~DXSavedFrameBuffer();
INLINE ~DXSavedFrameBuffer7();
PT(Texture) _back_rgba;
PT(PixelBuffer) _depth;
@ -46,7 +46,7 @@ public:
}
static void init_type() {
SavedFrameBuffer::init_type();
register_type(_type_handle, "DXSavedFrameBuffer",
register_type(_type_handle, "DXSavedFrameBuffer7",
SavedFrameBuffer::get_class_type());
}
virtual TypeHandle get_type() const {
@ -58,7 +58,7 @@ private:
static TypeHandle _type_handle;
};
#include "dxSavedFrameBuffer.I"
#include "dxSavedFrameBuffer7.I"
#endif

View File

@ -1,4 +1,4 @@
// Filename: dxTextureContext.cxx
// Filename: dxTextureContext7.cxx
// Created by: drose (07Oct99)
//
////////////////////////////////////////////////////////////////////
@ -18,9 +18,9 @@
#include <assert.h>
#include <time.h>
#include "dxTextureContext.h"
#include "config_dxgsg.h"
#include "dxGraphicsStateGuardian.h"
#include "dxTextureContext7.h"
#include "config_dxgsg7.h"
#include "dxGraphicsStateGuardian7.h"
#include "pnmImage.h"
static const DWORD g_LowByteMask = 0x000000FF;
@ -64,14 +64,14 @@ char *PandaFilterNameStrs[] = {"FT_nearest","FT_linear","FT_nearest_mipmap_neare
"FT_nearest_mipmap_linear", "FT_linear_mipmap_linear"
};
TypeHandle DXTextureContext::_type_handle;
TypeHandle DXTextureContext7::_type_handle;
#define SWAPDWORDS(X,Y) { DWORD temp=X; X=Y; Y=temp; }
#ifdef _DEBUG
static void DebugPrintPixFmt(DDPIXELFORMAT* pddpf) {
static int iddpfnum=0;
ostream *dbgout = &dxgsg_cat.debug();
ostream *dbgout = &dxgsg7_cat.debug();
*dbgout << "DDPF[" << iddpfnum << "]: RGBBitCount:" << pddpf->dwRGBBitCount
<< " Flags:" << (void *)pddpf->dwFlags ;
@ -148,7 +148,7 @@ enum Format {
*/
////////////////////////////////////////////////////////////////////
// Function: DXTextureContext::get_bits_per_pixel
// Function: DXTextureContext7::get_bits_per_pixel
// Access: Protected
// Description: Maps from the PixelBuffer's Format symbols
// to bpp. returns # of alpha bits
@ -156,7 +156,7 @@ enum Format {
// not the stored format, which is indicated by pixelbuffer type
////////////////////////////////////////////////////////////////////
unsigned int DXTextureContext::
unsigned int DXTextureContext7::
get_bits_per_pixel(PixelBuffer::Format format, int *alphbits) {
*alphbits = 0; // assume no alpha bits
switch(format) {
@ -209,12 +209,12 @@ HRESULT ConvertPixBuftoDDSurf(ConversionType ConvNeeded,BYTE *pbuf,LPDIRECTDRAWS
DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd);
if(IsBadWritePtr(pDDSurf,sizeof(DWORD))) {
dxgsg_cat.error() << "ConvertPixBuftoDDSurf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
dxgsg7_cat.error() << "ConvertPixBuftoDDSurf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
exit(1);
}
if(FAILED( hr = pDDSurf->Lock( NULL, &ddsd, DDLOCK_NOSYSLOCK | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) {
dxgsg_cat.error() << "CreateTexture failed: _surface->Lock() failed on texture! hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "CreateTexture failed: _surface->Lock() failed on texture! hr = " << ConvD3DErrorToString(hr) << "\n";
return hr;
}
@ -662,7 +662,7 @@ HRESULT ConvertPixBuftoDDSurf(ConversionType ConvNeeded,BYTE *pbuf,LPDIRECTDRAWS
}
default:
dxgsg_cat.error() << "CreateTexture failed! unhandled texture conversion type: "<< ConvNeeded <<" \n";
dxgsg7_cat.error() << "CreateTexture failed! unhandled texture conversion type: "<< ConvNeeded <<" \n";
pDDSurf->Unlock(NULL);
return E_INVALIDARG;
}
@ -686,12 +686,12 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
BYTE *pbuf=pixbuf->_image.p();
if(IsBadWritePtr(pDDSurf,sizeof(DWORD))) {
dxgsg_cat.error() << "ConvertDDSurftoPixBuf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
dxgsg7_cat.error() << "ConvertDDSurftoPixBuf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
exit(1);
}
if(FAILED( hr = pDDSurf->Lock( NULL, &ddsd, DDLOCK_NOSYSLOCK | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) {
dxgsg_cat.error() << "ConvertDDSurftoPixBuf Lock() failed! hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "ConvertDDSurftoPixBuf Lock() failed! hr = " << ConvD3DErrorToString(hr) << "\n";
return hr;
}
@ -705,7 +705,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
#ifdef _DEBUG
if(FAILED(hr) && !((hr == DDERR_NOCLIPPERATTACHED) && dx_full_screen)) {
dxgsg_cat.error() << "ConvertDDSurftoPixBuf GetClipper failed! hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "ConvertDDSurftoPixBuf GetClipper failed! hr = " << ConvD3DErrorToString(hr) << "\n";
return hr;
}
#endif
@ -714,7 +714,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
HWND hWin;
if(FAILED(hr = pDDClipper->GetHWnd(&hWin))) {
dxgsg_cat.error() << "ConvertDDSurftoPixBuf GetHwnd failed! hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "ConvertDDSurftoPixBuf GetHwnd failed! hr = " << ConvD3DErrorToString(hr) << "\n";
return hr;
}
@ -737,7 +737,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
if(!((dwCopyWidth==pixbuf->get_xsize()) && (dwCopyHeight<=(DWORD)pixbuf->get_ysize()))) {
pDDSurf->Unlock(NULL);
assert(0);
dxgsg_cat.error() << "ConvertDDSurftoPixBuf, PixBuf incorrect size to hold display surface!\n";
dxgsg7_cat.error() << "ConvertDDSurftoPixBuf, PixBuf incorrect size to hold display surface!\n";
return E_FAIL;
}
@ -751,8 +751,8 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
// writes out last line in DDSurf first in PixelBuf, so Y line order precedes inversely
if(dxgsg_cat.is_debug())
dxgsg_cat.debug() << "ConvertDDSurftoPixBuf converting " << ddsd.ddpfPixelFormat.dwRGBBitCount << "bpp DDSurf to "
if(dxgsg7_cat.is_debug())
dxgsg7_cat.debug() << "ConvertDDSurftoPixBuf converting " << ddsd.ddpfPixelFormat.dwRGBBitCount << "bpp DDSurf to "
<< dwNumComponents << "-channel panda PixelBuffer\n";
@ -1003,7 +1003,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
// gets the attributes of the texture from the bitmap, creates the
// texture, and then copies the bitmap into the texture.
//-----------------------------------------------------------------------------
LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice,
LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice,
#ifdef USE_TEXFMTVEC
DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
#else
@ -1045,7 +1045,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
assert(pixbuf_type==PixelBuffer::T_unsigned_byte); // cant handle anything else now
if((pixbuf_type != PixelBuffer::T_unsigned_byte) || (pbuf->get_component_width()!=1)) {
dxgsg_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
dxgsg7_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
return NULL;
}
@ -1099,7 +1099,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
ddsd.dwHeight = dwOrigHeight;
if(!ISPOW2(ddsd.dwWidth) || !ISPOW2(ddsd.dwHeight)) {
dxgsg_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "!!!!! \n";
dxgsg7_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "!!!!! \n";
#ifdef _DEBUG
exit(1); // want to catch badtexsize errors
#else
@ -1112,7 +1112,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
if((dwOrigWidth>pD3DDevDesc->dwMaxTextureWidth)||(dwOrigHeight>pD3DDevDesc->dwMaxTextureHeight)) {
#ifdef _DEBUG
dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !!\n"
dxgsg7_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !!\n"
<< "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !\n";
#endif
@ -1134,7 +1134,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
bShrinkOriginal=true;
#ifdef _DEBUG
dxgsg_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< ddsd.dwWidth<<"," << ddsd.dwHeight << ") to meet HW square texture reqmt\n";
dxgsg7_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< ddsd.dwWidth<<"," << ddsd.dwHeight << ") to meet HW square texture reqmt\n";
#endif
}
@ -1157,7 +1157,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
// easier to use dxcapsviewer instead of this
{ static BOOL bPrinted=FALSE;
if(!bPrinted) {
dxgsg_cat.debug() << "Gfx card supported TexFmts:\n";
dxgsg7_cat.debug() << "Gfx card supported TexFmts:\n";
for(i=0;i<cNumTexPixFmts;i++) {
DebugPrintPixFmt(&pTexPixFmts[i]);
}
@ -1174,8 +1174,8 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
szErrorMsg = "CreateTexture failed: couldn't find compatible Tex DDPIXELFORMAT!\n";
if(dxgsg_cat.is_spam())
dxgsg_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
if(dxgsg7_cat.is_spam())
dxgsg7_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
// Mark formats I dont want to deal with
for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
@ -1483,7 +1483,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
// if we've gotten here, haven't found a match
dxgsg_cat.error() << szErrorMsg << "; requested tex bitdepth: " << bpp << "\n";
dxgsg7_cat.error() << szErrorMsg << "; requested tex bitdepth: " << bpp << "\n";
goto error_exit;
///////////////////////////////////////////////////////////
@ -1541,7 +1541,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
if(dx_mipmap_everything) { // debug toggle, ok to leave in since its just a creation cost
_bHasMipMaps=TRUE;
if(ft != Texture::FT_linear_mipmap_linear) {
dxgsg_cat.spam() << "Forcing mipmap filtering on DX texture [" << _tex->get_name() << "]\n";
dxgsg7_cat.spam() << "Forcing mipmap filtering on DX texture [" << _tex->get_name() << "]\n";
}
ft = Texture::FT_linear_mipmap_linear;
_tex->set_minfilter(ft);
@ -1594,14 +1594,14 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
}
_tex->set_anisotropic_degree(aniso_degree);
#ifdef _DEBUG
dxgsg_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
dxgsg7_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
#endif
if(_bHasMipMaps) {
// We dont specify mipmapcount, so CreateSurface will auto-create surfs
// for all mipmaps down to 1x1 (if driver supports deep-mipmaps, otherwise Nx1)
ddsd.ddsCaps.dwCaps |= (DDSCAPS_MIPMAP | DDSCAPS_COMPLEX);
dxgsg_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
dxgsg7_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
}
if(pD3DDevDesc->dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
@ -1615,13 +1615,13 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
// Create a new surface for the texture
if(FAILED( hr = pDD->CreateSurface( &ddsd, &_surface, NULL ) )) {
dxgsg_cat.error() << "CreateTexture failed: pDD->CreateSurface() failed! hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "CreateTexture failed: pDD->CreateSurface() failed! hr = " << ConvD3DErrorToString(hr) << "\n";
goto error_exit;
}
#ifdef _DEBUG
dxgsg_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converted " << ConvNameStrs[ConvNeeded] << " \n";
dxgsg7_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converted " << ConvNameStrs[ConvNeeded] << " \n";
#endif
_PixBufConversionType=ConvNeeded;
@ -1652,12 +1652,12 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
return NULL;
}
HRESULT DXTextureContext::
HRESULT DXTextureContext7::
FillDDSurfTexturePixels(void) {
PixelBuffer *pbuf = _texture->get_ram_image();
if (pbuf == (PixelBuffer *)NULL) {
dxgsg_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
dxgsg7_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
// The texture doesn't have an image to load.
return E_FAIL;
}
@ -1762,7 +1762,7 @@ FillDDSurfTexturePixels(void) {
hr = pCurDDSurf->GetAttachedSurface(&ddsCaps, &pMipLevel_DDSurf);
if(FAILED(hr)) {
dxgsg_cat.error() << "CreateTexture failed creating mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "CreateTexture failed creating mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
delete [] pMipMapPixBufSpace;
pCurDDSurf->Release();
return hr;
@ -1790,7 +1790,7 @@ FillDDSurfTexturePixels(void) {
if(dx_debug_view_mipmaps) {
#if 0
if(!(ddcaps.dwCaps & DDCAPS_BLTSTRETCH)) {
dxgsg_cat.error() << "CreateTexture failed debug-viewing mipmaps, BLT stretching not supported! ( we need to do SW stretch) \n";
dxgsg7_cat.error() << "CreateTexture failed debug-viewing mipmaps, BLT stretching not supported! ( we need to do SW stretch) \n";
return hr;
}
#endif
@ -1817,14 +1817,14 @@ FillDDSurfTexturePixels(void) {
hr = pTexturePrev->GetDC(&hTexDC);
if(FAILED(hr)) {
dxgsg_cat.error() << "GetDC failed hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "GetDC failed hr = " << ConvD3DErrorToString(hr) << "\n";
break;
}
BOOL res;
// res = BitBlt(_dxgsg->_hdc,0,0,ddsd.dwWidth,ddsd.dwHeight, TexDC,0,0,SRCCOPY);
// res = BitBlt(_dxgsg7->_hdc,0,0,ddsd.dwWidth,ddsd.dwHeight, TexDC,0,0,SRCCOPY);
// loader inverts y, so use StretchBlt to re-invert it
// res = StretchBlt(_dxgsg->hdc,0,ddsd_cur.dwHeight+cury,ddsd_cur.dwWidth,-ddsd_cur.dwHeight, TexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,SRCCOPY);
// res = StretchBlt(_dxgsg7->hdc,0,ddsd_cur.dwHeight+cury,ddsd_cur.dwWidth,-ddsd_cur.dwHeight, TexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,SRCCOPY);
#if 0
if(cNumAlphaBits>0) {
BLENDFUNCTION bf;
@ -1833,7 +1833,7 @@ FillDDSurfTexturePixels(void) {
res = AlphaBlend(hScreenDC,curx,cury,ddsd_cur.dwWidth,ddsd_cur.dwHeight, TexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,bf);
if(!res) {
PrintLastError(msg);
dxgsg_cat.error() << "AlphaBlend BLT failed: "<<msg<<"\n";
dxgsg7_cat.error() << "AlphaBlend BLT failed: "<<msg<<"\n";
}
} else
@ -1842,7 +1842,7 @@ FillDDSurfTexturePixels(void) {
res = StretchBlt(hScreenDC,curx,ddsd_cur.dwHeight+cury,ddsd_cur.dwWidth,-((int)ddsd_cur.dwHeight), hTexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,SRCCOPY);
if(!res) {
PrintLastError(msg);
dxgsg_cat.error() << "StretchBLT failed: "<<msg<<"\n";
dxgsg7_cat.error() << "StretchBLT failed: "<<msg<<"\n";
}
}
@ -1859,7 +1859,7 @@ FillDDSurfTexturePixels(void) {
hr = pTexturePrev->ReleaseDC(hTexDC);
if(FAILED(hr)) {
dxgsg_cat.error() << "tex ReleaseDC failed for mip "<<i<<" hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << "tex ReleaseDC failed for mip "<<i<<" hr = " << ConvD3DErrorToString(hr) << "\n";
break;
}
@ -1874,7 +1874,7 @@ FillDDSurfTexturePixels(void) {
ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
hr = pTexturePrev->GetAttachedSurface(&ddsCaps, &pTextureCurrent);
if(FAILED(hr)) {
dxgsg_cat.error() << " failed displaying mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
dxgsg7_cat.error() << " failed displaying mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
}
// done with the previous texture
pTexturePrev->Release();
@ -1891,9 +1891,9 @@ FillDDSurfTexturePixels(void) {
int val=MsgWaitForMultipleObjects(1,hArr,TRUE,INFINITE,QS_KEY);
if(val==-1) {
PrintLastError(msg);
dxgsg_cat.error() << " MsgWaitForMultipleObjects returns " << val << " " <<msg << endl;
dxgsg7_cat.error() << " MsgWaitForMultipleObjects returns " << val << " " <<msg << endl;
} else {
dxgsg_cat.error() << " MsgWaitForMultipleObjects returns " << val << endl;
dxgsg7_cat.error() << " MsgWaitForMultipleObjects returns " << val << endl;
}
}
#endif
@ -1907,10 +1907,10 @@ FillDDSurfTexturePixels(void) {
// Name: DeleteTexture()
// Desc: Release the surface used to store the texture
//-----------------------------------------------------------------------------
void DXTextureContext::
void DXTextureContext7::
DeleteTexture( ) {
if(dxgsg_cat.is_spam()) {
dxgsg_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
if(dxgsg7_cat.is_spam()) {
dxgsg7_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
}
ULONG refcnt;
@ -1922,26 +1922,26 @@ DeleteTexture( ) {
pDD->Release();
PRINTREFCNT(pDD,"before DeleteTex, IDDraw7");
RELEASE(_surface,dxgsg,"texture",false);
RELEASE(_surface,dxgsg7,"texture",false);
PRINTREFCNT(pDD,"after DeleteTex, IDDraw7");
}
#else
RELEASE(_surface,dxgsg,"texture",false);
RELEASE(_surface,dxgsg7,"texture",false);
#endif
}
////////////////////////////////////////////////////////////////////
// Function: DXTextureContext::Constructor
// Function: DXTextureContext7::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
DXTextureContext::
DXTextureContext(Texture *tex) :
DXTextureContext7::
DXTextureContext7(Texture *tex) :
TextureContext(tex) {
//#ifdef NDEBUG
if(dxgsg_cat.is_spam()) {
dxgsg_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
if(dxgsg7_cat.is_spam()) {
dxgsg7_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
}
//#endif
_surface = NULL;
@ -1949,8 +1949,8 @@ TextureContext(tex) {
_tex = tex;
}
DXTextureContext::
~DXTextureContext() {
DXTextureContext7::
~DXTextureContext7() {
DeleteTexture();
TextureContext::~TextureContext();
_tex = NULL;

View File

@ -1,4 +1,4 @@
// Filename: dxTextureContext.h
// Filename: dxTextureContext7.h
// Created by: drose (07Oct99)
//
////////////////////////////////////////////////////////////////////
@ -16,25 +16,25 @@
//
////////////////////////////////////////////////////////////////////
#ifndef DXTEXTURECONTEXT_H
#define DXTEXTURECONTEXT_H
#ifndef DXTEXTURECONTEXT7_H
#define DXTEXTURECONTEXT7_H
#include "dxgsgbase.h"
#include "dxgsg7base.h"
#include <texture.h>
#include <textureContext.h>
////////////////////////////////////////////////////////////////////
// Class : DXTextureContext
// Class : DXTextureContext7
// Description :
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXTextureContext : public TextureContext {
friend class DXGraphicsStateGuardian;
friend class wdxGraphicsWindow;
class EXPCL_PANDADX DXTextureContext7 : public TextureContext {
friend class DXGraphicsStateGuardian7;
friend class wdxGraphicsWindow7;
public:
DXTextureContext(Texture *tex);
~DXTextureContext();
DXTextureContext7(Texture *tex);
~DXTextureContext7();
LPDIRECTDRAWSURFACE7 _surface;
Texture *_tex; // ptr to parent, primarily for access to namestr
@ -63,7 +63,7 @@ public:
}
static void init_type() {
TextureContext::init_type();
register_type(_type_handle, "DXTextureContext",
register_type(_type_handle, "DXTextureContext7",
TextureContext::get_class_type());
}
virtual TypeHandle get_type() const {

View File

@ -0,0 +1,7 @@
#include "config_dxgsg7.cxx"
#include "dxgsg7base.cxx"
#include "dxSavedFrameBuffer7.cxx"
#include "dxTextureContext7.cxx"
#include "dxGeomNodeContext7.cxx"
#include "wdxGraphicsPipe7.cxx"
#include "wdxGraphicsWindow7.cxx"

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Filename: dxTextureContext.h
// Filename: dxTextureContext7.h
// Created by: drose (07Oct99)
//
////////////////////////////////////////////////////////////////////
@ -86,7 +86,7 @@ typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl; \
}
#define PRINTREFCNT(OBJECT,STR) { (OBJECT)->AddRef(); dxgsg_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
#define PRINTREFCNT(OBJECT,STR) { (OBJECT)->AddRef(); dxgsg7_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
#else
#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero) \
if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) { \
@ -109,7 +109,7 @@ typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
#define DO_PSTATS_STUFF(XX)
#endif
extern char * ConvD3DErrorToString(const HRESULT &error); // defined in wdxGraphicsPipe.cxx
const char *ConvD3DErrorToString(HRESULT error);
typedef struct {
LPDIRECT3DDEVICE7 pD3DDevice;

View File

@ -1,5 +1,5 @@
// Filename: interactiveGraphicsPipe.I
// Created by: cary (10Mar99)
// Filename: wdxGraphicsPipe7.I
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
@ -15,4 +15,3 @@
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,63 @@
// Filename: wdxGraphicsPipe7.cxx
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "wdxGraphicsPipe7.h"
#include "wdxGraphicsWindow7.h"
#include "config_dxgsg7.h"
TypeHandle wdxGraphicsPipe7::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe7::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
wdxGraphicsPipe7::
wdxGraphicsPipe7() {
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe7::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
wdxGraphicsPipe7::
~wdxGraphicsPipe7() {
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe7::pipe_constructor
// Access: Public, Static
// Description: This function is passed to the GraphicsPipeSelection
// object to allow the user to make a default
// wdxGraphicsPipe7.
////////////////////////////////////////////////////////////////////
PT(GraphicsPipe) wdxGraphicsPipe7::
pipe_constructor() {
return new wdxGraphicsPipe7;
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe7::make_window
// Access: Protected, Virtual
// Description: Creates a new window on the pipe, if possible.
////////////////////////////////////////////////////////////////////
PT(GraphicsWindow) wdxGraphicsPipe7::
make_window() {
return new wdxGraphicsWindow7(this);
}

View File

@ -0,0 +1,60 @@
// Filename: wdxGraphicsPipe7.h
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef WDXGRAPHICSPIPE7_H
#define WDXGRAPHICSPIPE7_H
#include "pandabase.h"
#include "winGraphicsPipe.h"
////////////////////////////////////////////////////////////////////
// Class : wdxGraphicsPipe7
// Description : This graphics pipe represents the interface for
// creating DirectX graphics windows.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX wdxGraphicsPipe7 : public WinGraphicsPipe {
public:
wdxGraphicsPipe7();
virtual ~wdxGraphicsPipe7();
static PT(GraphicsPipe) pipe_constructor();
protected:
virtual PT(GraphicsWindow) make_window();
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
WinGraphicsPipe::init_type();
register_type(_type_handle, "wdxGraphicsPipe7",
WinGraphicsPipe::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;
};
#include "wdxGraphicsPipe7.I"
#endif

View File

@ -1,5 +1,5 @@
// Filename: noninteractiveGraphicsPipe.I
// Created by: cary (10Mar99)
// Filename: wdxGraphicsWindow7.I
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,92 @@
// Filename: wdxGraphicsWindow7.h
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef WDXGRAPHICSWINDOW7_H
#define WDXGRAPHICSWINDOW7_H
#include "pandabase.h"
#include "winGraphicsWindow.h"
#include "pvector.h"
class DXGraphicsStateGuardian7;
typedef struct {
char szDriver[MAX_DDDEVICEID_STRING];
char szDescription[MAX_DDDEVICEID_STRING];
GUID guidDeviceIdentifier;
HMONITOR hMon;
} DXDeviceInfo;
typedef pvector<DXDeviceInfo> DXDeviceInfoVec;
typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter);
////////////////////////////////////////////////////////////////////
// Class : wdxGraphicsWindow7
// Description : A single graphics window for rendering DirectX under
// Microsoft Windows.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX wdxGraphicsWindow7 : public WinGraphicsWindow {
public:
wdxGraphicsWindow7(GraphicsPipe *pipe);
virtual ~wdxGraphicsWindow7();
virtual void make_gsg();
virtual void release_gsg();
virtual void end_flip();
protected:
virtual void fullscreen_restored(WindowProperties &properties);
virtual void handle_reshape();
virtual bool do_fullscreen_resize(int x_size, int y_size);
private:
bool set_to_temp_rendertarget();
void create_screen_buffers_and_device(DXScreenData &Display,
bool force_16bpp_zbuffer);
bool search_for_device(int devnum, DXDeviceInfo *pDevinfo);
void set_coop_levels_and_display_modes();
static void init_ddraw();
DXGraphicsStateGuardian7 *_dxgsg;
static HINSTANCE _hDDrawDLL;
static LPDIRECTDRAWCREATEEX _pDDCreateEx;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
WinGraphicsWindow::init_type();
register_type(_type_handle, "wdxGraphicsWindow7",
WinGraphicsWindow::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;
};
#include "wdxGraphicsWindow7.I"
#endif

View File

@ -7,7 +7,7 @@
#begin lib_target
#define TARGET dxgsg8
#define LOCAL_LIBS \
gsgmisc gsgbase gobj display \
gsgmisc gsgbase gobj display windisplay \
putil linmath mathutil pnmimage event
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
@ -20,9 +20,16 @@
// build dxGraphicsStateGuardian separately since its so big
#define SOURCES \
dxGraphicsStateGuardian8.cxx dxSavedFrameBuffer8.I dxSavedFrameBuffer8.h $[INSTALL_HEADERS]
dxGraphicsStateGuardian8.cxx dxSavedFrameBuffer8.I dxSavedFrameBuffer8.h \
wdxGraphicsPipe8.I wdxGraphicsPipe8.h \
wdxGraphicsWindow8.I wdxGraphicsWindow8.h \
$[INSTALL_HEADERS]
#define INCLUDED_SOURCES \
config_dxgsg8.cxx dxSavedFrameBuffer8.cxx dxTextureContext8.cxx dxGeomNodeContext8.cxx d3dfont8.cxx
config_dxgsg8.cxx \
dxSavedFrameBuffer8.cxx dxTextureContext8.cxx \
dxGeomNodeContext8.cxx \
d3dfont8.cxx \
wdxGraphicsPipe8.cxx wdxGraphicsWindow8.cxx
#end lib_target

View File

@ -1,4 +1,4 @@
// Filename: config_dxgsg.cxx
// Filename: config_dxgsg8.cxx
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -20,39 +20,43 @@
#include "dxGraphicsStateGuardian8.h"
#include "dxSavedFrameBuffer8.h"
#include "dxTextureContext8.h"
#include "graphicsPipeSelection.h"
#include "wdxGraphicsWindow8.h"
#include "wdxGraphicsPipe8.h"
#include <dconfig.h>
Configure(config_dxgsg);
NotifyCategoryDef(dxgsg, ":display:gsg");
Configure(config_dxgsg8);
NotifyCategoryDef(dxgsg8, ":display:gsg");
NotifyCategoryDef(wdxdisplay8, "windisplay");
// Configure this variable true to cause the DXGSG to show each
// transform space it renders by drawing a little unit axis. This
// cannot be enabled when the player is compiled in NDEBUG mode.
bool dx_show_transforms = config_dxgsg.GetBool("dx-show-transforms", false);
bool dx_show_transforms = config_dxgsg8.GetBool("dx-show-transforms", false);
// Configure this to TRUE if you want DirectX to control the entire screen,
// If false, it will just blit into a window.
bool dx_full_screen = config_dxgsg.GetBool("dx-full-screen", false);
bool dx_full_screen = config_dxgsg8.GetBool("dx-full-screen", false);
// Configure this true to force the rendering to sync to the video
// refresh, or false to let your frame rate go as high as it can,
// irrespective of the video refresh.
bool dx_sync_video = config_dxgsg.GetBool("sync-video", true);
bool dx_sync_video = config_dxgsg8.GetBool("sync-video", true);
// Set Level of MultiSampling to be used, if HW supports it. Valid values are 2-16.
DWORD dx_multisample_antialiasing_level = (DWORD) config_dxgsg.GetInt("dx-multisample-antialiasing-level", 0);
DWORD dx_multisample_antialiasing_level = (DWORD) config_dxgsg8.GetInt("dx-multisample-antialiasing-level", 0);
// Configure this true to perform a cull traversal over the geometry
// by default, false otherwise. The cull traversal provides support
// for state-sorting, z-sorting, and binning.
bool dx_cull_traversal = config_dxgsg.GetBool("dx-cull-traversal", true);
bool dx_cull_traversal = config_dxgsg8.GetBool("dx-cull-traversal", true);
// if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
bool dx_no_vertex_fog = config_dxgsg.GetBool("dx-no-vertex-fog", false);
bool dx_no_vertex_fog = config_dxgsg8.GetBool("dx-no-vertex-fog", false);
// if true, overwrite cursor bitmap tip with "D3D" to distinguish it from GDI cursor
bool dx_show_cursor_watermark = config_dxgsg.GetBool("dx-show-cursor-watermark",
bool dx_show_cursor_watermark = config_dxgsg8.GetBool("dx-show-cursor-watermark",
#ifdef _DEBUG
true
#else
@ -61,7 +65,7 @@ bool dx_show_cursor_watermark = config_dxgsg.GetBool("dx-show-cursor-watermark",
);
// if true, triangle filter will be used to generate mipmap levels instead of default box filter
bool dx_use_triangle_mipgen_filter = config_dxgsg.GetBool("dx-use-triangle-mipgen-filter", false);
bool dx_use_triangle_mipgen_filter = config_dxgsg8.GetBool("dx-use-triangle-mipgen-filter", false);
// Configure this true to cause all lighting normals to automatically
// be normalized by the CPU before rendering. This is
@ -69,40 +73,50 @@ bool dx_use_triangle_mipgen_filter = config_dxgsg.GetBool("dx-use-triangle-mipge
// expect lighting to work correctly. Maybe one day there will be
// another way to set this at runtime, instead of only as a configure
// variable
bool dx_auto_normalize_lighting = config_dxgsg.GetBool("auto-normalize-lighting", false);
bool dx_auto_normalize_lighting = config_dxgsg8.GetBool("auto-normalize-lighting", false);
bool dx_show_fps_meter = config_dxgsg.GetBool("show-fps-meter", false);
float dx_fps_meter_update_interval = max(0.5,config_dxgsg.GetFloat("fps-meter-update-interval", 1.7));
bool dx_show_fps_meter = config_dxgsg8.GetBool("show-fps-meter", false);
float dx_fps_meter_update_interval = max(0.5,config_dxgsg8.GetFloat("fps-meter-update-interval", 1.7));
#ifndef NDEBUG
// debugging flag
// values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
int dx_force_backface_culling = config_dxgsg.GetInt("dx-force-backface-culling", 0);
int dx_force_backface_culling = config_dxgsg8.GetInt("dx-force-backface-culling", 0);
#endif
bool dx_mipmap_everything = config_dxgsg.GetBool("dx-mipmap-everything", false);
bool dx_ignore_mipmaps = config_dxgsg.GetBool("dx-ignore-mipmaps", false);
bool dx_mipmap_everything = config_dxgsg8.GetBool("dx-mipmap-everything", false);
bool dx_ignore_mipmaps = config_dxgsg8.GetBool("dx-ignore-mipmaps", false);
// if this is set, more accurate but more expensive fog computations are performed
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);
bool dx_use_rangebased_fog = config_dxgsg8.GetBool("dx-use-rangebased-fog", false);
bool dx_force_16bpptextures = config_dxgsg8.GetBool("dx-force-16bpptextures", false);
bool dx_no_dithering = config_dxgsg8.GetBool("dx-no-dithering", false);
bool dx_force_16bpp_zbuffer = config_dxgsg8.GetBool("dx-force-16bpp-zbuffer", false);
bool dx_do_vidmemsize_check = config_dxgsg8.GetBool("do-vidmemsize-check", true);
bool dx_preserve_fpu_state = config_dxgsg8.GetBool("dx-preserve-fpu-state", false);
// if true, override win-width/height and use driver vidmem info to
// pick what will be a fullscreen window size close to the best perf
// capability of card, based on a heuristic
bool dx_pick_best_screenres = config_dxgsg8.GetBool("pick-best-screenres", false);
int dx_preferred_device_id = config_dxgsg8.GetInt("dx-preferred-device-id", -1);
#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);
//int dx_print_texstats = config_dxgsg.GetBool("dx-print-texstats", 0);
float dx_global_miplevel_bias = config_dxgsg8.GetFloat("dx-global-miplevel-bias", 0.0);
bool dx_debug_view_mipmaps = config_dxgsg8.GetBool("dx-debug-view-mipmaps", false);
//int dx_print_texstats = config_dxgsg8.GetBool("dx-print-texstats", 0);
#endif
// use dx8 or GDI mouse cursor in fullscreen mode?
// Nvidia dx8 cursor is invisible as of 28.32 drivers, so using GDI in fullscrn by default for now
bool dx_use_dx_cursor = config_dxgsg.GetBool("dx-use-dx-cursor", false);
bool dx_use_dx_cursor = config_dxgsg8.GetBool("dx-use-dx-cursor", false);
bool dx_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
bool dx_force_anisotropic_filtering = config_dxgsg8.GetBool("dx-force-anisotropic-filtering", false);
// set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom
// together using degenerate tris
const bool link_tristrips = config_dxgsg.GetBool("link-tristrips", false);
const bool link_tristrips = config_dxgsg8.GetBool("link-tristrips", false);
// note: offset currently disabled since it wasnt working properly
DXDecalType dx_decal_type = GDT_mask;
@ -116,7 +130,7 @@ string *pdx_pixelshader_filename=NULL;
// texture file to be set globally, usually for special FX
string *pdx_globaltexture_filename=NULL;
// tex stagenum to set the global tex to
UINT dx_globaltexture_stagenum = (UINT) config_dxgsg.GetInt("dx-globaltexture-stagenum", 0);
UINT dx_globaltexture_stagenum = (UINT) config_dxgsg8.GetInt("dx-globaltexture-stagenum", 0);
static DXDecalType
parse_decal_type(const string &type) {
@ -127,11 +141,11 @@ parse_decal_type(const string &type) {
} else if (type == "offset") {
return GDT_offset;
}
dxgsg_cat.error() << "Invalid dx-decal-type: " << type << "\n";
dxgsg8_cat.error() << "Invalid dx-decal-type: " << type << "\n";
return GDT_mask;
}
ConfigureFn(config_dxgsg) {
ConfigureFn(config_dxgsg8) {
init_libdxgsg8();
}
@ -139,7 +153,7 @@ void init_config_string(string *&pFname,const char *ConfigrcVarname) {
// pFname is reference to string ptr
// dont try to take the & of a soon-to-be-gone stack var string, this must be on the heap!
pFname = new string(config_dxgsg.GetString(ConfigrcVarname, ""));
pFname = new string(config_dxgsg8.GetString(ConfigrcVarname, ""));
if(pFname->empty()) {
delete pFname;
pFname=NULL;
@ -162,7 +176,7 @@ init_libdxgsg8() {
}
initialized = true;
string decal_type = config_dxgsg.GetString("dx-decal-type", "");
string decal_type = config_dxgsg8.GetString("dx-decal-type", "");
if (!decal_type.empty()) {
dx_decal_type = parse_decal_type(decal_type);
}
@ -171,14 +185,17 @@ init_libdxgsg8() {
init_config_string(pdx_pixelshader_filename,"dx-pixelshader-filename");
init_config_string(pdx_globaltexture_filename,"dx-globaltexture-filename");
DXGraphicsStateGuardian::init_type();
DXSavedFrameBuffer::init_type();
DXTextureContext::init_type();
DXGeomNodeContext::init_type();
DXGraphicsStateGuardian8::init_type();
DXSavedFrameBuffer8::init_type();
DXTextureContext8::init_type();
DXGeomNodeContext8::init_type();
GraphicsStateGuardian::get_factory().register_factory
(DXGraphicsStateGuardian::get_class_type(),
DXGraphicsStateGuardian::make_DXGraphicsStateGuardian);
wdxGraphicsPipe8::init_type();
wdxGraphicsWindow8::init_type();
GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
selection->add_pipe_type(wdxGraphicsPipe8::get_class_type(),
wdxGraphicsPipe8::pipe_constructor);
}
const char *D3DFormatStr(D3DFORMAT fmt) {

View File

@ -19,11 +19,12 @@
#ifndef CONFIG_DXGSG8_H
#define CONFIG_DXGSG8_H
#include <pandabase.h>
#include <notifyCategoryProxy.h>
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include <d3d8.h>
NotifyCategoryDecl(dxgsg, EXPCL_PANDADX, EXPTP_PANDADX);
NotifyCategoryDecl(dxgsg8, EXPCL_PANDADX, EXPTP_PANDADX);
NotifyCategoryDecl(wdxdisplay8, EXPCL_PANDADX, EXPTP_PANDADX);
extern bool dx_full_screen;
extern bool dx_sync_video;
@ -48,6 +49,11 @@ extern bool dx_show_transforms;
extern bool dx_force_16bpptextures;
extern bool dx_no_dithering;
extern bool dx_force_anisotropic_filtering;
extern bool dx_force_16bpp_zbuffer;
extern bool dx_do_vidmemsize_check;
extern bool dx_preserve_fpu_state;
extern bool dx_pick_best_screenres;
extern int dx_preferred_device_id;
extern string *pdx_vertexshader_filename;
extern string *pdx_pixelshader_filename;

View File

@ -123,7 +123,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
VARIABLE_PITCH, m_strFontName );
if(NULL==hFont) {
dxgsg_cat.error() << "CD3DFont InitDeviceObjects(): initial CreateFont failed! GetLastError=" << GetLastError() << endl;
dxgsg8_cat.error() << "CD3DFont InitDeviceObjects(): initial CreateFont failed! GetLastError=" << GetLastError() << endl;
return E_FAIL;
}
@ -194,7 +194,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
// moved here to allow deletion of GDI objects
if(dwTexSize == 0) {
dxgsg_cat.error() << "CD3DFont InitDeviceObjects() error: Texture didnt fit, creation failed!\n";
dxgsg8_cat.error() << "CD3DFont InitDeviceObjects() error: Texture didnt fit, creation failed!\n";
return E_FAIL;
}
@ -228,7 +228,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
VARIABLE_PITCH, m_strFontName );
if(NULL==hFont) {
dxgsg_cat.error() << "CD3DFont InitDeviceObjects(): optimal CreateFont failed! GetLastError=" << GetLastError() << endl;
dxgsg8_cat.error() << "CD3DFont InitDeviceObjects(): optimal CreateFont failed! GetLastError=" << GetLastError() << endl;
return E_FAIL;
}
@ -263,7 +263,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
DeleteObject( hFont );
DeleteDC( hDC );
dxgsg_cat.error() << "CD3DFont InitDeviceObjs CreateTexture failed!" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "CD3DFont InitDeviceObjs CreateTexture failed!" << D3DERRORSTRING(hr);
return hr;
};
@ -341,11 +341,11 @@ HRESULT CD3DFont::RestoreDeviceObjects() {
D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
D3DPOOL_DEFAULT, // D3DUSAGE_DYNAMIC makes D3DPOOL_MANAGED impossible
&m_pVB ) )) {
dxgsg_cat.error() << "CD3DFont CreateVB failed!" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "CD3DFont CreateVB failed!" << D3DERRORSTRING(hr);
return hr;
}
PRINT_REFCNT(dxgsg,m_pd3dDevice);
PRINT_REFCNT(dxgsg8,m_pd3dDevice);
// Create the state blocks for rendering text
for(UINT which=0; which<2; which++) {
@ -403,7 +403,7 @@ HRESULT CD3DFont::RestoreDeviceObjects() {
HRESULT CD3DFont::InvalidateDeviceObjects() {
HRESULT hr;
PRINT_REFCNT(dxgsg,m_pd3dDevice);
PRINT_REFCNT(dxgsg8,m_pd3dDevice);
if(IS_VALID_PTR(m_pd3dDevice)) {
// undo SetStreamSource before releasing VB
@ -416,11 +416,11 @@ HRESULT CD3DFont::InvalidateDeviceObjects() {
hr = m_pd3dDevice->SetStreamSource(0,NULL,0);
}
PRINT_REFCNT(dxgsg,m_pVB);
PRINT_REFCNT(dxgsg8,m_pVB);
RELEASE(m_pVB,dxgsg,"d3dfont VB",RELEASE_ONCE);
RELEASE(m_pVB,dxgsg8,"d3dfont VB",RELEASE_ONCE);
PRINT_REFCNT(dxgsg,m_pd3dDevice);
PRINT_REFCNT(dxgsg8,m_pd3dDevice);
// Delete the state blocks
if(m_pd3dDevice) {
@ -431,7 +431,7 @@ HRESULT CD3DFont::InvalidateDeviceObjects() {
m_pd3dDevice->DeleteStateBlock( m_dwDrawTextStateBlock );
}
PRINT_REFCNT(dxgsg,m_pd3dDevice);
PRINT_REFCNT(dxgsg8,m_pd3dDevice);
m_dwSavedStateBlock = NULL;
m_dwDrawTextStateBlock = NULL;
@ -445,13 +445,13 @@ HRESULT CD3DFont::InvalidateDeviceObjects() {
// Desc: Destroys all device-dependent objects
//-----------------------------------------------------------------------------
HRESULT CD3DFont::DeleteDeviceObjects() {
PRINT_REFCNT(dxgsg,m_pd3dDevice);
PRINT_REFCNT(dxgsg8,m_pd3dDevice);
InvalidateDeviceObjects();
SAFE_RELEASE( m_pTexture );
PRINT_REFCNT(dxgsg,m_pd3dDevice);
PRINT_REFCNT(dxgsg8,m_pd3dDevice);
m_pd3dDevice = NULL;
@ -581,7 +581,7 @@ HRESULT CD3DFont::DeferedDraw
FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
TCHAR* strText, DWORD dwFlags ) {
if(m_nDeferedCalls >= MaxCalls) {
dxgsg_cat.error() << "CD3DFont DeferedDraw() error, MaxCalls exceeded!\n";
dxgsg8_cat.error() << "CD3DFont DeferedDraw() error, MaxCalls exceeded!\n";
return E_FAIL ;
}
@ -591,7 +591,7 @@ HRESULT CD3DFont::DeferedDraw
int nStrLen = strlen ( strText ) + 1 ;
int nUsed = m_pTextBuffer - & m_pTextBuffer [ 0 ] ;
if(nUsed + nStrLen > TextBufferLength) {
dxgsg_cat.error() << "CD3DFont DeferedDraw() error, TextBufferLength exceeded!\n";
dxgsg8_cat.error() << "CD3DFont DeferedDraw() error, TextBufferLength exceeded!\n";
return E_FAIL ;
}
@ -637,7 +637,7 @@ HRESULT CD3DFont::EndText ( void ) {
hr = m_pd3dDevice->GetStreamSource(0,&pSavedStreamData,&SavedStreamStride);
if(FAILED(hr)) {
dxgsg_cat.error() << "CD3DFont EndText GetStreamSource() failed!" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "CD3DFont EndText GetStreamSource() failed!" << D3DERRORSTRING(hr);
return E_FAIL;
}
@ -647,7 +647,7 @@ HRESULT CD3DFont::EndText ( void ) {
if((pSavedStreamData!=m_pVB)||(SavedStreamStride!=sizeof(FONT2DVERTEX))) {
hr = m_pd3dDevice->SetStreamSource(0,m_pVB,sizeof(FONT2DVERTEX));
if(FAILED(hr)) {
dxgsg_cat.error() << "CD3DFont EndText initial SetStreamSource() failed!" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "CD3DFont EndText initial SetStreamSource() failed!" << D3DERRORSTRING(hr);
return E_FAIL;
}
}
@ -821,7 +821,7 @@ HRESULT CD3DFont::EndText ( void ) {
if(IS_VALID_PTR(pSavedStreamData) && ((pSavedStreamData!=m_pVB)||(SavedStreamStride!=sizeof(FONT2DVERTEX)))) {
hr = m_pd3dDevice->SetStreamSource(0,pSavedStreamData,SavedStreamStride);
if(FAILED(hr)) {
dxgsg_cat.error() << "CD3DFont EndText restore SetStreamSource() failed!" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "CD3DFont EndText restore SetStreamSource() failed!" << D3DERRORSTRING(hr);
return E_FAIL;
}
pSavedStreamData->Release();

View File

@ -18,12 +18,12 @@
////////////////////////////////////////////////////////////////////
// Function: dxGeomNodeContext::Constructor
// Function: DXGeomNodeContext8::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE DXGeomNodeContext::
DXGeomNodeContext(GeomNode *node) : GeomNodeContext(node)
INLINE DXGeomNodeContext8::
DXGeomNodeContext8(GeomNode *node) : GeomNodeContext(node)
{
_num_verts = 0;
/*

View File

@ -18,9 +18,9 @@
#include "dxGeomNodeContext8.h"
TypeHandle DXGeomNodeContext::_type_handle;
TypeHandle DXGeomNodeContext8::_type_handle;
DXGeomNodeContext::~DXGeomNodeContext()
DXGeomNodeContext8::~DXGeomNodeContext8()
{
/*
if(_pXformed_VB!=NULL)

View File

@ -1,4 +1,4 @@
// Filename: dxGeomNodeContext.h
// Filename: dxGeomNodeContext8.h
// Created by: drose (12Jun01)
//
////////////////////////////////////////////////////////////////////
@ -16,8 +16,8 @@
//
////////////////////////////////////////////////////////////////////
#ifndef DXGEOMNODECONTEXT_H
#define DXGEOMNODECONTEXT_H
#ifndef DXGEOMNODECONTEXT8_H
#define DXGEOMNODECONTEXT8_H
#include "dxgsg8base.h"
@ -33,13 +33,13 @@ typedef struct {
// empty shell unimplemented for DX8 right now
////////////////////////////////////////////////////////////////////
// Class : DXGeomNodeContext
// Class : DXGeomNodeContext8
// Description :
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXGeomNodeContext : public GeomNodeContext {
class EXPCL_PANDADX DXGeomNodeContext8 : public GeomNodeContext {
public:
INLINE DXGeomNodeContext(GeomNode *node);
~DXGeomNodeContext();
INLINE DXGeomNodeContext8(GeomNode *node);
~DXGeomNodeContext8();
// A list of the dynamic Geoms within the GeomNode; these aren't
// part of the above display list and must be drawn separately
@ -71,7 +71,7 @@ public:
}
static void init_type() {
GeomNodeContext::init_type();
register_type(_type_handle, "DXGeomNodeContext",
register_type(_type_handle, "DXGeomNodeContext8",
GeomNodeContext::get_class_type());
}
virtual TypeHandle get_type() const {

View File

@ -1,4 +1,4 @@
// Filename: dxGraphicsStateGuardian.I
// Filename: dxGraphicsStateGuardian8.I
// Created by: mike (02Feb99)
//
////////////////////////////////////////////////////////////////////
@ -16,22 +16,22 @@
//
////////////////////////////////////////////////////////////////////
// for dxgsg_cat stuff
// for dxgsg8_cat stuff
#include "config_dxgsg8.h"
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_line_smooth
// Function: DXGraphicsStateGuardian8::enable_line_smooth
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_line_smooth(bool val) {
if(_line_smooth_enabled != val) {
_line_smooth_enabled = val;
#ifdef NDEBUG
{
if(val && (scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
dxgsg_cat.error() << "no HW support for line smoothing!!\n";
dxgsg8_cat.error() << "no HW support for line smoothing!!\n";
}
#endif
@ -40,18 +40,18 @@ enable_line_smooth(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_dither
// Function: DXGraphicsStateGuardian8::enable_dither
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_dither(bool val) {
if (_dither_enabled != val) {
#ifdef _DEBUG
{
if(val && !(scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_DITHER))
dxgsg_cat.error() << "no HW support for color dithering!!\n";
dxgsg8_cat.error() << "no HW support for color dithering!!\n";
return;
}
#endif
@ -62,11 +62,11 @@ enable_dither(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_stencil_test
// Function: DXGraphicsStateGuardian8::enable_stencil_test
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_stencil_test(bool val) {
if (_stencil_test_enabled != val) {
_stencil_test_enabled = val;
@ -75,11 +75,11 @@ enable_stencil_test(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_color_material
// Function: DXGraphicsStateGuardian8::enable_color_material
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_color_material(bool val) {
if (_color_material_enabled != val) {
_color_material_enabled = val;
@ -88,11 +88,11 @@ enable_color_material(bool val) {
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_blend
// Function: DXGraphicsStateGuardian8::enable_blend
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_blend(bool val) {
if (_blend_enabled != val) {
_blend_enabled = val;
@ -101,11 +101,11 @@ enable_blend(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::set_color_writemask
// Function: DXGraphicsStateGuardian8::set_color_writemask
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
set_color_writemask(UINT color_writemask) {
if (_color_writemask != color_writemask) {
_color_writemask = color_writemask;
@ -121,11 +121,11 @@ set_color_writemask(UINT color_writemask) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_blend
// Function: DXGraphicsStateGuardian8::enable_blend
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_gouraud_shading(bool val) {
if (_bGouraudShadingOn != val) {
_bGouraudShadingOn = val;
@ -133,7 +133,7 @@ enable_gouraud_shading(bool val) {
}
}
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_primitive_clipping(bool val) {
if (_clipping_enabled != val) {
_clipping_enabled = val;
@ -142,11 +142,11 @@ enable_primitive_clipping(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_fog
// Function: DXGraphicsStateGuardian8::enable_fog
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_fog(bool val) {
if ((_fog_enabled != val) && (_doFogType!=None)) {
_fog_enabled = val;
@ -155,11 +155,11 @@ enable_fog(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::set_vertex_format
// Function: DXGraphicsStateGuardian8::set_vertex_format
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
set_vertex_format(DWORD NewFvfType) {
#ifdef USE_VERTEX_SHADERS
if(_CurVertexShader!=NULL) {
@ -167,7 +167,7 @@ set_vertex_format(DWORD NewFvfType) {
HRESULT hr = scrn.pD3DDevice->SetVertexShader(_CurVertexShader);
#ifndef NDEBUG
if(FAILED(hr)) {
dxgsg_cat.error() << "SetVertexShader for custom vtx shader failed" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "SetVertexShader for custom vtx shader failed" << D3DERRORSTRING(hr);
exit(1);
}
#endif
@ -182,7 +182,7 @@ set_vertex_format(DWORD NewFvfType) {
HRESULT hr = scrn.pD3DDevice->SetVertexShader(NewFvfType);
#ifndef NDEBUG
if(FAILED(hr)) {
dxgsg_cat.error() << "SetVertexShader(0x" << (void*)NewFvfType<<") failed" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "SetVertexShader(0x" << (void*)NewFvfType<<") failed" << D3DERRORSTRING(hr);
exit(1);
}
#endif
@ -190,11 +190,11 @@ set_vertex_format(DWORD NewFvfType) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_alpha_test
// Function: DXGraphicsStateGuardian8::enable_alpha_test
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_alpha_test(bool val )
{
if (_alpha_test_enabled != val) {
@ -204,17 +204,17 @@ enable_alpha_test(bool val )
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::call_dxLightModelAmbient
// Function: DXGraphicsStateGuardian8::call_dxLightModelAmbient
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
call_dxLightModelAmbient( const Colorf& color)
{
if (_lmodel_ambient != color) {
_lmodel_ambient = color;
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
dxgsg8_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
#endif
scrn.pD3DDevice->SetRenderState( D3DRS_AMBIENT,
D3DCOLOR_COLORVALUE(color[0], color[1], color[2], color[3]));
@ -223,43 +223,47 @@ call_dxLightModelAmbient( const Colorf& color)
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::call_dxAlphaFunc
// Function: DXGraphicsStateGuardian8::call_dxAlphaFunc
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
if (_alpha_func != func) {
_alpha_func = func;
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxAlphaFunc(";
dxgsg8_cat.debug() << "dxAlphaFunc(";
switch (func) {
case D3DCMP_NEVER:
dxgsg_cat.debug(false) << "D3DCMP_NEVER";
dxgsg8_cat.debug(false) << "D3DCMP_NEVER";
break;
case D3DCMP_LESS:
dxgsg_cat.debug(false) << "D3DCMP_LESS";
dxgsg8_cat.debug(false) << "D3DCMP_LESS";
break;
case D3DCMP_EQUAL:
dxgsg_cat.debug(false) << "D3DCMP_EQUAL";
dxgsg8_cat.debug(false) << "D3DCMP_EQUAL";
break;
#ifdef D3DCMP_LEQUAL
case D3DCMP_LEQUAL:
dxgsg_cat.debug(false) << "D3DCMP_LEQUAL";
dxgsg8_cat.debug(false) << "D3DCMP_LEQUAL";
break;
#endif
case D3DCMP_GREATER:
dxgsg_cat.debug(false) << "D3DCMP_GREATER";
dxgsg8_cat.debug(false) << "D3DCMP_GREATER";
break;
case D3DCMP_NOTEQUAL:
dxgsg_cat.debug(false) << "D3DCMP_NOTEQUAL";
dxgsg8_cat.debug(false) << "D3DCMP_NOTEQUAL";
break;
#ifdef D3DCMP_GEQUAL
case D3DCMP_GEQUAL:
dxgsg_cat.debug(false) << "D3DCMP_GEQUAL";
dxgsg8_cat.debug(false) << "D3DCMP_GEQUAL";
break;
#endif
case D3DCMP_ALWAYS:
dxgsg_cat.debug(false) << "D3DCMP_ALWAYS";
dxgsg8_cat.debug(false) << "D3DCMP_ALWAYS";
break;
}
dxgsg_cat.debug() << " , " << reference_alpha << ")" << endl;
dxgsg8_cat.debug() << " , " << reference_alpha << ")" << endl;
#endif
scrn.pD3DDevice->SetRenderState(D3DRS_ALPHAFUNC, func);
}
@ -271,7 +275,7 @@ call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
}
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
{
if (_blend_source_func != sfunc)
@ -279,41 +283,41 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
_blend_source_func = sfunc;
scrn.pD3DDevice->SetRenderState(D3DRS_SRCBLEND, sfunc);
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxSrcBlendFunc(";
dxgsg8_cat.debug() << "dxSrcBlendFunc(";
switch (sfunc)
{
case D3DBLEND_ZERO:
dxgsg_cat.debug(false) << "ZERO, ";
dxgsg8_cat.debug(false) << "ZERO, ";
break;
case D3DBLEND_ONE:
dxgsg_cat.debug(false) << "ONE, ";
dxgsg8_cat.debug(false) << "ONE, ";
break;
case D3DBLEND_DESTCOLOR:
dxgsg_cat.debug(false) << "DESTCOLOR, ";
dxgsg8_cat.debug(false) << "DESTCOLOR, ";
break;
case D3DBLEND_INVDESTCOLOR:
dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
dxgsg8_cat.debug(false) << "INVDESTCOLOR, ";
break;
case D3DBLEND_SRCALPHA:
dxgsg_cat.debug(false) << "SRCALPHA, ";
dxgsg8_cat.debug(false) << "SRCALPHA, ";
break;
case D3DBLEND_INVSRCALPHA:
dxgsg_cat.debug(false) << "INVSRCALPHA, ";
dxgsg8_cat.debug(false) << "INVSRCALPHA, ";
break;
case D3DBLEND_DESTALPHA:
dxgsg_cat.debug(false) << "DESTALPHA, ";
dxgsg8_cat.debug(false) << "DESTALPHA, ";
break;
case D3DBLEND_INVDESTALPHA:
dxgsg_cat.debug(false) << "INVDESTALPHA, ";
dxgsg8_cat.debug(false) << "INVDESTALPHA, ";
break;
case D3DBLEND_SRCALPHASAT:
dxgsg_cat.debug(false) << "SRCALPHASAT, ";
dxgsg8_cat.debug(false) << "SRCALPHASAT, ";
break;
default:
dxgsg_cat.debug(false) << "unknown, ";
dxgsg8_cat.debug(false) << "unknown, ";
break;
}
dxgsg_cat.debug(false) << endl;
dxgsg8_cat.debug(false) << endl;
#endif
}
if ( _blend_dest_func != dfunc)
@ -321,43 +325,43 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
_blend_dest_func = dfunc;
scrn.pD3DDevice->SetRenderState(D3DRS_DESTBLEND, dfunc);
#ifdef GSG_VERBOSE
dxgsg_cat.debug() << "dxDstBlendFunc(";
dxgsg8_cat.debug() << "dxDstBlendFunc(";
switch (dfunc)
{
case D3DBLEND_ZERO:
dxgsg_cat.debug(false) << "ZERO, ";
dxgsg8_cat.debug(false) << "ZERO, ";
break;
case D3DBLEND_ONE:
dxgsg_cat.debug(false) << "ONE, ";
dxgsg8_cat.debug(false) << "ONE, ";
break;
case D3DBLEND_DESTCOLOR:
dxgsg_cat.debug(false) << "DESTCOLOR, ";
dxgsg8_cat.debug(false) << "DESTCOLOR, ";
break;
case D3DBLEND_INVDESTCOLOR:
dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
dxgsg8_cat.debug(false) << "INVDESTCOLOR, ";
break;
case D3DBLEND_SRCALPHA:
dxgsg_cat.debug(false) << "SRCALPHA, ";
dxgsg8_cat.debug(false) << "SRCALPHA, ";
break;
case D3DBLEND_INVSRCALPHA:
dxgsg_cat.debug(false) << "INVSRCALPHA, ";
dxgsg8_cat.debug(false) << "INVSRCALPHA, ";
break;
case D3DBLEND_DESTALPHA:
dxgsg_cat.debug(false) << "DESTALPHA, ";
dxgsg8_cat.debug(false) << "DESTALPHA, ";
break;
case D3DBLEND_INVDESTALPHA:
dxgsg_cat.debug(false) << "INVDESTALPHA, ";
dxgsg8_cat.debug(false) << "INVDESTALPHA, ";
break;
case D3DBLEND_SRCALPHASAT:
dxgsg_cat.debug(false) << "SRCALPHASAT, ";
dxgsg8_cat.debug(false) << "SRCALPHASAT, ";
break;
}
dxgsg_cat.debug(false) << endl;
dxgsg8_cat.debug(false) << endl;
#endif
}
}
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_zwritemask(bool val) {
if (_depth_write_enabled != val) {
_depth_write_enabled = val;
@ -368,24 +372,24 @@ enable_zwritemask(bool val) {
/** unimplemented
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_multisample
// Function: DXGraphicsStateGuardian8::enable_multisample
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_multisample(bool val) {
_multisample_enabled = val;
#ifdef NDEBUG
dxgsg_cat.error() << "dx multisample unimplemented!!\n";
dxgsg8_cat.error() << "dx multisample unimplemented!!\n";
#endif
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_one
// Function: DXGraphicsStateGuardian8::enable_multisample_alpha_one
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_multisample_alpha_one(bool val) {
if (_multisample_alpha_one_enabled != val) {
_multisample_alpha_one_enabled = val;
@ -393,11 +397,11 @@ enable_multisample_alpha_one(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_mask
// Function: DXGraphicsStateGuardian8::enable_multisample_alpha_mask
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_multisample_alpha_mask(bool val) {
if (_multisample_alpha_mask_enabled != val) {
_multisample_alpha_mask_enabled = val;
@ -405,16 +409,16 @@ enable_multisample_alpha_mask(bool val) {
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian::enable_point_smooth
// Function: DXGraphicsStateGuardian8::enable_point_smooth
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian::
INLINE void DXGraphicsStateGuardian8::
enable_point_smooth(bool val) {
// _point_smooth_enabled = val;
#ifdef NDEBUG
dxgsg_cat.error() << "dx point smoothing unimplemented!!\n";
dxgsg8_cat.error() << "dx point smoothing unimplemented!!\n";
#endif
}
*/

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
#ifndef DXGRAPHICSSTATEGUARDIAN_H
#define DXGRAPHICSSTATEGUARDIAN_H
//#define GSG_VERBOSE
//#define GSG_VERBOSE 1
#include "dxgsg8base.h"
#include "dxGeomNodeContext8.h"
@ -58,20 +58,20 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
#endif
////////////////////////////////////////////////////////////////////
// Class : DXGraphicsStateGuardian
// Class : DXGraphicsStateGuardian8
// Description : A GraphicsStateGuardian specialized for rendering
// into DX. There should be no DX calls
// outside of this object.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
friend class wdxGraphicsWindow;
friend class wdxGraphicsPipe;
friend class wdxGraphicsWindowGroup;
friend class DXTextureContext;
class EXPCL_PANDADX DXGraphicsStateGuardian8 : public GraphicsStateGuardian {
friend class wdxGraphicsWindow8;
friend class wdxGraphicsPipe8;
friend class wdxGraphicsWindowGroup8;
friend class DXTextureContext8;
public:
DXGraphicsStateGuardian(GraphicsWindow *win);
~DXGraphicsStateGuardian();
DXGraphicsStateGuardian8(GraphicsWindow *win);
~DXGraphicsStateGuardian8();
virtual void reset();
@ -134,12 +134,11 @@ public:
virtual void bind_light(DirectionalLight *light, int light_id);
virtual void bind_light(Spotlight *light, int light_id);
// default gsg begin_frame() used
virtual bool begin_frame();
virtual bool begin_scene();
virtual void end_scene();
virtual void end_frame();
virtual void start_rendering();
virtual void finish_rendering();
virtual bool wants_normals(void) const;
virtual bool wants_texcoords(void) const;
@ -179,8 +178,7 @@ protected:
bool _bDXisReady;
HRESULT _last_testcooplevel_result;
bool _bShowFPSMeter;
DXTextureContext *_pCurTexContext;
DXTextureContext8 *_pCurTexContext;
bool _bTransformIssued; // decaling needs to tell when a transform has been issued
D3DMATRIX _SavedTransform;
@ -246,7 +244,7 @@ protected:
bool _bGouraudShadingOn;
UINT _color_writemask;
bool _bDrawPrimDoSetupVertexBuffer; // if true, draw methods just copy vertex data into pCurrentGeomContext
DXGeomNodeContext *_pCurrentGeomContext; // used in vertex buffer setup
DXGeomNodeContext8 *_pCurrentGeomContext; // used in vertex buffer setup
// iterators for primitives
Geom::VertexIterator vi;
@ -322,16 +320,9 @@ protected:
bool _overlay_windows_supported;
// vars for frames/sec meter
DWORD _start_time;
DWORD _start_frame_count;
DWORD _cur_frame_count;
float _current_fps,_fpsmeter_x_offset,_fpsmeter_y_offset;
::CD3DFont *_pStatMeterFont;
public:
static GraphicsStateGuardian*
make_DXGraphicsStateGuardian(const FactoryParams &params);
make_DXGraphicsStateGuardian8(const FactoryParams &params);
static TypeHandle get_class_type(void);
static void init_type(void);
@ -339,7 +330,7 @@ public:
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
INLINE void SetDXReady(bool status) { _bDXisReady = status; }
INLINE bool GetDXReady(void) { return _bDXisReady;}
void DXGraphicsStateGuardian::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
void DXGraphicsStateGuardian8::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
// Shader Stuff
DXShaderHandle read_vertex_shader(string &filename);
@ -364,7 +355,7 @@ private:
static TypeHandle _type_handle;
};
#include "dxGraphicsStateGuardian8.I"
#include "DXGraphicsStateGuardian8.I"
#endif

View File

@ -1,4 +1,4 @@
// Filename: dxSavedFrameBuffer.I
// Filename: dxSavedFrameBuffer8.I
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -18,22 +18,22 @@
////////////////////////////////////////////////////////////////////
// Function: DXSavedFrameBuffer::Constructor
// Function: DXSavedFrameBuffer8::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE DXSavedFrameBuffer::
DXSavedFrameBuffer(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
INLINE DXSavedFrameBuffer8::
DXSavedFrameBuffer8(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
SavedFrameBuffer(buffer, dr)
{
}
////////////////////////////////////////////////////////////////////
// Function: DXSavedFrameBuffer::Destructor
// Function: DXSavedFrameBuffer8::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE DXSavedFrameBuffer::
~DXSavedFrameBuffer() {
INLINE DXSavedFrameBuffer8::
~DXSavedFrameBuffer8() {
}

View File

@ -1,4 +1,4 @@
// Filename: dxSavedFrameBuffer.cxx
// Filename: dxSavedFrameBuffer8.cxx
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -18,4 +18,4 @@
#include "dxSavedFrameBuffer8.h"
TypeHandle DXSavedFrameBuffer::_type_handle;
TypeHandle DXSavedFrameBuffer8::_type_handle;

View File

@ -1,4 +1,4 @@
// Filename: dxSavedFrameBuffer.h
// Filename: dxSavedFrameBuffer8.h
// Created by: drose (06Oct99)
//
////////////////////////////////////////////////////////////////////
@ -28,14 +28,14 @@
////////////////////////////////////////////////////////////////////
// Class : DXSavedFrameBuffer
// Class : DXSavedFrameBuffer8
// Description :
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXSavedFrameBuffer : public SavedFrameBuffer {
class EXPCL_PANDADX DXSavedFrameBuffer8 : public SavedFrameBuffer {
public:
INLINE DXSavedFrameBuffer(const RenderBuffer &buffer,
INLINE DXSavedFrameBuffer8(const RenderBuffer &buffer,
CPT(DisplayRegion) dr);
INLINE ~DXSavedFrameBuffer();
INLINE ~DXSavedFrameBuffer8();
PT(Texture) _back_rgba;
PT(PixelBuffer) _depth;
@ -46,7 +46,7 @@ public:
}
static void init_type() {
SavedFrameBuffer::init_type();
register_type(_type_handle, "DXSavedFrameBuffer",
register_type(_type_handle, "DXSavedFrameBuffer8",
SavedFrameBuffer::get_class_type());
}
virtual TypeHandle get_type() const {
@ -58,7 +58,7 @@ private:
static TypeHandle _type_handle;
};
#include "dxSavedFrameBuffer8.I"
#include "DXSavedFrameBuffer8.I"
#endif

View File

@ -67,7 +67,7 @@ char *PandaFilterNameStrs[] = {"FT_nearest","FT_linear","FT_nearest_mipmap_neare
};
TypeHandle DXTextureContext::_type_handle;
TypeHandle DXTextureContext8::_type_handle;
#define SWAPDWORDS(X,Y) { DWORD temp=X; X=Y; Y=temp; }
@ -152,7 +152,7 @@ enum Format {
*/
////////////////////////////////////////////////////////////////////
// Function: DXTextureContext::get_bits_per_pixel
// Function: DXTextureContext8::get_bits_per_pixel
// Access: Protected
// Description: Maps from the PixelBuffer's Format symbols
// to bpp. returns # of alpha bits
@ -160,7 +160,7 @@ enum Format {
// not the stored format, which is indicated by pixelbuffer type
////////////////////////////////////////////////////////////////////
unsigned int DXTextureContext::
unsigned int DXTextureContext8::
get_bits_per_pixel(PixelBuffer::Format format, int *alphbits) {
*alphbits = 0; // assume no alpha bits
switch(format) {
@ -725,7 +725,7 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
BYTE *pbuf=pixbuf->_image.p();
if(IsBadWritePtr(pD3DSurf8,sizeof(DWORD))) {
dxgsg_cat.error() << "ConvertDDSurftoPixBuf failed: bad pD3DSurf ptr value (" << ((void*)pD3DSurf8) << ")\n";
dxgsg8_cat.error() << "ConvertDDSurftoPixBuf failed: bad pD3DSurf ptr value (" << ((void*)pD3DSurf8) << ")\n";
exit(1);
}
@ -745,14 +745,14 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
// or scanlines will be too long
if(!((dwCopyWidth==pixbuf->get_xsize()) && (dwCopyHeight<=(DWORD)pixbuf->get_ysize()))) {
dxgsg_cat.error() << "ConvertDDSurftoPixBuf, PixBuf size too small to hold display surface!\n";
dxgsg8_cat.error() << "ConvertDDSurftoPixBuf, PixBuf size too small to hold display surface!\n";
assert(0);
return E_FAIL;
}
hr = pD3DSurf8->LockRect(&LockedRect,(CONST RECT*)NULL,(D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE /* | D3DLOCK_NOSYSLOCK */));
if(FAILED(hr)) {
dxgsg_cat.error() << "ConvertDDSurftoPixBuf LockRect() failed!" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "ConvertDDSurftoPixBuf LockRect() failed!" << D3DERRORSTRING(hr);
return hr;
}
@ -768,8 +768,8 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
// writes out last line in DDSurf first in PixelBuf, so Y line order precedes inversely
if(dxgsg_cat.is_debug()) {
dxgsg_cat.debug() << "ConvertD3DSurftoPixBuf converting " << D3DFormatStr(SurfDesc.Format) << "bpp DDSurf to "
if(dxgsg8_cat.is_debug()) {
dxgsg8_cat.debug() << "ConvertD3DSurftoPixBuf converting " << D3DFormatStr(SurfDesc.Format) << "bpp DDSurf to "
<< dwNumComponents << "-channel panda PixelBuffer\n";
}
@ -970,7 +970,7 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
}
default:
dxgsg_cat.error() << "ConvertD3DSurftoPixBuf: unsupported D3DFORMAT!\n";
dxgsg8_cat.error() << "ConvertD3DSurftoPixBuf: unsupported D3DFORMAT!\n";
}
pD3DSurf8->UnlockRect();
@ -983,7 +983,7 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
// This code gets the attributes of the texture from the bitmap, creates the
// texture, and then copies the bitmap into the texture.
//-----------------------------------------------------------------------------
IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
IDirect3DTexture8 *DXTextureContext8::CreateTexture(DXScreenData &scrn) {
HRESULT hr;
int cNumAlphaBits; // number of alpha bits in texture pixfmt
D3DFORMAT TargetPixFmt=D3DFMT_UNKNOWN;
@ -1001,7 +1001,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
assert(pixbuf_type==PixelBuffer::T_unsigned_byte); // cant handle anything else now
if((pixbuf_type!=PixelBuffer::T_unsigned_byte) || (pbuf->get_component_width()!=1)) {
dxgsg_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
dxgsg8_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
return NULL;
}
@ -1016,7 +1016,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
if(cNumAlphaBits>0) {
if(cNumColorChannels==3) {
dxgsg_cat.error() << "ERROR: texture " << _tex->get_name() << " has no inherent alpha channel, but alpha format is requested (that would be wasteful)!\n";
dxgsg8_cat.error() << "ERROR: texture " << _tex->get_name() << " has no inherent alpha channel, but alpha format is requested (that would be wasteful)!\n";
exit(1);
}
}
@ -1053,7 +1053,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
DWORD TargetHeight=dwOrigHeight;
if(!ISPOW2(dwOrigWidth) || !ISPOW2(dwOrigHeight)) {
dxgsg_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "! Please rescale them so it doesnt have to be done at runtime.\n";
dxgsg8_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "! Please rescale them so it doesnt have to be done at runtime.\n";
#ifndef NDEBUG
exit(1); // want to catch badtexsize errors
#else
@ -1066,7 +1066,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
if((dwOrigWidth>scrn.d3dcaps.MaxTextureWidth)||(dwOrigHeight>scrn.d3dcaps.MaxTextureHeight)) {
#ifdef _DEBUG
dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << scrn.d3dcaps.MaxTextureWidth << "," << scrn.d3dcaps.MaxTextureHeight << ") !!\n"
dxgsg8_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << scrn.d3dcaps.MaxTextureWidth << "," << scrn.d3dcaps.MaxTextureHeight << ") !!\n"
<< "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< scrn.d3dcaps.MaxTextureWidth << "," << scrn.d3dcaps.MaxTextureHeight << ") !\n";
#endif
@ -1087,7 +1087,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
bShrinkOriginal=true;
#ifdef _DEBUG
dxgsg_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< TargetWidth<<"," << TargetHeight << ") to meet HW square texture reqmt\n";
dxgsg8_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< TargetWidth<<"," << TargetHeight << ") to meet HW square texture reqmt\n";
#endif
}
/*
@ -1109,10 +1109,10 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
char *szErrorMsg;
szErrorMsg = "CreateTexture failed: couldn't find compatible device Texture Pixel Format for input texture: ";
szErrorMsg = "CreateTexture failed: couldn't find compatible device Texture Pixel Format for input texture";
if(dxgsg_cat.is_spam())
dxgsg_cat.spam() << "CreateTexture handling target bitdepth: " << target_bpp << " alphabits: " << cNumAlphaBits << endl;
if(dxgsg8_cat.is_spam())
dxgsg8_cat.spam() << "CreateTexture handling target bitdepth: " << target_bpp << " alphabits: " << cNumAlphaBits << endl;
// I could possibly replace some of this logic with D3DXCheckTextureRequirements(), but
// it wouldnt handle all my specialized low-memory cases perfectly
@ -1298,7 +1298,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
}
// if we've gotten here, haven't found a match
dxgsg_cat.error() << szErrorMsg << ": " << _tex->get_name() << endl
dxgsg8_cat.error() << szErrorMsg << ": " << _tex->get_name() << endl
<< "NumColorChannels: " <<cNumColorChannels << "; NumAlphaBits: " << cNumAlphaBits
<< "; targetbpp: " <<target_bpp << "; SupportedTexFmtsMask: 0x" << (void*)scrn.SupportedTexFmtsMask
<< "; NeedLuminance: " << bNeedLuminance << endl;
@ -1339,9 +1339,9 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
if(dx_mipmap_everything) { // debug toggle, ok to leave in since its just a creation cost
_bHasMipMaps=TRUE;
if(dxgsg_cat.is_spam()) {
if(dxgsg8_cat.is_spam()) {
if(ft != Texture::FT_linear_mipmap_linear)
dxgsg_cat.spam() << "Forcing trilinear mipmapping on DX texture [" << _tex->get_name() << "]\n";
dxgsg8_cat.spam() << "Forcing trilinear mipmapping on DX texture [" << _tex->get_name() << "]\n";
}
ft = Texture::FT_linear_mipmap_linear;
_tex->set_minfilter(ft);
@ -1397,7 +1397,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
_tex->set_anisotropic_degree(aniso_degree);
#ifdef _DEBUG
dxgsg_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
dxgsg8_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
#endif
UINT cMipLevelCount;
@ -1405,13 +1405,13 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
if(_bHasMipMaps) {
cMipLevelCount=0; // tell CreateTex to alloc space for all mip levels down to 1x1
if(dxgsg_cat.is_debug())
dxgsg_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
if(dxgsg8_cat.is_debug())
dxgsg8_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
} else cMipLevelCount=1;
if(FAILED( hr = scrn.pD3DDevice->CreateTexture(TargetWidth,TargetHeight,cMipLevelCount,0x0,
TargetPixFmt,D3DPOOL_MANAGED,&_pD3DTexture8) )) {
dxgsg_cat.error() << "pD3DDevice->CreateTexture() failed!" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "pD3DDevice->CreateTexture() failed!" << D3DERRORSTRING(hr);
goto error_exit;
}
@ -1421,9 +1421,9 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
#ifdef _DEBUG
#ifdef DO_CUSTOM_CONVERSIONS
dxgsg_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting " << ConvNameStrs[ConvNeeded] << " \n";
dxgsg8_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting " << ConvNameStrs[ConvNeeded] << " \n";
#else
dxgsg_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting panda equivalent of " << D3DFormatStr(_PixBufD3DFmt) << " => " << D3DFormatStr(TargetPixFmt) << endl;
dxgsg8_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting panda equivalent of " << D3DFormatStr(_PixBufD3DFmt) << " => " << D3DFormatStr(TargetPixFmt) << endl;
#endif
#endif
@ -1439,23 +1439,23 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
error_exit:
RELEASE(_pD3DTexture8,dxgsg,"texture",RELEASE_ONCE);
RELEASE(_pD3DTexture8,dxgsg8,"texture",RELEASE_ONCE);
return NULL;
}
HRESULT DXTextureContext::
HRESULT DXTextureContext8::
FillDDSurfTexturePixels(void) {
HRESULT hr=E_FAIL;
assert(IS_VALID_PTR(_texture));
if(!_texture->has_ram_image()) {
dxgsg_cat.warning() << "CreateTexture: tried to fill surface that has no ram image!\n";
dxgsg8_cat.warning() << "CreateTexture: tried to fill surface that has no ram image!\n";
return S_OK;
}
PixelBuffer *pbuf = _texture->get_ram_image();
if (pbuf == (PixelBuffer *)NULL) {
dxgsg_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
dxgsg8_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
// The texture doesn't have an image to load.
return E_FAIL;
}
@ -1473,7 +1473,7 @@ FillDDSurfTexturePixels(void) {
IDirect3DSurface8 *pMipLevel0;
hr=_pD3DTexture8->GetSurfaceLevel(0,&pMipLevel0);
if(FAILED(hr)) {
dxgsg_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", GetSurfaceLevel failed" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", GetSurfaceLevel failed" << D3DERRORSTRING(hr);
return E_FAIL;
}
@ -1496,7 +1496,7 @@ FillDDSurfTexturePixels(void) {
// alloc buffer for explicit D3DFMT_A8L8
USHORT *pTempPixBuf=new USHORT[OrigWidth*OrigHeight];
if(!IS_VALID_PTR(pTempPixBuf)) {
dxgsg_cat.error() << "FillDDSurfaceTexturePixels couldnt alloc mem for temp pixbuf!\n";
dxgsg8_cat.error() << "FillDDSurfaceTexturePixels couldnt alloc mem for temp pixbuf!\n";
goto exit_FillDDSurf;
}
bUsingTempPixBuf=true;
@ -1516,7 +1516,7 @@ FillDDSurfTexturePixels(void) {
hr=D3DXLoadSurfaceFromMemory(pMipLevel0,(PALETTEENTRY*)NULL,(RECT*)NULL,(LPCVOID)pPixels,SrcFormat,
SrcPixBufRowByteLength,(PALETTEENTRY*)NULL,&SrcSize,Lev0Filter,(D3DCOLOR)0x0);
if(FAILED(hr)) {
dxgsg_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXLoadSurfFromMem failed" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXLoadSurfFromMem failed" << D3DERRORSTRING(hr);
goto exit_FillDDSurf;
}
@ -1529,7 +1529,7 @@ FillDDSurfTexturePixels(void) {
hr=D3DXFilterTexture(_pD3DTexture8,(PALETTEENTRY*)NULL,0,MipFilterFlags);
if(FAILED(hr)) {
dxgsg_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXFilterTex failed" << D3DERRORSTRING(hr);
dxgsg8_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXFilterTex failed" << D3DERRORSTRING(hr);
goto exit_FillDDSurf;
}
}
@ -1538,7 +1538,7 @@ FillDDSurfTexturePixels(void) {
if(bUsingTempPixBuf) {
SAFE_DELETE_ARRAY(pPixels);
}
RELEASE(pMipLevel0,dxgsg,"texture",RELEASE_ONCE);
RELEASE(pMipLevel0,dxgsg8,"texture",RELEASE_ONCE);
return hr;
}
@ -1548,13 +1548,13 @@ FillDDSurfTexturePixels(void) {
// Name: DeleteTexture()
// Desc: Release the surface used to store the texture
//-----------------------------------------------------------------------------
void DXTextureContext::
void DXTextureContext8::
DeleteTexture( ) {
if(dxgsg_cat.is_spam()) {
dxgsg_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
if(dxgsg8_cat.is_spam()) {
dxgsg8_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
}
RELEASE(_pD3DTexture8,dxgsg,"texture",RELEASE_ONCE);
RELEASE(_pD3DTexture8,dxgsg8,"texture",RELEASE_ONCE);
/*
#ifdef DEBUG_RELEASES
if(_surface) {
@ -1563,28 +1563,28 @@ DeleteTexture( ) {
pDD->Release();
PRINTREFCNT(pDD,"before DeleteTex, IDDraw7");
RELEASE(_surface,dxgsg,"texture",false);
RELEASE(_surface,dxgsg8,"texture",false);
PRINTREFCNT(pDD,"after DeleteTex, IDDraw7");
}
#else
RELEASE(_pD3DSurf8,dxgsg,"texture",false);
RELEASE(_pD3DSurf8,dxgsg8,"texture",false);
#endif
*/
}
////////////////////////////////////////////////////////////////////
// Function: DXTextureContext::Constructor
// Function: DXTextureContext8::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
DXTextureContext::
DXTextureContext(Texture *tex) :
DXTextureContext8::
DXTextureContext8(Texture *tex) :
TextureContext(tex) {
if(dxgsg_cat.is_spam()) {
dxgsg_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
if(dxgsg8_cat.is_spam()) {
dxgsg8_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
}
_pD3DTexture8 = NULL;
@ -1592,8 +1592,8 @@ TextureContext(tex) {
_tex = tex;
}
DXTextureContext::
~DXTextureContext() {
DXTextureContext8::
~DXTextureContext8() {
DeleteTexture();
TextureContext::~TextureContext();
_tex = NULL;

View File

@ -1,4 +1,4 @@
// Filename: dxTextureContext.h
// Filename: dxTextureContext8.h
// Created by: drose (07Oct99)
//
////////////////////////////////////////////////////////////////////
@ -16,26 +16,26 @@
//
////////////////////////////////////////////////////////////////////
#ifndef DXTEXTURECONTEXT_H
#define DXTEXTURECONTEXT_H
#ifndef DXTEXTURECONTEXT8_H
#define DXTEXTURECONTEXT8_H
#include "dxgsg8base.h"
#include <texture.h>
#include <textureContext.h>
#include "texture.h"
#include "textureContext.h"
//#define DO_CUSTOM_CONVERSIONS
////////////////////////////////////////////////////////////////////
// Class : DXTextureContext
// Class : DXTextureContext8
// Description :
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX DXTextureContext : public TextureContext {
class EXPCL_PANDADX DXTextureContext8 : public TextureContext {
friend class DXGraphicsStateGuardian;
friend class wdxGraphicsWindow;
public:
DXTextureContext(Texture *tex);
~DXTextureContext();
DXTextureContext8(Texture *tex);
~DXTextureContext8();
IDirect3DTexture8 *_pD3DTexture8;
Texture *_tex; // ptr to parent, primarily for access to namestr
@ -62,7 +62,7 @@ public:
}
static void init_type() {
TextureContext::init_type();
register_type(_type_handle, "DXTextureContext",
register_type(_type_handle, "DXTextureContext8",
TextureContext::get_class_type());
}
virtual TypeHandle get_type() const {

View File

@ -3,3 +3,5 @@
#include "dxTextureContext8.cxx"
#include "dxGeomNodeContext8.cxx"
#include "d3dfont8.cxx"
#include "wdxGraphicsPipe8.cxx"
#include "wdxGraphicsWindow8.cxx"

View File

@ -186,7 +186,6 @@ typedef struct {
LPDIRECT3D8 pD3D8;
HWND hWnd;
HMONITOR hMon;
GraphicsWindow::Properties *pProps; // can get window rect here (or from GetWindowRect(hWnd), can also get window size in PresParams
DWORD MaxAvailVidMem;
ushort CardIDNum; // adapter ID
ushort depth_buffer_bitdepth; //GetSurfaceDesc is not reliable so must store this explicitly

View File

@ -1,5 +1,5 @@
// Filename: config_sgiglutdisplay.h
// Created by: cary (07Oct99)
// Filename: wdxGraphicsPipe8.I
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
@ -15,13 +15,3 @@
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef CONFIG_SGIGLUTDISPLAY_H
#define CONFIG_SGIGLUTDISPLAY_H
#include <pandabase.h>
#include <notifyCategoryProxy.h>
NotifyCategoryDecl(sgiglutdisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
#endif

View File

@ -0,0 +1,339 @@
// Filename: wdxGraphicsPipe8.cxx
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "wdxGraphicsPipe8.h"
#include "wdxGraphicsWindow8.h"
#include "config_dxgsg8.h"
TypeHandle wdxGraphicsPipe8::_type_handle;
// #define LOWVIDMEMTHRESHOLD 3500000
// #define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000
#define LOWVIDMEMTHRESHOLD 5700000 // 4MB cards should fall below this
#define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000 // if # is > 1MB, card is lying and I cant tell what it is
#define UNKNOWN_VIDMEM_SIZE 0xFFFFFFFF
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe8::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
wdxGraphicsPipe8::
wdxGraphicsPipe8() {
_hDDrawDLL = NULL;
_hD3D8_DLL = NULL;
_is_valid = init();
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe8::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
wdxGraphicsPipe8::
~wdxGraphicsPipe8() {
if (_hDDrawDLL != NULL) {
FreeLibrary(_hDDrawDLL);
_hDDrawDLL = NULL;
}
if(_hD3D8_DLL != NULL) {
FreeLibrary(_hD3D8_DLL);
_hD3D8_DLL = NULL;
}
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe8::pipe_constructor
// Access: Public, Static
// Description: This function is passed to the GraphicsPipeSelection
// object to allow the user to make a default
// wdxGraphicsPipe8.
////////////////////////////////////////////////////////////////////
PT(GraphicsPipe) wdxGraphicsPipe8::
pipe_constructor() {
return new wdxGraphicsPipe8;
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe8::make_window
// Access: Protected, Virtual
// Description: Creates a new window on the pipe, if possible.
////////////////////////////////////////////////////////////////////
PT(GraphicsWindow) wdxGraphicsPipe8::
make_window() {
if (!_is_valid) {
return NULL;
}
return new wdxGraphicsWindow8(this);
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe8::init
// Access: Private
// Description: Performs some initialization steps to load up
// function pointers from the relevant DLL's, and
// determine the number and type of available graphics
// adapters, etc. Returns true on success, false on
// failure.
////////////////////////////////////////////////////////////////////
bool wdxGraphicsPipe8::
init() {
static const char * const ddraw_name = "ddraw.dll";
_hDDrawDLL = LoadLibrary(ddraw_name);
if(_hDDrawDLL == 0) {
wdxdisplay8_cat.error()
<< "can't locate " << ddraw_name << "!\n";
return false;
}
_DirectDrawCreateEx =
(LPDIRECTDRAWCREATEEX)GetProcAddress(_hDDrawDLL, "DirectDrawCreateEx");
if (_DirectDrawCreateEx == NULL) {
wdxdisplay8_cat.error()
<< "GetProcAddr failed for DDCreateEx" << endl;
return false;
}
_DirectDrawEnumerateExA = (LPDIRECTDRAWENUMERATEEX)GetProcAddress(_hDDrawDLL, "DirectDrawEnumerateExA");
if (_DirectDrawEnumerateExA == NULL) {
wdxdisplay8_cat.error()
<< "GetProcAddr failed for DirectDrawEnumerateEx! (win95 system?)\n";
return false;
}
static const char * const d3d8_name = "d3d8.dll";
_hD3D8_DLL = LoadLibrary(d3d8_name);
if (_hD3D8_DLL == 0) {
wdxdisplay8_cat.error()
<< "PandaDX8 requires DX8, can't locate " << d3d8_name << "!\n";
return false;
}
// dont want to statically link to possibly non-existent d3d8 dll,
// so must call D3DCr8 indirectly
static const char * const d3dcreate8_name = "Direct3DCreate8";
_Direct3DCreate8 =
(Direct3DCreate8_ProcPtr)GetProcAddress(_hD3D8_DLL, d3dcreate8_name);
if (_Direct3DCreate8 == NULL) {
wdxdisplay8_cat.error()
<< "GetProcAddress for " << d3dcreate8_name << "failed!" << endl;
return false;
}
return find_all_card_memavails();
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe8::find_all_card_memavails
// Access: Private
// Description: Uses DX7 calls to determine how much video memory is
// available for each video adapter in the system.
// Returns true on success, false on failure.
////////////////////////////////////////////////////////////////////
bool wdxGraphicsPipe8::
find_all_card_memavails() {
HRESULT hr;
hr = (*_DirectDrawEnumerateExA)(dx7_driver_enum_callback, this,
DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES);
if (FAILED(hr)) {
wdxdisplay8_cat.fatal()
<< "DirectDrawEnumerateEx failed" << D3DERRORSTRING(hr);
return false;
}
if (_card_ids.empty()) {
wdxdisplay8_cat.error()
<< "DirectDrawEnumerateEx enum'ed no devices!\n";
return false;
}
GUID ZeroGUID;
ZeroMemory(&ZeroGUID, sizeof(GUID));
if (_card_ids.size() > 1) {
assert(IsEqualGUID(ZeroGUID, _card_ids[0].DX7_DeviceGUID));
// delete enum of primary display (always the first), since it is
// duplicated by explicit entry
_card_ids.erase(_card_ids.begin());
}
for (UINT i=0; i < _card_ids.size(); i++) {
LPDIRECTDRAW7 pDD;
BYTE ddd_space[sizeof(DDDEVICEIDENTIFIER2)+4]; //bug in DX7 requires 4 extra bytes for GetDeviceID
DDDEVICEIDENTIFIER2 *pDX7DeviceID=(DDDEVICEIDENTIFIER2 *)&ddd_space[0];
GUID *pGUID= &(_card_ids[i].DX7_DeviceGUID);
if (IsEqualGUID(*pGUID, ZeroGUID)) {
pGUID=NULL;
}
// Create the Direct Draw Object
hr = (*_DirectDrawCreateEx)(pGUID,(void **)&pDD, IID_IDirectDraw7, NULL);
if (FAILED(hr)) {
wdxdisplay8_cat.error()
<< "DirectDrawCreateEx failed for device (" << i
<< ")" << D3DERRORSTRING(hr);
continue;
}
ZeroMemory(ddd_space, sizeof(DDDEVICEIDENTIFIER2));
hr = pDD->GetDeviceIdentifier(pDX7DeviceID, 0x0);
if (FAILED(hr)) {
wdxdisplay8_cat.error()
<< "GetDeviceID failed for device ("<< i << ")" << D3DERRORSTRING(hr);
continue;
}
_card_ids[i].DeviceID = pDX7DeviceID->dwDeviceId;
_card_ids[i].VendorID = pDX7DeviceID->dwVendorId;
// Get Current VidMem avail. Note this is only an estimate, when
// we switch to fullscreen mode from desktop, more vidmem will be
// available (typically 1.2 meg). I dont want to switch to
// fullscreen more than once due to the annoying monitor flicker,
// so try to figure out optimal mode using this estimate
DDSCAPS2 ddsGAVMCaps;
DWORD dwVidMemTotal,dwVidMemFree;
dwVidMemTotal=dwVidMemFree=0;
{
// print out total INCLUDING AGP just for information purposes
// and future use. The real value I'm interested in for
// purposes of measuring possible valid screen sizes shouldnt
// include AGP.
ZeroMemory(&ddsGAVMCaps, sizeof(DDSCAPS2));
ddsGAVMCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
hr = pDD->GetAvailableVidMem(&ddsGAVMCaps, &dwVidMemTotal, &dwVidMemFree);
if (FAILED(hr)) {
wdxdisplay8_cat.error()
<< "GetAvailableVidMem failed for device #" << i
<< D3DERRORSTRING(hr);
// goto skip_device;
exit(1); // probably want to exit, since it may be my fault
}
}
wdxdisplay8_cat.info()
<< "GetAvailableVidMem (including AGP) returns Total: "
<< dwVidMemTotal <<", Free: " << dwVidMemFree
<< " for device #" << i << endl;
ZeroMemory(&ddsGAVMCaps, sizeof(DDSCAPS2));
// just want to measure localvidmem, not AGP texmem
ddsGAVMCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
hr = pDD->GetAvailableVidMem(&ddsGAVMCaps, &dwVidMemTotal, &dwVidMemFree);
if (FAILED(hr)) {
wdxdisplay8_cat.error()
<< "GetAvailableVidMem failed for device #"<< i<< D3DERRORSTRING(hr);
// goto skip_device;
exit(1); // probably want to exit, since it may be my fault
}
wdxdisplay8_cat.info()
<< "GetAvailableVidMem (no AGP) returns Total: " << dwVidMemTotal
<< ", Free: " << dwVidMemFree << " for device #"<< i<< endl;
pDD->Release(); // release DD obj, since this is all we needed it for
if (!dx_do_vidmemsize_check) {
// still calling the DD stuff to get deviceID, etc. is this necessary?
_card_ids[i].MaxAvailVidMem = UNKNOWN_VIDMEM_SIZE;
_card_ids[i].bIsLowVidMemCard = false;
continue;
}
if (dwVidMemTotal == 0) { // unreliable driver
dwVidMemTotal = UNKNOWN_VIDMEM_SIZE;
} else {
if (!ISPOW2(dwVidMemTotal)) {
// assume they wont return a proper max value, so
// round up to next pow of 2
UINT count=0;
while ((dwVidMemTotal >> count) != 0x0) {
count++;
}
dwVidMemTotal = (1 << count);
}
}
// after SetDisplayMode, GetAvailVidMem totalmem seems to go down
// by 1.2 meg (contradicting above comment and what I think would
// be correct behavior (shouldnt FS mode release the desktop
// vidmem?), so this is the true value
_card_ids[i].MaxAvailVidMem = dwVidMemTotal;
// I can never get this stuff to work reliably, so I'm just
// rounding up to nearest pow2. Could try to get
// HardwareInformation.Memory_size MB number from registry like
// video control panel, but its not clear how to find the proper
// registry location for a given card
// assume buggy drivers (this means you, FireGL2) may return zero
// (or small amts) for dwVidMemTotal, so ignore value if its <
// CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD
bool bLowVidMemFlag =
((dwVidMemTotal > CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD) &&
(dwVidMemTotal< LOWVIDMEMTHRESHOLD));
_card_ids[i].bIsLowVidMemCard = bLowVidMemFlag;
wdxdisplay8_cat.info()
<< "SetLowVidMem flag to " << bLowVidMemFlag
<< " based on adjusted VidMemTotal: " << dwVidMemTotal << endl;
}
return true;
}
////////////////////////////////////////////////////////////////////
// Function: wdxGraphicsPipe8::dx7_driver_enum_callback
// Access: Private, Static
// Description:
////////////////////////////////////////////////////////////////////
BOOL WINAPI wdxGraphicsPipe8::
dx7_driver_enum_callback(GUID *pGUID, TCHAR *strDesc, TCHAR *strName,
VOID *argptr, HMONITOR hm) {
// #define PRNT(XX) ((XX!=NULL) ? XX : "NULL")
// cout << "strDesc: "<< PRNT(strDesc) << " strName: "<< PRNT(strName)<<endl;
wdxGraphicsPipe8 *self = (wdxGraphicsPipe8 *)argptr;
CardID card_id;
ZeroMemory(&card_id, sizeof(CardID));
if (hm == NULL) {
card_id.hMon = MonitorFromWindow(GetDesktopWindow(),
MONITOR_DEFAULTTOPRIMARY);
} else {
card_id.hMon = hm;
}
if (pGUID != NULL) {
memcpy(&card_id.DX7_DeviceGUID, pGUID, sizeof(GUID));
}
card_id.MaxAvailVidMem = UNKNOWN_VIDMEM_SIZE;
self->_card_ids.push_back(card_id);
return DDENUMRET_OK;
}

View File

@ -0,0 +1,109 @@
// Filename: wdxGraphicsPipe8.h
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef WDXGRAPHICSPIPE8_H
#define WDXGRAPHICSPIPE8_H
#include "pandabase.h"
#include "winGraphicsPipe.h"
#include "pvector.h"
#include <ddraw.h>
typedef struct {
UINT cardID;
char szDriver[MAX_DEVICE_IDENTIFIER_STRING];
char szDescription[MAX_DEVICE_IDENTIFIER_STRING];
GUID guidDeviceIdentifier;
DWORD VendorID, DeviceID;
HMONITOR hMon;
} DXDeviceInfo;
typedef pvector<DXDeviceInfo> DXDeviceInfoVec;
////////////////////////////////////////////////////////////////////
// Class : wdxGraphicsPipe8
// Description : This graphics pipe represents the interface for
// creating DirectX graphics windows.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDADX wdxGraphicsPipe8 : public WinGraphicsPipe {
public:
wdxGraphicsPipe8();
virtual ~wdxGraphicsPipe8();
static PT(GraphicsPipe) pipe_constructor();
protected:
virtual PT(GraphicsWindow) make_window();
private:
bool init();
bool find_all_card_memavails();
static BOOL WINAPI
dx7_driver_enum_callback(GUID *pGUID, TCHAR *strDesc, TCHAR *strName,
VOID *argptr, HMONITOR hm);
private:
HINSTANCE _hDDrawDLL;
HINSTANCE _hD3D8_DLL;
bool _is_valid;
typedef LPDIRECT3D8 (WINAPI *Direct3DCreate8_ProcPtr)(UINT SDKVersion);
typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter);
LPDIRECTDRAWCREATEEX _DirectDrawCreateEx;
LPDIRECTDRAWENUMERATEEX _DirectDrawEnumerateExA;
Direct3DCreate8_ProcPtr _Direct3DCreate8;
// CardID is used in DX7 lowmem card-classification pass so DX8 can
// establish correspondence b/w DX7 mem info & DX8 device
struct CardID {
HMONITOR hMon;
DWORD MaxAvailVidMem;
bool bIsLowVidMemCard;
GUID DX7_DeviceGUID;
DWORD VendorID, DeviceID;
// char szDriver[MAX_DEVICE_IDENTIFIER_STRING];
};
typedef pvector<CardID> CardIDs;
CardIDs _card_ids;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
WinGraphicsPipe::init_type();
register_type(_type_handle, "wdxGraphicsPipe8",
WinGraphicsPipe::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 wdxGraphicsWindow8;
};
#include "wdxGraphicsPipe8.I"
#endif

View File

@ -0,0 +1,17 @@
// Filename: wdxGraphicsWindow8.I
// Created by: drose (20Dec02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////

Some files were not shown because too many files have changed in this diff Show More