Skip to content

Commit

Permalink
Add, import, python, and bundle Glf.
Browse files Browse the repository at this point in the history
  • Loading branch information
furby-tm committed Apr 6, 2024
1 parent bde736c commit 542aaaf
Show file tree
Hide file tree
Showing 77 changed files with 6,390 additions and 6,613 deletions.
53 changes: 53 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ let package = Package(
name: "Hio",
targets: ["Hio"]
),
.library(
name: "Glf",
targets: ["Glf"]
),
// ----- Pixar.UsdImaging -----
.library(
name: "UsdShaders",
Expand Down Expand Up @@ -368,6 +372,11 @@ let package = Package(
type: .dynamic,
targets: ["PyGarch"]
),
.library(
name: "PyGlf",
type: .dynamic,
targets: ["PyGlf"]
),
// ----------------- Apps -----
.executable(
name: "UsdView",
Expand Down Expand Up @@ -415,6 +424,7 @@ let package = Package(
"PyCameraUtil",
"PyPxOsd",
"PyGarch",
"PyGlf",
"PyUsdShaders",
]
),
Expand Down Expand Up @@ -1386,6 +1396,31 @@ let package = Package(
]
),

.target(
name: "Glf",
dependencies: [
.target(name: "Arch"),
.target(name: "Plug"),
.target(name: "Tf"),
.target(name: "Gf"),
.target(name: "Trace"),
.target(name: "Ar"),
.target(name: "Sdf"),
.target(name: "Garch"),
.target(name: "Hf"),
.target(name: "Hio"),
],
resources: [
.process("Resources")
],
cxxSettings: [
.define("MFB_PACKAGE_NAME", to: "Glf"),
.define("MFB_ALT_PACKAGE_NAME", to: "Glf"),
.define("MFB_PACKAGE_MODULE", to: "Glf"),
.define("GLF_EXPORTS", to: "1"),
]
),

