diff --git a/panda/src/dxgsg/Sources.pp b/panda/src/dxgsg/Sources.pp index 35bd6d0819..c25e73b374 100644 --- a/panda/src/dxgsg/Sources.pp +++ b/panda/src/dxgsg/Sources.pp @@ -6,19 +6,21 @@ #begin lib_target - #define TARGET dxgsg #define LOCAL_LIBS \ cull gsgmisc gsgbase gobj sgattrib sgraphutil graph display light \ putil linmath sgraph mathutil pnmimage event + + #define COMBINED_SOURCES $[TARGET]_composite1.cxx #define SOURCES \ - config_dxgsg.cxx config_dxgsg.h dxGraphicsStateGuardian.I \ + config_dxgsg.h dxGraphicsStateGuardian.I \ dxGraphicsStateGuardian.cxx dxGraphicsStateGuardian.h \ - dxSavedFrameBuffer.I dxSavedFrameBuffer.cxx dxSavedFrameBuffer.h \ - dxTextureContext.I dxTextureContext.cxx dxTextureContext.h + dxSavedFrameBuffer.I dxSavedFrameBuffer.h \ + dxTextureContext.I dxTextureContext.h -// #define PRECOMPILED_HEADER dxgsg_headers.h + #define INCLUDED_SOURCES \ + config_dxgsg.cxx dxSavedFrameBuffer.cxx dxTextureContext.cxx #define INSTALL_HEADERS \ config_dxgsg.h dxGraphicsStateGuardian.I dxGraphicsStateGuardian.h \ diff --git a/panda/src/dxgsg/config_dxgsg.cxx b/panda/src/dxgsg/config_dxgsg.cxx index 0dac58d6b5..f5dbfa81c1 100644 --- a/panda/src/dxgsg/config_dxgsg.cxx +++ b/panda/src/dxgsg/config_dxgsg.cxx @@ -16,8 +16,12 @@ // //////////////////////////////////////////////////////////////////// -#include "dxgsg_headers.h" -#pragma hdrstop +#include "config_dxgsg.h" +#include "dxGraphicsStateGuardian.h" +#include "dxSavedFrameBuffer.h" +#include "dxTextureContext.h" + +#include Configure(config_dxgsg); NotifyCategoryDef(dxgsg, ":display:gsg"); diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index 9edc7649c6..c209a21999 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -16,8 +16,74 @@ // //////////////////////////////////////////////////////////////////// -#include "dxgsg_headers.h" -#pragma hdrstop +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef DO_PSTATS +#include +#include +#endif + +#include "config_dxgsg.h" +#include "dxGraphicsStateGuardian.h" + +#include // print out simple drawprim stats every few secs @@ -5672,6 +5738,63 @@ void DXGraphicsStateGuardian::adjust_view_rect(int x, int y) { } } +#if 0 + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::save_mipmap_images +// Access: Protected +// Description: Saves out each mipmap level of the indicated texture +// (which must also be the currently active texture in +// the GL state) as a separate image file to disk. +//////////////////////////////////////////////////////////////////// +void DXGraphicsStateGuardian::read_mipmap_images(Texture *tex) { + Filename filename = tex->get_name(); + string name; + if (filename.empty()) { + static index = 0; + name = "texture" + format_string(index); + index++; + } else { + name = filename.get_basename_wo_extension(); + } + + PixelBuffer *pb = tex->get_ram_image(); + nassertv(pb != (PixelBuffer *)NULL); + + GLenum external_format = get_external_image_format(pb->get_format()); + GLenum type = get_image_type(pb->get_image_type()); + + int xsize = pb->get_xsize(); + int ysize = pb->get_ysize(); + + // Specify byte-alignment for the pixels on output. + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + int mipmap_level = 0; + do { + xsize = max(xsize, 1); + ysize = max(ysize, 1); + + PT(PixelBuffer) mpb = + new PixelBuffer(xsize, ysize, pb->get_num_components(), + pb->get_component_width(), pb->get_image_type(), + pb->get_format()); + glGetTexImage(GL_TEXTURE_2D, mipmap_level, external_format, + type, mpb->_image); + Filename mipmap_filename = name + "_" + format_string(mipmap_level) + ".pnm"; + nout << "Writing mipmap level " << mipmap_level + << " (" << xsize << " by " << ysize << ") " + << mipmap_filename << "\n"; + mpb->write(mipmap_filename); + + xsize >>= 1; + ysize >>= 1; + mipmap_level++; + } while (xsize > 0 && ysize > 0); +} +#endif + + #if 0 //----------------------------------------------------------------------------- // Name: SetViewMatrix() diff --git a/panda/src/dxgsg/dxSavedFrameBuffer.cxx b/panda/src/dxgsg/dxSavedFrameBuffer.cxx index 4571835863..c174d6411c 100644 --- a/panda/src/dxgsg/dxSavedFrameBuffer.cxx +++ b/panda/src/dxgsg/dxSavedFrameBuffer.cxx @@ -16,7 +16,6 @@ // //////////////////////////////////////////////////////////////////// -#include "dxgsg_headers.h" -#pragma hdrstop +#include "dxSavedFrameBuffer.h" TypeHandle DXSavedFrameBuffer::_type_handle; diff --git a/panda/src/dxgsg/dxTextureContext.cxx b/panda/src/dxgsg/dxTextureContext.cxx index 9b7b29cbd1..f9956b5cdd 100644 --- a/panda/src/dxgsg/dxTextureContext.cxx +++ b/panda/src/dxgsg/dxTextureContext.cxx @@ -16,8 +16,12 @@ // //////////////////////////////////////////////////////////////////// -#include "dxgsg_headers.h" -#pragma hdrstop +#include +#include +#include "dxTextureContext.h" +#include "config_dxgsg.h" +#include "dxGraphicsStateGuardian.h" +#include "pnmImage.h" //#define FORCE_16bpp_1555 diff --git a/panda/src/dxgsg/dxgsg_composite1.cxx b/panda/src/dxgsg/dxgsg_composite1.cxx new file mode 100644 index 0000000000..6fc9a6c710 --- /dev/null +++ b/panda/src/dxgsg/dxgsg_composite1.cxx @@ -0,0 +1,3 @@ +#include "config_dxgsg.cxx" +#include "dxSavedFrameBuffer.cxx" +#include "dxTextureContext.cxx" diff --git a/panda/src/dxgsg/dxgsg_headers.h b/panda/src/dxgsg/dxgsg_headers.h deleted file mode 100644 index 8acce7deae..0000000000 --- a/panda/src/dxgsg/dxgsg_headers.h +++ /dev/null @@ -1,94 +0,0 @@ -// Filename: dxgsg-headers.h -// Created by: georges (30May01) -// -// local headers for dxgsg .cxx files -//////////////////////////////////////////////////////////////////// -// -// 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config_dxgsg.h" -#include "dxTextureContext.h" -#include "dxSavedFrameBuffer.h" -#include "dxGraphicsStateGuardian.h" - -#include - -#pragma hdrstop -