Delete MesaGL renderer, it seems not to be used any more

This commit is contained in:
rdb
2014-06-18 14:59:11 +00:00
parent e4747ebf50
commit c33ef307d6
22 changed files with 7 additions and 963 deletions

View File

@@ -653,40 +653,6 @@
// space (instead of a dot). Thus, "1 1" means OpenGL version 1.1.
#define MIN_GL_VERSION 1 1
// Is Mesa installed separately from OpenGL? Mesa is an open-source
// software-only OpenGL renderer. Panda can link with it
// independently from OpenGL (and if Mesa is built statically, and/or
// with -DUSE_MGL_NAMESPACE declared to rename gl* to mgl*, it can
// switch between the system OpenGL implementation and the Mesa
// implementation at runtime).
// Also, Mesa includes some core libraries (in libOSMesa.so) that
// allow totally headless rendering, handy if you want to run a
// renderer as a batch service, and you don't want to insist that a
// user be logged on to the desktop or otherwise deal with X11 or
// Windows.
// If you define HAVE_MESA here, and the appropriate paths to headers
// and libraries, then Panda will build libmesadisplay, which can be
// used in lieu of libpandagl or libpandadx to do rendering. However,
// for most applications, you don't need to do this, since (a) if you
// have hardware rendering capability, you probably don't want to use
// Mesa, since it's software-only, and (b) if you don't have hardware
// rendering, you can install Mesa as the system's OpenGL
// implementation, so you can just use the normal libpandagl. You
// only need to define HAVE_MESA if you want to run totally headless,
// or if you want to be able to easily switch between Mesa and the
// system OpenGL implementation at runtime. If you compiled Mesa with
// USE_MGL_NAMESPACE defined, define MESA_MGL here.
#define MESA_IPATH
#define MESA_LPATH
#define MESA_LIBS
#define MESA_MGL
#defer HAVE_MESA $[libtest $[MESA_LPATH],$[MESA_LIBS]]
// Similar to MIN_GL_VERSION, above.
#define MIN_MESA_VERSION 1 1
// Do you want to build tinydisplay, a light and fast software
// renderer built into Panda, based on TinyGL? This isn't as
// full-featured as Mesa, but it is many times faster, and in fact

View File

@@ -176,11 +176,6 @@
#else
#print - Did not find X11
#endif
#if $[HAVE_MESA]
#print + Mesa
#else
#print - Did not find Mesa
#endif
#if $[HAVE_OPENCV]
#print + OpenCV
#else
@@ -437,14 +432,6 @@ $[cdefine HAVE_ODE]
/* Define if we have AWESOMIUM installed and want to build for AWESOMIUM. */
$[cdefine HAVE_AWESOMIUM]
/* Define if we have Mesa installed and want to build mesadisplay. */
$[cdefine HAVE_MESA]
$[cdefine MESA_MGL]
#if HAVE_MESA
# define MIN_MESA_VERSION_MAJOR $[word 1,$[MIN_MESA_VERSION]]
# define MIN_MESA_VERSION_MINOR $[word 2,$[MIN_MESA_VERSION]]
#endif
/* Define if we have GLX installed and want to build for GLX. */
$[cdefine HAVE_GLX]

View File

@@ -236,12 +236,6 @@
#set GLES2_LIBS $[GLES2_LIBS]
#set HAVE_GLES2 $[HAVE_GLES2]
#set MESA_IPATH $[unixfilename $[MESA_IPATH]]
#set MESA_LPATH $[unixfilename $[MESA_LPATH]]
#set MESA_LIBS $[MESA_LIBS]
#set MESA_MGL $[MESA_MGL]
#set HAVE_MESA $[HAVE_MESA]
#set GLX_IPATH $[unixfilename $[GLX_IPATH]]
#set GLX_LPATH $[unixfilename $[GLX_LPATH]]
#set HAVE_GLX $[HAVE_GLX]

View File

