/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef ODEXGSOPENGLVECTORIZEDEVICE #define ODEXGSOPENGLVECTORIZEDEVICE #include "TD_PackPush.h" #include "GsOpenGLVectorizer.h" #include "ExGsWin32Device.h" #include "ExGsBitmapDevice.h" #include "CommonOpenGLProps.h" #include "WinComposite/ExGsCompositeModuleInterface.h" // Comment it, if you want compile with non-streamed version of vectorizer #include "GsOpenGLStreamVectorizer.h" // Enables PBuffer extension usage. It optimizes pixel-data extraction from frame buffer. Moreover, glReadPixels isn't // able to read something from non top-level window, in this case PBuffer is necessary for off-screen rendering. #define OD_OGL_USE_PBUFFER // Enables PBO extension usage. It optimizes pixel-data transfer from frame buffer. Moreover, glReadPixels isn't // able to read something from non top-level window, in this case PBuffer is necessary for off-screen rendering. #define OD_OGL_USE_PBO #ifdef OD_OGL_USE_PBUFFER #include "OpenGLExtensions.h" #endif #ifdef OD_OGL_ENABLEMETASTREAM OD_OPENGL_DEFINE_COMMON_PROPS(ExGsOpenGLVectorizeDeviceBase, ExGsCompositeClientDevice, ExGsWin32Device); typedef OdGsOpenGLStreamVectorizeView ExGsOpenGLVectorizeViewBase; #else OD_OPENGL_DEFINE_COMMON_PROPS(ExGsOpenGLVectorizeDeviceBase, ExGsCompositeClientDevice, ExGsWin32Device); typedef OdGsOpenGLVectorizeView ExGsOpenGLVectorizeViewBase; #endif /** \details This class implements a Win32 OpenGL Vectorizer Device objects. Library: Source code provided. */ class ExGsOpenGLVectorizeDevice : public ExGsOpenGLVectorizeDeviceBase { bool m_bContextCreated; HGLRC m_hGLRC; GsDIBSection m_dibSection; OdUInt8 m_uDepthBufferBits; HDC m_hPrevDC; #ifdef OD_OGL_USE_PBUFFER HPBUFFERARB m_pPBuffer; #endif #ifdef OD_OGL_USE_PBO GLuint m_pPBOs[4]; #endif public: /** \details Returns a Windows OpenGL context handle created internally by the renderer. \returns OdIntPtr representing a Windows OpenGL context handle (can be cast to HGLRC). \remarks Applications can set their own or already created OpenGL context, in this case the vectorizer does not create an internal OpenGL context and renders geometry directly inside the context which is set by the application. This option is also useful to enable rendering of multiple devices onto the same graphics surface. */ OdIntPtr getWGLContext() const; /** \details Sets a Windows OpenGL context handle. \param ctx [in] OdIntPtr representing a Windows OpenGL context handle. \remarks Applications can set their own or already created OpenGL context, in this case the vectorizer does not create an internal OpenGL context and renders geometry directly inside the context which is set by the application. This option is also useful to enable rendering of multiple devices onto the same graphics surface. */ void setWGLContext(OdIntPtr ctx); OdUInt8 getDepthBufferBits() const; void setDepthBufferBits(OdUInt8 uSet); /** \details Returns height of a window. \returns Window height in pixels. */ long int windowHeight() const override; protected: ODRX_USING_HEAP_OPERATORS(ExGsOpenGLVectorizeDeviceBase); ODRX_DECLARE_DYNAMIC_PROPERTY_MAP(ExGsOpenGLVectorizeDevice); ExGsOpenGLVectorizeDevice(); ~ExGsOpenGLVectorizeDevice() override; void update(OdGsDCRect* pUpdatedRect) override; void updateScreen() override; /** \details Creates a context for this Device object. */ void createContext() override; void deleteContext() override; void preReleaseResource() override; void postReleaseResource() override; void createPalette(ODGSPALETTE *logicalPalette) override; #ifdef OD_OGL_ENABLEMETASTREAM bool supportMultithreading() const override { return checkMtRegenEnabled(userGiContext()); } #endif OpenGLExtSupport checkExtensionSupport(const char *pExtName, OpenGLExtension extIdx) const override; bool checkExtensionFuncSupport(OpenGLExtension extIdx) const override; void *getExtensionFuncPtrFromListInt(const char *pFuncName) const override; bool requireWindow() const override { return true; } void makeBitBltOp(const ExWinCompositeBitBltOp &bitBltOp) override; OdGiRasterImagePtr snapshotRegion(const OdGsDCRect &area, bool bCrop) const override; }; /** \details This class implements Win32 OpenGL Vectorizer View objects. Library: Source code provided. */ class ExGsOpenGLVectorizeView : public ExGsOpenGLVectorizeViewBase { /** \details Returns a device that owns this view. \returns Pointer a device that contains this view. */ ExGsOpenGLVectorizeDevice* device() { return static_cast(OdGsOpenGLVectorizeView::device()); } bool m_bSelecting; public: /** \details Default constructor for the ExGsOpenGLVectorizeView class. */ ExGsOpenGLVectorizeView(); /** \details Invokes the specified OdGsSelectionReactor object for the specified selection area (or point) in this view. \param points [in] Array of points. \param numPoints [in] Number of points. \param pReactor [in] Pointer to the reactor. \param mode [in] Selection mode. */ void select(const OdGePoint2d* points, int numPoints, OdGsSelectionReactor* pReactor, OdGsView::SelectionMode mode) override; /** \details Processes polyline data. \param numPoints [in] Number of points in the polyline. \param vertexList [in] Array of vertices that make up the polyline. \sa */ void polylineOut(OdInt32 numPoints, const OdGePoint3d* vertexList) override; /** \details Processes mesh data. \param numRows [in] Number of rows. \param numColumns [in] Number of columns. \param vertexList [in] Array of vertices. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. \param pVertexData [in] Pointer to additional vertex data. \sa */ void meshProc(OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d* vertexList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0) override; /** \details Processes shell data. \param numVertices [in] Number of vertices. \param vertexList [in] Array of vertices. \param faceListSize [in] Number of entries in faceList. \param faceList [in] Array of numbers that define the faces. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. \param pVertexData [in] Pointer to additional vertex data. \sa */ void shellProc(OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0) override; /** \details Processes raster images data. \param origin [in] Lower-left corner. \param u [in] Image width vector. \param v [in] Image height vector. \param pImage [in] Pointer to the RasterImage object. \param uvBoundary [in] Array of image boundary points (may not be null). \param numBoundPts [in] Number of boundary points. \param transparency [in] True if and only if image transparency is on. \param brightness [in] Image brightness [0.0 .. 100.0]. \param contrast [in] Image contrast [0.0 .. 100.0]. \param fade [in] Image fade value [0.0 .. 100.0]. \sa */ void rasterImageProc(const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiRasterImage* pImage, const OdGePoint2d* uvBoundary, OdUInt32 numBoundPts, bool transparency = false, double brightness = 50.0, double contrast = 50.0, double fade = 0.0) override; /** \details Processes metafile data. \param origin [in] Metafile origin. \param u [in] Metafile width vector. \param v [in] Metafile height vector. \param pMetafile [in] Pointer to the metafile object. \param dcAligned [in] Reserved. \param allowClipping [in] Reserved. */ void metafileProc(const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiMetafile* pMetafile, bool dcAligned = true, bool allowClipping = false) override; /** \details Passes to the visualization framework an object that can visualize itself. \param origin [in] Object origin. \param u [in] Object width vector. \param v [in] Object height vector. \param pDrawable [in] Pointer to the drawable. \param dcAligned [in] Reserved. \param allowClipping [in] Reserved. \remarks The visualization framework uses this function to visualize Ole2Frame entities. \remarks ownerDrawDc is not conveyor primitive, so the ODA visualization framework performs no processing (transformation, linetyping, or clipping) for this object. All coordinates are in Model coordinates. */ void ownerDrawDc( const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiSelfGdiDrawable* pDrawable, bool dcAligned = true, bool allowClipping = false) override; }; #include "TD_PackPop.h" #endif //ODEXGSOPENGLVECTORIZEDEVICE