Panda3D
config_tinydisplay.cxx
1 // Filename: config_tinydisplay.cxx
2 // Created by: drose (24Apr08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_tinydisplay.h"
16 #include "tinyXGraphicsPipe.h"
17 #include "tinyXGraphicsWindow.h"
18 #include "tinyWinGraphicsPipe.h"
19 #include "tinyWinGraphicsWindow.h"
20 #include "tinyOsxGraphicsPipe.h"
21 #include "tinyOsxGraphicsWindow.h"
22 #include "tinySDLGraphicsPipe.h"
23 #include "tinySDLGraphicsWindow.h"
24 #include "tinyOffscreenGraphicsPipe.h"
25 #include "tinyGraphicsBuffer.h"
26 #include "tinyGraphicsStateGuardian.h"
27 #include "tinyGeomMunger.h"
28 #include "tinyTextureContext.h"
29 #include "graphicsPipeSelection.h"
30 #include "dconfig.h"
31 #include "pandaSystem.h"
32 
33 Configure(config_tinydisplay);
34 NotifyCategoryDef(tinydisplay, "display");
35 
36 ConfigureFn(config_tinydisplay) {
37  init_libtinydisplay();
38 }
39 
40 ConfigVariableBool show_resize_box
41 ("show-resize-box", true,
42  PRC_DESC("When this variable is true, then resizable OSX Panda windows will "
43  "be rendered with a resize control in the lower-right corner. "
44  "This is specially handled by Panda, since otherwise the 3-d "
45  "window would completely hide any resize control drawn by the "
46  "OS. Set this variable false to allow this control to be hidden."));
47 
48 ConfigVariableBool osx_disable_event_loop
49 ("osx-disable-event-loop", false,
50  PRC_DESC("Set this true to disable the window event loop for the Panda "
51  "windows. This makes sense only in a publish environment where "
52  "the window event loop is already handled by another part of the "
53  "app."));
54 
55 ConfigVariableInt osx_mouse_wheel_scale
56 ("osx-mouse-wheel-scale", 1,
57  PRC_DESC("Specify the number of units to spin the Mac mouse wheel to "
58  "represent a single wheel_up or wheel_down message."));
59 
60 ConfigVariableBool td_ignore_mipmaps
61  ("td-ignore-mipmaps", false,
62  PRC_DESC("Configure this true to disable use of mipmaps on the "
63  "tinydisplay software renderer."));
64 
65 ConfigVariableBool td_ignore_clamp
66  ("td-ignore-clamp", false,
67  PRC_DESC("Configure this true to disable texture clamp mode and other "
68  "wrap modes other than repeat (all textures will repeat, which "
69  "is a little cheaper)."));
70 
71 ConfigVariableBool td_perspective_textures
72  ("td-perspective-textures", true,
73  PRC_DESC("Configure this false to disable use of perspective-correct "
74  "textures on the tinydisplay software renderer, for a small "
75  "performance gain."));
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: init_libtinydisplay
79 // Description: Initializes the library. This must be called at
80 // least once before any of the functions or classes in
81 // this library can be used. Normally it will be
82 // called by the static initializers and need not be
83 // called explicitly, but special cases exist.
84 ////////////////////////////////////////////////////////////////////
85 void
86 init_libtinydisplay() {
87  static bool initialized = false;
88  if (initialized) {
89  return;
90  }
91  initialized = true;
92 
93  TinyGraphicsBuffer::init_type();
94  TinyGraphicsStateGuardian::init_type();
95  TinyGeomMunger::init_type();
96  TinyTextureContext::init_type();
97 
99  ps->add_system("TinyPanda");
100 
102 
103 #ifdef HAVE_X11
104  TinyXGraphicsPipe::init_type();
105  TinyXGraphicsWindow::init_type();
106  selection->add_pipe_type(TinyXGraphicsPipe::get_class_type(),
107  TinyXGraphicsPipe::pipe_constructor);
108  ps->set_system_tag("TinyPanda", "native_window_system", "X11");
109 #endif
110 
111 #ifdef WIN32
112  TinyWinGraphicsPipe::init_type();
113  TinyWinGraphicsWindow::init_type();
114  selection->add_pipe_type(TinyWinGraphicsPipe::get_class_type(),
115  TinyWinGraphicsPipe::pipe_constructor);
116  ps->set_system_tag("TinyPanda", "native_window_system", "Win");
117 #endif
118 
119 #if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
120  TinyOsxGraphicsPipe::init_type();
121  TinyOsxGraphicsWindow::init_type();
122  selection->add_pipe_type(TinyOsxGraphicsPipe::get_class_type(),
123  TinyOsxGraphicsPipe::pipe_constructor);
124  ps->set_system_tag("TinyPanda", "native_window_system", "OSX");
125 #endif
126 
127 #ifdef HAVE_SDL
128  TinySDLGraphicsPipe::init_type();
129  TinySDLGraphicsWindow::init_type();
130  selection->add_pipe_type(TinySDLGraphicsPipe::get_class_type(),
131  TinySDLGraphicsPipe::pipe_constructor);
132  ps->set_system_tag("TinyPanda", "SDL", "SDL");
133 #endif
134 
135  TinyOffscreenGraphicsPipe::init_type();
136  selection->add_pipe_type(TinyOffscreenGraphicsPipe::get_class_type(),
137  TinyOffscreenGraphicsPipe::pipe_constructor);
138  ps->set_system_tag("TinyPanda", "", "");
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: get_pipe_type_p3tinydisplay
143 // Description: Returns the TypeHandle index of the recommended
144 // graphics pipe type defined by this module.
145 ////////////////////////////////////////////////////////////////////
146 int
147 get_pipe_type_p3tinydisplay() {
148 
149 #ifdef WIN32
150  return TinyWinGraphicsPipe::get_class_type().get_index();
151 #endif
152 
153 #if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
154  return TinyOsxGraphicsPipe::get_class_type().get_index();
155 #endif
156 
157 #ifdef HAVE_X11
158  return TinyXGraphicsPipe::get_class_type().get_index();
159 #endif
160 
161 #ifdef HAVE_SDL
162  return TinySDLGraphicsPipe::get_class_type().get_index();
163 #endif
164 
165  return TinyOffscreenGraphicsPipe::get_class_type().get_index();
166 }
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
This class is used as a namespace to group several global properties of Panda.
Definition: pandaSystem.h:29
This is a convenience class to specialize ConfigVariable as a boolean type.
int get_index() const
Returns the integer index associated with this TypeHandle.
Definition: typeHandle.I:253
void add_system(const string &system)
Intended for use by each subsystem to register itself at startup.
This maintains a list of GraphicsPipes by type that are available for creation.
static GraphicsPipeSelection * get_global_ptr()
Returns a pointer to the one global GraphicsPipeSelection object.
bool add_pipe_type(TypeHandle type, PipeConstructorFunc *func)
Adds a new kind of GraphicsPipe to the list of available pipes for creation.
This is a convenience class to specialize ConfigVariable as an integer type.
void set_system_tag(const string &system, const string &tag, const string &value)
Intended for use by each subsystem to register its set of capabilities at startup.