Added placeholder for PixelBufferWin32

This commit is contained in:
Robert Osfield 2007-06-20 12:29:19 +00:00
parent 69b778c2ad
commit 1de128de27
4 changed files with 208 additions and 117 deletions

View File

@ -0,0 +1,87 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
/* Note, elements of PixeBufferWin32 have used Prodcer/RenderSurface_Win32.cpp as both
* a guide to use of X11/GLX and copiying directly in the case of setBorder().
* These elements are license under OSGPL as above, with Copyright (C) 2001-2004 Don Burns.
*/
#ifndef OSGVIEWER_PIXELBUFFERWIN32
#define OSGVIEWER_PIXELBUFFERWIN32 1
#include <osgViewer/GraphicsWindow>
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
namespace osgViewer
{
class OSGVIEWER_EXPORT PixelBufferWin32 : public osgViewer::GraphicsWindow
{
public:
PixelBufferWin32(osg::GraphicsContext::Traits* traits);
virtual ~PixelBufferWin32();
virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const PixelBufferWin32*>(object)!=0; }
virtual const char* libraryName() const { return "osgViewer"; }
virtual const char* className() const { return "PixelBufferWin32"; }
virtual bool valid() const { return _valid; }
/** Realize the GraphicsContext.*/
virtual bool realizeImplementation();
/** Return true if the graphics context has been realised and is ready to use.*/
virtual bool isRealizedImplementation() const { return _realized; }
/** Close the graphics context.*/
virtual void closeImplementation();
/** Make this graphics context current.*/
virtual bool makeCurrentImplementation();
/** Release the graphics context.*/
virtual bool releaseContextImplementation();
/** Swap the front and back buffers.*/
virtual void swapBuffersImplementation();
/** Get native window.*/
HWND getHWND() const { return _hwnd; }
HDC getHDC() const { return _hdc; }
/** Get native OpenGL graphics context.*/
HGLRC getWGLContext() const { return _hglrc; }
protected:
void init();
HWND _hwnd;
HDC _hdc;
HGLRC _hglrc;
bool _initialized;
bool _valid;
bool _realized;
};
}
#endif

View File

@ -33,10 +33,18 @@ SET(LIB_COMMON_FILES
IF(WIN32)
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} ${HEADER_PATH}/api/Win32/GraphicsWindowWin32)
SET(LIB_COMMON_FILES ${LIB_COMMON_FILES} GraphicsWindowWin32.cpp)
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
${HEADER_PATH}/api/Win32/GraphicsWindowWin32
${HEADER_PATH}/api/Win32/PixelBufferWin32
)
SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
GraphicsWindowWin32.cpp
PixelBufferWin32.cpp
)
ELSE(WIN32)
IF(APPLE)
# FIXME: OS X needs selection mechanism for Cocoa, Carbon, X11
@ -56,6 +64,7 @@ ELSE(WIN32)
)
ENDIF(APPLE)
ENDIF(WIN32)

View File

