1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

Compare commits

..

6 Commits

Author SHA1 Message Date
kgv
2c9d55a1aa 0031373: Samples - provide sample combining OCCT and 3 viewer 2020-02-17 15:14:34 +03:00
kgv
566851816b 0031315: Visualization - marker texture is lost after multi-textured object
OpenGl_Context::BindTextures() now iterates over pair of texture sets
considering inconsistent texture unit ranges.
2020-02-17 14:35:46 +03:00
kgv
b380b06c5d 0031206: Foundation Classes, Message_PrinterSystemLog - log messages to Browser console within Emscripten
Message_PrinterOStream::SetConsoleTextColor() skips color tags in case of Emscripten.
Message_PrinterSystemLog now implements log via emscripten_log().
2020-02-17 14:35:46 +03:00
kgv
c64efd9e30 0031375: Visualization, TKOpenGl - suppress warning on WebGL 1.0
Check for WebGL version in advance.
2020-02-17 14:35:44 +03:00
kgv
cd43c08f2b 0031372: Visualization, TKOpenGl - failed to create texture on OpenGL ES 2.0 due to unknown GL_TEXTURE_BASE_LEVEL
OpenGl_Sampler::applySamplerParams() has been corrected to check for OpenGL ES 3.0
when applying GL_TEXTURE_BASE_LEVEL/GL_TEXTURE_MAX_LEVEL parameters.
2020-02-16 15:05:41 +03:00
nds
28b13b31aa 0031014: Inspectors - variables for Qt in CMake
It restores path to Qt binaries in 3RDPARTY_DLL_DIRS for correct start TInspectorEXE under VStudio.
2020-02-13 20:48:05 +03:00
19 changed files with 347 additions and 127 deletions

View File

@@ -7,7 +7,8 @@ if (NOT DEFINED ${3RDPARTY_QT_DIR} AND ${3RDPARTY_QT_DIR} STREQUAL "")
FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" Qt 3RDPARTY_QT_DIR_NAME)
if (NOT DEFINED ${3RDPARTY_QT_DIR_NAME} AND ${3RDPARTY_QT_DIR_NAME} STREQUAL "")
message (FATAL_ERROR "... Qt root directory was not found")
set (3RDPARTY_QT_DIR "" CACHE PATH "The directory containing qt")
message (FATAL_ERROR "Could not find used third-party product: 3RDPARTY_QT_DIR")
endif()
# Combine directory name with absolute path and show in GUI
@@ -31,4 +32,10 @@ if (NOT ${Qt5_FOUND})
#message (STATUS "Qt4 cmake configuration")
else()
#message (STATUS "Qt5 cmake configuration")
endif()
endif()
if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}")
list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin")
else()
list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_QT_DLL_DIR)
endif()

View File