@@ -185,13 +185,6 @@
#define xcursor_libs $[XCURSOR_LIBS]
#endif
#if $[HAVE_MESA]
#define mesa_ipath $[wildcard $[MESA_IPATH]]
#define mesa_lpath $[wildcard $[MESA_LPATH]]
#define mesa_cflags $[MESA_CFLAGS]
#define mesa_libs $[MESA_LIBS]
#endif
#if $[HAVE_GLX]
#define glx_ipath $[wildcard $[GLX_IPATH]]
#define glx_lpath $[wildcard $[GLX_LPATH]]

View File

@@ -92,7 +92,7 @@ PkgListSet(["PYTHON", "DIRECT", # Python support
"GTK2", "WX", "FLTK", # Toolkit support
"ROCKET", # GUI libraries
"CARBON", "COCOA", # Mac OS X toolkits
"OSMESA", "X11", "XF86DGA", "XRANDR", "XCURSOR", # Unix platform support
"X11", "XF86DGA", "XRANDR", "XCURSOR", # Unix platform support
"PANDATOOL", "PVIEW", "DEPLOYTOOLS", # Toolchain
"SKEL", # Example SKEL project
"PANDAFX", # Some distortion special lenses
@@ -697,7 +697,6 @@ if (COMPILER=="GCC"):
SmartPkgEnable("GLES", "glesv1_cm", ("GLESv1_CM"), ("GLES/gl.h"), framework = "OpenGLES")
SmartPkgEnable("GLES2", "glesv2", ("GLESv2"), ("GLES2/gl2.h")) #framework = "OpenGLES"?
SmartPkgEnable("EGL", "egl", ("EGL"), ("EGL/egl.h"))
SmartPkgEnable("OSMESA", "osmesa", ("OSMesa"), ("GL/osmesa.h"))
SmartPkgEnable("NVIDIACG", "", ("Cg"), "Cg/cg.h", framework = "Cg")
SmartPkgEnable("ODE", "", ("ode"), "ode/ode.h", tool = "ode-config")
SmartPkgEnable("OPENAL", "openal", ("openal"), "AL/al.h", framework = "OpenAL")
@@ -1901,9 +1900,6 @@ DTOOL_CONFIG=[
("HAVE_GL", '1', 'UNDEF'),
("HAVE_GLES", 'UNDEF', 'UNDEF'),
("HAVE_GLES2", 'UNDEF', 'UNDEF'),
("HAVE_MESA", 'UNDEF', 'UNDEF'),
("MESA_MGL", 'UNDEF', 'UNDEF'),
("HAVE_SGIGL", 'UNDEF', 'UNDEF'),
("HAVE_GLX", 'UNDEF', '1'),
("HAVE_EGL", 'UNDEF', 'UNDEF'),
("HAVE_WGL", '1', 'UNDEF'),
@@ -4035,20 +4031,6 @@ if (not RUNTIME):
TargetAdd('egg.pyd', input=COMMON_PANDA_LIBS)
TargetAdd('egg.pyd', opts=['PYTHON'])
#
# DIRECTORY: panda/src/mesadisplay/
#
if (GetTarget() != 'windows' and PkgSkip("GL")==0 and PkgSkip("OSMESA")==0 and not RUNTIME):
OPTS=['DIR:panda/src/mesadisplay', 'DIR:panda/src/glstuff', 'BUILDING:PANDAMESA', 'NVIDIACG', 'GL', 'OSMESA']
TargetAdd('p3mesadisplay_composite1.obj', opts=OPTS, input='p3mesadisplay_composite1.cxx')
OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAMESA', 'NVIDIACG', 'GL']
TargetAdd('libpandamesa.dll', input='p3mesadisplay_composite1.obj')
if (PkgSkip('PANDAFX')==0):
TargetAdd('libpandamesa.dll', input='libpandafx.dll')
TargetAdd('libpandamesa.dll', input=COMMON_PANDA_LIBS)
TargetAdd('libpandamesa.dll', opts=['MODULE', 'GL', 'OSMESA'])
#
# DIRECTORY: panda/src/x11display/
#

View File

@@ -793,11 +793,6 @@ reset() {
_supports_multitexture = false;
_supports_mesa_6 = false;
if (_gl_version.find("Mesa 6.",0) != string::npos) {
_supports_mesa_6 = true;
}
#ifdef OPENGLES
_supports_tex_non_pow2 =
has_extension("GL_OES_texture_npot");
@@ -1588,6 +1583,7 @@ reset() {
// Check availability of image read/write functionality in shaders.
_max_image_units = 0;
#ifndef OPENGLES
if (is_at_least_gl_version(4, 2) || has_extension("GL_ARB_shader_image_load_store")) {
_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)
get_extension_func(GLPREFIX_QUOTED, "BindImageTexture");
@@ -1600,6 +1596,7 @@ reset() {
GLP(GetIntegerv)(GL_MAX_IMAGE_UNITS_EXT, &_max_image_units);
}
#endif
// Check availability of multi-bind functions.
_supports_multi_bind = false;
@@ -1865,8 +1862,6 @@ reset() {
vertex_profile = cgGLGetLatestProfile(CG_GL_VERTEX);
pixel_profile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
if (GLCAT.is_debug()) {
// Temp ifdef: this crashes Mesa.
#ifndef OSMESA_MAJOR_VERSION
#if CG_VERSION_NUM >= 2200
GLCAT.debug() << "Supported Cg profiles:\n";
int num_profiles = cgGetNumSupportedProfiles();
@@ -1883,7 +1878,6 @@ reset() {
<< "\nCg pixel profile = " << cgGetProfileString(pixel_profile) << " id = " << pixel_profile
<< "\nshader model = " << _shader_model
<< "\n";
#endif
}
#endif
@@ -2588,10 +2582,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
// extra vertex arrays used by the previous rendering mode.
#ifdef SUPPORT_IMMEDIATE_MODE
_use_sender = !vertex_arrays;
// This is a workaround for a bug in Mesa 6 vertex array handling.
if ((_supports_mesa_6) && (_current_properties->get_force_software())) {
_use_sender = true;
}
#endif
#ifdef OPENGLES_1
@@ -9685,10 +9675,8 @@ get_texture_memory_size(Texture *tex) {
GLP(GetTexLevelParameteriv)(page_target, 0,
GL_TEXTURE_INTENSITY_SIZE, &intensity_size);
if (_supports_depth_texture) {
// Actually, this seems to cause problems on some Mesa versions,
// even though they advertise GL_ARB_depth_texture. Who needs it.
// GLP(GetTexLevelParameteriv)(page_target, 0,
// GL_TEXTURE_DEPTH_SIZE, &depth_size);
GLP(GetTexLevelParameteriv)(page_target, 0,
GL_TEXTURE_DEPTH_SIZE, &depth_size);
}
GLint width = 1, height = 1, depth = 1;
@@ -9794,10 +9782,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
#endif
}
GLP(GetTexParameteriv)(target, GL_TEXTURE_MIN_FILTER, &minfilter);
// Mesa has a bug querying this property.
magfilter = GL_LINEAR;
// GLP(GetTexParameteriv)(target, GL_TEXTURE_MAG_FILTER, &magfilter);
GLP(GetTexParameteriv)(target, GL_TEXTURE_MAG_FILTER, &magfilter);
#ifndef OPENGLES
GLP(GetTexParameterfv)(target, GL_TEXTURE_BORDER_COLOR, border_color);

View File

@@ -581,8 +581,7 @@ public:
bool _supports_bgr;
bool _supports_rescale_normal;
bool _supports_mesa_6;
bool _supports_multitexture;
PFNGLACTIVETEXTUREPROC _glActiveTexture;
PFNGLCLIENTACTIVETEXTUREPROC _glClientActiveTexture;

View File

@@ -1,23 +0,0 @@
#define BUILD_DIRECTORY $[HAVE_MESA]
#define BUILDING_DLL BUILDING_PANDAMESA
#define OTHER_LIBS p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m
#define USE_PACKAGES mesa cg cggl
#begin lib_target
#define TARGET p3mesadisplay
#define LOCAL_LIBS \
p3glstuff p3gsgbase p3gobj p3display \
p3putil p3linmath p3mathutil p3pnmimage
#define SOURCES \
config_mesadisplay.cxx config_mesadisplay.h \
mesagsg.h mesagsg.cxx \
osMesaGraphicsBuffer.I osMesaGraphicsBuffer.cxx osMesaGraphicsBuffer.h \
osMesaGraphicsPipe.I osMesaGraphicsPipe.cxx osMesaGraphicsPipe.h \
osMesaGraphicsStateGuardian.h osMesaGraphicsStateGuardian.cxx \
osMesaGraphicsStateGuardian.I
#end lib_target

View File

@@ -1,65 +0,0 @@
// Filename: config_mesadisplay.cxx
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "config_mesadisplay.h"
#include "osMesaGraphicsBuffer.h"
#include "osMesaGraphicsPipe.h"
#include "osMesaGraphicsStateGuardian.h"
#include "graphicsPipeSelection.h"
#include "dconfig.h"
#include "mesagsg.h"
ConfigureDef(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;
OsMesaGraphicsBuffer::init_type();
OsMesaGraphicsPipe::init_type();
OSMesaGraphicsStateGuardian::init_type();
GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
selection->add_pipe_type(OsMesaGraphicsPipe::get_class_type(),
OsMesaGraphicsPipe::pipe_constructor);
Mesainit_classes();
}
////////////////////////////////////////////////////////////////////
// Function: get_pipe_type_mesadisplay
// Description: Returns the TypeHandle index of the recommended
// graphics pipe type defined by this module.
////////////////////////////////////////////////////////////////////
int
get_pipe_type_mesadisplay() {
return OsMesaGraphicsPipe::get_class_type().get_index();
}

View File

@@ -1,28 +0,0 @@
// Filename: config_mesadisplay.h
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef CONFIG_MESADISPLAY_H
#define CONFIG_MESADISPLAY_H
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include "dconfig.h"
ConfigureDecl(config_mesadisplay, EXPCL_PANDAMESA, EXPTP_PANDAMESA);
NotifyCategoryDecl(mesadisplay, EXPCL_PANDAMESA, EXPTP_PANDAMESA);
extern EXPCL_PANDAMESA void init_libmesadisplay();
extern "C" EXPCL_PANDAMESA int get_pipe_type_mesadisplay();
#endif

View File

@@ -1,20 +0,0 @@
// Filename: mesagsg.cxx
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
// This is the actual .cxx file to include if you want to pick up
// any or all of the header files in this directory as compiled to use
// the Mesa library.
#include "mesagsg.h"
#include "glstuff_src.cxx"

View File

@@ -1,103 +0,0 @@
// Filename: mesagsg.h
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef MESAGSG_H
#define MESAGSG_H
// This is the actual header file to include if you want to pick up
// any or all of the header files in this directory as compiled to use
// the Mesa library.
#include "pandabase.h"
#include "config_mesadisplay.h"
// This stuff seems to crash with Mesa.
#undef HAVE_CG
#undef HAVE_CGGL
#ifdef MESA_MGL
#define GLP(name) mgl##name
#ifndef STDFLOAT_DOUBLE
#define GLPf(name) mgl ## name ## f
#define GLPfv(name) mgl ## name ## fv
#else // STDFLOAT_DOUBLE
#define GLPf(name) mgl ## name ## d
#define GLPfv(name) mgl ## name ## dv
#endif // STDFLOAT_DOUBLE
#define GLPREFIX_QUOTED "mgl"
#define USE_MGL_NAMESPACE 1
#else // MESA_MGL
#ifndef STDFLOAT_DOUBLE
#define GLPf(name) gl ## name ## f
#define GLPfv(name) gl ## name ## fv
#else // STDFLOAT_DOUBLE
#define GLPf(name) gl ## name ## d
#define GLPfv(name) gl ## name ## dv
#endif // STDFLOAT_DOUBLE
#define GLP(name) gl##name
#define GLPREFIX_QUOTED "gl"
#endif // MESA_MGL
#define CLP(name) Mesa##name
#define CLASSPREFIX_QUOTED "Mesa"
#define GLSYSTEM_NAME "Mesa"
#define CONFIGOBJ config_mesadisplay
#define GLCAT mesadisplay_cat
#define EXPCL_GL EXPCL_PANDAMESA
#define EXPTP_GL EXPTP_PANDAMESA
#if MIN_MESA_VERSION_MAJOR > 1 || (MIN_MESA_VERSION_MAJOR == 1 && MIN_MESA_VERSION_MINOR >= 2)
#define EXPECT_GL_VERSION_1_2
#endif
#if MIN_MESA_VERSION_MAJOR > 1 || (MIN_MESA_VERSION_MAJOR == 1 && MIN_MESA_VERSION_MINOR >= 3)
#define EXPECT_GL_VERSION_1_3
#endif
#if MIN_MESA_VERSION_MAJOR > 1 || (MIN_MESA_VERSION_MAJOR == 1 && MIN_MESA_VERSION_MINOR >= 4)
#define EXPECT_GL_VERSION_1_4
#endif
#if MIN_MESA_VERSION_MAJOR > 1 || (MIN_MESA_VERSION_MAJOR == 1 && MIN_MESA_VERSION_MINOR >= 5)
#define EXPECT_GL_VERSION_1_5
#endif
#if MIN_MESA_VERSION_MAJOR > 2 || (MIN_MESA_VERSION_MAJOR == 2 && MIN_MESA_VERSION_MINOR >= 0)
#define EXPECT_GL_VERSION_2_0
#endif
#if MIN_MESA_VERSION_MAJOR > 2 || (MIN_MESA_VERSION_MAJOR == 2 && MIN_MESA_VERSION_MINOR >= 1)
#define EXPECT_GL_VERSION_2_1
#endif
// This prevents glext.h from getting included by gl.h
// That way, we can provide our own, better version.
#define __glext_h_
#define GL_GLEXT_VERSION 0
#include <GL/gl.h>
#include <GL/osmesa.h>
#undef GL_GLEXT_VERSION
#include "panda_glext.h"
#include "glstuff_src.h"
#endif // MESAGSG_H

View File

@@ -1,14 +0,0 @@
// Filename: osMesaGraphicsBuffer.I
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////

View File

@@ -1,153 +0,0 @@
// Filename: osMesaGraphicsBuffer.cxx
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "osMesaGraphicsBuffer.h"
#include "config_mesadisplay.h"
#include "osMesaGraphicsPipe.h"
#include "osMesaGraphicsStateGuardian.h"
TypeHandle OsMesaGraphicsBuffer::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsBuffer::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
OsMesaGraphicsBuffer::
OsMesaGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
const string &name,
const FrameBufferProperties &fb_prop,
const WindowProperties &win_prop,
int flags,
GraphicsStateGuardian *gsg,
GraphicsOutput *host) :
GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
{
_type = GL_UNSIGNED_BYTE;
_screenshot_buffer_type = _draw_buffer_type;
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsBuffer::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
OsMesaGraphicsBuffer::
~OsMesaGraphicsBuffer() {
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsBuffer::begin_frame
// Access: Public, Virtual
// Description: This function will be called within the draw thread
// before beginning rendering for a given frame. It
// should do whatever setup is required, and return true
// if the frame should be rendered, or false if it
// should be skipped.
////////////////////////////////////////////////////////////////////
bool OsMesaGraphicsBuffer::
begin_frame(FrameMode mode, Thread *current_thread) {
begin_frame_spam(mode);
if (_gsg == (GraphicsStateGuardian *)NULL) {
return false;
}
OSMesaGraphicsStateGuardian *mesagsg;
DCAST_INTO_R(mesagsg, _gsg, false);
OSMesaMakeCurrent(mesagsg->_context, _image.p(), _type,
_x_size, _y_size);
mesagsg->reset_if_new();
if (mode == FM_render) {
CDLockedReader cdata(_cycler);
for (size_t i = 0; i != cdata->_textures.size(); ++i) {
const RenderTexture &rt = cdata->_textures[i];
RenderTextureMode rtm_mode = rt._rtm_mode;
if (rtm_mode == RTM_bind_or_copy) {
CDWriter cdataw(_cycler, cdata, false);
nassertr(cdata->_textures.size() == cdataw->_textures.size(), false);
cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
}
}
clear_cube_map_selection();
}
_gsg->set_current_properties(&get_fb_properties());
return _gsg->begin_frame(current_thread);
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsBuffer::end_frame
// Access: Public, Virtual
// Description: This function will be called within the draw thread
// after rendering is completed for a given frame. It
// should do whatever finalization is required.
////////////////////////////////////////////////////////////////////
void OsMesaGraphicsBuffer::
end_frame(FrameMode mode, Thread *current_thread) {
end_frame_spam(mode);
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
if (mode == FM_render) {
copy_to_textures();
}
_gsg->end_frame(current_thread);
if (mode == FM_render) {
trigger_flip();
clear_cube_map_selection();
}
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsBuffer::close_buffer
// Access: Protected, Virtual
// Description: Closes the buffer right now. Called from the window
// thread.
////////////////////////////////////////////////////////////////////
void OsMesaGraphicsBuffer::
close_buffer() {
_image.clear();
_is_valid = false;
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsBuffer::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 OsMesaGraphicsBuffer::
open_buffer() {
if (_gsg == 0) {
_gsg = new OSMesaGraphicsStateGuardian(_engine, _pipe, NULL);
}
_image = PTA_uchar::empty_array(_x_size * _y_size * 4);
_is_valid = true;
// All OSMesa buffers (that we create) always have the same format.
_fb_properties.clear();
_fb_properties.set_rgb_color(1);
_fb_properties.set_color_bits(24);
_fb_properties.set_alpha_bits(8);
_fb_properties.set_stencil_bits(8);
_fb_properties.set_depth_bits(16);
_fb_properties.set_accum_bits(8);
_fb_properties.set_force_software(1);
return true;
}

View File

@@ -1,71 +0,0 @@
// Filename: osMesaGraphicsBuffer.h
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef OSMESAGRAPHICSBUFFER_H
#define OSMESAGRAPHICSBUFFER_H
#include "pandabase.h"
#include "osMesaGraphicsPipe.h"
#include "graphicsBuffer.h"
////////////////////////////////////////////////////////////////////
// Class : OsMesaGraphicsBuffer
// Description : An offscreen buffer using direct calls to Mesa. This
// is the only kind of graphics output supported by
// osmesa.h.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAMESA OsMesaGraphicsBuffer : public GraphicsBuffer {
public:
OsMesaGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
const string &name,
const FrameBufferProperties &fb_prop,
const WindowProperties &win_prop,
int flags,
GraphicsStateGuardian *gsg,
GraphicsOutput *host);
virtual ~OsMesaGraphicsBuffer();
virtual bool begin_frame(FrameMode mode, Thread *current_thread);
virtual void end_frame(FrameMode mode, Thread *current_thread);
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, "OsMesaGraphicsBuffer",
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 "osMesaGraphicsBuffer.I"
#endif

View File

@@ -1,14 +0,0 @@
// Filename: osMesaGraphicsPipe.I
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////

View File

@@ -1,113 +0,0 @@
// Filename: osMesaGraphicsPipe.cxx
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "osMesaGraphicsPipe.h"
#include "osMesaGraphicsBuffer.h"
#include "osMesaGraphicsStateGuardian.h"
#include "config_mesadisplay.h"
#include "frameBufferProperties.h"
#include "mutexHolder.h"
TypeHandle OsMesaGraphicsPipe::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsPipe::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
OsMesaGraphicsPipe::
OsMesaGraphicsPipe() {
_supported_types = OT_buffer | OT_texture_buffer;
_is_valid = true;
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsPipe::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
OsMesaGraphicsPipe::
~OsMesaGraphicsPipe() {
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsPipe::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 OsMesaGraphicsPipe::
get_interface_name() const {
return "Offscreen Mesa";
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsPipe::pipe_constructor
// Access: Public, Static
// Description: This function is passed to the GraphicsPipeSelection
// object to allow the user to make a default
// OsMesaGraphicsPipe.
////////////////////////////////////////////////////////////////////
PT(GraphicsPipe) OsMesaGraphicsPipe::
pipe_constructor() {
return new OsMesaGraphicsPipe;
}
////////////////////////////////////////////////////////////////////
// Function: OsMesaGraphicsPipe::make_output
// Access: Protected, Virtual
// Description: Creates a new window on the pipe, if possible.
////////////////////////////////////////////////////////////////////
PT(GraphicsOutput) OsMesaGraphicsPipe::
make_output(const string &name,
const FrameBufferProperties &fb_prop,
const WindowProperties &win_prop,
int flags,
GraphicsEngine *engine,
GraphicsStateGuardian *gsg,
GraphicsOutput *host,
int retry,
bool &precertify) {
if (!_is_valid) {
return NULL;
}
if (retry == 0) {
if ((!support_render_texture)||
((flags&BF_require_parasite)!=0)||
((flags&BF_require_window)!=0)||
((flags&BF_resizeable)!=0)||
((flags&BF_size_track_host)!=0)||
((flags&BF_can_bind_every)!=0)||
((flags&BF_rtt_cumulative)!=0)) {
return NULL;
}
// We know that OsMesa windows only support single buffering. So
// don't bother asking for more than that.
FrameBufferProperties fb_prop2 = fb_prop;
fb_prop2.set_back_buffers(0);
return new OsMesaGraphicsBuffer(engine, this, name, fb_prop2, win_prop,
flags, gsg, host);
}
// Nothing else left to try.
return NULL;
}

View File

@@ -1,77 +0,0 @@
// Filename: osMesaGraphicsPipe.h
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef OSMESAGRAPHICSPIPE_H
#define OSMESAGRAPHICSPIPE_H
#include "pandabase.h"
#include "graphicsWindow.h"
#include "graphicsPipe.h"
#include "mesagsg.h"
class FrameBufferProperties;
////////////////////////////////////////////////////////////////////
// Class : OsMesaGraphicsPipe
// 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 EXPCL_PANDAMESA OsMesaGraphicsPipe : public GraphicsPipe {
public:
OsMesaGraphicsPipe();
virtual ~OsMesaGraphicsPipe();
virtual string get_interface_name() const;
static PT(GraphicsPipe) pipe_constructor();
protected:
virtual PT(GraphicsOutput) make_output(const string &name,
const FrameBufferProperties &fb_prop,
const WindowProperties &win_prop,
int flags,
GraphicsEngine *engine,
GraphicsStateGuardian *gsg,
GraphicsOutput *host,
int retry,
bool &precertify);
private:
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
GraphicsPipe::init_type();
register_type(_type_handle, "OsMesaGraphicsPipe",
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 "osMesaGraphicsPipe.I"
#endif

View File

@@ -1,13 +0,0 @@
// Filename: osMesaGraphicsStateGuardian.I
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////

View File

@@ -1,106 +0,0 @@
// Filename: osMesaGraphicsStateGuardian.cxx
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "osMesaGraphicsStateGuardian.h"
TypeHandle OSMesaGraphicsStateGuardian::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: OSMesaGraphicsStateGuardian::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
OSMesaGraphicsStateGuardian::
OSMesaGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
OSMesaGraphicsStateGuardian *share_with) :
MesaGraphicsStateGuardian(engine, pipe)
{
OSMesaContext share_context = NULL;
if (share_with != (OSMesaGraphicsStateGuardian *)NULL) {
share_context = share_with->_context;
_prepared_objects = share_with->get_prepared_objects();
}
_context = OSMesaCreateContext(OSMESA_RGBA, share_context);
// OSMesa is never hardware-accelerated.
_is_hardware = false;
}
////////////////////////////////////////////////////////////////////
// Function: OSMesaGraphicsStateGuardian::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
OSMesaGraphicsStateGuardian::
~OSMesaGraphicsStateGuardian() {
if (_context != (OSMesaContext)NULL) {
OSMesaDestroyContext(_context);
_context = (OSMesaContext)NULL;
}
}
////////////////////////////////////////////////////////////////////
// Function: OSMesaGraphicsStateGuardian::do_get_extension_func
// Access: Public, Virtual
// Description: Returns the pointer to the GL extension function with
// the indicated name. It is the responsibility of the
// caller to ensure that the required extension is
// defined in the OpenGL runtime prior to calling this;
// it is an error to call this for a function that is
// not defined.
////////////////////////////////////////////////////////////////////
void *OSMesaGraphicsStateGuardian::
do_get_extension_func(const char *prefix, const char *name) {
#if (OSMESA_MAJOR_VERSION == 4 && OSMESA_MINOR_VERSION >= 1) || OSMESA_MAJOR_VERSION > 4
// If we've got at least OSMesa version 4.1, then we can use
// OSMesaGetProcAddress.
// We ignore the prefix and always use "gl", since that's what Mesa
// does (even if we compile with name mangling enabled to rename the
// Mesa functions to "mgl", they're still stored as "gl" in the
// OSMesaGetProcAddress() lookup table.
string fullname = string("gl") + string(name);
void *ptr = (void *)OSMesaGetProcAddress(fullname.c_str());
if (mesadisplay_cat.is_debug()) {
mesadisplay_cat.debug()
<< "Looking for function " << fullname << ": " << ptr << "\n";
}
if (ptr == (void *)NULL) {
// Well, try for the more accurate name.
fullname = string(prefix) + string(name);
ptr = (void *)OSMesaGetProcAddress(fullname.c_str());
if (mesadisplay_cat.is_debug()) {
mesadisplay_cat.debug()
<< "Looking for function " << fullname << ": " << ptr << "\n";
}
}
return ptr;
#else
if (mesadisplay_cat.is_debug()) {
mesadisplay_cat.debug()
<< "Couldn't look up extension function: compiled with Mesa version "
<< OSMESA_MAJOR_VERSION << "." << OSMESA_MINOR_VERSION << "\n";
}
// Otherwise, too bad. No extension functions for you. We could
// try to write code that would dig around in the system interface
// (using dlopen(), for instance) to find the extension functions,
// but why should we have to do that? Just go get the latest Mesa,
// for goodness sakes!
return NULL;
#endif
}

View File

@@ -1,57 +0,0 @@
// Filename: osMesaGraphicsStateGuardian.h
// Created by: drose (09Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef OSMESAGRAPHICSSTATEGUARDIAN_H
#define OSMESAGRAPHICSSTATEGUARDIAN_H
#include "pandabase.h"
#include "mesagsg.h"
////////////////////////////////////////////////////////////////////
// Class : OSMesaGraphicsStateGuardian
// Description : A tiny specialization on MesaGraphicsStateGuardian to
// add a reference to the OSMesaContext.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAMESA OSMesaGraphicsStateGuardian : public MesaGraphicsStateGuardian {
public:
OSMesaGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
OSMesaGraphicsStateGuardian *share_with);
virtual ~OSMesaGraphicsStateGuardian();
OSMesaContext _context;
protected:
virtual void *do_get_extension_func(const char *prefix, const char *name);
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
MesaGraphicsStateGuardian::init_type();
register_type(_type_handle, "OSMesaGraphicsStateGuardian",
MesaGraphicsStateGuardian::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 "osMesaGraphicsStateGuardian.I"
#endif

View File

@@ -1,5 +0,0 @@
#include "config_mesadisplay.cxx"
#include "osMesaGraphicsBuffer.cxx"
#include "osMesaGraphicsPipe.cxx"
#include "osMesaGraphicsStateGuardian.cxx"
#include "mesagsg.cxx"