/////////////////////////////////////////////////////////////////////////////// // 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 ODOPENGLVECTORIZER_INCLUDED #define ODOPENGLVECTORIZER_INCLUDED #include "TD_PackPush.h" #include "Gs/GsBaseInclude.h" #include "Gs/GsBaseMaterialView.h" #include "Gs/GsProperties.h" #include "RxObjectImpl.h" #include "Gi/GiPlotStyleDefs.h" #include "Gi/GiGeometrySimplifier.h" #include "ExFPPrecisionFix.h" #include "../ExColorConverterCallback.h" #include "GsOpenGLInclude.h" class OdGiLightTraitsData; class OdGeQuaternion; #ifdef OD_OGL_ES #include "OdStack.h" //DOM-IGNORE-BEGIN /** \details */ struct OdGlEsTexGenSaver { double sPlane[4]; double tPlane[4]; }; /** \details */ class OdGlEsStencilBitSaver { protected: struct Entry { GLboolean m_enabled; GLenum m_func; GLint m_ref; GLuint m_mask; GLenum m_fail; GLenum m_zfail; GLenum m_zpass; GLuint m_writemask; }; OdStack m_stack; public: OdGlEsStencilBitSaver() { } void pushAttrib(); void popAttrib(); }; #endif //DOM-IGNORE-END /** \details This class implements device -independent OpenGL Vectorizer devices. Library: Source code provided. */ class OdGsOpenGLVectorizeDevice : public OdGsBaseVectorizeDevice { friend class OdGsOpenGLVectorizeView; bool m_bDiscardBackFaces; bool m_bClearScreen; bool m_bForceAlternativeHlt; OdUInt32 m_alternativeHltColor; bool m_bUseTTFCache; OdUInt32 m_bUseLutPalette; bool m_bLinesRepMode; OdUInt32 m_lineweightOptimization; OdGiMaterialTextureManagerPtr m_pTexManager; OdGsBaseDeviceMTHelpers m_deviceSync; GLint m_maxTextureSize; public: /** List of OpenGL extensions used by device. */ enum OpenGLExtension { OpenGLExtension_EXT_bgra = 0, // GL_EXT_bgra OpenGL extension OpenGLExtension_ARB_NPOT, // GL_ARB_texture_non_power_of_two OpenGLExtension_ARB_Mirror, // GL_ARB_texture_mirrored_repeat OpenGLExtension_ARB_Transpose, // GL_ARB_transpose_matrix OpenGLExtension_EXT_BlendClr, // GL_EXT_blend_color OpenGLExtension_EXT_Dxt, // GL_EXT_texture_compression_s3tc OpenGLExtension_EXT_EdgeClamp, // GL_EXT_texture_edge_clamp OpenGLExtension_ARB_VertexBuf, // GL_ARB_vertex_buffer_object OpenGLExtension_ARB_PixelBuf, // GL_ARB_pixel_buffer_object OpenGLExtension_ARB_FragProg, // GL_ARB_fragment_program OpenGLExtension_ARB_WinPos, // GL_ARB_window_pos #if defined(ODA_WINDOWS) OpenGLExtension_ARB_PixelFormat, // WGL_ARB_pixel_format OpenGLExtension_ARB_PBuffer, // WGL_ARB_pbuffer #endif OpenGLExtension_NExtensions // Count of extensions used by device }; /** List of OpenGL extension functions used by device. */ enum OpenGLExtFunc { // GL_ARB_transpose_matrix functions OpenGLExtFunc_ARB_LoadTransposeMatrixf = 0, OpenGLExtFunc_ARB_LoadTransposeMatrixd, OpenGLExtFunc_ARB_MultTransposeMatrixf, OpenGLExtFunc_ARB_MultTransposeMatrixd, // GL_EXT_blend_color functions OpenGLExtFunc_EXT_BlendColor, // GL_EXT_texture_compression_s3tc functions OpenGLExtFunc_EXT_CompressedTexImage2D, // GL_ARB_pixel_buffer_object functions OpenGLExtFunc_ARB_BindBuffer, OpenGLExtFunc_ARB_DeleteBuffers, OpenGLExtFunc_ARB_GenBuffers, OpenGLExtFunc_ARB_IsBuffer, OpenGLExtFunc_ARB_BufferData, OpenGLExtFunc_ARB_BufferSubData, OpenGLExtFunc_ARB_GetBufferSubData, OpenGLExtFunc_ARB_MapBuffer, OpenGLExtFunc_ARB_UnmapBuffer, OpenGLExtFunc_ARB_GetBufferParameteriv, OpenGLExtFunc_ARB_GetBufferPointerv, // GL_ARB_fragment_program functions OpenGLExtFunc_ARB_ActiveTexture, OpenGLExtFunc_ARB_ProgramString, OpenGLExtFunc_ARB_BindProgram, OpenGLExtFunc_ARB_DeletePrograms, OpenGLExtFunc_ARB_GenPrograms, OpenGLExtFunc_ARB_ProgramLocalParameter4f, OpenGLExtFunc_ARB_ProgramLocalParameter4fv, // GL_ARB_window_pos OpenGLExtFunc_ARB_WindowPos2i, #if defined(ODA_WINDOWS) // WGL_ARB_pixel_format functions OpenGLExtFunc_ARB_GetPixelFormatAttribiv, OpenGLExtFunc_ARB_GetPixelFormatAttribfv, OpenGLExtFunc_ARB_ChoosePixelFormat, // WGL_ARB_pbuffer functions OpenGLExtFunc_ARB_CreatePBuffer, OpenGLExtFunc_ARB_GetPBufferDC, OpenGLExtFunc_ARB_ReleasePBufferDC, OpenGLExtFunc_ARB_DestroyPBuffer, OpenGLExtFunc_ARB_QueryPBuffer, #endif OpenGLExtFunc_NFuncs }; protected: enum OpenGLExtSupport { kExtSupportUndetermined = -1, kExtNotSupported = 0, kExtSupported = 1 }; mutable OpenGLExtSupport m_extAvail[OpenGLExtension_NExtensions]; mutable void* m_extFuncs[OpenGLExtFunc_NFuncs]; virtual OpenGLExtSupport checkExtensionSupport(const char *pExtName, OpenGLExtension extIdx) const; virtual const char *getExtensionNameFromList(OpenGLExtension extIdx) const; // This is required to be sure if platform wrapper could provide function accessors virtual bool checkExtensionFuncSupport(OpenGLExtension extIdx) const; // Should be overrided by platform wrapper virtual void *getExtensionFuncPtrFromList(OpenGLExtFunc funcIdx) const; virtual void *getExtensionFuncPtrFromListInt(const char *pFuncName) const; // Should be overrided by platform wrapper virtual void onContextCreate(); virtual void onContextDelete(); public: /** \details Default constructor for the OdGsOpenGLVectorizeDevice class. */ OdGsOpenGLVectorizeDevice(); /** \details Destructor for the OdGsOpenGLVectorizeDevice class. */ ~OdGsOpenGLVectorizeDevice(); virtual void preReleaseResource() { } virtual void postReleaseResource() { } /** \details Updates screen display. */ void updateScreen(); /** \details Checks compatibility between specified OdGsModel and this device. \param pModel [in] Model object pointer to check compatibility. \returns true if the provided model is compatible with this device, false otherwise. \remarks Use this method to check compatibility of existing Model object and newly created device to be sure that existing Model object could be used with this Device object. If Device object use overriden Model object it should return false if input Model object isn't overriden. Typical way to check compatibility is using RTTI. \remarks Model sharing is not supported on this level. */ bool isModelCompatible(OdGsModel* pModel) const { return OdGsDevice::isModelCompatible(pModel); } /** \details Checks whether multithreading is supported. \returns By default returns false. */ virtual bool supportMultithreading() const { return false; } /** \details Returns color converter used by the device. \returns Pointer to the OdColorConverterCallback object. \remarks For more information, see */ OdColorConverterCallback *getColorConverter(); /** \details Converts the passed color. \param color [in] Color to convert. \param bBackground [in] Flag that indicates whether the color is background color. \returns Converted color. */ ODCOLORREF colorConvert(ODCOLORREF color, bool bBackground = false); /** \details Setup OpenGL viewport. \param xOffset [in] Horizontal offset in pixels. \param yOffset [in] Vertical offset in pixels. \param width [in] Viewport width in pixels. \param height [in] Viewport height in pixels. */ void setGLViewport(long int xOffset, long int yOffset, long int width, long int height); /** \details Returns actual window height if this is possible. \returns Window height in pixels. */ virtual long int windowHeight() const { return vOffset() + height(); } /** \details Clears (erases) this Vectorizer Device. */ virtual void clear(); /** \details Checks whether the back faces are discarded. \returns true if back faces are discarded, false otherwise. \remarks The back-face culling process makes rendering quicker and more efficient by reducing the number of triangles for the program to draw. For convex geometry primitives it removes invisible faces on the primitive's back side. */ bool discardBackFaces() const { return m_bDiscardBackFaces; } /** \details Controls the discarding of back faces. \param discard [in] Controls discarding of back faces. \remarks The back-face culling process makes rendering quicker and more efficient by reducing the number of triangles for the program to draw. For convex geometry primitives it removes invisible faces on the primitive's back side. */ void setDiscardBackFaces(bool discard) { m_bDiscardBackFaces = discard; } /** \details Returns common regeneration coefficient. \returns Regeneration coefficient value. \remarks Since 3D vectorization devices invoke with GPU's that typically don't support 64-bit floating point variables, a geometry which is placed on large coordinates can look broken because of truncation to 32-bit floating point variables. An application can use this device property to detect if truncation takes place and initiate geometry regeneration. */ double getRegenCoef() const; /** \details Returns current state of ClearScreen flag. \returns true if the ClearScreen flag is enabled, false otherwise. \remarks By default vectorization devices clear their rendering surface with a specified background color. This property can be set to false to prevent surface filling by the background color. This feature is useful in the case when multiple devices are used to render onto a single rendering surface. */ bool isClearScreenEnabled() const { return m_bClearScreen; } /** \details Sets new state of ClearScreen flag. \param bSet [in] New flag state. \remarks By default vectorization devices clear their rendering surface with a specified background color. This property can be set to false to prevent surface filling by the background color. This feature is useful in the case when multiple devices are used to render onto a single rendering surface. */ void enableClearScreen(bool bSet) { m_bClearScreen = bSet; } /** \details Returns current state of AlternativeHlt flag. \returns true if the AlternativeHlt flag is enabled, false otherwise. \remarks This flag instructs vectorizer to use alternative highlighting behavior. Highlighting in alternative highlighting behavior renders as a semi-transparent color on top of highlighted geometry. */ bool isAlternativeHltEnabled() const { return m_bForceAlternativeHlt; } #ifndef OD_OGL_ALTERNATIVEHLT /** \details Sets new state of AlternativeHlt flag. \param bSet [in] New flag state. \remarks This flag instructs vectorizer to use alternative highlighting behavior. Highlighting in alternative highlighting behavior renders as a semi-transparent color on top of highlighted geometry. */ void enableAlternativeHlt(bool bSet) { m_bForceAlternativeHlt = bSet; } #else /** \details Sets new state of AlternativeHlt flag. \remarks This variation of the method does nothing. \remarks This flag instructs vectorizer to use alternative highlighting behavior. Highlighting in alternative highlighting behavior renders as a semi-transparent color on top of highlighted geometry. */ void enableAlternativeHlt(bool /*bSet*/) { } #endif /** \details Returns alternative highlighting color. \returns Alternative highlighting color value. */ OdUInt32 alternativeHltColor() const { return m_alternativeHltColor; } /** \details Sets alternative highlighting color. \param newColor [in] New alternative highlighting color. */ void setAlternativeHltColor(OdUInt32 newColor) { m_alternativeHltColor = newColor; } /** \details Returns current state of UseTTFCache flag. \returns true if the m_bUseTTFCache flag is enabled, false otherwise. \remarks TrueType fonts cache is useful for rendering drawings that contain a lot of text. If TrueType fonts cache is enabled, each font character used inside the drawing is cached as a separate metafile. This feature reduces memory usage, but rendering can be little bit slower if it is turned on. */ bool isTTFCacheEnabled() const { return m_bUseTTFCache; } /** \details Sets new state of UseTTFCache flag. \param bSet [in] New flag state. \remarks TrueType fonts cache is useful for rendering drawings that contain a lot of text. If TrueType fonts cache is enabled, each font character used inside the drawing is cached as a separate metafile. This feature reduces memory usage, but rendering can be little bit slower if it is turned on. */ void enableTTFCache(bool bSet) { m_bUseTTFCache = bSet; } /** \details Returns current state of UseLutPalette flags. \returns A set of flags that instruct a vectorization device how to process raster images with a palette. BitValue 1 Process monochrome raster images as 1 byte per pixel textures with palette. This reduces memory usage for monochrome raster images 2 Process 4 and 8 bits per pixel raster images as 1 byte per pixel textures with palette. This reduces memory usage for raster images with 16 and 256 color palettes
*/ OdUInt32 useLutPalette() const { return m_bUseLutPalette; } /** \details Sets new state of UseLutPalette flags. \param bSet [in] New flags state. \remarks A set of flags instruct a vectorization device how to process raster images with a palette. BitValue 1 Process monochrome raster images as 1 byte per pixel textures with palette. This reduces memory usage for monochrome raster images 2 Process 4 and 8 bits per pixel raster images as 1 byte per pixel textures with palette. This reduces memory usage for raster images with 16 and 256 color palettes
*/ void setUseLutPalette(OdUInt32 bSet) { m_bUseLutPalette = bSet; } /** \details Checks whether the UseLutPalette flag is applicable for the specified color depth. \param colDepth [in] Color depth. \returns true if the corresponding bit is set for the specified color depth, false otherwise. */ bool canUseLutPalette(OdUInt32 colDepth) const { if (colDepth > 2) colDepth = 2; return GETBIT(m_bUseLutPalette, colDepth); } /** \details Returns current state of LinesRepMode flag. \returns true if old-style detection of degenerate lines is enabled, false otherwise. */ bool isLinesRepModeEnabled() const { return m_bLinesRepMode; } /** \details Sets new state of LinesRepMode flag. \param bSet [in] New flag state. \remarks If bSet flag is true then old-style detection of degenerate lines is enabled. */ void enableLinesRepMode(bool bSet) { m_bLinesRepMode = bSet; } /** \details Returns requested point lineweight optimization state. \returns true if point lineweight optimization is enabled, false otherwise. */ bool isPointLineweightOptimizationEnabled() const { return GETBIT(m_lineweightOptimization, 1); } /** \details Sets requested point lineweight optimization state. \param bSet [in] New flag state. */ void enablePointLineweightOptimization(bool bSet) { SETBIT(m_lineweightOptimization, 1, bSet); } /** \details Returns requested line lineweight optimization state. \returns true if point lineweight optimization is enabled, false otherwise. */ bool isLineLineweightOptimizationEnabled() const { return GETBIT(m_lineweightOptimization, 2); } /** \details Sets requested line lineweight optimization state. \param bSet [in] New flag state. */ void enableLineLineweightOptimization(bool bSet) { SETBIT(m_lineweightOptimization, 2, bSet); } /** \details Checks whether the specified OpenGL extension is supported by driver. \param extIdx [in] Extension index from OpenGLExtension enum. \returns true if OpenGL extension is supported by driver, false otherwise. */ bool isExtensionSupported(OpenGLExtension extIdx) const; /** \details Returns extension function (should be compatible with internal protocol prototype) \param funcIdx [in] Function index from OpenGLExtFunc enum. */ void *getExtensionFunc(OpenGLExtFunc funcIdx) const; /** \details Returns material textures manager. \returns Pointer to the material textures manager. */ OdGiMaterialTextureManager *materialTextureManager(); /** \details Returns MT synchronization helpers. \returns Reference to MT synchronization helpers. */ OdGsBaseDeviceMTHelpers &mtDeviceSync() { return m_deviceSync; } // Extension helpers /** \details Replaces the current matrix with the specified row-major ordered matrix. \param x [in] Matrix. */ void glLoadTransposedMatrix(OdGeMatrix3d &x); /** \details Returns an approximate value of the largest texture that the GL can handle. \returns Maximum texture size value handled by GL. \remarks Must be at least 64. */ GLint glMaxTextureSize() const { return m_maxTextureSize; } // Snapshot support /** \details Gets a snapshot of the current device. \param pImage [out] Receives a snapshot image. \param region [in] Region from which to take a snapshot. */ void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect ®ion); /** \details Gets a snapshot of the graphics view that belongs in the current device. \param pImage [out] Receives a snapshot image. \param region [in] Region from which to take a snapshot. \param pView [in] Pointer to a graphics view from which to take a snapshot. */ void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect ®ion, OdGsView *pView); /** \details Gets snapshot parameters of the current device. \returns Smart pointer to the OdGiRasterImage instance that contains image-related parameters that are used for creating snapshots. */ virtual OdGiRasterImagePtr snapshotImageParams() const; /** \details Gets a snapshot of the current device. \param area [in] Area from which to take a snapshot. \returns Smart pointer to the OdGiRasterImage instance that represents the created snapshot. */ virtual OdGiRasterImagePtr snapshotRegion(const OdGsDCRect &area, bool bCrop) const; }; /** \details This class implements device -independent OpenGL vectorizer views. Library: Source code provided. */ class OdGsOpenGLVectorizeView : public OdGsBaseMaterialViewMT , public OdGiGeometrySimplifier , public ExFPPrecisionFix #ifdef GL_VERSION_1_1 , protected OdGsPropertiesDirectRenderOutput #endif { friend class OdGsOpenGLVectorizeDevice; protected: bool m_bFill; bool m_bTexCoords; bool m_bIsVertsNormals; bool m_bFaceNormalsRequired; bool m_bAcceptColorChange; bool m_bRasterImage; bool m_bForceAlternativeHlt; bool m_bProcessingTTF; bool m_bDontShade; bool m_bFading; OdUInt8 m_nCurFading; bool m_bBackfacesDiscarded; bool m_bDrawTransparency; bool m_bNoColorMod; bool m_bCheckFaceMaterials; bool m_bPlineProc; float m_dLwScaler; OdGeVector3d m_n1, m_n2; OdGeMatrix3d m_correction; OdUInt8Array m_colors; // number of non-default lights OdUInt32 m_numLights; OdOpenGLLinePatt m_lnPattState, m_lnPattPrevState; OdOpenGLFillPatt m_fillPattState, m_fillPattPrevState; // Current recording metafile pointer OdRxObject* m_pCurMetafile; GLfloat m_fCurLw; OdOpenGLLwdSetting m_lineWeight; ODCOLORREF m_cCurColor; // Color converter OdColorConverterCallback *m_pColorConverter; bool m_bConvertBackgroundColor; // Lineweights GLfloat m_fMaxLineWidth; mutable OdArray m_lwdCaps; // Transparency patterns mutable OdArray m_trpPats; // Array for optional texture coordinates OdGePoint2dArray m_texCoordsArray; #ifdef OD_OGL_ES OdGlEsTexGenSaver m_esTexGenSaver; OdGlEsStencilBitSaver m_esStencilSaver; #endif const OdGeMatrix3d& projectionCorrection() { return m_correction; } OdGeMatrix3d dividedDcToNormalizedDc() const; void getGLScreenRect(double& left, double& bottom, double& width, double& height); void initArrays(OdInt32 nbVertex, const OdGePoint3d* pVertexList, const OdGiVertexData* pVertexData); void uninitArrays(bool bVertexData); void calcFaceNormal( const OdInt32* indices ); const OdGiPsLinetypes::PsLinetypeOGL *m_psLinetypeDefs; const OdGiPsFillstyles::PsFillstyleOGL *m_psFillstyleDefs; static const GLubyte g_selPatt[128]; virtual void beginFaces(GLenum mode, OdGsView::RenderMode rm); virtual void endFaces(OdGsView::RenderMode rm); public: /** \details Returns a device that owns this view. \returns Pointer a device that contains this view. */ OdGsOpenGLVectorizeDevice* device() { return static_cast(OdGsBaseVectorizeView::device()); } protected: /** \details Sets the draw color for this VectorizeView object. \param color [in] Color. \param colorIndex [in] Color index. \param transparency [in] Transparency. */ void draw_color(const OdCmEntityColor& color); virtual void draw_color(ODCOLORREF color); void draw_color(OdUInt16 colorIndex); void draw_color(const OdCmEntityColor& color, const OdCmTransparency& transparency); void draw_color(OdUInt16 colorIndex, const OdCmTransparency& transparency); /** \details Sets "no color modification" mode state. \param bState [in] New state. */ virtual void draw_noColorMod(bool bState); /** \details Sets the draw lineweight for this VectorizeView object. \param lwLineWeight [in] Lineweight as enum. \param lineweight [in] Lineweight in pixels. */ virtual void draw_lineweight(OdDb::LineWeight lwLineWeight, GLfloat lineweight); /** \details Sets the draw lineweight for this VectorizeView object. \param dLineWeight [in] Plot style Lineweight. \param lineweight [in] Lineweight in pixels. */ virtual void draw_lineweight(double dLineWeight, GLfloat lineweight); /** \details Sets the draw lineweight for this VectorizeView object. \param nLineWeight [in] Lineweight in pixels. \param bReset [in] Reset previously set lineweight override. */ virtual void draw_lineweight(OdInt32 nLineWeight, bool bReset); /** \details Sets the draw linetype for this VectorizeView object. \param lineType [in] Linetype. \param isAdaptive [in] Controls if linetype is adaptive. \param scaleFactor [in] Scale factor for linetype. */ virtual void draw_linetype(OdOpenGLLinePatt::Entry entry, OdInt32 state, bool isAdaptive = true, double scaleFactor = 1.0); /** \details Sets the draw fillstyle for this VectorizeView object. \param fillStyle [in] Fillstyle. */ virtual void draw_fillStyle(OdOpenGLFillPatt::Entry entry, OdInt32 state); /** \details Sets the draw line caps and joints style for this VectorizeView object. \param bByDefault [in] Enables default line style. \param capStyle [in] Line cap style for non-default line style. \param joinStyle [in] Line join style for non-default line style. */ virtual void draw_lineStyle(bool /*bByDefault*/, OdPs::LineEndStyle /*capStyle*/ = OdPs::kLesRound, OdPs::LineJoinStyle /*joinStyle*/ = OdPs::kLjsRound) { } bool usesDept(double* pMinDeptSupported, double* pMaxDeptSupported) const; bool sceneDept(double& zNear, double& zFar) const; OdGeMatrix3d projectionMatrixGL(bool bNoDept); public: /** \details Default constructor for the OdGsOpenGLVectorizeView class. */ OdGsOpenGLVectorizeView(); /** \details Destructor for the OdGsOpenGLVectorizeView class. */ ~OdGsOpenGLVectorizeView(); /** \details Creates a new metafile (cache) object. \returns Smart pointer to the newly created object. */ OdRxObjectPtr newGsMetafile(); /** \details Begins vectorization of the specified metafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void beginMetafile(OdRxObject* pMetafile); /** \details Ends vectorization of the specified metafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void endMetafile(OdRxObject* pMetafile); /** \details Plays (draws) the specified Metafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void playMetafile(const OdRxObject* pMetafile); /** \details Pushes a transformation matrix for a metafile onto the stack. The resulting transformation is created by multiplying the specified transform matrix by the existing one. This allows you to easily adjust an entity coordinate system. Use the popMetafileTransform() to remove this transform matrix from the stack when you are finished with this transformation. \param mtx [in] Transformation matrix. \param uFlags [in] Metafile transform flags. \remarks This method takes effect only if the passed flags parameter has the OdGsBaseVectorizer::kSharedRefUpdate flag set to true. */ void pushMetafileTransform(const OdGeMatrix3d& mtx, OdUInt32 uFlags = 0); /** \details Pops a transformation from the stack. This method should be used after a successful pushMetafileTransform() method call to restore previous transform state. \param uFlags [in] Metafile transform flags. */ void popMetafileTransform(OdUInt32 uFlags = 0); /** \details Retrieves the block insert transform, which is the model-to-world coordinate transform. \returns Model-to-world transform matrix. */ const OdGeMatrix3d &metafileTransform() const; bool useSharedBlockReferences() const { return false; } /** \details Resets fading status. \param bFlag [in] New fading status. \remarks If the passed value is true, the fading is enabled and the method recalculates fog parameter unless alternative highlight behavior is forced. */ void resetFading(bool bFlag); /** \details Enables or disables usage of alternative highlight behavior. \param bFlag [in] Flag that specifies whether to enable alternative highlight behavior. \remarks Typical highlighting behavior of ODA vectorizers is to render a checkerboard pattern for highlighted triangles and a dashed pattern for highlighted lines. Setting this property to true instructs vectorizer to use alternative highlighting behavior. Highlighting in alternative highlighting behavior will be rendered as a semi-transparent color on top of highlighted geometry. */ void alternativeHighlight(bool bHLT); /** \details Checks whether the model cache is enabled. \returns true if model cache is enabled, false otherwise. */ bool isModelCacheEnabled() const; /** \details Adds a light to this VectorizeView object. \param traits [in] Light traits data. \returns Light identifier. */ OdUInt32 addLight(const OdGiLightTraitsData& traits); /** \details Adds a point light to this VectorizeView object. \param traits [in] Light traits data. \sa */ void addPointLight(const OdGiPointLightTraitsData& traits); /** \details Adds a spotlight to this VectorizeView object. \param traits [in] Light traits data. \sa */ void addSpotLight(const OdGiSpotLightTraitsData& traits); /** \details Adds a distant light to this VectorizeView object. \param traits [in] Light traits data. \sa */ void addDistantLight(const OdGiDistantLightTraitsData& traits); /** \details Begins the view vectorization procedure. */ void beginViewVectorization(); /** \details Sets viewport's common data before display() call. */ void loadViewport(); /** \details Ends the view vectorization procedure. */ void endViewVectorization(); bool forceMetafilesDependence() const; /** \details Returns common regeneration coefficient. \returns Regeneration coefficient value. \remarks Since 3D vectorization devices invoke with GPU's that typically don't support 64-bit floating point variables, a geometry which is placed on large coordinates can look broken because of truncation to 32-bit floating point variables. An application can use this device property to detect if truncation takes place and initiate geometry regeneration. */ double regenCoef(); /** \details Method that is called when entity traits are modified. */ void onTraitsModified(); void onHighlightModified(bool bDisableLine = false, bool bDisableFill = false); /** \details Method that is called when render type is changed. \param renderType [in] Render type. \remarks mode must be one of the following: NameValueDescription kUserBg1 -3 User-defined background rendering type without Z-buffer kUserBg2 -2 User-defined background rendering type with own Z-buffer kUserBg3 -1 User-defined background rendering type with Z-buffer kMain 0 Use main Z-buffer kSprite 1 Use alternate Z-buffer (for sprites) kDirect 2 Render on device directly kHighlight 3 Render on device directly (skipping frame buffer and Z-buffer) kHighlightSelection 4 Render on device directly using highlighting style (skipping frame buffer and Z-buffer) kDirectTopmost 5 Render on top of all other render types without Z-buffer kContrast 6 Render with contrast style kCount 7 Number of primary predefined RenderType's kUserFg1 8 User-defined foreground rendering type with Z-buffer kUserFg2 9 User-defined foreground rendering type with own Z-buffer kUserFg3 10 Second user-defined foreground rendering type without Z-buffer
*/ void renderTypeOnChange(OdGsModel::RenderType renderType); /** \details Clears existing lights and assigns lights provided by traversing with the iterator. \param pLightsIterator [in] Pointer to the lights iterator. */ void initLights(OdRxIterator* pLightsIterator); /** \details Updates the lights attached to this VectorizeView object. \remarks The default implementation of this function sets the first light to a distant, "over-the-shoulder" light, and disables all other lights. */ void updateLights(); /** An array of pointers to lights attached to this view. */ OdRxObjectPtrArray m_lights; /** \details Introduces a raster image into this vectorization context in device coordinate system. \param origin [in] Image origin. \param u [in] Image width vector. \param v [in] Image height vector. \param pImage [in] Pointer to a raster image. \param uvBoundary [in] Pointer to an array of boundary points. \param numBoundPts [in] Number of boundary points. \param transparency [in] Flag that specifies image transparency. \param brightness [in] Brightness of an image in range of [0..100]. \param contrast [in] Contrast of an image in range of [0..100]. \param fade [in] Fade of an image in range of [0..100]. \sa */ void rasterImageDc( 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); /** \details Introduces a text into this vectorization context. \param position [in] Position of the text. \param normal [in] Normal to a plane where text lies. Used to define v parameter as normal.crossProduct(direction). \param direction [in] Direction vector that is interpreted as u parameter. \param height [in] Height of the text. \param width [in] Width of the text. \param oblique [in] Oblique angle. Must not exceed an equivalent of 85 degrees in radians in both directions. \param msg [in] Message string. \sa */ void text(const OdGePoint3d& position, const OdGeVector3d& normal, const OdGeVector3d& direction, const OdChar* msg, OdInt32 length, bool raw, const OdGiTextStyle* pTextStyle); /** \details Introduces a pline into this Vectorizer context. \param polyline [in] Polyline data to be processed. \param fromIndex [in] Index of the first segment to be processed. \param numSegs [in] Number of segments to be processed. \sa */ void pline(const OdGiPolyline &polyline, OdUInt32 fromIndex = 0, OdUInt32 numSegs = 0); // OdGiConveyorGeometry // handling primitives in eye CS // required by simplifier /** \details Outputs 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); /** \details Outputs polyline data. \param numPoints [in] Number of points in the polyline. \param vertexIndexList [in] Array of indices of vertices that make up the polyline. \sa */ void polylineOut(OdInt32 numPoints, const OdInt32* vertexIndexList); /** \details Outputs polygon data. \param numPoints [in] Number of points in the polygon. \param vertexList [in] Array of vertices that make up the polygon. \param pNormal [in] Normal vector for the polygon. \sa */ void polygonOut(OdInt32 numPoints, const OdGePoint3d* vertexList, const OdGeVector3d* pNormal); /** \details Tessellates a filled mesh. \param rows [in] Number of rows in the mesh. \param columns [in] Number of columns in the mesh. \param pFaceData [in] Pointer to additional face data. */ void generateMeshFaces(OdInt32 rows, OdInt32 columns, const OdGiFaceData* pFaceData); /** \details Applies given fill pattern to the shell. \param pHatch [in] Smart pointer to hatch pattern to be applied. \param fillDensity [in] Fill density. \param pVertexList [in] Pointer to a vertex list. \param faceListSize [in] Number of faces. \param pFaceList [in] Pointer to a face list. \param pFaceData [in] Additional face data. \param pMapper [in] Pointer to a material mapper. \returns true if pattern is applied successfully and false if pattern is too dense and solid fill is required. */ bool generateShellFill(OdGiHatchPatternPtr pHatch, OdDouble& fillDensity, const OdGePoint3d* pVertexList, OdInt32 faceListSize, const OdInt32* pFaceList, const OdGiFaceData* pFaceData = 0, OdGiMapperItemEntry* pMapper = 0); /** \details Tessellates a filled wireframe shell. \param faceListSize [in] Number of entries in faceList. \param faceList [in] List of numbers that define the faces in the shell. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. */ void generateShellFaces(OdInt32 faceListSize, const OdInt32* faceList, const OdGiEdgeData* pEdgeData, const OdGiFaceData* pFaceData); /** \details Tessellates a wireframe. \param bPline [in] Flag that specifies whether to generate wires for a polyline and not a shell. \param faceListSize [in] Number of entries in faceList. Used when bPline = false. \param faceList [in] List of numbers that define the faces in the shell. Used when bPline = false. \param pEdgeData [in] Pointer to additional edge data. Used when bPline = false. \param pFaceData [in] Pointer to additional face data. Used when bPline = false. */ void generateThinWires(OdInt32 faceListSize = 0, const OdInt32 *pFaceList = NULL, const OdGiEdgeData *pEdgeData = NULL, const OdGiFaceData *pFaceData = NULL); /** \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); /** \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); /** \details Prepares this Vectorizer object for shell and mesh face generation. \param pFaceData [in] Pointer to additional face data. \param rm [in] Render mode for the view. */ virtual void prepareShMFacesGeneration(const OdGiFaceData* pFaceData, OdGsView::RenderMode rm); bool isTextureCoordinatesEnabled(OdGsView::RenderMode rm) const; bool isTextureCoordinatesPredefined() const { return vertexData() && vertexData()->mappingCoords(OdGiVertexData::kAllChannels); } /** \details Outputs a face of a tesselated mesh. \param faceList [in] Array of numbers that define the face. \param pNormal [in] Pointer to the normal to the face. */ void meshFaceOut(const OdInt32* faceList, const OdGeVector3d* pNormal); /** \details Outputs the face of a tessellated shell. \param faceListSize [in] Number of entries in faceList. \param faceList [in] List of numbers that define the face. \param pNormal [in] Normal vector for this face. */ void shellFaceOut(OdInt32 faceListSize, const OdInt32* faceList, const OdGeVector3d* pNormal); /** \details Outputs a triangle. \param vertices [in] List of 3 numbers that define the vertices in the triangle. \param pNormal [in] Normal vector for this triangle. */ void triangleOut( const OdInt32* vertices, const OdGeVector3d* pNormal ); /** \details Initializes a texture map. \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 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]. */ void initTexture(const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiRasterImage* pImage, bool transparency, double brightness, double contrast, double fade); /** \details Releases a texture map. */ void uninitTexture(); virtual bool isTextureLoaded(const OdGiRasterImage* pImage, bool transparency, ODCOLORREF fgColor, // only if transparency enabled bool secColor, ODCOLORREF bkColor, // only if secColor enabled double brightness, double contrast, double fade, const OdUInt8 *&pData, OdUInt32 &bufSize, const OdUInt8 *&pPalData, OdUInt32 &lutSize); virtual void glInitTexture(OdOpenGLAlphaTestType bEnableAlphaTest, GLint glFormat, GLsizei pxWidth, GLsizei pxHeight, const void *pTexture, GLint glFilter, GLint glEnvMode, const OdGeQuaternion &glSPlane, const OdGeQuaternion &glTPlane, OdUInt32 bufSize, bool bBitonal, const void *pPalTexture, OdUInt32 lutSize); void glInitLutTexture(const void *pPalTexture, OdUInt32 lutSize); virtual bool canUseLut() const { return false; } void glInitTextureTransform(OdOpenGLAlphaTestType bEnableAlphaTest, bool bBitonal, GLint glEnvMode, const OdGeQuaternion &glSPlane, const OdGeQuaternion &glTPlane); /** \details Introduces a shell into this Vectorizer context. \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 shell( OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList, const OdGiEdgeData* pEdgeData = NULL, const OdGiFaceData* pFaceData = NULL, const OdGiVertexData* pVertexData = NULL); /** \details Introduces a mesh into this Vectorizer context. \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 mesh( OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d* vertexList, const OdGiEdgeData* pEdgeData = NULL, const OdGiFaceData* pFaceData = NULL, const OdGiVertexData* pVertexData = NULL); /** \details Processes polypoint data. \param numPoints [in] Number of points. \param vertexList [in] Pointer to an array of vertices. \param pColors [in] Pointer to point colors. \param pTransparency [in] Pointer to point transparency. \param pNormals [in] Array of normal vectors. \param pExtrusions [in] Array of vectors defining extrusions. \param pSubEntMarkers [in] Array of sub-entity markers. \param nPointSize [in] Points size. */ void polypointProc(OdInt32 numPoints, const OdGePoint3d* vertexList, const OdCmEntityColor* pColors, const OdCmTransparency* pTransparency = 0, const OdGeVector3d* pNormals = 0, const OdGeVector3d* pExtrusions = 0, const OdGsMarker* pSubEntMarkers = 0, OdInt32 nPointSize = 0); /* These are to be simplified by OdGiGeometrySimplifier void polygonOut(OdInt32 nbPoints, const OdGePoint3d* pVertexList, const OdGeVector3d* pNormal = 0); void polylineProc(OdInt32 nbPoints, const OdGePoint3d* pVertexList, const OdGeVector3d* pNormal = 0, const OdGeVector3d* pExtrusion = 0, OdGsMarker lBaseSubEntMarker = -1); void textProc(const OdGePoint3d& position, const OdGeVector3d& u, const OdGeVector3d& v, const OdChar* msg, OdInt32 length, bool raw, const OdGiTextStyle* pTextStyle, const OdGeVector3d* pExtrusion = 0); void polygonOut(OdInt32 nbPoints, const OdGePoint3d* pVertexList, const OdGeVector3d* pNormal = 0); void polylineProc(OdInt32 nbPoints, const OdGePoint3d* pVertexList, const OdGeVector3d* pNormal = 0, const OdGeVector3d* pExtrusion = 0, OdGsMarker lBaseSubEntMarker = -1); void polygonProc(OdInt32 nbPoints, const OdGePoint3d* pVertexList, const OdGeVector3d* pNormal = 0, const OdGeVector3d* pExtrusion = 0); void circleProc(const OdGePoint3d& center, double radius, const OdGeVector3d& normal, const OdGeVector3d* pExtrusion = 0); void circleProc(const OdGePoint3d&, const OdGePoint3d&, const OdGePoint3d&, const OdGeVector3d* pExtrusion = 0); void circularArcProc(const OdGePoint3d& center, double radius, const OdGeVector3d& normal, const OdGeVector3d& startVector, double sweepAngle, OdGiArcType arcType = kOdGiArcSimple, const OdGeVector3d* pExtrusion = 0); void circularArcProc( const OdGePoint3d& start, const OdGePoint3d& point, const OdGePoint3d& end, OdGiArcType arcType = kOdGiArcSimple, const OdGeVector3d* pExtrusion = 0); void nurbsProc(const OdGeNurbCurve3d& nurbs); void ellipArcProc(const OdGeEllipArc3d& arc, OdGiArcType arcType = kOdGiArcSimple, const OdGeVector3d* pExtrusion = 0); void ellipArcProc(const OdGePoint3d& center, const OdGeVector3d& majorRadius, const OdGeVector3d& minorRadius, const OdGePoint3d& startPoint, const OdGePoint3d& endPoint, OdGiArcType arcType = kOdGiArcSimple, const OdGeVector3d* pExtrusion = 0); void shapeProc(const OdGePoint3d& position, const OdGeVector3d& u, const OdGeVector3d& v, int shapeNo, const OdGiTextStyle* pStyle, const OdGeVector3d* pExtrusion = 0); void shellProc(OdInt32 nbVertex, const OdGePoint3d* pVertexList, OdInt32 faceListSize, const OdInt32* pFaceList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0); void xlineProc(const OdGePoint3d&, const OdGePoint3d&); void rayProc(const OdGePoint3d&, const OdGePoint3d&); void metafileProc( const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiMetafile* pMetafile, bool bDcAligned = true, // reserved bool bAllowClipping = false); // reserved */ /** \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. */ virtual void ownerDrawDc( const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const class OdGiSelfGdiDrawable* pDrawable, bool dcAligned = true, bool allowClipping = false); /** \details Gets a snapshot of the current view. \param pImage [out] Receives a snapshot image. \param region [in] Region from which to take a snapshot. */ void getSnapShot(OdGiRasterImagePtr &pImage, const OdGsDCRect ®ion); // Materials support protected: // OdGsBaseMaterialView overrides virtual bool getDeviceMapperMatrix(OdGeMatrix3d &dm) const; virtual bool skipMaterialProcess(OdDbStub *materialId) const; virtual void nullMaterialStub(); virtual OdGiMaterialItemPtr fillMaterialCache(OdGiMaterialItemPtr prevCache, OdDbStub *materialId, const OdGiMaterialTraitsData &materialData); virtual void renderMaterialCache(OdGiMaterialItemPtr pCache, OdDbStub *materialId); void renderMaterial(OdGiMaterialItemPtr pMaterialItem); virtual OdRxClassPtr createMaterialDesc() const; void checkFaceMaterialChange(); // override viewport frame rendering void drawViewportFrame(); // Background rendering compatibility protected: void display(bool update); void renderBackground(bool secondPass = false); #ifdef GL_VERSION_1_1 void directRenderOutputImage(const OdGePoint3d *pRect, const OdGiRasterImage *pImage, const OdGsPropertiesDirectRenderOutput::DirectRenderImageParams &driParams); OdUInt32 directRenderOutputFlags() const; // directRenderImages cache struct DRICacheElement { DRICacheElement(); DRICacheElement(const DRICacheElement &celm); ~DRICacheElement(); const DRICacheElement &operator =(const DRICacheElement &celm); void initialize(const OdGiDrawable *pDrawable, const OdGiRasterImage *pImage, OdGsOpenGLVectorizeView &view); void destroy(); bool isBackground() const; bool isInitialized() const; bool isEqual(const OdGiDrawable *pDrawable, const OdGiRasterImage *pImage) const; private: const OdGiDrawable* m_pDrawable; // For pointer compare only const OdGiRasterImage* m_pImage; // For pointer compare only public: OdGiDrawable::DrawableType dType; OdUInt32 uTexture; mutable OdUInt32 nRefs; }; OdArray m_driCache; #endif public: void renderLineCap(int iPx, const OdGePoint3d *origin, const OdGeVector3d &fwd, const OdGeVector3d &side, const OdUInt8 *color, OdUInt8 nColorComponents = 4, const OdUInt8 *color2 = NULL) const; /** \details Clears line caps. */ void clearLineCaps() const; /** \details Validates metafile extents. Can be useful to remove invalid geometry with too large extents to display in a scene. \returns true if successful, false otherwise. */ bool validateMetafileExtents() const; const OdUInt8 *renderTransparency(OdUInt8 transp) const; void clearTransparencies() const; void updateLinePattState(); void updateFillPattState(); inline bool forceAlternativeHlt() const { return m_bForceAlternativeHlt; } OdInt32 lwdSettingToPixels(const OdOpenGLLwdSetting &lineWeight) const; }; // Internal types which now moved to header //DOM-IGNORE-BEGIN /** \details Library: Source code provided. */ class OdOpenGLDynamicSubList; /** \details Library: Source code provided. */ class OdOpenGLCheckMarkIface { public: /** \details Defines marker states */ enum MarkerChangeState { /** Highlight state is true */ kHighlightStateChanged = 1, /** Hide state is true */ kVisibilityStateChanged = 1 << 1, /** Transform state is true */ kTransformStateChanged = 1 << 2 }; virtual OdUInt8 metafileCheckMarker(OdOpenGLGsMarker gsMarker, bool bPrevState, const OdGsMatrixParam *&pXform) = 0; virtual void metafileSelectMarker(OdOpenGLGsMarker gsMarker) = 0; }; /** \details Library: Source code provided. */ class OdOpenGLDynamicSubListProc { OdOpenGLDynamicSubList *m_pDynSubList; public: /** \details Default constructor for the OdOpenGLDynamicSubListProc class. */ OdOpenGLDynamicSubListProc(); /** \details Destructor for the OdOpenGLDynamicSubListProc class. */ virtual ~OdOpenGLDynamicSubListProc(); void clear(); void end(); void play(OdGsOpenGLVectorizeView *pOGLView, bool bHighlighted = false, OdOpenGLCheckMarkIface *pCheckMark = NULL) const; void play4Select(OdGsOpenGLVectorizeView *pOGLView, OdGiConveyorGeometry *pGeom, OdGiConveyorContext *pCtx, OdOpenGLCheckMarkIface *pCheckMark = NULL) const; void appendDynamicLwLines(const OdGePoint3d *pPoints, OdInt32 nPoints, const OdOpenGLLwdSetting &lineWeight, ODCOLORREF cColor, OdGsMarker gsMark, bool bSelGeom, bool bSelIgnore, bool bHighlight); void appendDynamicLwLines(const OdGePoint3d *pPoints, const OdInt32* vertexIndexList, OdInt32 nPoints, const OdOpenGLLwdSetting &lineWeight, ODCOLORREF cColor, OdGsMarker gsMark, bool bSelGeom, bool bSelIgnore, bool bHighlight); }; /** \details This class represents a texture data container. Library: Source code provided. */ class OdGiOpenGLMaterialTextureData : public OdGiMaterialTextureData { protected: OdGiPixelBGRA32Array m_pxArray; OdUInt32 m_uWidth, m_uHeight; bool m_bInBGRA; GLint m_nBorder; OdUInt8Array m_pxOpacity; public: /** \details Default constructor for the OdGiOpenGLMaterialTextureData class. */ OdGiOpenGLMaterialTextureData(); /** \details Destructor for the OdGiOpenGLMaterialTextureData class. */ ~OdGiOpenGLMaterialTextureData(); /** \details Set texture pixels from RGBA array. \param pDeviceInfo [in] Optional external device information. \param image [in] Input BGRA image. */ void setTextureData(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, const OdGiImageBGRA32 &image); /** \details Returns texture pixels as array of RGBA colors. \param data [out] Output BGRA colors array. \param width [out] Width of texture. \param width [out] Height of texture. */ void textureData(OdGiPixelBGRA32Array &data, OdUInt32 &width, OdUInt32 &height) const; /** \details Checks whether texture data was previously initialized. \returns true if texture data is initialized, false otherwise. */ bool haveData() const; /** \details Returns a device texture. \returns Pointer to an array of OdGiPixelBGRA32 instances. */ const OdGiPixelBGRA32 *deviceTexture() const; /** \details Renders the texture. \param pDevice [in] Vectorization device. Not used. */ virtual void renderTexture(OdGsOpenGLVectorizeDevice *pDevice); /** \details Sets texture border width. \param nBorder [in] Border width. */ void setBorder(GLint nBorder); void convertToOpacityPattern(); /** \details Multiplies alpha component of the texture by the specified value. \param fValue [in] Multiplication coefficient. */ void adjustAlphaComponent(double fValue); /** \details Returns pixel oppacity pattern. \returns Array of OdUInt8 values composing a pixel opacity pattern. */ inline const OdUInt8Array &accessOpacityPattern() const { return m_pxOpacity; } // RxClass class Desc : public OdRxClass { public: OdRxObjectPtr create() const; }; }; //DOM-IGNORE-END /** \details Structure contains cached material data. */ struct OdOpenGLMaterialData { /** Ambient color material component. */ GLfloat m_paAmbient[4]; /** Diffuse color material component. */ GLfloat m_paDiffuse[4]; /** Specular color material component. */ GLfloat m_paSpecular[4]; /** Specular power. */ GLfloat m_fSpecularPower; /** Emmision color material component. */ GLfloat m_paEmission[4]; /** Flag that indicates whether to use diffuse material component. */ bool m_bUseDiffuseMat; /** Flag that indicates whether to use ambient material component. */ bool m_bUseAmbientMat; /** Flag that indicates whether to use specular material component. */ bool m_bUseSpecularMat; /** Indicates material channels that are in use. */ GLenum m_nUseChannel; /** Material opacity percentage. */ double m_fOpacityPercentage; /** Material blend factor. 0 - no diffuse map, 1 - opaque diffuse map. */ double m_fDiffuseBlendFactor; /** Material tiling for u and v parameters. */ OdGiMapper::Tiling m_uTiling, m_vTiling; }; /** \details This class represents a cached data container. Library: Source code provided. */ class OdOpenGLMaterialDataContainer : public OdRxObject { protected: OdOpenGLMaterialData m_mData; public: /** \details Default constructor for the OdOpenGLMaterialDataContainer class. */ OdOpenGLMaterialDataContainer() { } /** \details Destructor for the OdOpenGLMaterialDataContainer class. */ ~OdOpenGLMaterialDataContainer() { } /** \details Returns material data contained by this container. \returns Constant reference to the material data. */ inline const OdOpenGLMaterialData &data() const { return m_mData; } /** \details Returns material data contained by this container. \returns Reference to the material data. */ inline OdOpenGLMaterialData &data() { return m_mData; } /** \details Sets material data for this container. \param mData [in] Material data. */ inline void setData(const OdOpenGLMaterialData &mData) { m_mData = mData; } }; /** \details Wraps resource releasing. Library: Source code provided. */ class OdOpenGLWrapResourceRelease { protected: OdGsOpenGLVectorizeDevice *m_pDevice; public: /** \details Constructor for the OdOpenGLWrapResourceRelease implementation class. \param pDevice [in] a pointer to the OdGsOpenGLVectorizeDevice class that represents a device for which resources need to be released. \remarks Performs operations prior to releasing resources. */ OdOpenGLWrapResourceRelease(OdGsOpenGLVectorizeDevice *pDevice) : m_pDevice(pDevice) { if (pDevice) pDevice->preReleaseResource(); } /** \details Destructor for the OdOpenGLWrapResourceRelease implementation class. \remarks Performs operations after releasing resources. */ ~OdOpenGLWrapResourceRelease() { if (m_pDevice) m_pDevice->postReleaseResource(); } }; // bool OpenGLParseExtension_base(const char *pExtName, const char *pExtensions = NULL); #include "TD_PackPop.h" #endif //ODOPENGLVECTORIZER_INCLUDED