// Copyright (C) 2002-2003 Gideon May (gideon@computer.org) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. #include #include #include #include #include #ifdef __USE_OSX_IMPLEMENTATION__ #include "missing.hpp" #undef check #endif #include #include #include "producer_ptr.hpp" using namespace boost::python; BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(setWindowRectangle_overloads, Producer::RenderSurface::setWindowRectangle, 4, 5); namespace { tuple getWindowRectangle(Producer::RenderSurface& surface) { int x, y; unsigned int width, height; surface.getWindowRectangle(x, y, width, height); return make_tuple(x, y, width, height); } } namespace PyProd { void init_RenderSurface() { class_, bases, boost::noncopyable> render_surface("RenderSurface", no_init); #if 0 "class RenderSurface\n" "brief A RenderSurface provides a rendering surface for 3D graphics applications.\n" "\n" "A RenderSurface creates a window in a windowing system for the purpose of 3D \n" "rendering. The focus of a RenderSurface differs from a windowing system window\n" "in that it is not a user input/output device, but rather a context and screen area\n" "specifically designed for 3D applications. Consequently, a RenderSurface does not \n" "provide or impose a requirement on the caller to structure the application around\n" "the capturing or handling of events. Further, RenderSurface provides increased \n" "control over the quality of pixel formats."); #endif scope render_surface_scope(render_surface); // class_ callback("Callback"); class_ input_rectangle("InputRectangle"); input_rectangle .def(init()) .def("set", &Producer::RenderSurface::InputRectangle::set) .def("left", &Producer::RenderSurface::InputRectangle::left) .def("bottom", &Producer::RenderSurface::InputRectangle::bottom) .def("width", &Producer::RenderSurface::InputRectangle::width) .def("height", &Producer::RenderSurface::InputRectangle::height) ; render_surface .def(init<>()) .def("setInputRectangle", &Producer::RenderSurface::setInputRectangle) .def("getInputRectangle", &Producer::RenderSurface::getInputRectangle, return_internal_reference<>()) .def("bindInputRectangleToWindowSize", &Producer::RenderSurface::bindInputRectangleToWindowSize) .def("setHostName", &Producer::RenderSurface::setHostName, "Set the name of the Host the window is to be created on.\n" "Ignored on Win32\n") .def("getHostName", &Producer::RenderSurface::getHostName, return_internal_reference<>(), "Get the name of the Host the window is to be created on. \n" "Ignored on Win32\n") .def("setDisplayNum", &Producer::RenderSurface::setDisplayNum, "Set the number of the display the render surface is to \n" "be created on. In XWindows, this is the number of the\n" "XServer. Ignored on Win32") .def("getDisplayNum", &Producer::RenderSurface::getDisplayNum, " Get the number of the display the render surface is to \n" " be created on. In XWindows, this is the number of the\n" " XServer. Ignored on Win32\n") .def("setScreenNum", &Producer::RenderSurface::setScreenNum) /** Set the number of the screen the render surface is to * be created on. In XWindows, this is the number of the * XServer. Ignored on Win32 */ .def("getScreenNum", &Producer::RenderSurface::getScreenNum) /** Get the number of the screen the render surface is to * be created on. In XWindows, this is the number of the * XServer. Ignored on Win32 */ .def("getScreenSize", (void (Producer::RenderSurface::*)(unsigned int &, unsigned int &)) &Producer::RenderSurface::getScreenSize) .def("setWindowName", &Producer::RenderSurface::setWindowName) /** Set the Window system Window name of the Render Surface */ .def("getWindowName", &Producer::RenderSurface::getWindowName, return_internal_reference<>()) /** Get the Window system Window name of the Render Surface */ .def("setWindowRectangle", &Producer::RenderSurface::setWindowRectangle, setWindowRectangle_overloads()) /** Set the windowing system rectangle the RenderSurface will * occupy on the screen. The parameters are given as integers * in screen space. x and y determine the lower left hand corner * of the RenderSurface. Width and height are given in screen * coordinates */ .def("getWindowRectangle", &getWindowRectangle) /** Get the X coordinate of the origin of the RenderSurface's window */ .def("getWindowOriginX", &Producer::RenderSurface::getWindowOriginX) /** Get the X coordinate of the origin of the RenderSurface's window */ .def("getWindowOriginY", &Producer::RenderSurface::getWindowOriginY) /** Get the Y coordinate of the origin of the RenderSurface's window */ .def("getWindowWidth", &Producer::RenderSurface::getWindowWidth) /** Get the width of the RenderSurface in windowing system screen coordinates */ .def("getWindowHeight", &Producer::RenderSurface::getWindowHeight) /** Get the height of the RenderSurface in windowing system screen coordinates */ //"Explicitely set the Windowing system window before realization." // Problems with Boost. //.def("setWindow", &Producer::RenderSurface::setWindow) //.def("getWindow", &Producer::RenderSurface::getWindow, return_internal_reference<>()) //.def("getGLContext", &Producer::RenderSurface::getGLContext, return_internal_reference<>()) #ifdef __linux // XXX Fix this for Mac Os X .def("setParentWindow", &Producer::RenderSurface::setParentWindow) #endif //.def("getParentWindow", &Producer::RenderSurface::getParentWindow, return_internal_reference<>()) .def("setVisualChooser", &Producer::RenderSurface::setVisualChooser) .def("getVisualChooser", (Producer::VisualChooser * (Producer::RenderSurface::*)(void)) &Producer::RenderSurface::getVisualChooser, return_internal_reference<>()) #ifdef __linux // XXX Fix this for Mac Os X .def("setVisualInfo", &Producer::RenderSurface::setVisualInfo) #endif .def("isRealized", &Producer::RenderSurface::isRealized) /** Returns true if the RenderSurface has been realized, false if not. */ .def("useBorder", &Producer::RenderSurface::useBorder) /** Request the use of a window border. If flag is false, no border will * appear after realization. If flag is true, the windowing system window * will be created in default state. */ .def("usesBorder", &Producer::RenderSurface::usesBorder) .def("useCursor", &Producer::RenderSurface::useCursor) /** Request whether the window should have a visible cursor. If true, the * windowing system's default cursur will be assigned to the window. If false * the window will not have a visible cursor. */ .def("useConfigEventThread", &Producer::RenderSurface::useConfigEventThread) /** Specify whether the RenderSurface should use a separate thread for * window configuration events. If flag is set to true, then the * RenderSurface will spawn a new thread to manage events caused by * resizing the window, mapping or destroying the window. */ // /** Realize the RenderSurface. When realized, all components of the RenderSurface // * not already configured are configured, a window and a graphics context are // * created and made current. If an already existing graphics context is passed // * through "shared_context", then the graphics context created will share certain // * graphics constructs (such as display lists) with "shared_context". */ // bool realize( VisualChooser *vc=NULL, GLContext shared_context=0 ); #ifdef __linux // XXX Fix this for Mac Os X .def("realize", (bool (Producer::RenderSurface::*)()) &Producer::RenderSurface::realize) #endif .def("addRealizeCallback", &Producer::RenderSurface::addRealizeCallback) .def("setRealizeCallback", &Producer::RenderSurface::setRealizeCallback) // void addRealizeCallback( Callback *realizeCB ); // void setRealizeCallback( Callback *realizeCB ) { addRealizeCallback(realizeCB); } // .def("swapBuffers", &Producer::RenderSurface::swapBuffers) /** Swaps buffers if RenderSurface quality attribute is DoubleBuffered */ .def("makeCurrent", (bool (Producer::RenderSurface::*)(void) const) &Producer::RenderSurface::makeCurrent) .def("sync", &Producer::RenderSurface::sync) .def("getRefreshRate", &Producer::RenderSurface::getRefreshRate) .def("initThreads", &Producer::RenderSurface::initThreads) .def("waitForRealize", &Producer::RenderSurface::waitForRealize) .def("fullScreen", &Producer::RenderSurface::fullScreen) .def("isFullScreen", &Producer::RenderSurface::isFullScreen) .def("positionPointer", &Producer::RenderSurface::positionPointer) // /** set/getUseDefaultEsc is deprecated */ // void setUseDefaultEsc( bool flag ) {_useDefaultEsc = flag; } // bool getUseDefaultEsc() { return _useDefaultEsc; } #ifdef __linux // XXX Fix this for Mac Os X .def("mapWindow", &Producer::RenderSurface::mapWindow) .def("unmapWindow", &Producer::RenderSurface::unmapWindow) #endif ; } }