Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

direct/src/showbase/showBase.cxx

Go to the documentation of this file.
00001 // Filename: showBase.cxx
00002 // Created by:  shochet (02Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "showBase.h"
00020 
00021 #include "throw_event.h"
00022 #include "graphicsWindow.h"
00023 #include "chancfg.h"
00024 #include "renderBuffer.h"
00025 #include "get_config_path.h"
00026 #include "camera.h"
00027 #include "graphicsPipeSelection.h"
00028 
00029 
00030 ConfigureDef(config_showbase);
00031 ConfigureFn(config_showbase) {
00032 }
00033 
00034 DSearchPath &
00035 get_particle_path() {
00036   static DSearchPath *particle_path = NULL;
00037   return get_config_path("particle-path", particle_path);
00038 }
00039 
00040 // Throw the "NewFrame" event in the C++ world.  Some of the lerp code
00041 // depends on receiving this.
00042 void 
00043 throw_new_frame() {
00044   throw_event("NewFrame");
00045 }
00046 
00047 
00048 void
00049 take_snapshot(GraphicsWindow *win, const string &name) {
00050   GraphicsStateGuardian* gsg = win->get_gsg();
00051   const RenderBuffer& rb = gsg->get_render_buffer(RenderBuffer::T_front);
00052 
00053   CPT(DisplayRegion) dr = win->get_display_region(0);
00054   nassertv(dr != (DisplayRegion *)NULL);
00055 
00056   int width = dr->get_pixel_width();
00057   int height = dr->get_pixel_height();
00058 
00059   PixelBuffer p(width, height, 3, 1, PixelBuffer::T_unsigned_byte,
00060                 PixelBuffer::F_rgb);
00061 
00062   p.copy(gsg, dr, rb);
00063   p.write(name);
00064 }
00065 
00066 // Returns the configure object for accessing config variables from a
00067 // scripting language.
00068 ConfigShowbase &
00069 get_config_showbase() {
00070   return config_showbase;
00071 }
00072 
00073 // klunky interface since we cant pass array from python->C++ to use verify_window_sizes directly
00074 static int num_fullscreen_testsizes = 0;
00075 #define MAX_FULLSCREEN_TESTS 10
00076 static int fullscreen_testsizes[MAX_FULLSCREEN_TESTS * 2];
00077 
00078 void
00079 add_fullscreen_testsize(int xsize, int ysize) {
00080   if ((xsize == 0) && (ysize == 0)) {
00081     num_fullscreen_testsizes = 0;
00082     return;
00083   }
00084 
00085   // silently fail if maxtests exceeded
00086   if (num_fullscreen_testsizes < MAX_FULLSCREEN_TESTS) {
00087     fullscreen_testsizes[num_fullscreen_testsizes * 2] = xsize;
00088     fullscreen_testsizes[num_fullscreen_testsizes * 2 + 1] = ysize;
00089     num_fullscreen_testsizes++;
00090   }
00091 }
00092 
00093 void
00094 runtest_fullscreen_sizes(GraphicsWindow *win) {
00095   win->verify_window_sizes(num_fullscreen_testsizes, fullscreen_testsizes);
00096 }
00097 
00098 bool
00099 query_fullscreen_testresult(int xsize, int ysize) {
00100   // stupid linear search that works ok as long as total tests are small
00101   int i;
00102   for (i=0; i < num_fullscreen_testsizes; i++) {
00103     if((fullscreen_testsizes[i * 2] == xsize) &&
00104        (fullscreen_testsizes[i * 2 + 1] == ysize))
00105       return true;
00106   }
00107   return false;
00108 }
00109 

Generated on Fri May 2 01:37:58 2003 for Direct by doxygen1.3