.target(
name: "PyTf",
dependencies: [
Expand Down Expand Up @@ -1965,6 +2000,23 @@ let package = Package(
]
),

.target(
name: "PyGlf",
dependencies: [
.target(name: "PixarUSD"),
],
path: "Python/PyGlf",
resources: [
.process("Resources"),
],
publicHeadersPath: "include",
cxxSettings: [
.define("MFB_PACKAGE_NAME", to: "Glf"),
.define("MFB_ALT_PACKAGE_NAME", to: "Glf"),
.define("MFB_PACKAGE_MODULE", to: "Glf"),
]
),

.executableTarget(
name: "UsdView",
dependencies: [
Expand Down Expand Up @@ -2066,6 +2118,7 @@ let package = Package(
.target(name: "HgiGL"),
.target(name: "HgiInterop"),
.target(name: "Hio"),
.target(name: "Glf"),
// --- usd imaging. ------
.target(name: "UsdShaders"),
// -------- macros. ------
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions Python/PyGlf/include/PyGlf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __PXR_IMAGING_PY_GLF_H__
#define __PXR_IMAGING_PY_GLF_H__

/* no includes. */

#endif // __PXR_IMAGING_PY_GLF_H__
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/pxr.h"
#include "pxr/base/tf/pyModule.h"
#include <pxr/pxrns.h>
#include "Tf/pyModule.h"

PXR_NAMESPACE_USING_DIRECTIVE

TF_WRAP_MODULE
{
TF_WRAP( Diagnostic );
TF_WRAP( DrawTarget );
TF_WRAP( Texture );
TF_WRAP( SimpleLight );
TF_WRAP( SimpleMaterial );
TF_WRAP(Diagnostic);
TF_WRAP(DrawTarget);
TF_WRAP(Texture);
TF_WRAP(SimpleLight);
TF_WRAP(SimpleMaterial);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,29 @@
//
////////////////////////////////////////////////////////////////////////

#include "pxr/pxr.h"
#include "pxr/base/tf/registryManager.h"
#include "pxr/base/tf/scriptModuleLoader.h"
#include "pxr/base/tf/token.h"
#include <pxr/pxrns.h>
#include "Tf/registryManager.h"
#include "Tf/scriptModuleLoader.h"
#include "Tf/token.h"

#include <vector>

PXR_NAMESPACE_OPEN_SCOPE

TF_REGISTRY_FUNCTION(TfScriptModuleLoader) {
// List of direct dependencies for this library.
const std::vector<TfToken> reqs = {
TfToken("arch"),
TfToken("garch"),
TfToken("gf"),
TfToken("hf"),
TfToken("hio"),
TfToken("sdf"),
TfToken("tf"),
TfToken("trace"),
TfToken("vt")
};
TfScriptModuleLoader::GetInstance().
RegisterLibrary(TfToken("glf"), TfToken("pxr.Glf"), reqs);
TF_REGISTRY_FUNCTION(TfScriptModuleLoader)
{
// List of direct dependencies for this library.
const std::vector<TfToken> reqs = {
TfToken("arch"),
TfToken("garch"),
TfToken("gf"),
TfToken("hf"),
TfToken("hio"),
TfToken("sdf"),
TfToken("tf"),
TfToken("trace"),
TfToken("vt")};
TfScriptModuleLoader::GetInstance().RegisterLibrary(TfToken("glf"), TfToken("pxr.Glf"), reqs);
}

PXR_NAMESPACE_CLOSE_SCOPE


Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/imaging/glf/diagnostic.h"
#include "Glf/diagnostic.h"

#include <boost/python/def.hpp>
#include <boost/python/class.hpp>
Expand All @@ -31,18 +31,18 @@ using namespace boost::python;
PXR_NAMESPACE_USING_DIRECTIVE

void wrapDiagnostic()
{
def("RegisterDefaultDebugOutputMessageCallback",
&GlfRegisterDefaultDebugOutputMessageCallback);
{
def("RegisterDefaultDebugOutputMessageCallback",
&GlfRegisterDefaultDebugOutputMessageCallback);

class_<GlfGLQueryObject, boost::noncopyable>("GLQueryObject")
.def("Begin", &GlfGLQueryObject::Begin)
.def("BeginPrimitivesGenerated", &GlfGLQueryObject::BeginPrimitivesGenerated)
.def("BeginTimeElapsed", &GlfGLQueryObject::BeginTimeElapsed)
.def("BeginSamplesPassed", &GlfGLQueryObject::BeginSamplesPassed)
.def("End", &GlfGLQueryObject::End)
.def("GetResult", &GlfGLQueryObject::GetResult)
.def("GetResultNoWait", &GlfGLQueryObject::GetResultNoWait)
class_<GlfGLQueryObject, boost::noncopyable>("GLQueryObject")
.def("Begin", &GlfGLQueryObject::Begin)
.def("BeginPrimitivesGenerated", &GlfGLQueryObject::BeginPrimitivesGenerated)
.def("BeginTimeElapsed", &GlfGLQueryObject::BeginTimeElapsed)
.def("BeginSamplesPassed", &GlfGLQueryObject::BeginSamplesPassed)
.def("End", &GlfGLQueryObject::End)
.def("GetResult", &GlfGLQueryObject::GetResult)
.def("GetResultNoWait", &GlfGLQueryObject::GetResultNoWait)

;
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/imaging/glf/drawTarget.h"
#include "Glf/drawTarget.h"

#include "pxr/base/tf/makePyConstructor.h"
#include "pxr/base/tf/pyPtrHelpers.h"
#include "pxr/base/tf/pyResultConversions.h"
#include "pxr/base/tf/pyEnum.h"
#include "Tf/makePyConstructor.h"
#include "Tf/pyPtrHelpers.h"
#include "Tf/pyResultConversions.h"
#include "Tf/pyEnum.h"

#include <boost/python/bases.hpp>
#include <boost/python/class.hpp>
Expand All @@ -36,40 +36,37 @@ using namespace boost::python;

PXR_NAMESPACE_USING_DIRECTIVE

namespace {

static GlfDrawTargetRefPtr _NewDrawTarget(
GfVec2i const & size)
namespace
{

static GlfDrawTargetRefPtr _NewDrawTarget(
GfVec2i const &size)
{
return GlfDrawTarget::New(size);
}
}

static GlfDrawTargetRefPtr _NewDrawTarget2(
unsigned int width, unsigned int height)
{
static GlfDrawTargetRefPtr _NewDrawTarget2(
unsigned int width, unsigned int height)
{
return GlfDrawTarget::New(GfVec2i(width, height));
}
}

} // anonymous namespace
} // anonymous namespace

void wrapDrawTarget()
{
typedef GlfDrawTarget This;
typedef GlfDrawTargetPtr ThisPtr;

class_<This, ThisPtr, boost::noncopyable>("DrawTarget", no_init)
.def(TfPyRefAndWeakPtr())
.def("__init__",TfMakePyConstructor(&_NewDrawTarget))
.def("__init__",TfMakePyConstructor(&_NewDrawTarget2))
.def("AddAttachment", &This::AddAttachment)
.def("Bind", &This::Bind)
.def("Unbind", &This::Unbind)
.def("WriteToFile",
&This::WriteToFile, (
arg("attachment"),
arg("filename"),
arg("viewMatrix") = GfMatrix4d(1),
arg("projectionMatrix") = GfMatrix4d(1)))

;
typedef GlfDrawTarget This;
typedef GlfDrawTargetPtr ThisPtr;

class_<This, ThisPtr, boost::noncopyable>("DrawTarget", no_init)
.def(TfPyRefAndWeakPtr())
.def("__init__", TfMakePyConstructor(&_NewDrawTarget))
.def("__init__", TfMakePyConstructor(&_NewDrawTarget2))
.def("AddAttachment", &This::AddAttachment)
.def("Bind", &This::Bind)
.def("Unbind", &This::Unbind)
.def("WriteToFile",
&This::WriteToFile, (arg("attachment"), arg("filename"), arg("viewMatrix") = GfMatrix4d(1), arg("projectionMatrix") = GfMatrix4d(1)))

;
}
Loading

0 comments on commit 542aaaf

Please sign in to comment.