#include <Graphic3d_Group.hxx>
#include <Graphic3d_ShaderObject.hxx>
#include <Graphic3d_ShaderProgram.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_GlCore20.hxx>
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
// To test linking against OpenGl_Workspace and all aspect classes
- const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker();
- aMA->Aspect()->Type();
- const OpenGl_AspectText* aTA = theWorkspace->AspectText();
- aTA->Aspect()->Font();
- OpenGl_Vec4 aColor = theWorkspace->LineColor();
+ const OpenGl_Aspects* aMA = theWorkspace->Aspects();
+ aMA->Aspect()->MarkerType();
+ OpenGl_Vec4 aColor = theWorkspace->InteriorColor();
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), Aspect_TOL_SOLID,
Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, false,
//function : VShaderProg
//purpose : Sets the pair of vertex and fragment shaders for the object
//==============================================================================
-static Standard_Integer VShaderProg (Draw_Interpretor& /*theDI*/,
+static Standard_Integer VShaderProg (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{
anArg.LowerCase();
Graphic3d_TypeOfShaderObject aShaderTypeArg = Graphic3d_TypeOfShaderObject(-1);
if (!aProgram.IsNull()
- && aProgram->ShaderObjects().IsEmpty()
- && (anArg == "-off"
- || anArg == "off"))
+ && anArg == "-uniform"
+ && anArgIter + 2 < theArgNb)
+ {
+ TCollection_AsciiString aName = theArgVec[++anArgIter];
+ aProgram->PushVariableFloat (aName, float (Draw::Atof (theArgVec[++anArgIter])));
+ }
+ else if (anArg == "-list"
+ || ((anArg == "-update"
+ || anArg == "-dump"
+ || anArg == "-debug"
+ || anArg == "-reload"
+ || anArg == "-load")
+ && anArgIter + 1 < theArgNb))
+ {
+ Handle(OpenGl_Context) aGlCtx;
+ if (Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aCtx->CurrentViewer()->Driver()))
+ {
+ aGlCtx = aDriver->GetSharedContext();
+ }
+ if (aGlCtx.IsNull())
+ {
+ std::cout << "Error: no OpenGl_Context\n";
+ return 1;
+ }
+
+ if (anArg == "-list")
+ {
+ for (OpenGl_Context::OpenGl_ResourcesMap::Iterator aResIter (aGlCtx->SharedResources()); aResIter.More(); aResIter.Next())
+ {
+ if (Handle(OpenGl_ShaderProgram) aResProg = Handle(OpenGl_ShaderProgram)::DownCast (aResIter.Value()))
+ {
+ theDI << aResProg->ResourceId() << " ";
+ }
+ }
+ }
+ else
+ {
+ TCollection_AsciiString aShaderName = theArgVec[++anArgIter];
+ Handle(OpenGl_ShaderProgram) aResProg;
+ if (!aGlCtx->GetResource (aShaderName, aResProg))
+ {
+ std::cout << "Syntax error: shader resource '" << aShaderName << "' is not found\n";
+ return 1;
+ }
+ if (aResProg->UpdateDebugDump (aGlCtx, "", false, anArg == "-dump"))
+ {
+ aCtx->UpdateCurrentViewer();
+ }
+ }
+ if (anArgIter + 1 < theArgNb)
+ {
+ std::cout << "Syntax error: wrong number of arguments\n";
+ return 1;
+ }
+ return 0;
+ }
+ else if (!aProgram.IsNull()
+ && aProgram->ShaderObjects().IsEmpty()
+ && (anArg == "-off"
+ || anArg == "off"))
{
aProgram.Nullify();
}
"\n\t\t: [-off] [-phong] [-aspect {shading|line|point|text}=shading]"
"\n\t\t: [-header VersionHeader]"
"\n\t\t: [-tessControl TessControlShader -tesseval TessEvaluationShader]"
- "\n\t\t: Assign custom GLSL program to presentation aspects.",
+ "\n\t\t: [-uniform Name FloatValue]"
+ "\n\t\t: Assign custom GLSL program to presentation aspects."
+ "\nvshader [-list] [-dump] [-reload] ShaderId"
+ "\n\t\t: -list prints the list of registered GLSL programs"
+ "\n\t\t: -dump dumps specified GLSL program (for debugging)"
+ "\n\t\t: -reload restores dump of specified GLSL program",
__FILE__, VShaderProg, aGroup);
theCommands.Add("vshaderprog", "Alias for vshader", __FILE__, VShaderProg, aGroup);
}