diff --git a/panda/src/tinydisplay/Sources.pp b/panda/src/tinydisplay/Sources.pp index 92cc68a0d8..b964367a57 100644 --- a/panda/src/tinydisplay/Sources.pp +++ b/panda/src/tinydisplay/Sources.pp @@ -10,7 +10,7 @@ #define TARGET tinydisplay #define LOCAL_LIBS \ gsgmisc gsgbase gobj display \ - putil linmath mathutil pnmimage + putil linmath mathutil pnmimage windisplay #define SOURCES \ config_tinydisplay.cxx config_tinydisplay.h \ @@ -20,6 +20,8 @@ tinyGraphicsStateGuardian.h tinyGraphicsStateGuardian.I \ tinyGraphicsStateGuardian.cxx \ tinyTextureContext.I tinyTextureContext.cxx tinyTextureContext.h \ + tinyWinGraphicsPipe.I tinyWinGraphicsPipe.cxx tinyWinGraphicsPipe.h \ + tinyWinGraphicsWindow.h tinyWinGraphicsWindow.I tinyWinGraphicsWindow.cxx \ tinyXGraphicsPipe.I tinyXGraphicsPipe.cxx tinyXGraphicsPipe.h \ tinyXGraphicsWindow.h tinyXGraphicsWindow.I tinyXGraphicsWindow.cxx \ clip.cxx error.cxx \ diff --git a/panda/src/tinydisplay/config_tinydisplay.cxx b/panda/src/tinydisplay/config_tinydisplay.cxx index b8c40d5f0a..ce4af6ab9f 100644 --- a/panda/src/tinydisplay/config_tinydisplay.cxx +++ b/panda/src/tinydisplay/config_tinydisplay.cxx @@ -17,10 +17,12 @@ //////////////////////////////////////////////////////////////////// #include "config_tinydisplay.h" -#include "tinySDLGraphicsPipe.h" -#include "tinySDLGraphicsWindow.h" #include "tinyXGraphicsPipe.h" #include "tinyXGraphicsWindow.h" +#include "tinyWinGraphicsPipe.h" +#include "tinyWinGraphicsWindow.h" +#include "tinySDLGraphicsPipe.h" +#include "tinySDLGraphicsWindow.h" #include "tinyGraphicsStateGuardian.h" #include "tinyGeomMunger.h" #include "tinyTextureContext.h" @@ -88,6 +90,9 @@ init_libtinydisplay() { TinyGeomMunger::init_type(); TinyTextureContext::init_type(); + PandaSystem *ps = PandaSystem::get_global_ptr(); + ps->add_system("TinyGL"); + GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); #ifdef IS_LINUX @@ -95,6 +100,15 @@ init_libtinydisplay() { TinyXGraphicsWindow::init_type(); selection->add_pipe_type(TinyXGraphicsPipe::get_class_type(), TinyXGraphicsPipe::pipe_constructor); + ps->set_system_tag("TinyGL", "native_window_system", "X"); +#endif + +#ifdef WIN32 + TinyWinGraphicsPipe::init_type(); + TinyWinGraphicsWindow::init_type(); + selection->add_pipe_type(TinyWinGraphicsPipe::get_class_type(), + TinyWinGraphicsPipe::pipe_constructor); + ps->set_system_tag("TinyGL", "native_window_system", "Win"); #endif #ifdef HAVE_SDL @@ -102,8 +116,6 @@ init_libtinydisplay() { TinySDLGraphicsWindow::init_type(); selection->add_pipe_type(TinySDLGraphicsPipe::get_class_type(), TinySDLGraphicsPipe::pipe_constructor); + ps->set_system_tag("TinyGL", "SDL", "SDL"); #endif - - PandaSystem *ps = PandaSystem::get_global_ptr(); - ps->add_system("TinyGL"); } diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx index 6ad3c70547..1737b6c862 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx @@ -70,7 +70,7 @@ TinySDLGraphicsPipe:: //////////////////////////////////////////////////////////////////// string TinySDLGraphicsPipe:: get_interface_name() const { - return "TinyGL"; + return "TinyGL SDL"; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.I b/panda/src/tinydisplay/tinyWinGraphicsPipe.I new file mode 100755 index 0000000000..62263b6253 --- /dev/null +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.I @@ -0,0 +1,18 @@ +// Filename: tinyWinGraphicsPipe.I +// Created by: drose (06May08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx new file mode 100755 index 0000000000..dd9a47449b --- /dev/null +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx @@ -0,0 +1,127 @@ +// Filename: tinyWinGraphicsPipe.cxx +// Created by: drose (06May08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "pandabase.h" + +#ifdef WIN32 + +#include "tinyWinGraphicsPipe.h" +#include "config_tinydisplay.h" +#include "config_windisplay.h" +#include "tinyWinGraphicsWindow.h" + +TypeHandle TinyWinGraphicsPipe::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsPipe::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +TinyWinGraphicsPipe:: +TinyWinGraphicsPipe() { +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsPipe::Destructor +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +TinyWinGraphicsPipe:: +~TinyWinGraphicsPipe() { +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsPipe::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 TinyWinGraphicsPipe:: +get_interface_name() const { + return "TinyGL Windows"; +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsPipe::pipe_constructor +// Access: Public, Static +// Description: This function is passed to the GraphicsPipeSelection +// object to allow the user to make a default +// TinyWinGraphicsPipe. +//////////////////////////////////////////////////////////////////// +PT(GraphicsPipe) TinyWinGraphicsPipe:: +pipe_constructor() { + return new TinyWinGraphicsPipe; +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsPipe::make_output +// Access: Protected, Virtual +// Description: Creates a new window or buffer on the pipe, if possible. +// This routine is only called from GraphicsEngine::make_output. +//////////////////////////////////////////////////////////////////// +PT(GraphicsOutput) TinyWinGraphicsPipe:: +make_output(const string &name, + const FrameBufferProperties &fb_prop, + const WindowProperties &win_prop, + int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host, + int retry, + bool &precertify) { + + if (!_is_valid) { + return NULL; + } + + TinyGraphicsStateGuardian *tinygsg = 0; + if (gsg != 0) { + DCAST_INTO_R(tinygsg, gsg, NULL); + } + + // First thing to try: a TinyWinGraphicsWindow + + if (retry == 0) { + if (((flags&BF_require_parasite)!=0)|| + ((flags&BF_refuse_window)!=0)|| + ((flags&BF_resizeable)!=0)|| + ((flags&BF_size_track_host)!=0)|| + ((flags&BF_rtt_cumulative)!=0)|| + ((flags&BF_can_bind_color)!=0)|| + ((flags&BF_can_bind_every)!=0)) { + return NULL; + } + if ((flags & BF_fb_props_optional)==0) { + if ((fb_prop.get_aux_rgba() > 0)|| + (fb_prop.get_aux_hrgba() > 0)|| + (fb_prop.get_aux_float() > 0)) { + return NULL; + } + } + return new TinyWinGraphicsWindow(this, name, fb_prop, win_prop, + flags, gsg, host); + } + + // Nothing else left to try. + return NULL; +} + +#endif // WIN32 diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.h b/panda/src/tinydisplay/tinyWinGraphicsPipe.h new file mode 100755 index 0000000000..54e0d34b7b --- /dev/null +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.h @@ -0,0 +1,75 @@ +// Filename: tinyWinGraphicsPipe.h +// Created by: drose (06May08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef TINYWINGRAPHICSPIPE_H +#define TINYWINGRAPHICSPIPE_H + +#include "pandabase.h" + +#ifdef WIN32 + +#include "winGraphicsPipe.h" +#include "tinyGraphicsStateGuardian.h" + +//////////////////////////////////////////////////////////////////// +// Class : TinyWinGraphicsPipe +// Description : This graphics pipe represents the interface for +// creating TinyGL graphics windows on a Windows-based +// client. +//////////////////////////////////////////////////////////////////// +class EXPCL_TINYDISPLAY TinyWinGraphicsPipe : public WinGraphicsPipe { +public: + TinyWinGraphicsPipe(); + virtual ~TinyWinGraphicsPipe(); + + 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, + GraphicsStateGuardian *gsg, + GraphicsOutput *host, + int retry, + bool &precertify); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + WinGraphicsPipe::init_type(); + register_type(_type_handle, "TinyWinGraphicsPipe", + WinGraphicsPipe::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 "tinyWinGraphicsPipe.I" + +#endif // WIN32 + +#endif diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.I b/panda/src/tinydisplay/tinyWinGraphicsWindow.I new file mode 100755 index 0000000000..f32dbe7e12 --- /dev/null +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.I @@ -0,0 +1,18 @@ +// Filename: tinyWinGraphicsWindow.I +// Created by: drose (06May08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx new file mode 100755 index 0000000000..c099ed3cf1 --- /dev/null +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx @@ -0,0 +1,278 @@ +// Filename: tinyWinGraphicsWindow.cxx +// Created by: drose (06May08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "pandabase.h" + +#ifdef WIN32 + +#include "tinyWinGraphicsWindow.h" +#include "config_tinydisplay.h" +#include "config_windisplay.h" +#include "tinyWinGraphicsPipe.h" +#include "tinyGraphicsStateGuardian.h" +#include "pStatTimer.h" + +#include + +TypeHandle TinyWinGraphicsWindow::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +TinyWinGraphicsWindow:: +TinyWinGraphicsWindow(GraphicsPipe *pipe, + const string &name, + const FrameBufferProperties &fb_prop, + const WindowProperties &win_prop, + int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host) : + WinGraphicsWindow(pipe, name, fb_prop, win_prop, flags, gsg, host) +{ + _frame_buffer = NULL; + _hdc = (HDC)0; +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::Destructor +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +TinyWinGraphicsWindow:: +~TinyWinGraphicsWindow() { +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::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 TinyWinGraphicsWindow:: +begin_frame(FrameMode mode, Thread *current_thread) { + begin_frame_spam(mode); + if (_gsg == (GraphicsStateGuardian *)NULL) { + return false; + } + + TinyGraphicsStateGuardian *tinygsg; + DCAST_INTO_R(tinygsg, _gsg, false); + + tinygsg->_current_frame_buffer = _frame_buffer; + tinygsg->reset_if_new(); + + _gsg->set_current_properties(&get_fb_properties()); + return _gsg->begin_frame(current_thread); +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::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 TinyWinGraphicsWindow:: +end_frame(FrameMode mode, Thread *current_thread) { + end_frame_spam(mode); + nassertv(_gsg != (GraphicsStateGuardian *)NULL); + + if (mode == FM_render) { + // end_render_texture(); + copy_to_textures(); + } + + _gsg->end_frame(current_thread); + + if (mode == FM_render) { + trigger_flip(); + if (_one_shot) { + prepare_for_deletion(); + } + clear_cube_map_selection(); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::begin_flip +// Access: Public, Virtual +// Description: This function will be called within the draw thread +// after end_frame() has been called on all windows, to +// initiate the exchange of the front and back buffers. +// +// This should instruct the window to prepare for the +// flip at the next video sync, but it should not wait. +// +// We have the two separate functions, begin_flip() and +// end_flip(), to make it easier to flip all of the +// windows at the same time. +//////////////////////////////////////////////////////////////////// +void TinyWinGraphicsWindow:: +begin_flip() { + HBITMAP bm = CreateCompatibleBitmap(_hdc, _frame_buffer->xsize, _frame_buffer->ysize); + HDC bmdc = CreateCompatibleDC(_hdc); + SelectObject(bmdc, bm); + + SetDIBits(_hdc, bm, 0, _frame_buffer->ysize, _frame_buffer->pbuf, + &_bitmap_info, DIB_RGB_COLORS); + + BitBlt(_hdc, 0, 0, _frame_buffer->xsize, _frame_buffer->ysize, + bmdc, 0, 0, SRCCOPY); + + DeleteDC(bmdc); + DeleteObject(bm); + GdiFlush(); +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::close_window +// Access: Protected, Virtual +// Description: Closes the window right now. Called from the window +// thread. +//////////////////////////////////////////////////////////////////// +void TinyWinGraphicsWindow:: +close_window() { + if (_gsg != (GraphicsStateGuardian *)NULL) { + TinyGraphicsStateGuardian *tinygsg; + DCAST_INTO_V(tinygsg, _gsg); + tinygsg->_current_frame_buffer = NULL; + _gsg.clear(); + _active = false; + } + + ReleaseDC(_hWnd, _hdc); + _hdc = (HDC)0; + WinGraphicsWindow::close_window(); +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::open_window +// Access: Protected, Virtual +// Description: Opens the window right now. Called from the window +// thread. Returns true if the window is successfully +// opened, or false if there was a problem. +//////////////////////////////////////////////////////////////////// +bool TinyWinGraphicsWindow:: +open_window() { + if (!WinGraphicsWindow::open_window()) { + return false; + } + + // GSG Creation/Initialization + TinyGraphicsStateGuardian *tinygsg; + if (_gsg == 0) { + // There is no old gsg. Create a new one. + tinygsg = new TinyGraphicsStateGuardian(_pipe, NULL); + _gsg = tinygsg; + } else { + DCAST_INTO_R(tinygsg, _gsg, false); + } + + _hdc = GetDC(_hWnd); + + create_frame_buffer(); + if (_frame_buffer == NULL) { + tinydisplay_cat.error() + << "Could not create frame buffer.\n"; + return false; + } + + tinygsg->_current_frame_buffer = _frame_buffer; + + tinygsg->reset_if_new(); + if (!tinygsg->is_valid()) { + close_window(); + return false; + } + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: WinGraphicsWindow::handle_reshape +// Access: Protected, Virtual +// Description: Called in the window thread when the window size or +// location is changed, this updates the properties +// structure accordingly. +//////////////////////////////////////////////////////////////////// +void TinyWinGraphicsWindow:: +handle_reshape() { + WinGraphicsWindow::handle_reshape(); + ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + setup_bitmap_info(); +} + +//////////////////////////////////////////////////////////////////// +// Function: WinGraphicsWindow::do_fullscreen_resize +// Access: Protected, Virtual +// Description: Called in the window thread when the window size or +// location is changed, this updates the properties +// structure accordingly. +//////////////////////////////////////////////////////////////////// +bool TinyWinGraphicsWindow:: +do_fullscreen_resize(int x_size, int y_size) { + bool result = WinGraphicsWindow::do_fullscreen_resize(x_size, y_size); + ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + setup_bitmap_info(); + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::create_frame_buffer +// Access: Private +// Description: Creates a suitable frame buffer for the current +// window size. +//////////////////////////////////////////////////////////////////// +void TinyWinGraphicsWindow:: +create_frame_buffer() { + if (_frame_buffer != NULL) { + ZB_close(_frame_buffer); + _frame_buffer = NULL; + } + + _frame_buffer = ZB_open(_properties.get_x_size(), _properties.get_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0); + setup_bitmap_info(); +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyWinGraphicsWindow::setup_bitmap_info +// Access: Private +// Description: Determines the BITMAPINFO stuff for blitting the +// frame buffer to the window. +//////////////////////////////////////////////////////////////////// +void TinyWinGraphicsWindow:: +setup_bitmap_info() { + _bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + _bitmap_info.bmiHeader.biWidth = _frame_buffer->xsize; + _bitmap_info.bmiHeader.biHeight = -_frame_buffer->ysize; + _bitmap_info.bmiHeader.biPlanes = 1; + _bitmap_info.bmiHeader.biBitCount = 32; + _bitmap_info.bmiHeader.biCompression = BI_RGB; + _bitmap_info.bmiHeader.biSizeImage = _frame_buffer->linesize * _frame_buffer->ysize; + _bitmap_info.bmiHeader.biXPelsPerMeter = 0; + _bitmap_info.bmiHeader.biYPelsPerMeter = 0; + _bitmap_info.bmiHeader.biClrUsed = 0; + _bitmap_info.bmiHeader.biClrImportant = 0; +} + +#endif // WIN32 diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.h b/panda/src/tinydisplay/tinyWinGraphicsWindow.h new file mode 100755 index 0000000000..02aad7c6e0 --- /dev/null +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.h @@ -0,0 +1,88 @@ +// Filename: tinyWinGraphicsWindow.h +// Created by: drose (06May08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef TINYWINGRAPHICSWINDOW_H +#define TINYWINGRAPHICSWINDOW_H + +#include "pandabase.h" + +#ifdef WIN32 + +#include "winGraphicsWindow.h" +#include "tinyWinGraphicsPipe.h" + +//////////////////////////////////////////////////////////////////// +// Class : TinyWinGraphicsWindow +// Description : Opens a window on Microsoft Windows to display the +// TinyGL software rendering. +//////////////////////////////////////////////////////////////////// +class EXPCL_TINYDISPLAY TinyWinGraphicsWindow : public WinGraphicsWindow { +public: + TinyWinGraphicsWindow(GraphicsPipe *pipe, + const string &name, + const FrameBufferProperties &fb_prop, + const WindowProperties &win_prop, + int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host); + virtual ~TinyWinGraphicsWindow(); + + virtual bool begin_frame(FrameMode mode, Thread *current_thread); + virtual void end_frame(FrameMode mode, Thread *current_thread); + + virtual void begin_flip(); + +protected: + virtual void close_window(); + virtual bool open_window(); + + virtual void handle_reshape(); + virtual bool do_fullscreen_resize(int x_size, int y_size); + +private: + void create_frame_buffer(); + void setup_bitmap_info(); + +private: + ZBuffer *_frame_buffer; + HDC _hdc; + BITMAPINFO _bitmap_info; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + WinGraphicsWindow::init_type(); + register_type(_type_handle, "TinyWinGraphicsWindow", + WinGraphicsWindow::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 "tinyWinGraphicsWindow.I" + +#endif // WIN32 + +#endif diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx index acb0f26694..2c5a7f86fa 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx @@ -151,7 +151,7 @@ TinyXGraphicsPipe:: //////////////////////////////////////////////////////////////////// string TinyXGraphicsPipe:: get_interface_name() const { - return "OpenGL"; + return "TinyGL X11"; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.h b/panda/src/tinydisplay/tinyXGraphicsPipe.h index 27e904e319..cc7c7c8548 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.h @@ -50,7 +50,7 @@ typedef int XIC; //////////////////////////////////////////////////////////////////// // Class : TinyXGraphicsPipe // Description : This graphics pipe represents the interface for -// creating OpenGL graphics windows on an X-based +// creating TinyGL graphics windows on an X11-based // (e.g. Unix) client. //////////////////////////////////////////////////////////////////// class EXPCL_TINYDISPLAY TinyXGraphicsPipe : public GraphicsPipe { diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index 1c3b594849..f94723779c 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -573,7 +573,9 @@ set_properties_now(WindowProperties &properties) { void TinyXGraphicsWindow:: close_window() { if (_gsg != (GraphicsStateGuardian *)NULL) { - // glXMakeCurrent(_display, None, NULL); + TinyGraphicsStateGuardian *tinygsg; + DCAST_INTO_R(tinygsg, _gsg, false); + tinygsg->_current_frame_buffer = NULL; _gsg.clear(); _active = false; }