@@ -52,6 +52,14 @@ namespace
return aDevicePixelRatio;
});
/*EM_JS(void, jsSetOcctCamera, (float theFOV, float theAspect, float theNear, float theFar), {
setOcctCamera();
});*/
EM_JS(void, jsPostFrameRender, (), {
postFrameRender();
});
//! Return cavas size in pixels.
static Graphic3d_Vec2i jsCanvasSize()
{
@@ -336,7 +344,13 @@ void WasmOcctView::handleViewRedraw (const Handle(AIS_InteractiveContext)& theCt
const Handle(V3d_View)& theView)
{
myUpdateRequests = 0;
theView->Invalidate(); /// Three.js cannot be rendered properly without full redraw
glEnable (GL_POLYGON_OFFSET_FILL); /// reset defaults Graphic3d_PolygonOffset after Three.js
glPolygonOffset (1.0f, 1.0f);
AIS_ViewController::handleViewRedraw (theCtx, theView);
jsPostFrameRender();
if (myToAskNextFrame)
{
// ask more frames

View File

@@ -4,6 +4,7 @@
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <Message_PrinterSystemLog.hxx>
#include <OSD_MemInfo.hxx>
#include <OSD_Parallel.hxx>
@@ -56,6 +57,8 @@ static void onFileReadFailed (void* theOpaque)
int main()
{
Message::DefaultMessenger()->Printers().First()->SetTraceLevel (Message_Trace);
Handle(Message_PrinterSystemLog) aJSConsolePrinter = new Message_PrinterSystemLog ("webgl-sample", Message_Trace);
Message::DefaultMessenger()->AddPrinter (aJSConsolePrinter); // open JavaScript console within the Browser to see this output
Message::DefaultMessenger()->Send (TCollection_AsciiString("NbLogicalProcessors: ") + OSD_Parallel::NbLogicalProcessors(), Message_Trace);
aViewer.run();
Message::DefaultMessenger()->Send (OSD_MemInfo::PrintInfo(), Message_Trace);

View File

@@ -16,6 +16,7 @@
<div><label for="fileInput">Choose BREP file to upload: </label><input type="file" id="fileInput" accept=".brep"></div>
<h4>Console output:</h4>
<p id="output"></p>
<script src="three.min.js"></script>
<script>
//! Resize canvas to fit into window.
function updateCanvasSize()
@@ -57,6 +58,7 @@ if (!isWasmSupported())
{
var anElement = document.getElementById('output');
anElement.innerHTML += "Browser is too old - WebAssembly support is missing!<br>Please check updates or install a modern browser.<br>";
throw new Error();
}
//! Define OCCT WebGL Viewer module.
@@ -76,6 +78,44 @@ var Module =
})()
};
var aCanvas = document.getElementById ('canvas');
var aGlCtx = aCanvas.getContext ('webgl2', { alpha: false, depth: true, antialias: false, preserveDrawingBuffer: true } );
if (aGlCtx == null)
{
aGlCtx = aCanvas.getContext ('webgl', { alpha: false, depth: true, antialias: false, preserveDrawingBuffer: true } );
}
var aScene = new THREE.Scene();
var aCamera = new THREE.PerspectiveCamera (75, window.innerWidth / window.innerHeight);
//var aRenderer = new THREE.WebGLRenderer ({antialias: true});
var aRenderer = new THREE.WebGLRenderer ({antialias: false, canvas: aCanvas, context: aGlCtx});
aRenderer.autoClear = false;
aRenderer.autoClearColor = false;
aRenderer.autoClearDepth = false;
aRenderer.autoClearStencil = false;
aRenderer.setSize (window.innerWidth,window.innerHeight);
//document.body.appendChild (aRenderer.domElement);
var aGeom = new THREE.BoxGeometry (1,1,1);
var aMat = new THREE.MeshBasicMaterial ({color: 0xff0000});
var aCube = new THREE.Mesh (aGeom, aMat);
aScene.add (aCube);
aCube.position.z = -5; aCube.rotation.x = 10; aCube.rotation.y = 5;
/*aRenderer.render (aScene, aCamera);
var anAnimate = function(){
aCube.rotation.x += 0.01;
aRenderer.state.reset();
aRenderer.render (aScene, aCamera);
requestAnimationFrame (anAnimate);
}
anAnimate();*/
function postFrameRender()
{
//console.log("postFrameRender()"); ///
//aCamera.
aRenderer.state.reset();
aRenderer.render (aScene, aCamera)
}
//! Handle file uploading.
fileInput.onchange = function()
{

View File

@@ -2554,15 +2554,6 @@ void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_Interacti
const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
theObject->SetTransformPersistence (theTrsfPers);
UpdateOnTransformPersistence (theObject);
}
//=======================================================================
//function : UpdateOnTransformPersistence
//purpose :
//=======================================================================
void AIS_InteractiveContext::UpdateOnTransformPersistence (const Handle(AIS_InteractiveObject)& theObject)
{
if (!myObjects.IsBound (theObject))
{
return;

View File

@@ -344,11 +344,6 @@ public: //! @name object local transformation management
Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Updates displayed interactive object by checking and recomputing its flagged as "to be recomputed" presentation and selection structures.
//! This method does not force any recomputation on its own.
//! The method recomputes selections even if they are loaded without activation in particular selector.
Standard_EXPORT void UpdateOnTransformPersistence (const Handle(AIS_InteractiveObject)& theIObj);
Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj,
const Graphic3d_TransModeFlags& theFlag,

View File

@@ -83,17 +83,6 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
}
}
//-----------------------------------------------------------------------------
void AIS_InteractiveObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
SelectMgr_SelectableObject::SetTransformPersistence (theTrsfPers);
if (!GetContext().IsNull())
{
GetContext()->UpdateOnTransformPersistence (this);
}
}
//=======================================================================
//function : HasPresentation
//purpose :