@ -17,6 +17,7 @@
*/
#include <osgViewer/api/Win32/GraphicsWindowWin32>
#include <osgViewer/api/Win32/PixelBufferWin32>
#include <vector>
#include <map>
#include <sstream>
@ -299,59 +300,7 @@ class Win32WindowingSystem : public osg::GraphicsContext::WindowingSystemInterfa
Win32WindowingSystem& operator=( const Win32WindowingSystem& );
};
//
// This is the class we need to create for pbuffers and display devices that are not attached to the desktop
// (and thus cannot have windows created on their surface).
//
// Note its not a GraphicsWindow as it won't need any of the event handling and window mapping facilities.
//
class GraphicsContextWin32 : public osg::GraphicsContext
{
public:
GraphicsContextWin32(osg::GraphicsContext::Traits* traits);
~GraphicsContextWin32();
virtual bool valid() const;
/** Realise the GraphicsContext implementation,
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
virtual bool realizeImplementation();
/** Return true if the graphics context has been realised, and is ready to use, implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
virtual bool isRealizedImplementation() const;
/** Close the graphics context implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
virtual void closeImplementation();
/** Make this graphics context current implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
virtual bool makeCurrentImplementation();
/** Make this graphics context current with specified read context implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
virtual bool makeContextCurrentImplementation(GraphicsContext* /*readContext*/);
/** Release the graphics context.*/
virtual bool releaseContextImplementation();
/** Pure virtual, Bind the graphics context to associated texture implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
virtual void bindPBufferToTextureImplementation(GLenum /*buffer*/);
/** Swap the front and back buffers implementation.
* Pure virtual - must be implemented by Concrate implementations of GraphicsContext. */
virtual void swapBuffersImplementation();
protected:
bool _valid;
};
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Error reporting
//////////////////////////////////////////////////////////////////////////////
@ -955,7 +904,7 @@ osg::GraphicsContext* Win32WindowingSystem::createGraphicsContext( osg::Graphics
{
if (traits->pbuffer)
{
osg::ref_ptr<osgViewer::GraphicsContextWin32> pbuffer = new GraphicsContextWin32(traits);
osg::ref_ptr<osgViewer::PixelBufferWin32> pbuffer = new PixelBufferWin32(traits);
if (pbuffer->valid()) return pbuffer.release();
else return 0;
}
@ -2177,67 +2126,6 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
::CallWindowProc(_windowProcedure, hwnd, uMsg, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
// GraphicsContextWin32 implementation
//////////////////////////////////////////////////////////////////////////////
GraphicsContextWin32::GraphicsContextWin32( osg::GraphicsContext::Traits* traits )
: _valid(false)
{
_traits = traits;
}
GraphicsContextWin32::~GraphicsContextWin32()
{
}
bool GraphicsContextWin32::valid() const
{
return _valid;
}
bool GraphicsContextWin32::realizeImplementation()
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32::realizeImplementation() not implemented." << std::endl; return false;
}
bool GraphicsContextWin32::isRealizedImplementation() const
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32::isRealizedImplementation() not implemented." << std::endl; return false;
}
void GraphicsContextWin32::closeImplementation()
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32::closeImplementation() not implemented." << std::endl;
}
bool GraphicsContextWin32::makeCurrentImplementation()
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32::makeCurrentImplementation() not implemented." << std::endl;
return false;
}
bool GraphicsContextWin32::makeContextCurrentImplementation( GraphicsContext* /*readContext*/ )
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32::makeContextCurrentImplementation(..) not implemented." << std::endl;
return false;
}
bool GraphicsContextWin32::releaseContextImplementation()
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32::releaseContextImplementation(..) not implemented." << std::endl;
return false;
}
void GraphicsContextWin32::bindPBufferToTextureImplementation( GLenum /*buffer*/ )
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32::void bindPBufferToTextureImplementation(..) not implemented." << std::endl;
}
void GraphicsContextWin32::swapBuffersImplementation()
{
osg::notify(osg::NOTICE) << "GraphicsContextWin32:: swapBuffersImplementation() not implemented." << std::endl;
}
//////////////////////////////////////////////////////////////////////////////
// Class responsible for registering the Win32 Windowing System interface

View File

@ -0,0 +1,107 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* Some elements of GraphicsWindowWin32 have used the Producer implementation as a reference.
* These elements are licensed under OSGPL as above, with Copyright (C) 2001-2004 Don Burns.
*/
#include <osgViewer/api/Win32/PixelBufferWin32>
#include <vector>
#include <map>
#include <sstream>
#include <windowsx.h>
using namespace osgViewer;
PixelBufferWin32::PixelBufferWin32( osg::GraphicsContext::Traits* traits ):
_hwnd(0),
_hdc(0),
_hglrc(0),
_initialized(false),
_valid(false),
_realized(false)
{
_traits = traits;
init();
if (valid())
{
setState( new osg::State );
getState()->setGraphicsContext(this);
if (_traits.valid() && _traits->sharedContext)
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
}
}
}
PixelBufferWin32::~PixelBufferWin32()
{
}
bool PixelBufferWin32::valid() const
{
return _valid;
}
bool PixelBufferWin32::realizeImplementation()
{
osg::notify(osg::NOTICE) << "PixelBufferWin32::realizeImplementation() not implemented." << std::endl; return false;
}
bool PixelBufferWin32::isRealizedImplementation() const
{
osg::notify(osg::NOTICE) << "PixelBufferWin32::isRealizedImplementation() not implemented." << std::endl; return false;
}
void PixelBufferWin32::closeImplementation()
{
osg::notify(osg::NOTICE) << "PixelBufferWin32::closeImplementation() not implemented." << std::endl;
}
bool PixelBufferWin32::makeCurrentImplementation()
{
osg::notify(osg::NOTICE) << "PixelBufferWin32::makeCurrentImplementation() not implemented." << std::endl;
return false;
}
bool PixelBufferWin32::makeContextCurrentImplementation( GraphicsContext* /*readContext*/ )
{
osg::notify(osg::NOTICE) << "PixelBufferWin32::makeContextCurrentImplementation(..) not implemented." << std::endl;
return false;
}
bool PixelBufferWin32::releaseContextImplementation()
{
osg::notify(osg::NOTICE) << "PixelBufferWin32::releaseContextImplementation(..) not implemented." << std::endl;
return false;
}
void PixelBufferWin32::bindPBufferToTextureImplementation( GLenum /*buffer*/ )
{
osg::notify(osg::NOTICE) << "PixelBufferWin32::void bindPBufferToTextureImplementation(..) not implemented." << std::endl;
}
void PixelBufferWin32::swapBuffersImplementation()
{
osg::notify(osg::NOTICE) << "PixelBufferWin32:: swapBuffersImplementation() not implemented." << std::endl;
}