From 6b80b2db797744f8597d40245f39a74c5cfa8af9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 28 Jan 2003 16:49:40 +0000 Subject: [PATCH] create gsg first, then window --- panda/src/display/frameBufferProperties.I | 208 ++++++++++++++++++ panda/src/display/frameBufferProperties.cxx | 151 +++++++++++++ panda/src/display/frameBufferProperties.h | 107 +++++++++ panda/src/display/graphicsThreadingModel.I | 119 ++++++++++ panda/src/display/graphicsThreadingModel.cxx | 86 ++++++++ panda/src/display/graphicsThreadingModel.h | 54 +++++ .../src/glxdisplay/glxGraphicsStateGuardian.I | 17 ++ .../glxdisplay/glxGraphicsStateGuardian.cxx | 54 +++++ .../src/glxdisplay/glxGraphicsStateGuardian.h | 63 ++++++ 9 files changed, 859 insertions(+) create mode 100644 panda/src/display/frameBufferProperties.I create mode 100644 panda/src/display/frameBufferProperties.cxx create mode 100644 panda/src/display/frameBufferProperties.h create mode 100644 panda/src/display/graphicsThreadingModel.I create mode 100644 panda/src/display/graphicsThreadingModel.cxx create mode 100644 panda/src/display/graphicsThreadingModel.h create mode 100644 panda/src/glxdisplay/glxGraphicsStateGuardian.I create mode 100644 panda/src/glxdisplay/glxGraphicsStateGuardian.cxx create mode 100644 panda/src/glxdisplay/glxGraphicsStateGuardian.h diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I new file mode 100644 index 0000000000..85b252efaa --- /dev/null +++ b/panda/src/display/frameBufferProperties.I @@ -0,0 +1,208 @@ +// Filename: frameBufferProperties.I +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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: FrameBufferProperties::Copy Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE FrameBufferProperties:: +FrameBufferProperties(const FrameBufferProperties ©) { + (*this) = copy; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::Destructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE FrameBufferProperties:: +~FrameBufferProperties() { +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::operator != +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +operator != (const FrameBufferProperties &other) const { + return !operator == (other); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::is_any_specified +// Access: Published +// Description: Returns true if any properties have been specified, +// false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +is_any_specified() const { + return (_specified != 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_frame_buffer_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 FrameBufferProperties:: +set_frame_buffer_mode(int frameBuffer_mode) { + _frame_buffer_mode = frameBuffer_mode; + _specified |= S_frame_buffer_mode; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_frame_buffer_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 FrameBufferProperties:: +get_frame_buffer_mode() const { + nassertr(has_frame_buffer_mode(), false); + return _frame_buffer_mode; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::has_frame_buffer_mode +// Access: Published +// Description: Returns true if the frameBuffer mode has been +// specified, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +has_frame_buffer_mode() const { + return ((_specified & S_frame_buffer_mode) != 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::clear_frame_buffer_mode +// Access: Published +// Description: Removes the frameBuffer_mode specification from the +// properties. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +clear_frame_buffer_mode() { + _specified &= ~S_frame_buffer_mode; + _frame_buffer_mode = 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::set_depth_bits +// Access: Published +// Description: Specifies the minimum number of bits that are +// required for the depth buffer. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +set_depth_bits(int depth_bits) { + _depth_bits = depth_bits; + _specified |= S_depth_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_depth_bits +// Access: Published +// Description: Returns the number of bits specified for the depth +// buffer. +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_depth_bits() const { + return _depth_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::has_depth_bits +// Access: Published +// Description: Returns true if the number of bits for the depth +// buffer has been specified, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +has_depth_bits() const { + return ((_specified & S_depth_bits) != 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::clear_depth_bits +// Access: Published +// Description: Removes the depth_bits specification from the +// properties. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +clear_depth_bits() { + _specified &= ~S_depth_bits; + _depth_bits = 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::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 FrameBufferProperties:: +set_color_bits(int color_bits) { + _color_bits = color_bits; + _specified |= S_color_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::get_color_bits +// Access: Published +// Description: Returns the number of bits specified for the color +// buffer. +//////////////////////////////////////////////////////////////////// +INLINE int FrameBufferProperties:: +get_color_bits() const { + return _color_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::has_color_bits +// Access: Published +// Description: Returns true if the number of bits for the color +// buffer has been specified, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool FrameBufferProperties:: +has_color_bits() const { + return ((_specified & S_color_bits) != 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::clear_color_bits +// Access: Published +// Description: Removes the color_bits specification from the +// properties. +//////////////////////////////////////////////////////////////////// +INLINE void FrameBufferProperties:: +clear_color_bits() { + _specified &= ~S_color_bits; + _color_bits = 0; +} + +INLINE ostream & +operator << (ostream &out, const FrameBufferProperties &properties) { + properties.output(out); + return out; +} diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx new file mode 100644 index 0000000000..4d5e0d69fb --- /dev/null +++ b/panda/src/display/frameBufferProperties.cxx @@ -0,0 +1,151 @@ +// Filename: frameBufferProperties.cxx +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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 "frameBufferProperties.h" + + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +FrameBufferProperties:: +FrameBufferProperties() { + clear(); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::Copy Assignment Operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +void FrameBufferProperties:: +operator = (const FrameBufferProperties ©) { + _specified = copy._specified; + _flags = copy._flags; + _frame_buffer_mode = copy._frame_buffer_mode; + _depth_bits = copy._depth_bits; + _color_bits = copy._color_bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::operator == +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +bool FrameBufferProperties:: +operator == (const FrameBufferProperties &other) const { + return (_specified == other._specified && + _flags == other._flags && + _frame_buffer_mode == other._frame_buffer_mode && + _depth_bits == other._depth_bits && + _color_bits == other._color_bits); +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::clear +// Access: Published +// Description: Unsets all properties that have been specified so +// far, and resets the FrameBufferProperties structure to its +// initial empty state. +//////////////////////////////////////////////////////////////////// +void FrameBufferProperties:: +clear() { + _specified = 0; + _flags = 0; + _frame_buffer_mode = 0; + _depth_bits = 0; + _color_bits = 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: FrameBufferProperties::add_properties +// Access: Published +// Description: Sets any properties that are explicitly specified in +// other on this object. Leaves other properties +// unchanged. +//////////////////////////////////////////////////////////////////// +void FrameBufferProperties:: +add_properties(const FrameBufferProperties &other) { + if (other.has_frame_buffer_mode()) { + set_frame_buffer_mode(other.get_frame_buffer_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: FrameBufferProperties::output +// Access: Published +// Description: Sets any properties that are explicitly specified in +// other on this object. Leaves other properties +// unchanged. +//////////////////////////////////////////////////////////////////// +void FrameBufferProperties:: +output(ostream &out) const { + if (has_frame_buffer_mode()) { + out << "frameBuffer_mode="; + int frameBuffer_mode = get_frame_buffer_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() << " "; + } +} diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h new file mode 100644 index 0000000000..6bc7102451 --- /dev/null +++ b/panda/src/display/frameBufferProperties.h @@ -0,0 +1,107 @@ +// Filename: frameBufferProperties.h +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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 FRAMEBUFFERPROPERTIES_H +#define FRAMEBUFFERPROPERTIES_H + +#include "pandabase.h" + +//////////////////////////////////////////////////////////////////// +// Class : FrameBufferProperties +// Description : A container for the various kinds of properties we +// might ask to have on a graphics frameBuffer before we +// create a GSG. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA FrameBufferProperties { +PUBLISHED: + FrameBufferProperties(); + INLINE FrameBufferProperties(const FrameBufferProperties ©); + void operator = (const FrameBufferProperties ©); + INLINE ~FrameBufferProperties(); + + bool operator == (const FrameBufferProperties &other) const; + INLINE bool operator != (const FrameBufferProperties &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_frame_buffer_mode(int frameBuffer_mode); + INLINE int get_frame_buffer_mode() const; + INLINE bool has_frame_buffer_mode() const; + INLINE void clear_frame_buffer_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 FrameBufferProperties &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_frame_buffer_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 { + }; + */ + + int _specified; + int _flags; + int _frame_buffer_mode; + int _depth_bits; + int _color_bits; +}; + +INLINE ostream &operator << (ostream &out, const FrameBufferProperties &properties); + +#include "frameBufferProperties.I" + +#endif diff --git a/panda/src/display/graphicsThreadingModel.I b/panda/src/display/graphicsThreadingModel.I new file mode 100644 index 0000000000..6db71b20a6 --- /dev/null +++ b/panda/src/display/graphicsThreadingModel.I @@ -0,0 +1,119 @@ +// Filename: graphicsThreadingModel.I +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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: GraphicsThreadingModel::Copy Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE GraphicsThreadingModel:: +GraphicsThreadingModel(const GraphicsThreadingModel ©) : + _cull_name(copy._cull_name), + _draw_name(copy._draw_name), + _cull_sorting(copy._cull_sorting) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::Copy Assignment Operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void GraphicsThreadingModel:: +operator = (const GraphicsThreadingModel ©) { + _cull_name = copy._cull_name; + _draw_name = copy._draw_name; + _cull_sorting = copy._cull_sorting; +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::get_cull_name +// Access: Published +// Description: Returns the name of the thread that will handle +// culling in this model. +//////////////////////////////////////////////////////////////////// +INLINE const string &GraphicsThreadingModel:: +get_cull_name() const { + return _cull_name; +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::get_draw_name +// Access: Published +// Description: Returns the name of the thread that will handle +// sending the actual graphics primitives to the +// graphics API in this model. +//////////////////////////////////////////////////////////////////// +INLINE const string &GraphicsThreadingModel:: +get_draw_name() const { + return _draw_name; +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::get_cull_sorting +// Access: Published +// Description: Returns true if the model involves a separate cull +// pass, or false if culling happens implicitly, at the +// same time as draw. +//////////////////////////////////////////////////////////////////// +INLINE bool GraphicsThreadingModel:: +get_cull_sorting() const { + return _cull_sorting; +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::is_single_threaded +// Access: Published +// Description: Returns true if the threading model is a +// single-threaded model, or false if it involves +// threads. +//////////////////////////////////////////////////////////////////// +INLINE bool GraphicsThreadingModel:: +is_single_threaded() const { + return _cull_name.empty() && _draw_name.empty(); +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::is_default +// Access: Published +// Description: Returns true if the threading model is the default, +// cull-then-draw single-threaded model, or false +// otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool GraphicsThreadingModel:: +is_default() const { + return is_single_threaded() && _cull_sorting; +} + + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::output +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void GraphicsThreadingModel:: +output(ostream &out) const { + out << get_model(); +} + +INLINE ostream & +operator << (ostream &out, const GraphicsThreadingModel &threading_model) { + threading_model.output(out); + return out; +} diff --git a/panda/src/display/graphicsThreadingModel.cxx b/panda/src/display/graphicsThreadingModel.cxx new file mode 100644 index 0000000000..bd5423ad24 --- /dev/null +++ b/panda/src/display/graphicsThreadingModel.cxx @@ -0,0 +1,86 @@ +// Filename: graphicsThreadingModel.cxx +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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 "graphicsThreadingModel.h" + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::Constructor +// Access: Published +// Description: The threading model accepts a string representing the +// names of the two threads that will process cull and +// draw for the given window, separated by a slash. The +// names are completely arbitrary and are used only to +// differentiate threads. The two names may be the +// same, meaning the same thread, or each may be the +// empty string, which represents the previous thread. +// +// Thus, for example, "cull/draw" indicates that the +// window will be culled in a thread called "cull", and +// drawn in a separate thread called "draw". +// "draw/draw" or simply "draw/" indicates the window +// will be culled and drawn in the same thread, "draw". +// On the other hand, "/draw" indicates the thread will +// be culled in the main, or app thread, and drawn in a +// separate thread named "draw". The empty string, "" +// or "/", indicates the thread will be culled and drawn +// in the main thread; that is to say, a single-process +// model. +// +// Finally, if the threading model begins with a "-" +// character, then cull and draw are run simultaneously, +// in the same thread, with no binning or state sorting. +// It simplifies the cull process but it forces the +// scene to render in scene graph order; state sorting +// and alpha sorting is lost. +//////////////////////////////////////////////////////////////////// +GraphicsThreadingModel:: +GraphicsThreadingModel(const string &model) { + _cull_sorting = true; + size_t start = 0; + if (!model.empty() && model[0] == '-') { + start = 1; + _cull_sorting = false; + } + + size_t slash = model.find('/', start); + if (slash == string::npos) { + _cull_name = model; + } else { + _cull_name = model.substr(start, slash - start); + _draw_name = model.substr(slash + 1); + } + if (!_cull_sorting || _draw_name.empty()) { + _draw_name = _cull_name; + } +} + + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsThreadingModel::get_model +// Access: Published +// Description: Returns the string that describes the threading +// model. See the constructor. +//////////////////////////////////////////////////////////////////// +string GraphicsThreadingModel:: +get_model() const { + if (get_cull_sorting()) { + return get_cull_name() + "/" + get_draw_name(); + } else { + return string("-") + get_cull_name(); + } +} diff --git a/panda/src/display/graphicsThreadingModel.h b/panda/src/display/graphicsThreadingModel.h new file mode 100644 index 0000000000..6f2a112d29 --- /dev/null +++ b/panda/src/display/graphicsThreadingModel.h @@ -0,0 +1,54 @@ +// Filename: graphicsThreadingModel.h +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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 GRAPHICSTHREADINGMODEL_H +#define GRAPHICSTHREADINGMODEL_H + +#include "pandabase.h" + +//////////////////////////////////////////////////////////////////// +// Class : GraphicsThreadingModel +// Description : This represents the user's specification of how a +// particular frame is handled by the various threads. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA GraphicsThreadingModel { +PUBLISHED: + GraphicsThreadingModel(const string &model = string()); + INLINE GraphicsThreadingModel(const GraphicsThreadingModel ©); + INLINE void operator = (const GraphicsThreadingModel ©); + + string get_model() const; + INLINE const string &get_cull_name() const; + INLINE const string &get_draw_name() const; + INLINE bool get_cull_sorting() const; + + INLINE bool is_single_threaded() const; + INLINE bool is_default() const; + INLINE void output(ostream &out) const; + +private: + string _cull_name; + string _draw_name; + bool _cull_sorting; +}; + +INLINE ostream &operator << (ostream &out, const GraphicsThreadingModel &threading_model); + +#include "graphicsThreadingModel.I" + +#endif diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.I b/panda/src/glxdisplay/glxGraphicsStateGuardian.I new file mode 100644 index 0000000000..ccb78bb8e7 --- /dev/null +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.I @@ -0,0 +1,17 @@ +// Filename: glxGraphicsStateGuardian.I +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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 . +// +//////////////////////////////////////////////////////////////////// diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx new file mode 100644 index 0000000000..522e8c48a3 --- /dev/null +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -0,0 +1,54 @@ +// Filename: glxGraphicsStateGuardian.cxx +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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 "glxGraphicsStateGuardian.h" + + +TypeHandle glxGraphicsStateGuardian::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: glxGraphicsStateGuardian::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +glxGraphicsStateGuardian:: +glxGraphicsStateGuardian(const FrameBufferProperties &properties) : + GLGraphicsStateGuardian(properties) +{ + _context = (GLXContext)NULL; + _visual = (XVisualInfo *)NULL; + _display = NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: glxGraphicsStateGuardian::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +glxGraphicsStateGuardian:: +~glxGraphicsStateGuardian() { + if (_visual != (XVisualInfo *)NULL) { + XFree(_visual); + _visual = (XVisualInfo *)NULL; + } + + if (_context != (GLXContext)NULL) { + glXDestroyContext(_display, _context); + _context = (GLXContext)NULL; + } +} diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.h b/panda/src/glxdisplay/glxGraphicsStateGuardian.h new file mode 100644 index 0000000000..fc2b849587 --- /dev/null +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.h @@ -0,0 +1,63 @@ +// Filename: glxGraphicsStateGuardian.h +// Created by: drose (27Jan03) +// +//////////////////////////////////////////////////////////////////// +// +// 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 GLXGRAPHICSSTATEGUARDIAN_H +#define GLXGRAPHICSSTATEGUARDIAN_H + +#include "pandabase.h" + +#include "glGraphicsStateGuardian.h" + +#include +#include + +//////////////////////////////////////////////////////////////////// +// Class : glxGraphicsStateGuardian +// Description : A tiny specialization on GLGraphicsStateGuardian to +// add some glx-specific information. +//////////////////////////////////////////////////////////////////// +class glxGraphicsStateGuardian : public GLGraphicsStateGuardian { +public: + glxGraphicsStateGuardian(const FrameBufferProperties &properties); + virtual ~glxGraphicsStateGuardian(); + + GLXContext _context; + XVisualInfo *_visual; + Display *_display; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + GLGraphicsStateGuardian::init_type(); + register_type(_type_handle, "glxGraphicsStateGuardian", + GLGraphicsStateGuardian::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 "glxGraphicsStateGuardian.I" + +#endif