View File

@@ -108,11 +108,6 @@ public:
//! Returns the context pointer to the interactive context.
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
//! Sets up Transform Persistence defining a special Local Coordinate system where this object should be located.
//! Updates the presentation in context if it is not NULL
//! @sa Graphic3d_TransformPers class description
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Returns TRUE when this object has a presentation in the current DisplayMode()
Standard_EXPORT Standard_Boolean HasPresentation() const;

View File

@@ -18,6 +18,7 @@
#include <NCollection_Array1.hxx>
//! Class holding array of textures to be mapped as a set.
//! Textures should be defined in ascending order of texture units within the set.
class Graphic3d_TextureSet : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureSet, Standard_Transient)

View File

@@ -243,6 +243,12 @@ void Message_PrinterOStream::SetConsoleTextColor (Standard_OStream* theOStream,
}
SetConsoleTextAttribute (anStdOut, aFlags);
}
#elif defined(__EMSCRIPTEN__)
// Terminal capabilities are undefined on this platform.
// std::cout could be redirected to HTML page, into terminal or somewhere else.
(void )theOStream;
(void )theTextColor;
(void )theIsIntenseText;
#else
if (theOStream == NULL)
{

View File

@@ -54,6 +54,35 @@
}
return ANDROID_LOG_DEBUG;
}
#elif defined(__EMSCRIPTEN__)
#include <emscripten/emscripten.h>
// actual version of Emscripten does not define these yet
#ifndef EM_LOG_INFO
#define EM_LOG_INFO 0
#endif
#ifndef EM_LOG_DEBUG
#define EM_LOG_DEBUG 0
#endif
//! Convert message gravity into emscripten_log() flags.
static int getEmscriptenPriority (const Message_Gravity theGravity)
{
switch (theGravity)
{
case Message_Trace: return EM_LOG_CONSOLE | EM_LOG_DEBUG;
case Message_Info: return EM_LOG_CONSOLE | EM_LOG_INFO;
case Message_Warning: return EM_LOG_CONSOLE | EM_LOG_WARN;
case Message_Alarm: return EM_LOG_CONSOLE | EM_LOG_ERROR;
case Message_Fail: return EM_LOG_CONSOLE | EM_LOG_ERROR;
}
return EM_LOG_CONSOLE;
}
//! Print message to console.debug().
EM_JS(void, debugMsgToConsole, (const char* theStr), {
console.debug(UTF8ToString(theStr));
});
#else
#include <syslog.h>
@@ -90,6 +119,8 @@ Message_PrinterSystemLog::Message_PrinterSystemLog (const TCollection_AsciiStrin
myEventSource = (Standard_Address )RegisterEventSourceW (NULL, aWideSrcName.ToWideString());
#elif defined(__ANDROID__)
//
#elif defined(__EMSCRIPTEN__)
//
#else
openlog (myEventSourceName.ToCString(), LOG_PID | LOG_NDELAY, LOG_USER);
#endif
@@ -110,6 +141,8 @@ Message_PrinterSystemLog::~Message_PrinterSystemLog()
}
#elif defined(__ANDROID__)
//
#elif defined(__EMSCRIPTEN__)
//
#else
closelog();
#endif
@@ -132,6 +165,15 @@ void Message_PrinterSystemLog::Send (const Standard_CString theString,
Send (TCollection_ExtendedString (theString), theGravity, true);
#elif defined(__ANDROID__)
__android_log_write (getAndroidLogPriority (theGravity), myEventSourceName.ToCString(), theString);
#elif defined(__EMSCRIPTEN__)
if (theGravity == Message_Trace)
{
debugMsgToConsole (theString);
}
else
{
emscripten_log (getEmscriptenPriority (theGravity), "%s", theString);
}
#else
syslog (getSysLogPriority (theGravity), "%s", theString);
#endif
@@ -154,6 +196,15 @@ void Message_PrinterSystemLog::Send (const TCollection_AsciiString& theString,
Send (TCollection_ExtendedString (theString), theGravity, true);
#elif defined(__ANDROID__)
__android_log_write (getAndroidLogPriority (theGravity), myEventSourceName.ToCString(), theString.ToCString());
#elif defined(__EMSCRIPTEN__)
if (theGravity == Message_Trace)
{
debugMsgToConsole (theString.ToCString());
}
else
{
emscripten_log (getEmscriptenPriority (theGravity), "%s", theString.ToCString());
}
#else
syslog (getSysLogPriority (theGravity), "%s", theString.ToCString());
#endif

View File

@@ -56,6 +56,7 @@ OpenGl_TextureFormat.cxx
OpenGl_TextureFormat.hxx
OpenGl_TextureSet.cxx
OpenGl_TextureSet.hxx
OpenGl_TextureSetPairIterator.hxx
OpenGl_Resource.hxx
OpenGl_Resource.cxx
OpenGl_NamedResource.hxx

View File

@@ -195,6 +195,7 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
Standard_Integer& aTextureSetBits = myTextures[0]->ChangeTextureSetBits();
aTextureSetBits = Graphic3d_TextureSetBits_NONE;
Standard_Integer aPrevTextureUnit = -1;
if (theAspect->ToMapTexture())
{
Graphic3d_TextureSet::Iterator aTextureIter (aNewTextureSet);
@@ -212,6 +213,11 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
if (aResource->Init(theCtx, aTexture))
{
aResIter0.ChangeUnit() = aResource->Sampler()->Parameters()->TextureUnit();
if (aResIter0.Unit() < aPrevTextureUnit)
{
throw Standard_ProgramError("Graphic3d_TextureMap defines texture units in non-ascending order");
}
aPrevTextureUnit = aResIter0.Unit();
aResource->Sampler()->SetParameters(aTexture->GetParams());
aResource->SetRevision (aTexture->Revision());
}
@@ -262,6 +268,11 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
// update occupation of texture units
const Graphic3d_TextureUnit aTexUnit = aResource->Sampler()->Parameters()->TextureUnit();
aResIter0.ChangeUnit() = aTexUnit;
if (aResIter0.Unit() < aPrevTextureUnit)
{
throw Standard_ProgramError("Graphic3d_TextureMap defines texture units in non-ascending order");
}
aPrevTextureUnit = aResIter0.Unit();
if (aTexUnit >= Graphic3d_TextureUnit_0 && aTexUnit <= Graphic3d_TextureUnit_5)
{
aTextureSetBits |= (1 << int(aTexUnit));

View File

@@ -31,6 +31,7 @@
#include <OpenGl_FrameStats.hxx>
#include <OpenGl_Sampler.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_TextureSetPairIterator.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_Aspects.hxx>
#include <Graphic3d_TransformUtils.hxx>
@@ -1044,32 +1045,47 @@ void OpenGl_Context::ReadGlVersion (Standard_Integer& theGlVerMajor,
theGlVerMajor = 0;
theGlVerMinor = 0;
#ifdef GL_MAJOR_VERSION
// available since OpenGL 3.0 and OpenGL 3.0 ES
GLint aMajor = 0, aMinor = 0;
glGetIntegerv (GL_MAJOR_VERSION, &aMajor);
glGetIntegerv (GL_MINOR_VERSION, &aMinor);
// glGetError() sometimes does not report an error here even if
// GL does not know GL_MAJOR_VERSION and GL_MINOR_VERSION constants.
// This happens on some renderers like e.g. Cygwin MESA.
// Thus checking additionally if GL has put anything to
// the output variables.
if (::glGetError() == GL_NO_ERROR && aMajor != 0 && aMinor != 0)
bool toCheckVer3 = true;
#if defined(__EMSCRIPTEN__)
// WebGL 1.0 prints annoying invalid enumeration warnings to console.
toCheckVer3 = false;
if (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE aWebGlCtx = emscripten_webgl_get_current_context())
{
theGlVerMajor = aMajor;
theGlVerMinor = aMinor;
return;
}
for (GLenum anErr = ::glGetError(), aPrevErr = GL_NO_ERROR;; aPrevErr = anErr, anErr = ::glGetError())
{
if (anErr == GL_NO_ERROR
|| anErr == aPrevErr)
EmscriptenWebGLContextAttributes anAttribs = {};
if (emscripten_webgl_get_context_attributes (aWebGlCtx, &anAttribs) == EMSCRIPTEN_RESULT_SUCCESS)
{
break;
toCheckVer3 = anAttribs.majorVersion >= 2;
}
}
#endif
// Available since OpenGL 3.0 and OpenGL ES 3.0.
if (toCheckVer3)
{
GLint aMajor = 0, aMinor = 0;
glGetIntegerv (GL_MAJOR_VERSION, &aMajor);
glGetIntegerv (GL_MINOR_VERSION, &aMinor);
// glGetError() sometimes does not report an error here even if
// GL does not know GL_MAJOR_VERSION and GL_MINOR_VERSION constants.
// This happens on some renderers like e.g. Cygwin MESA.
// Thus checking additionally if GL has put anything to
// the output variables.
if (::glGetError() == GL_NO_ERROR && aMajor != 0 && aMinor != 0)
{
theGlVerMajor = aMajor;
theGlVerMinor = aMinor;
return;
}
for (GLenum anErr = ::glGetError(), aPrevErr = GL_NO_ERROR;; aPrevErr = anErr, anErr = ::glGetError())
{
if (anErr == GL_NO_ERROR
|| anErr == aPrevErr)
{
break;
}
}
}
// Read version string.
// Notice that only first two numbers split by point '2.1 XXXXX' are significant.
// Following trash (after space) is vendor-specific.
@@ -3413,93 +3429,56 @@ Handle(OpenGl_TextureSet) OpenGl_Context::BindTextures (const Handle(OpenGl_Text
if (myActiveTextures != theTextures)
{
Handle(OpenGl_Context) aThisCtx (this);
OpenGl_TextureSet::Iterator aTextureIterOld (myActiveTextures), aTextureIterNew (theTextures);
for (;;)
for (OpenGl_TextureSetPairIterator aSlotIter (myActiveTextures, theTextures); aSlotIter.More(); aSlotIter.Next())
{
if (!aTextureIterNew.More())
const Graphic3d_TextureUnit aTexUnit = aSlotIter.Unit();
const OpenGl_Texture* aTextureOld = aSlotIter.Texture1();
const OpenGl_Texture* aTextureNew = aSlotIter.Texture2();
if (aTextureNew == aTextureOld)
{
for (; aTextureIterOld.More(); aTextureIterOld.Next())
{
if (const Handle(OpenGl_Texture)& aTextureOld = aTextureIterOld.Value())
{
aTextureOld->Unbind (aThisCtx, aTextureIterOld.Unit());
#if !defined(GL_ES_VERSION_2_0)
if (core11 != NULL)
{
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
}
#endif
}
}
break;
}
const Handle(OpenGl_Texture)& aTextureNew = aTextureIterNew.Value();
if (aTextureIterOld.More())
{
const Handle(OpenGl_Texture)& aTextureOld = aTextureIterOld.Value();
if (aTextureNew == aTextureOld
&& aTextureIterNew.Unit() == aTextureIterOld.Unit())
{
aTextureIterNew.Next();
aTextureIterOld.Next();
continue;
}
else if (aTextureNew.IsNull()
|| !aTextureNew->IsValid())
{
if (!aTextureOld.IsNull())
{
aTextureOld->Unbind (aThisCtx, aTextureIterOld.Unit());
#if !defined(GL_ES_VERSION_2_0)
if (core11 != NULL)
{
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
}
#endif
}
aTextureIterNew.Next();
aTextureIterOld.Next();
continue;
}
aTextureIterOld.Next();
}
if (aTextureNew.IsNull())
{
aTextureIterNew.Next();
continue;
}
const Graphic3d_TextureUnit aTexUnit = aTextureIterNew.Unit();
if (aTexUnit >= myMaxTexCombined)
if (aTextureNew != NULL
&& aTextureNew->IsValid())
{
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString("Texture unit ") + aTexUnit + " for " + aTextureNew->ResourceId() + " exceeds hardware limit " + myMaxTexCombined);
aTextureIterNew.Next();
continue;
}
if (aTexUnit >= myMaxTexCombined)
{
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString("Texture unit ") + aTexUnit + " for " + aTextureNew->ResourceId() + " exceeds hardware limit " + myMaxTexCombined);
continue;
}
aTextureNew->Bind (aThisCtx, aTexUnit);
if (aTextureNew->Sampler()->ToUpdateParameters())
{
if (aTextureNew->Sampler()->IsImmutable())
aTextureNew->Bind (aThisCtx, aTexUnit);
if (aTextureNew->Sampler()->ToUpdateParameters())
{
aTextureNew->Sampler()->Init (aThisCtx, *aTextureNew);
if (aTextureNew->Sampler()->IsImmutable())
{
aTextureNew->Sampler()->Init (aThisCtx, *aTextureNew);
}
else
{
OpenGl_Sampler::applySamplerParams (aThisCtx, aTextureNew->Sampler()->Parameters(), aTextureNew->Sampler().get(), aTextureNew->GetTarget(), aTextureNew->HasMipmaps());
}
}
else
#if !defined(GL_ES_VERSION_2_0)
if (core11 != NULL)
{
OpenGl_Sampler::applySamplerParams (aThisCtx, aTextureNew->Sampler()->Parameters(), aTextureNew->Sampler().get(), aTextureNew->GetTarget(), aTextureNew->HasMipmaps());
OpenGl_Sampler::applyGlobalTextureParams (aThisCtx, *aTextureNew, aTextureNew->Sampler()->Parameters());
}
#endif
}
#if !defined(GL_ES_VERSION_2_0)
if (core11 != NULL)
else if (aTextureOld != NULL
&& aTextureOld->IsValid())
{
OpenGl_Sampler::applyGlobalTextureParams (aThisCtx, *aTextureNew, aTextureNew->Sampler()->Parameters());
aTextureOld->Unbind (aThisCtx, aTexUnit);
#if !defined(GL_ES_VERSION_2_0)
if (core11 != NULL)
{
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
}
#endif
}
#endif
aTextureIterNew.Next();
}
myActiveTextures = theTextures;
}

View File

@@ -495,6 +495,16 @@ public:
//! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1).
Standard_Integer TextureWrapClamp() const { return myTexClamp; }
//! @return true if texture parameters GL_TEXTURE_BASE_LEVEL/GL_TEXTURE_MAX_LEVEL are supported.
Standard_Boolean HasTextureBaseLevel() const
{
#if !defined(GL_ES_VERSION_2_0)
return IsGlGreaterEqual (1, 2);
#else
return IsGlGreaterEqual (3, 0);
#endif
}
//! @return maximum degree of anisotropy texture filter
Standard_Integer MaxDegreeOfAnisotropy() const { return myAnisoMax; }

View File

@@ -263,8 +263,8 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, aDegree);
}
if (theCtx->IsGlGreaterEqual(1, 2) &&
(theSampler == NULL || !theSampler->isValidSampler()))
if (theCtx->HasTextureBaseLevel()
&& (theSampler == NULL || !theSampler->isValidSampler()))
{
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_BASE_LEVEL, theParams->BaseLevel());
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_LEVEL, theParams->MaxLevel());

View File

@@ -20,6 +20,7 @@
class OpenGl_Texture;
//! Class holding array of textures to be mapped as a set.
//! Textures should be defined in ascending order of texture units within the set.
class OpenGl_TextureSet : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(OpenGl_TextureSet, Standard_Transient)
@@ -99,12 +100,18 @@ public:
//! Return the first texture.
Handle(OpenGl_Texture)& ChangeFirst() { return myTextures.ChangeFirst().Texture; }
//! Return the first texture unit.
Graphic3d_TextureUnit FirstUnit() const { return myTextures.First().Unit; }
//! Return the last texture.
const Handle(OpenGl_Texture)& Last() const { return myTextures.Last().Texture; }
//! Return the last texture.
Handle(OpenGl_Texture)& ChangeLast() { return myTextures.ChangeLast().Texture; }
//! Return the last texture unit.
Graphic3d_TextureUnit LastUnit() const { return myTextures.Last().Unit; }
//! Return the last texture unit.
Graphic3d_TextureUnit& ChangeLastUnit() { return myTextures.ChangeLast().Unit; }

View File

@@ -0,0 +1,104 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_TextureSetPairIterator_Header
#define _OpenGl_TextureSetPairIterator_Header
#include <OpenGl_TextureSet.hxx>
//! Class for iterating pair of texture sets through each defined texture slot.
//! Note that iterator considers texture slots being in ascending order within OpenGl_TextureSet.
class OpenGl_TextureSetPairIterator
{
public:
//! Constructor.
OpenGl_TextureSetPairIterator (const Handle(OpenGl_TextureSet)& theSet1,
const Handle(OpenGl_TextureSet)& theSet2)
: myIter1 (theSet1),
myIter2 (theSet2),
myTexture1 (NULL),
myTexture2 (NULL),
myUnitLower (IntegerLast()),
myUnitUpper (IntegerFirst()),
myUnitCurrent (0)
{
if (!theSet1.IsNull()
&& !theSet1->IsEmpty())
{
myUnitLower = Min (myUnitLower, theSet1->FirstUnit());
myUnitUpper = Max (myUnitUpper, theSet1->LastUnit());
}
if (!theSet2.IsNull()
&& !theSet2->IsEmpty())
{
myUnitLower = Min (myUnitLower, theSet2->FirstUnit());
myUnitUpper = Max (myUnitUpper, theSet2->LastUnit());
}
myUnitCurrent = myUnitLower;
myTexture1 = (myIter1.More() && myIter1.Unit() == myUnitCurrent)
? myIter1.ChangeValue().get()
: NULL;
myTexture2 = (myIter2.More() && myIter2.Unit() == myUnitCurrent)
? myIter2.ChangeValue().get()
: NULL;
}
//! Return TRUE if there are more texture units to pass through.
bool More() const { return myUnitCurrent <= myUnitUpper; }
//! Return current texture unit.
Graphic3d_TextureUnit Unit() const { return (Graphic3d_TextureUnit )myUnitCurrent; }
//! Access texture from first texture set.
const OpenGl_Texture* Texture1() const { return myTexture1; }
//! Access texture from second texture set.
const OpenGl_Texture* Texture2() const { return myTexture2; }
//! Move iterator position to the next pair.
void Next()
{
++myUnitCurrent;
myTexture1 = myTexture2 = NULL;
for (; myIter1.More(); myIter1.Next())
{
if (myIter1.Unit() >= myUnitCurrent)
{
myTexture1 = myIter1.Unit() == myUnitCurrent ? myIter1.ChangeValue().get() : NULL;
break;
}
}
for (; myIter2.More(); myIter2.Next())
{
if (myIter2.Unit() >= myUnitCurrent)
{
myTexture2 = myIter2.Unit() == myUnitCurrent ? myIter2.ChangeValue().get() : NULL;
break;
}
}
}
private:
OpenGl_TextureSet::Iterator myIter1;
OpenGl_TextureSet::Iterator myIter2;
OpenGl_Texture* myTexture1;
OpenGl_Texture* myTexture2;
Standard_Integer myUnitLower;
Standard_Integer myUnitUpper;
Standard_Integer myUnitCurrent;
};
#endif //_OpenGl_TextureSetPairIterator_Header

16
tests/bugs/vis/bug31315 Normal file
View File

@@ -0,0 +1,16 @@
puts "============="
puts "0031315: Visualization - marker texture is lost after multi-textured object"
puts "============="
pload MODELING VISUALIZATION
vclear
vinit View1
box b 1 2 3
vdisplay -dispMode 1 -highMode 1 b
vtexture b -tex0 3 -tex1 4
vfit
vpoint p0 -1 0 0
vaspects p0 -setMarkerSize 5
if { [vreadpixel 15 310 -rgb -name] != "BLACK" } { puts "Error: Black color is expected" }
vdump ${imagedir}/${casename}.png