mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
define mesadisplay
This commit is contained in:
parent
8c873de8a9
commit
be50ac2d73
@ -12,7 +12,7 @@
|
|||||||
// We don't have any components if we're linking the GL library
|
// We don't have any components if we're linking the GL library
|
||||||
// directly into Panda.
|
// directly into Panda.
|
||||||
#define COMPONENT_LIBS \
|
#define COMPONENT_LIBS \
|
||||||
glgsg glxdisplay \
|
glgsg glxdisplay mesadisplay \
|
||||||
wgldisplay
|
wgldisplay
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
22
panda/src/mesadisplay/Sources.pp
Normal file
22
panda/src/mesadisplay/Sources.pp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#define BUILD_DIRECTORY $[HAVE_MESA]
|
||||||
|
|
||||||
|
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||||
|
dtoolutil:c dtoolbase:c dtool:m
|
||||||
|
#define USE_PACKAGES gl mesa
|
||||||
|
|
||||||
|
#begin lib_target
|
||||||
|
#define TARGET mesadisplay
|
||||||
|
#define LOCAL_LIBS \
|
||||||
|
glgsg
|
||||||
|
|
||||||
|
#define SOURCES \
|
||||||
|
config_mesadisplay.cxx config_mesadisplay.h \
|
||||||
|
mesaGraphicsBuffer.I mesaGraphicsBuffer.cxx mesaGraphicsBuffer.h \
|
||||||
|
mesaGraphicsPipe.I mesaGraphicsPipe.cxx mesaGraphicsPipe.h \
|
||||||
|
mesaGraphicsStateGuardian.h mesaGraphicsStateGuardian.cxx \
|
||||||
|
mesaGraphicsStateGuardian.I
|
||||||
|
|
||||||
|
#define IGATESCAN mesaGraphicsPipe.h
|
||||||
|
|
||||||
|
#end lib_target
|
||||||
|
|
57
panda/src/mesadisplay/config_mesadisplay.cxx
Normal file
57
panda/src/mesadisplay/config_mesadisplay.cxx
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Filename: config_mesadisplay.cxx
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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_mesadisplay.h"
|
||||||
|
#include "mesaGraphicsBuffer.h"
|
||||||
|
#include "mesaGraphicsPipe.h"
|
||||||
|
#include "mesaGraphicsStateGuardian.h"
|
||||||
|
#include "graphicsPipeSelection.h"
|
||||||
|
#include "dconfig.h"
|
||||||
|
|
||||||
|
Configure(config_mesadisplay);
|
||||||
|
NotifyCategoryDef(mesadisplay, "display");
|
||||||
|
|
||||||
|
ConfigureFn(config_mesadisplay) {
|
||||||
|
init_libmesadisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: init_libmesadisplay
|
||||||
|
// 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_libmesadisplay() {
|
||||||
|
static bool initialized = false;
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
MesaGraphicsBuffer::init_type();
|
||||||
|
MesaGraphicsPipe::init_type();
|
||||||
|
MesaGraphicsStateGuardian::init_type();
|
||||||
|
|
||||||
|
cerr << "Adding MesaGraphicsPipe\n";
|
||||||
|
GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
|
||||||
|
selection->add_pipe_type(MesaGraphicsPipe::get_class_type(),
|
||||||
|
MesaGraphicsPipe::pipe_constructor);
|
||||||
|
}
|
29
panda/src/mesadisplay/config_mesadisplay.h
Normal file
29
panda/src/mesadisplay/config_mesadisplay.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Filename: config_mesadisplay.h
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 CONFIG_MESADISPLAY_H
|
||||||
|
#define CONFIG_MESADISPLAY_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "notifyCategoryProxy.h"
|
||||||
|
|
||||||
|
NotifyCategoryDecl(mesadisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
|
||||||
|
|
||||||
|
extern EXPCL_PANDAGL void init_libmesadisplay();
|
||||||
|
|
||||||
|
#endif
|
18
panda/src/mesadisplay/mesaGraphicsBuffer.I
Normal file
18
panda/src/mesadisplay/mesaGraphicsBuffer.I
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Filename: mesaGraphicsBuffer.I
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
115
panda/src/mesadisplay/mesaGraphicsBuffer.cxx
Normal file
115
panda/src/mesadisplay/mesaGraphicsBuffer.cxx
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
// Filename: mesaGraphicsBuffer.cxx
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "mesaGraphicsBuffer.h"
|
||||||
|
#include "config_mesadisplay.h"
|
||||||
|
#include "mesaGraphicsPipe.h"
|
||||||
|
#include "mesaGraphicsStateGuardian.h"
|
||||||
|
|
||||||
|
TypeHandle MesaGraphicsBuffer::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsBuffer::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
MesaGraphicsBuffer::
|
||||||
|
MesaGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
|
||||||
|
int x_size, int y_size, bool want_texture) :
|
||||||
|
GraphicsBuffer(pipe, gsg, x_size, y_size, want_texture)
|
||||||
|
{
|
||||||
|
_type = GL_UNSIGNED_BYTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsBuffer::Destructor
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
MesaGraphicsBuffer::
|
||||||
|
~MesaGraphicsBuffer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsBuffer::make_current
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This function will be called within the draw thread
|
||||||
|
// during begin_frame() to ensure the graphics context
|
||||||
|
// is ready for drawing.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void MesaGraphicsBuffer::
|
||||||
|
make_current() {
|
||||||
|
MesaGraphicsStateGuardian *mesagsg;
|
||||||
|
DCAST_INTO_V(mesagsg, _gsg);
|
||||||
|
OSMesaMakeCurrent(mesagsg->_context, _image.p(), _type,
|
||||||
|
_x_size, _y_size);
|
||||||
|
|
||||||
|
mesagsg->reset_if_new();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsBuffer::begin_flip
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This function will be called within the draw thread
|
||||||
|
// after end_frame() has been called on all windows, to
|
||||||
|
// initiate the exchange of the front and back buffers.
|
||||||
|
//
|
||||||
|
// This should instruct the window to prepare for the
|
||||||
|
// flip at the next video sync, but it should not wait.
|
||||||
|
//
|
||||||
|
// We have the two separate functions, begin_flip() and
|
||||||
|
// end_flip(), to make it easier to flip all of the
|
||||||
|
// windows at the same time.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void MesaGraphicsBuffer::
|
||||||
|
begin_flip() {
|
||||||
|
if (has_texture()) {
|
||||||
|
// Use glCopyTexImage2D to copy the framebuffer to the texture.
|
||||||
|
// This appears to be the only way to "render to a texture" in
|
||||||
|
// OpenGL; there's no interface to make the offscreen buffer
|
||||||
|
// itself be a texture.
|
||||||
|
DisplayRegion dr(_x_size, _y_size);
|
||||||
|
get_texture()->copy(_gsg, &dr, _gsg->get_render_buffer(RenderBuffer::T_back));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsBuffer::close_buffer
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Closes the buffer right now. Called from the window
|
||||||
|
// thread.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void MesaGraphicsBuffer::
|
||||||
|
close_buffer() {
|
||||||
|
_image.clear();
|
||||||
|
_is_valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsBuffer::open_buffer
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Opens the buffer right now. Called from the window
|
||||||
|
// thread. Returns true if the buffer is successfully
|
||||||
|
// opened, or false if there was a problem.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool MesaGraphicsBuffer::
|
||||||
|
open_buffer() {
|
||||||
|
_image = PTA_uchar::empty_array(_x_size * _y_size * 4);
|
||||||
|
_is_valid = true;
|
||||||
|
return true;
|
||||||
|
}
|
72
panda/src/mesadisplay/mesaGraphicsBuffer.h
Normal file
72
panda/src/mesadisplay/mesaGraphicsBuffer.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
// Filename: mesaGraphicsBuffer.h
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 MESAGRAPHICSBUFFER_H
|
||||||
|
#define MESAGRAPHICSBUFFER_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
|
||||||
|
#include "mesaGraphicsPipe.h"
|
||||||
|
#include "graphicsBuffer.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : MesaGraphicsBuffer
|
||||||
|
// Description : An offscreen buffer using direct calls to Mesa. This
|
||||||
|
// is the only kind of graphics output supported by
|
||||||
|
// osmesa.h.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class MesaGraphicsBuffer : public GraphicsBuffer {
|
||||||
|
public:
|
||||||
|
MesaGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
|
||||||
|
int x_size, int y_size, bool want_texture);
|
||||||
|
|
||||||
|
virtual ~MesaGraphicsBuffer();
|
||||||
|
|
||||||
|
virtual void make_current();
|
||||||
|
|
||||||
|
virtual void begin_flip();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void close_buffer();
|
||||||
|
virtual bool open_buffer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
GLenum _type;
|
||||||
|
PTA_uchar _image;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
GraphicsBuffer::init_type();
|
||||||
|
register_type(_type_handle, "MesaGraphicsBuffer",
|
||||||
|
GraphicsBuffer::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 "mesaGraphicsBuffer.I"
|
||||||
|
|
||||||
|
#endif
|
18
panda/src/mesadisplay/mesaGraphicsPipe.I
Normal file
18
panda/src/mesadisplay/mesaGraphicsPipe.I
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Filename: mesaGraphicsPipe.I
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
95
panda/src/mesadisplay/mesaGraphicsPipe.cxx
Normal file
95
panda/src/mesadisplay/mesaGraphicsPipe.cxx
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
// Filename: mesaGraphicsPipe.cxx
|
||||||
|
// Created by: mike (09Jan97)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "mesaGraphicsPipe.h"
|
||||||
|
#include "mesaGraphicsBuffer.h"
|
||||||
|
#include "mesaGraphicsStateGuardian.h"
|
||||||
|
#include "config_mesadisplay.h"
|
||||||
|
#include "frameBufferProperties.h"
|
||||||
|
#include "mutexHolder.h"
|
||||||
|
|
||||||
|
TypeHandle MesaGraphicsPipe::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsPipe::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
MesaGraphicsPipe::
|
||||||
|
MesaGraphicsPipe() {
|
||||||
|
_supported_types = OT_buffer;
|
||||||
|
_is_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsPipe::Destructor
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
MesaGraphicsPipe::
|
||||||
|
~MesaGraphicsPipe() {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsPipe::get_interface_name
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Returns the name of the rendering interface
|
||||||
|
// associated with this GraphicsPipe. This is used to
|
||||||
|
// present to the user to allow him/her to choose
|
||||||
|
// between several possible GraphicsPipes available on a
|
||||||
|
// particular platform, so the name should be meaningful
|
||||||
|
// and unique for a given platform.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string MesaGraphicsPipe::
|
||||||
|
get_interface_name() const {
|
||||||
|
return "Offscreen Mesa";
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsPipe::pipe_constructor
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: This function is passed to the GraphicsPipeSelection
|
||||||
|
// object to allow the user to make a default
|
||||||
|
// MesaGraphicsPipe.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(GraphicsPipe) MesaGraphicsPipe::
|
||||||
|
pipe_constructor() {
|
||||||
|
return new MesaGraphicsPipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsPipe::make_gsg
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Creates a new GSG to use the pipe (but no windows
|
||||||
|
// have been created yet for the GSG). This method will
|
||||||
|
// be called in the draw thread for the GSG.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(GraphicsStateGuardian) MesaGraphicsPipe::
|
||||||
|
make_gsg(const FrameBufferProperties &properties) {
|
||||||
|
return new MesaGraphicsStateGuardian(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsPipe::make_buffer
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Creates a new offscreen buffer on the pipe, if possible.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(GraphicsBuffer) MesaGraphicsPipe::
|
||||||
|
make_buffer(GraphicsStateGuardian *gsg, int x_size, int y_size, bool want_texture) {
|
||||||
|
return new MesaGraphicsBuffer(this, gsg, x_size, y_size, want_texture);
|
||||||
|
}
|
76
panda/src/mesadisplay/mesaGraphicsPipe.h
Normal file
76
panda/src/mesadisplay/mesaGraphicsPipe.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
// Filename: mesaGraphicsPipe.h
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 MESAGRAPHICSPIPE_H
|
||||||
|
#define MESAGRAPHICSPIPE_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "graphicsWindow.h"
|
||||||
|
#include "graphicsPipe.h"
|
||||||
|
|
||||||
|
#include <GL/osmesa.h>
|
||||||
|
|
||||||
|
class FrameBufferProperties;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : MesaGraphicsPipe
|
||||||
|
// Description : This graphics pipe represents the interface for
|
||||||
|
// rendering with direct calls to the Mesa open-source
|
||||||
|
// software-only implementation of OpenGL.
|
||||||
|
//
|
||||||
|
// Raw Mesa supports only offscreen buffers, but it's
|
||||||
|
// possible to create and render into these offscreen
|
||||||
|
// buffers without having any X server or other
|
||||||
|
// operating system infrastructure in place.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class MesaGraphicsPipe : public GraphicsPipe {
|
||||||
|
public:
|
||||||
|
MesaGraphicsPipe();
|
||||||
|
virtual ~MesaGraphicsPipe();
|
||||||
|
|
||||||
|
virtual string get_interface_name() const;
|
||||||
|
static PT(GraphicsPipe) pipe_constructor();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties);
|
||||||
|
virtual PT(GraphicsBuffer) make_buffer(GraphicsStateGuardian *gsg,
|
||||||
|
int x_size, int y_size, bool want_texture);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
GraphicsPipe::init_type();
|
||||||
|
register_type(_type_handle, "MesaGraphicsPipe",
|
||||||
|
GraphicsPipe::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 "mesaGraphicsPipe.I"
|
||||||
|
|
||||||
|
#endif
|
17
panda/src/mesadisplay/mesaGraphicsStateGuardian.I
Normal file
17
panda/src/mesadisplay/mesaGraphicsStateGuardian.I
Normal file
@ -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 .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
46
panda/src/mesadisplay/mesaGraphicsStateGuardian.cxx
Normal file
46
panda/src/mesadisplay/mesaGraphicsStateGuardian.cxx
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Filename: mesaGraphicsStateGuardian.cxx
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "mesaGraphicsStateGuardian.h"
|
||||||
|
|
||||||
|
TypeHandle MesaGraphicsStateGuardian::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsStateGuardian::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
MesaGraphicsStateGuardian::
|
||||||
|
MesaGraphicsStateGuardian(const FrameBufferProperties &properties) :
|
||||||
|
GLGraphicsStateGuardian(properties)
|
||||||
|
{
|
||||||
|
_context = OSMesaCreateContext(OSMESA_RGBA, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MesaGraphicsStateGuardian::Destructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
MesaGraphicsStateGuardian::
|
||||||
|
~MesaGraphicsStateGuardian() {
|
||||||
|
if (_context != (OSMesaContext)NULL) {
|
||||||
|
OSMesaDestroyContext(_context);
|
||||||
|
_context = (OSMesaContext)NULL;
|
||||||
|
}
|
||||||
|
}
|
59
panda/src/mesadisplay/mesaGraphicsStateGuardian.h
Normal file
59
panda/src/mesadisplay/mesaGraphicsStateGuardian.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Filename: mesaGraphicsStateGuardian.h
|
||||||
|
// Created by: drose (09Feb04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 MESAGRAPHICSSTATEGUARDIAN_H
|
||||||
|
#define MESAGRAPHICSSTATEGUARDIAN_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
|
||||||
|
#include "glGraphicsStateGuardian.h"
|
||||||
|
#include "mesaGraphicsPipe.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : MesaGraphicsStateGuardian
|
||||||
|
// Description : A tiny specialization on GLGraphicsStateGuardian to
|
||||||
|
// add some Mesa-specific information.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class MesaGraphicsStateGuardian : public GLGraphicsStateGuardian {
|
||||||
|
public:
|
||||||
|
MesaGraphicsStateGuardian(const FrameBufferProperties &properties);
|
||||||
|
virtual ~MesaGraphicsStateGuardian();
|
||||||
|
|
||||||
|
OSMesaContext _context;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
GLGraphicsStateGuardian::init_type();
|
||||||
|
register_type(_type_handle, "MesaGraphicsStateGuardian",
|
||||||
|
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 "mesaGraphicsStateGuardian.I"
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user