├── .gitattributes ├── .gitignore ├── .gitmodules ├── MeshDoc ├── MeshDoc.vcxproj └── MeshDoc.vcxproj.filters ├── Obj2Ply ├── Obj2Ply.vcxproj ├── Obj2Ply.vcxproj.filters └── main.cpp ├── PCF.sln ├── PCF ├── PCF.vcxproj ├── PCF.vcxproj.filters └── main.cpp ├── ReadMe.md ├── Src ├── FitParam_Custom.ini ├── GeometryObject.cpp ├── GeometryObject.h ├── MeshDoc │ ├── MeshDoc.cpp │ ├── MeshDoc.h │ └── plyhead.h ├── PCA │ ├── PCA.cpp │ └── PCA.h ├── PointCloudFit.cpp ├── PointCloudFit.h ├── PointCloudFitUtil.h ├── PointCloudFitUtil_Cube.cpp ├── PointCloudFitUtil_Cylinder.cpp ├── PointCloudFitUtil_MMFGCO.cpp ├── PointCloudFitUtil_Plane.cpp ├── PointCloudFit_Cube.cpp ├── PointCloudFit_Cylinder.cpp ├── PointCloudFit_Plane.cpp ├── PointCloudFit_Preproc.cpp ├── gco │ ├── GCO_README.TXT │ ├── GCoptimization.cpp │ ├── GCoptimization.h │ ├── LinkedBlockList.cpp │ ├── LinkedBlockList.h │ ├── block.h │ ├── energy.h │ ├── example.cpp │ ├── graph.cpp │ ├── graph.h │ ├── matlab │ │ ├── GCO_BuildLib.m │ │ ├── GCO_ComputeEnergy.m │ │ ├── GCO_Create.m │ │ ├── GCO_Delete.m │ │ ├── GCO_ExpandOnAlpha.m │ │ ├── GCO_Expansion.m │ │ ├── GCO_GetLabeling.m │ │ ├── GCO_ListHandles.m │ │ ├── GCO_LoadLib.m │ │ ├── GCO_SetDataCost.m │ │ ├── GCO_SetLabelCost.m │ │ ├── GCO_SetLabelOrder.m │ │ ├── GCO_SetLabeling.m │ │ ├── GCO_SetNeighbors.m │ │ ├── GCO_SetSmoothCost.m │ │ ├── GCO_SetVerbosity.m │ │ ├── GCO_Swap.m │ │ ├── GCO_UnitTest.m │ │ ├── README.TXT │ │ └── gco_matlab.cpp │ └── maxflow.cpp ├── gte │ ├── Applications │ │ ├── GLX │ │ │ ├── GteWICFileIO.h │ │ │ ├── GteWindow.h │ │ │ └── GteWindowSystem.h │ │ ├── GteCommand.h │ │ ├── GteEnvironment.h │ │ ├── GteOnIdleTimer.h │ │ ├── GteTextureIO.h │ │ ├── GteWindow2.h │ │ ├── GteWindow3.h │ │ ├── GteWindowBase.h │ │ └── MSW │ │ │ ├── DX11 │ │ │ ├── GteWindow.h │ │ │ └── GteWindowSystem.h │ │ │ ├── GteMSWWindow.h │ │ │ ├── GteMSWWindowSystem.h │ │ │ ├── GteWICFileIO.h │ │ │ └── WGL │ │ │ ├── GteWindow.h │ │ │ └── GteWindowSystem.h │ ├── GTApplications.h │ ├── GTEngine.h │ ├── GTEngineDEF.h │ ├── GTEnginePCH.h │ ├── GTGraphics.h │ ├── GTGraphicsDX11.h │ ├── GTGraphicsDX12.h │ ├── GTGraphicsGL4.h │ ├── GTImagics.h │ ├── GTLowLevel.h │ ├── GTMathematics.h │ ├── GTPhysics.h │ ├── GTWindows.h │ ├── Graphics │ │ ├── DX11 │ │ │ ├── GteDX11BlendState.h │ │ │ ├── GteDX11Buffer.h │ │ │ ├── GteDX11ComputeShader.h │ │ │ ├── GteDX11ConstantBuffer.h │ │ │ ├── GteDX11DepthStencilState.h │ │ │ ├── GteDX11DrawTarget.h │ │ │ ├── GteDX11DrawingState.h │ │ │ ├── GteDX11Engine.h │ │ │ ├── GteDX11GeometryShader.h │ │ │ ├── GteDX11GraphicsObject.h │ │ │ ├── GteDX11Include.h │ │ │ ├── GteDX11IndexBuffer.h │ │ │ ├── GteDX11IndirectArgumentsBuffer.h │ │ │ ├── GteDX11InputLayout.h │ │ │ ├── GteDX11InputLayoutManager.h │ │ │ ├── GteDX11PerformanceCounter.h │ │ │ ├── GteDX11PixelShader.h │ │ │ ├── GteDX11RasterizerState.h │ │ │ ├── GteDX11RawBuffer.h │ │ │ ├── GteDX11Resource.h │ │ │ ├── GteDX11SamplerState.h │ │ │ ├── GteDX11Shader.h │ │ │ ├── GteDX11StructuredBuffer.h │ │ │ ├── GteDX11Texture.h │ │ │ ├── GteDX11Texture1.h │ │ │ ├── GteDX11Texture1Array.h │ │ │ ├── GteDX11Texture2.h │ │ │ ├── GteDX11Texture2Array.h │ │ │ ├── GteDX11Texture3.h │ │ │ ├── GteDX11TextureArray.h │ │ │ ├── GteDX11TextureBuffer.h │ │ │ ├── GteDX11TextureCube.h │ │ │ ├── GteDX11TextureCubeArray.h │ │ │ ├── GteDX11TextureDS.h │ │ │ ├── GteDX11TextureRT.h │ │ │ ├── GteDX11TextureSingle.h │ │ │ ├── GteDX11VertexBuffer.h │ │ │ ├── GteDX11VertexShader.h │ │ │ ├── GteDXGIAdapter.h │ │ │ ├── GteDXGIOutput.h │ │ │ ├── GteFloatFunction.hlsli │ │ │ ├── GteHLSLBaseBuffer.h │ │ │ ├── GteHLSLByteAddressBuffer.h │ │ │ ├── GteHLSLComputeProgram.h │ │ │ ├── GteHLSLConstantBuffer.h │ │ │ ├── GteHLSLFactory.h │ │ │ ├── GteHLSLParameter.h │ │ │ ├── GteHLSLProgramFactory.h │ │ │ ├── GteHLSLResource.h │ │ │ ├── GteHLSLResourceBindInfo.h │ │ │ ├── GteHLSLSamplerState.h │ │ │ ├── GteHLSLShader.h │ │ │ ├── GteHLSLShaderFactory.h │ │ │ ├── GteHLSLShaderType.h │ │ │ ├── GteHLSLShaderVariable.h │ │ │ ├── GteHLSLStructuredBuffer.h │ │ │ ├── GteHLSLTexture.h │ │ │ ├── GteHLSLTextureArray.h │ │ │ ├── GteHLSLTextureBuffer.h │ │ │ ├── GteHLSLVisualProgram.h │ │ │ └── GteSqrtEstimate.hlsli │ │ ├── GL4 │ │ │ ├── GL │ │ │ │ ├── glcorearb.h │ │ │ │ ├── glext.h │ │ │ │ ├── glxext.h │ │ │ │ └── wglext.h │ │ │ ├── GLX │ │ │ │ └── GteGLXEngine.h │ │ │ ├── GteGL4AtomicCounterBuffer.h │ │ │ ├── GteGL4BlendState.h │ │ │ ├── GteGL4Buffer.h │ │ │ ├── GteGL4ConstantBuffer.h │ │ │ ├── GteGL4DepthStencilState.h │ │ │ ├── GteGL4DrawTarget.h │ │ │ ├── GteGL4DrawingState.h │ │ │ ├── GteGL4Engine.h │ │ │ ├── GteGL4GraphicsObject.h │ │ │ ├── GteGL4IndexBuffer.h │ │ │ ├── GteGL4InputLayout.h │ │ │ ├── GteGL4InputLayoutManager.h │ │ │ ├── GteGL4RasterizerState.h │ │ │ ├── GteGL4Resource.h │ │ │ ├── GteGL4SamplerState.h │ │ │ ├── GteGL4StructuredBuffer.h │ │ │ ├── GteGL4Texture.h │ │ │ ├── GteGL4Texture1.h │ │ │ ├── GteGL4Texture1Array.h │ │ │ ├── GteGL4Texture2.h │ │ │ ├── GteGL4Texture2Array.h │ │ │ ├── GteGL4Texture3.h │ │ │ ├── GteGL4TextureArray.h │ │ │ ├── GteGL4TextureCube.h │ │ │ ├── GteGL4TextureCubeArray.h │ │ │ ├── GteGL4TextureDS.h │ │ │ ├── GteGL4TextureRT.h │ │ │ ├── GteGL4TextureSingle.h │ │ │ ├── GteGL4VertexBuffer.h │ │ │ ├── GteGLSLComputeProgram.h │ │ │ ├── GteGLSLProgramFactory.h │ │ │ ├── GteGLSLReflection.h │ │ │ ├── GteGLSLVisualProgram.h │ │ │ ├── GteOpenGL.h │ │ │ ├── GteOpenGLHelper.h │ │ │ └── WGL │ │ │ │ └── GteWGLEngine.h │ │ ├── GteAmbientLightEffect.h │ │ ├── GteBaseEngine.h │ │ ├── GteBillboardNode.h │ │ ├── GteBlendState.h │ │ ├── GteBlendTransformController.h │ │ ├── GteBoundingSphere.h │ │ ├── GteBspNode.h │ │ ├── GteBuffer.h │ │ ├── GteCamera.h │ │ ├── GteCameraRig.h │ │ ├── GteComputeProgram.h │ │ ├── GteComputeShader.h │ │ ├── GteConstantBuffer.h │ │ ├── GteConstantColorEffect.h │ │ ├── GteControlledObject.h │ │ ├── GteController.h │ │ ├── GteCuller.h │ │ ├── GteCullingPlane.h │ │ ├── GteDataFormat.h │ │ ├── GteDepthStencilState.h │ │ ├── GteDirectionalLightEffect.h │ │ ├── GteDirectionalLightTextureEffect.h │ │ ├── GteDrawTarget.h │ │ ├── GteDrawingState.h │ │ ├── GteFont.h │ │ ├── GteFontArialW400H18.h │ │ ├── GteGEDrawTarget.h │ │ ├── GteGEInputLayoutManager.h │ │ ├── GteGEObject.h │ │ ├── GteGeometryShader.h │ │ ├── GteGraphicsEngine.h │ │ ├── GteGraphicsObject.h │ │ ├── GteIndexBuffer.h │ │ ├── GteIndexFormat.h │ │ ├── GteIndirectArgumentsBuffer.h │ │ ├── GteKeyframeController.h │ │ ├── GteLight.h │ │ ├── GteLightCameraGeometry.h │ │ ├── GteLighting.h │ │ ├── GteLightingEffect.h │ │ ├── GteMaterial.h │ │ ├── GteMemberLayout.h │ │ ├── GteMeshFactory.h │ │ ├── GteNode.h │ │ ├── GteOverlayEffect.h │ │ ├── GtePVWUpdater.h │ │ ├── GtePickRecord.h │ │ ├── GtePicker.h │ │ ├── GtePixelShader.h │ │ ├── GtePlanarReflectionEffect.h │ │ ├── GtePointLightEffect.h │ │ ├── GtePointLightTextureEffect.h │ │ ├── GteProgramDefines.h │ │ ├── GteProgramFactory.h │ │ ├── GteRasterizerState.h │ │ ├── GteRawBuffer.h │ │ ├── GteResource.h │ │ ├── GteSamplerState.h │ │ ├── GteShader.h │ │ ├── GteSkinController.h │ │ ├── GteSpatial.h │ │ ├── GteSpotLightEffect.h │ │ ├── GteStructuredBuffer.h │ │ ├── GteTextEffect.h │ │ ├── GteTexture.h │ │ ├── GteTexture1.h │ │ ├── GteTexture1Array.h │ │ ├── GteTexture2.h │ │ ├── GteTexture2Array.h │ │ ├── GteTexture2Effect.h │ │ ├── GteTexture3.h │ │ ├── GteTexture3Effect.h │ │ ├── GteTextureArray.h │ │ ├── GteTextureBuffer.h │ │ ├── GteTextureCube.h │ │ ├── GteTextureCubeArray.h │ │ ├── GteTextureDS.h │ │ ├── GteTextureRT.h │ │ ├── GteTextureSingle.h │ │ ├── GteTrackball.h │ │ ├── GteTransform.h │ │ ├── GteTransformController.h │ │ ├── GteTypedBuffer.h │ │ ├── GteVertexBuffer.h │ │ ├── GteVertexColorEffect.h │ │ ├── GteVertexFormat.h │ │ ├── GteVertexShader.h │ │ ├── GteViewVolume.h │ │ ├── GteViewVolumeNode.h │ │ ├── GteVisual.h │ │ ├── GteVisualEffect.h │ │ └── GteVisualProgram.h │ ├── Imagics │ │ ├── GteHistogram.h │ │ ├── GteImage.h │ │ ├── GteImage2.h │ │ ├── GteImage3.h │ │ ├── GteImageUtility2.h │ │ ├── GteImageUtility3.h │ │ ├── GteMarchingCubes.h │ │ ├── GteMarchingCubesTable.h │ │ └── GteSurfaceExtractor.h │ ├── LowLevel │ │ ├── GteArray2.h │ │ ├── GteArray3.h │ │ ├── GteArray4.h │ │ ├── GteAtomicMinMax.h │ │ ├── GteComputeModel.h │ │ ├── GteLexicoArray2.h │ │ ├── GteLogReporter.h │ │ ├── GteLogToFile.h │ │ ├── GteLogToStdout.h │ │ ├── GteLogToStringArray.h │ │ ├── GteLogger.h │ │ ├── GteMinHeap.h │ │ ├── GteRangeIteration.h │ │ ├── GteThreadSafeMap.h │ │ ├── GteThreadSafeQueue.h │ │ ├── GteTimer.h │ │ ├── GteWrapper.h │ │ └── MSW │ │ │ ├── GteLogToMessageBox.h │ │ │ └── GteLogToOutputWindow.h │ ├── Mathematics │ │ ├── GteACosEstimate.h │ │ ├── GteASinEstimate.h │ │ ├── GteATanEstimate.h │ │ ├── GteAlignedBox.h │ │ ├── GteApprCircle2.h │ │ ├── GteApprCylinder3.h │ │ ├── GteApprEllipse2.h │ │ ├── GteApprEllipseByArcs.h │ │ ├── GteApprEllipsoid3.h │ │ ├── GteApprGaussian2.h │ │ ├── GteApprGaussian3.h │ │ ├── GteApprGreatCircle3.h │ │ ├── GteApprHeightLine2.h │ │ ├── GteApprHeightPlane3.h │ │ ├── GteApprOrthogonalLine2.h │ │ ├── GteApprOrthogonalLine3.h │ │ ├── GteApprOrthogonalPlane3.h │ │ ├── GteApprParaboloid3.h │ │ ├── GteApprPolynomial2.h │ │ ├── GteApprPolynomial3.h │ │ ├── GteApprPolynomial4.h │ │ ├── GteApprPolynomialSpecial2.h │ │ ├── GteApprPolynomialSpecial3.h │ │ ├── GteApprPolynomialSpecial4.h │ │ ├── GteApprQuadratic2.h │ │ ├── GteApprQuadratic3.h │ │ ├── GteApprQuery.h │ │ ├── GteApprSphere3.h │ │ ├── GteArc2.h │ │ ├── GteAxisAngle.h │ │ ├── GteBSNumber.h │ │ ├── GteBSPrecision.h │ │ ├── GteBSRational.h │ │ ├── GteBSplineCurve.h │ │ ├── GteBSplineCurveFit.h │ │ ├── GteBSplineSurface.h │ │ ├── GteBSplineSurfaceFit.h │ │ ├── GteBSplineVolume.h │ │ ├── GteBandedMatrix.h │ │ ├── GteBasisFunction.h │ │ ├── GteBezierCurve.h │ │ ├── GteBitHacks.h │ │ ├── GteCapsule.h │ │ ├── GteChebyshevRatio.h │ │ ├── GteCircle3.h │ │ ├── GteCone.h │ │ ├── GteConstants.h │ │ ├── GteConstrainedDelaunay2.h │ │ ├── GteContCapsule3.h │ │ ├── GteContCircle2.h │ │ ├── GteContCylinder3.h │ │ ├── GteContEllipse2.h │ │ ├── GteContEllipse2MinCR.h │ │ ├── GteContEllipsoid3.h │ │ ├── GteContEllipsoid3MinCR.h │ │ ├── GteContOrientedBox2.h │ │ ├── GteContOrientedBox3.h │ │ ├── GteContPointInPolygon2.h │ │ ├── GteContPointInPolyhedron3.h │ │ ├── GteContScribeCircle2.h │ │ ├── GteContScribeCircle3Sphere3.h │ │ ├── GteContSphere3.h │ │ ├── GteConvertCoordinates.h │ │ ├── GteConvexHull2.h │ │ ├── GteConvexHull3.h │ │ ├── GteConvexPolyhedron3.h │ │ ├── GteCosEstimate.h │ │ ├── GteCubicRootsQR.h │ │ ├── GteCylinder3.h │ │ ├── GteDCPQuery.h │ │ ├── GteDarbouxFrame.h │ │ ├── GteDelaunay2.h │ │ ├── GteDelaunay2Mesh.h │ │ ├── GteDelaunay3.h │ │ ├── GteDelaunay3Mesh.h │ │ ├── GteDistAlignedBox3OrientedBox3.h │ │ ├── GteDistAlignedBoxAlignedBox.h │ │ ├── GteDistCircle3Circle3.h │ │ ├── GteDistLine3AlignedBox3.h │ │ ├── GteDistLine3Circle3.h │ │ ├── GteDistLine3OrientedBox3.h │ │ ├── GteDistLine3Rectangle3.h │ │ ├── GteDistLine3Triangle3.h │ │ ├── GteDistLineLine.h │ │ ├── GteDistLineRay.h │ │ ├── GteDistLineSegment.h │ │ ├── GteDistOrientedBox3OrientedBox3.h │ │ ├── GteDistPoint3Circle3.h │ │ ├── GteDistPoint3ConvexPolyhedron3.h │ │ ├── GteDistPoint3Cylinder3.h │ │ ├── GteDistPoint3Frustum3.h │ │ ├── GteDistPoint3Plane3.h │ │ ├── GteDistPoint3Rectangle3.h │ │ ├── GteDistPoint3Tetrahedron3.h │ │ ├── GteDistPointAlignedBox.h │ │ ├── GteDistPointHyperellipsoid.h │ │ ├── GteDistPointLine.h │ │ ├── GteDistPointOrientedBox.h │ │ ├── GteDistPointRay.h │ │ ├── GteDistPointSegment.h │ │ ├── GteDistPointTriangle.h │ │ ├── GteDistPointTriangleExact.h │ │ ├── GteDistRay3AlignedBox3.h │ │ ├── GteDistRay3OrientedBox3.h │ │ ├── GteDistRay3Rectangle3.h │ │ ├── GteDistRay3Triangle3.h │ │ ├── GteDistRayRay.h │ │ ├── GteDistRaySegment.h │ │ ├── GteDistRectangle3AlignedBox3.h │ │ ├── GteDistRectangle3OrientedBox3.h │ │ ├── GteDistRectangle3Rectangle3.h │ │ ├── GteDistSegment3AlignedBox3.h │ │ ├── GteDistSegment3OrientedBox3.h │ │ ├── GteDistSegment3Rectangle3.h │ │ ├── GteDistSegment3Triangle3.h │ │ ├── GteDistSegmentSegment.h │ │ ├── GteDistSegmentSegmentExact.h │ │ ├── GteDistTriangle3AlignedBox3.h │ │ ├── GteDistTriangle3OrientedBox3.h │ │ ├── GteDistTriangle3Rectangle3.h │ │ ├── GteDistTriangle3Triangle3.h │ │ ├── GteETManifoldMesh.h │ │ ├── GteEdgeKey.h │ │ ├── GteEllipse3.h │ │ ├── GteEulerAngles.h │ │ ├── GteExp2Estimate.h │ │ ├── GteExpEstimate.h │ │ ├── GteFIQuery.h │ │ ├── GteFeatureKey.h │ │ ├── GteFrenetFrame.h │ │ ├── GteFrustum3.h │ │ ├── GteFunctions.h │ │ ├── GteFunctionsBSNumber.h │ │ ├── GteFunctionsBSRational.h │ │ ├── GteFunctionsIEEEBinary16.h │ │ ├── GteGMatrix.h │ │ ├── GteGVector.h │ │ ├── GteGaussianElimination.h │ │ ├── GteGenerateMeshUV.h │ │ ├── GteHalfspace.h │ │ ├── GteHyperellipsoid.h │ │ ├── GteHyperplane.h │ │ ├── GteHypersphere.h │ │ ├── GteIEEEBinary.h │ │ ├── GteIEEEBinary16.h │ │ ├── GteIndexAttribute.h │ │ ├── GteIntegration.h │ │ ├── GteIntpAkima1.h │ │ ├── GteIntpAkimaNonuniform1.h │ │ ├── GteIntpAkimaUniform1.h │ │ ├── GteIntpAkimaUniform2.h │ │ ├── GteIntpAkimaUniform3.h │ │ ├── GteIntpBicubic2.h │ │ ├── GteIntpBilinear2.h │ │ ├── GteIntpLinearNonuniform2.h │ │ ├── GteIntpLinearNonuniform3.h │ │ ├── GteIntpQuadraticNonuniform2.h │ │ ├── GteIntpSphere2.h │ │ ├── GteIntpThinPlateSpline2.h │ │ ├── GteIntpThinPlateSpline3.h │ │ ├── GteIntpTricubic3.h │ │ ├── GteIntpTrilinear3.h │ │ ├── GteIntpVectorField2.h │ │ ├── GteIntrAlignedBox2AlignedBox2.h │ │ ├── GteIntrAlignedBox2OrientedBox2.h │ │ ├── GteIntrAlignedBox3AlignedBox3.h │ │ ├── GteIntrAlignedBox3Cone3.h │ │ ├── GteIntrAlignedBox3Cylinder3.h │ │ ├── GteIntrAlignedBox3OrientedBox3.h │ │ ├── GteIntrAlignedBox3Sphere3.h │ │ ├── GteIntrArc2Arc2.h │ │ ├── GteIntrCapsule3Capsule3.h │ │ ├── GteIntrCircle2Arc2.h │ │ ├── GteIntrCircle2Circle2.h │ │ ├── GteIntrConvexPolygonPlane.h │ │ ├── GteIntrDisk2Sector2.h │ │ ├── GteIntrEllipse2Ellipse2.h │ │ ├── GteIntrEllipsoid3Ellipsoid3.h │ │ ├── GteIntrHalfspace2Polygon2.h │ │ ├── GteIntrHalfspace3Capsule3.h │ │ ├── GteIntrHalfspace3Cylinder3.h │ │ ├── GteIntrHalfspace3Ellipsoid3.h │ │ ├── GteIntrHalfspace3OrientedBox3.h │ │ ├── GteIntrHalfspace3Segment3.h │ │ ├── GteIntrHalfspace3Sphere3.h │ │ ├── GteIntrHalfspace3Triangle3.h │ │ ├── GteIntrIntervals.h │ │ ├── GteIntrLine2AlignedBox2.h │ │ ├── GteIntrLine2Arc2.h │ │ ├── GteIntrLine2Circle2.h │ │ ├── GteIntrLine2Line2.h │ │ ├── GteIntrLine2OrientedBox2.h │ │ ├── GteIntrLine2Ray2.h │ │ ├── GteIntrLine2Segment2.h │ │ ├── GteIntrLine2Triangle2.h │ │ ├── GteIntrLine3AlignedBox3.h │ │ ├── GteIntrLine3Capsule3.h │ │ ├── GteIntrLine3Cone3.h │ │ ├── GteIntrLine3Cylinder3.h │ │ ├── GteIntrLine3Ellipsoid3.h │ │ ├── GteIntrLine3OrientedBox3.h │ │ ├── GteIntrLine3Plane3.h │ │ ├── GteIntrLine3Sphere3.h │ │ ├── GteIntrLine3Triangle3.h │ │ ├── GteIntrOrientedBox2Circle2.h │ │ ├── GteIntrOrientedBox2Cone2.h │ │ ├── GteIntrOrientedBox2OrientedBox2.h │ │ ├── GteIntrOrientedBox2Sector2.h │ │ ├── GteIntrOrientedBox3Cone3.h │ │ ├── GteIntrOrientedBox3Cylinder3.h │ │ ├── GteIntrOrientedBox3Frustum3.h │ │ ├── GteIntrOrientedBox3OrientedBox3.h │ │ ├── GteIntrOrientedBox3Sphere3.h │ │ ├── GteIntrPlane3Capsule3.h │ │ ├── GteIntrPlane3Circle3.h │ │ ├── GteIntrPlane3Cylinder3.h │ │ ├── GteIntrPlane3Ellipsoid3.h │ │ ├── GteIntrPlane3OrientedBox3.h │ │ ├── GteIntrPlane3Plane3.h │ │ ├── GteIntrPlane3Sphere3.h │ │ ├── GteIntrPlane3Triangle3.h │ │ ├── GteIntrRay2AlignedBox2.h │ │ ├── GteIntrRay2Arc2.h │ │ ├── GteIntrRay2Circle2.h │ │ ├── GteIntrRay2OrientedBox2.h │ │ ├── GteIntrRay2Ray2.h │ │ ├── GteIntrRay2Segment2.h │ │ ├── GteIntrRay2Triangle2.h │ │ ├── GteIntrRay3AlignedBox3.h │ │ ├── GteIntrRay3Capsule3.h │ │ ├── GteIntrRay3Cone3.h │ │ ├── GteIntrRay3Cylinder3.h │ │ ├── GteIntrRay3Ellipsoid3.h │ │ ├── GteIntrRay3OrientedBox3.h │ │ ├── GteIntrRay3Plane3.h │ │ ├── GteIntrRay3Sphere3.h │ │ ├── GteIntrRay3Triangle3.h │ │ ├── GteIntrSegment2AlignedBox2.h │ │ ├── GteIntrSegment2Arc2.h │ │ ├── GteIntrSegment2Circle2.h │ │ ├── GteIntrSegment2OrientedBox2.h │ │ ├── GteIntrSegment2Segment2.h │ │ ├── GteIntrSegment2Triangle2.h │ │ ├── GteIntrSegment3AlignedBox3.h │ │ ├── GteIntrSegment3Capsule3.h │ │ ├── GteIntrSegment3Cone3.h │ │ ├── GteIntrSegment3Cylinder3.h │ │ ├── GteIntrSegment3Ellipsoid3.h │ │ ├── GteIntrSegment3OrientedBox3.h │ │ ├── GteIntrSegment3Plane3.h │ │ ├── GteIntrSegment3Sphere3.h │ │ ├── GteIntrSegment3Triangle3.h │ │ ├── GteIntrSphere3Cone3.h │ │ ├── GteIntrSphere3Frustum3.h │ │ ├── GteIntrSphere3Sphere3.h │ │ ├── GteIntrTriangle3OrientedBox3.h │ │ ├── GteInvSqrtEstimate.h │ │ ├── GteIsPlanarGraph.h │ │ ├── GteLCPSolver.h │ │ ├── GteLine.h │ │ ├── GteLinearSystem.h │ │ ├── GteLog2Estimate.h │ │ ├── GteLogEstimate.h │ │ ├── GteMatrix.h │ │ ├── GteMatrix2x2.h │ │ ├── GteMatrix3x3.h │ │ ├── GteMatrix4x4.h │ │ ├── GteMesh.h │ │ ├── GteMinimalCycleBasis.h │ │ ├── GteMinimize1.h │ │ ├── GteMinimizeN.h │ │ ├── GteMinimumAreaBox2.h │ │ ├── GteMinimumAreaCircle2.h │ │ ├── GteMinimumVolumeBox3.h │ │ ├── GteMinimumVolumeSphere3.h │ │ ├── GteNURBSCurve.h │ │ ├── GteNURBSSurface.h │ │ ├── GteNURBSVolume.h │ │ ├── GteNaturalSplineCurve.h │ │ ├── GteNearestNeighborQuery.h │ │ ├── GteOBBTreeOfPoints.h │ │ ├── GteOdeEuler.h │ │ ├── GteOdeImplicitEuler.h │ │ ├── GteOdeMidpoint.h │ │ ├── GteOdeRungeKutta4.h │ │ ├── GteOdeSolver.h │ │ ├── GteOrientedBox.h │ │ ├── GteParametricCurve.h │ │ ├── GteParametricSurface.h │ │ ├── GtePlanarMesh.h │ │ ├── GtePolygon2.h │ │ ├── GtePolyhedron3.h │ │ ├── GtePolynomial1.h │ │ ├── GtePrimalQuery2.h │ │ ├── GtePrimalQuery3.h │ │ ├── GteProjection.h │ │ ├── GteQuarticRootsQR.h │ │ ├── GteQuaternion.h │ │ ├── GteRay.h │ │ ├── GteRectangle.h │ │ ├── GteRectangleMesh.h │ │ ├── GteRectanglePatchMesh.h │ │ ├── GteRevolutionMesh.h │ │ ├── GteRootsBisection.h │ │ ├── GteRootsBrentsMethod.h │ │ ├── GteRootsPolynomial.h │ │ ├── GteRotation.h │ │ ├── GteSector2.h │ │ ├── GteSegment.h │ │ ├── GteSeparatePoints2.h │ │ ├── GteSeparatePoints3.h │ │ ├── GteSinEstimate.h │ │ ├── GteSingularValueDecomposition.h │ │ ├── GteSlerpEstimate.h │ │ ├── GteSqrtEstimate.h │ │ ├── GteSymmetricEigensolver.h │ │ ├── GteSymmetricEigensolver2x2.h │ │ ├── GteSymmetricEigensolver3x3.h │ │ ├── GteTCBSplineCurve.h │ │ ├── GteTIQuery.h │ │ ├── GteTSManifoldMesh.h │ │ ├── GteTanEstimate.h │ │ ├── GteTetrahedron3.h │ │ ├── GteTetrahedronKey.h │ │ ├── GteTorus3.h │ │ ├── GteTriangle.h │ │ ├── GteTriangleKey.h │ │ ├── GteTriangulateCDT.h │ │ ├── GteTriangulateEC.h │ │ ├── GteTubeMesh.h │ │ ├── GteUIntegerALU32.h │ │ ├── GteUIntegerAP32.h │ │ ├── GteUIntegerFP32.h │ │ ├── GteUniqueVerticesTriangles.h │ │ ├── GteUnsymmetricEigenvalues.h │ │ ├── GteVEManifoldMesh.h │ │ ├── GteVETManifoldMesh.h │ │ ├── GteVector.h │ │ ├── GteVector2.h │ │ ├── GteVector3.h │ │ ├── GteVector4.h │ │ ├── GteVertexAttribute.h │ │ ├── GteVertexCollapseMesh.h │ │ └── MSW │ │ │ └── GteIntelSSE.h │ └── Physics │ │ ├── GteBoxManager.h │ │ ├── GteExtremalQuery3.h │ │ ├── GteExtremalQuery3BSP.h │ │ ├── GteExtremalQuery3PRJ.h │ │ ├── GteFluid2.h │ │ ├── GteFluid2AdjustVelocity.h │ │ ├── GteFluid2ComputeDivergence.h │ │ ├── GteFluid2EnforceStateBoundary.h │ │ ├── GteFluid2InitializeSource.h │ │ ├── GteFluid2InitializeState.h │ │ ├── GteFluid2Parameters.h │ │ ├── GteFluid2SolvePoisson.h │ │ ├── GteFluid2UpdateState.h │ │ ├── GteFluid3.h │ │ ├── GteFluid3AdjustVelocity.h │ │ ├── GteFluid3ComputeDivergence.h │ │ ├── GteFluid3EnforceStateBoundary.h │ │ ├── GteFluid3InitializeSource.h │ │ ├── GteFluid3InitializeState.h │ │ ├── GteFluid3Parameters.h │ │ ├── GteFluid3SolvePoisson.h │ │ ├── GteFluid3UpdateState.h │ │ ├── GteMassSpringArbitrary.h │ │ ├── GteMassSpringCurve.h │ │ ├── GteMassSpringSurface.h │ │ ├── GteMassSpringVolume.h │ │ ├── GteParticleSystem.h │ │ ├── GtePolyhedralMassProperties.h │ │ ├── GteRectangleManager.h │ │ └── GteRigidBody.h ├── obj2ply.cpp ├── obj2ply.h ├── struct2ply.cpp ├── struct2ply.h ├── ultitool.cpp ├── ultitool.h └── utility │ ├── flog.cpp │ ├── flog.h │ ├── melody.cpp │ ├── melody.h │ └── melodyNotes.h ├── Struct2Ply ├── Struct2Ply.vcxproj ├── Struct2Ply.vcxproj.filters └── main.cpp └── TestData ├── Ply ├── Recon │ ├── Log.txt │ ├── dsp.ply │ ├── dsp.struct │ ├── dsp_Opt.ply │ ├── dsp_Rej.ply │ ├── dsp_sample.ply │ ├── radarsat.ply │ ├── radarsat.struct │ ├── radarsat_Opt.ply │ ├── radarsat_Rej.ply │ └── radarsat_sample.ply └── Syn │ └── 50K_00U_00D │ ├── Log.txt │ ├── ReadMe.md │ ├── dsp.ply │ ├── dsp.struct │ ├── dsp_Opt.ply │ ├── dsp_Rej.ply │ ├── dsp_sample.ply │ ├── radarsat.ply │ ├── radarsat.struct │ ├── radarsat_Opt.ply │ ├── radarsat_Rej.ply │ └── radarsat_sample.ply └── Result.jpg /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "IoU"] 2 | path = Src/IoU 3 | url = https://github.com/CheckBoxStudio/IoU.git 4 | -------------------------------------------------------------------------------- /Obj2Ply/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "obj2ply.h" 5 | 6 | const std::string InputDir = "../TestData/Obj"; 7 | const std::string OutputDir = "../TestData/Ply/Syn"; 8 | 9 | int main() 10 | { 11 | #if 1 12 | obj2ply(InputDir, OutputDir, 50000); 13 | #else 14 | const int _K = 5; 15 | const int _M = 4; 16 | const int _N = 4; 17 | unsigned int num[_K] = { 50000, 20000, 10000, 5000, 2000 }; 18 | int ndis[_M] = { 0, 1, 2, 4 }; 19 | int nang[_N] = { 0, 5, 10, 15 }; 20 | 21 | const unsigned nnn = _K*_M*_N; 22 | unsigned int _num, _ndis, _nang; 23 | 24 | int nThreadMax = omp_get_max_threads(); 25 | omp_set_num_threads(nThreadMax); 26 | #pragma omp parallel for 27 | for (int idx = 0; idx < nnn; ++idx) { 28 | unsigned k = idx / (_M*_N); 29 | unsigned i = (idx % (_M*_N)) / _N; 30 | unsigned j = idx % _N; 31 | unsigned _num = num[k]; 32 | unsigned _ndis = ndis[i]; 33 | unsigned _nang = nang[j]; 34 | obj2ply(InputDir, OutputDir, _num, _ndis, _nang); 35 | } 36 | #endif 37 | system("pause"); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /Src/FitParam_Custom.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/FitParam_Custom.ini -------------------------------------------------------------------------------- /Src/MeshDoc/plyhead.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLY_HEAD_H_FILE_ 2 | #define _PLY_HEAD_H_FILE_ 3 | 4 | 5 | #define PlyHeadP \ 6 | "\ 7 | ply \n\ 8 | format ascii 1.0 \n\ 9 | comment generated by Wei \n\ 10 | element vertex %d \n\ 11 | property float x \n\ 12 | property float y \n\ 13 | property float z \n\ 14 | end_header \n\ 15 | " 16 | 17 | #define PlyHeadPN \ 18 | "\ 19 | ply \n\ 20 | format ascii 1.0 \n\ 21 | comment generated by Wei \n\ 22 | element vertex %d \n\ 23 | property float x \n\ 24 | property float y \n\ 25 | property float z \n\ 26 | property float nx \n\ 27 | property float ny \n\ 28 | property float nz \n\ 29 | end_header \n\ 30 | " 31 | 32 | 33 | #define PlyHeadPC \ 34 | "\ 35 | ply \n\ 36 | format ascii 1.0 \n\ 37 | comment generated by Wei \n\ 38 | element vertex %d \n\ 39 | property float x \n\ 40 | property float y \n\ 41 | property float z \n\ 42 | property uchar red \n\ 43 | property uchar green \n\ 44 | property uchar blue \n\ 45 | end_header \n\ 46 | " 47 | 48 | 49 | #define PlyHeadPNC \ 50 | "\ 51 | ply \n\ 52 | format ascii 1.0 \n\ 53 | comment generated by Wei \n\ 54 | element vertex %d \n\ 55 | property float x \n\ 56 | property float y \n\ 57 | property float z \n\ 58 | property float nx \n\ 59 | property float ny \n\ 60 | property float nz \n\ 61 | property uchar red \n\ 62 | property uchar green \n\ 63 | property uchar blue \n\ 64 | end_header \n\ 65 | " 66 | 67 | #endif // !_PLY_HEAD_H_FILE_ 68 | 69 | -------------------------------------------------------------------------------- /Src/PCA/PCA.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/PCA/PCA.cpp -------------------------------------------------------------------------------- /Src/PCA/PCA.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/PCA/PCA.h -------------------------------------------------------------------------------- /Src/PointCloudFit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/PointCloudFit.h -------------------------------------------------------------------------------- /Src/PointCloudFitUtil_Cube.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/PointCloudFitUtil_Cube.cpp -------------------------------------------------------------------------------- /Src/PointCloudFitUtil_MMFGCO.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/PointCloudFitUtil_MMFGCO.cpp -------------------------------------------------------------------------------- /Src/PointCloudFit_Cylinder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/PointCloudFit_Cylinder.cpp -------------------------------------------------------------------------------- /Src/PointCloudFit_Plane.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/PointCloudFit_Plane.cpp -------------------------------------------------------------------------------- /Src/gco/LinkedBlockList.cpp: -------------------------------------------------------------------------------- 1 | #include "LinkedBlockList.h" 2 | #include 3 | #include 4 | 5 | /*********************************************************************/ 6 | 7 | void LinkedBlockList::addFront(ListType item) { 8 | 9 | if ( m_head_block_size == GCLL_BLOCK_SIZE ) 10 | { 11 | LLBlock *tmp = (LLBlock *) new LLBlock; 12 | if ( !tmp ) {printf("\nOut of memory");exit(1);} 13 | tmp -> m_next = m_head; 14 | m_head = tmp; 15 | m_head_block_size = 0; 16 | } 17 | 18 | m_head ->m_item[m_head_block_size] = item; 19 | m_head_block_size++; 20 | } 21 | 22 | /*********************************************************************/ 23 | 24 | ListType LinkedBlockList::next() 25 | { 26 | ListType toReturn = m_cursor -> m_item[m_cursor_ind]; 27 | 28 | m_cursor_ind++; 29 | 30 | if ( m_cursor == m_head && m_cursor_ind >= m_head_block_size ) 31 | { 32 | m_cursor = m_cursor ->m_next; 33 | m_cursor_ind = 0; 34 | } 35 | else if ( m_cursor_ind == GCLL_BLOCK_SIZE ) 36 | { 37 | m_cursor = m_cursor ->m_next; 38 | m_cursor_ind = 0; 39 | } 40 | return(toReturn); 41 | } 42 | 43 | /*********************************************************************/ 44 | 45 | bool LinkedBlockList::hasNext() 46 | { 47 | if ( m_cursor != 0 ) return (true); 48 | else return(false); 49 | } 50 | 51 | 52 | /*********************************************************************/ 53 | 54 | LinkedBlockList::~LinkedBlockList() 55 | { 56 | LLBlock *tmp; 57 | 58 | while ( m_head != 0 ) 59 | { 60 | tmp = m_head; 61 | m_head = m_head->m_next; 62 | delete tmp; 63 | } 64 | }; 65 | 66 | /*********************************************************************/ 67 | 68 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_ComputeEnergy.m: -------------------------------------------------------------------------------- 1 | function [Energy D S L] = GCO_ComputeEnergy(Handle) 2 | % GCO_ComputeEnergy Run alpha-expansion algorithm. 3 | % E = GCO_ComputeEnergy(Handle) returns energy of current labeling. 4 | % [E D S L] = GCO_ComputeEnergy(Handle) also provides a breakdown of 5 | % the energy into Data, Smooth, and Label costs. 6 | 7 | GCO_LoadLib(); 8 | [Energy D S L] = gco_matlab('gco_computeenergy',Handle); 9 | end 10 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_Create.m: -------------------------------------------------------------------------------- 1 | function Handle = GCO_Create(NumSites,NumLabels) 2 | % GCO_Create Create a GCoptimization object. 3 | % Handle = GCO_Create(NumSites,NumLabels) creates a new GCoptimization 4 | % object and returns a 'handle' to uniquely identify it. 5 | % Call GCO_Delete(Handle) to delete the object and free its memory. 6 | % Call GCO_Delete(GCO_ListHandles) to delete all GCO objects. 7 | 8 | GCO_LoadLib(); 9 | if (nargin < 2), error('Expected 2 arguments'); end 10 | Handle = gco_matlab('gco_create_general',int32(NumSites),int32(NumLabels)); 11 | end 12 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_Delete.m: -------------------------------------------------------------------------------- 1 | function GCO_Delete(Handle) 2 | % GCO_Delete Delete a GCoptimization object. 3 | % GCO_Delete(Handle) deletes the object corresponding to Handle 4 | % and frees its memory. 5 | 6 | gco_matlab('gco_delete',int32(Handle)); 7 | end 8 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_ExpandOnAlpha.m: -------------------------------------------------------------------------------- 1 | function GCO_ExpandOnAlpha(Handle,Alpha) 2 | % GCO_ExpandOnAlpha Perform a single alpha-expansion step. 3 | % GCO_Expansion(Handle,Alpha) takes the current labeling and performs 4 | % a single expansion step on label Alpha. 5 | 6 | GCO_LoadLib(); 7 | gco_matlab('gco_alphaexpansion',Handle,int32(Alpha)); 8 | end 9 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_Expansion.m: -------------------------------------------------------------------------------- 1 | function Energy = GCO_Expansion(Handle,MaxIter) 2 | % GCO_Expansion Run alpha-expansion algorithm. 3 | % GCO_Expansion(Handle) minimizes the current energy via 4 | % alpha-expansion until convergence. 5 | % GCO_Expansion(Handle,MaxIter) runs at most MaxIter expansion 6 | % Returns the energy of the computed labeling. 7 | % The labeling itself can be retrieved via GCO_GetLabeling. 8 | % The order of expansion can be influenced by GCO_SetLabelOrder. 9 | % If GCO_SetNeighbors is not called (i.e. no smoothness terms), then 10 | % Expansion will internally use a greedy algorithm (no graph cuts). 11 | % 12 | % IMPORTANT: the first version uses "adaptive cycles" (changed labels) 13 | % until convergence whereas the second applies up to MaxIter 14 | % "standard cycles" (all labels). Each strategy is faster/slower for 15 | % different applications, so see what works fastest for yours. 16 | % 17 | 18 | GCO_LoadLib(); 19 | if (nargin < 1), error('Expansion requires handle to GCO instance'); end 20 | if (nargin < 2), MaxIter = -1; end 21 | Energy = gco_matlab('gco_expansion',Handle,int32(MaxIter)); 22 | end 23 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_GetLabeling.m: -------------------------------------------------------------------------------- 1 | function Labeling = GCO_GetLabeling(Handle,varargin) 2 | % GCO_GetLabeling Retrieve the current labeling 3 | % GCO_GetLabeling(Handle) returns a column vector of all labels. 4 | % GCO_GetLabeling(Handle,i) returns the label of site i. 5 | % GCO_GetLabeling(Handle,i,count) returns labels i..i+count-1 6 | 7 | GCO_LoadLib(); 8 | Start = int32(1); 9 | Count = gco_matlab('gco_getnumsites',Handle); 10 | if (length(varargin) > 2) 11 | error('Too many input arguments.'); 12 | end 13 | if (length(varargin) >= 1), Start = int32(varargin{1}); Count = int32(1); end 14 | if (length(varargin) == 2), Count = int32(varargin{2}); end 15 | Labeling = gco_matlab('gco_getlabeling',Handle,Start,Count); 16 | end 17 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_ListHandles.m: -------------------------------------------------------------------------------- 1 | function Handles = GCO_ListHandles() 2 | % GCO_ListHandles Retrieve handles to all current GCO instances 3 | % Useful for cleaning up GCO instances that are using memory, 4 | % particularly when a script was interrupted. 5 | % Example: 6 | % GCO_Delete(GCO_ListHandles); % delete all GCO instances 7 | 8 | GCO_LoadLib(); 9 | Handles = gco_matlab('gco_listhandles'); 10 | end 11 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_LoadLib.m: -------------------------------------------------------------------------------- 1 | function GCO_LoadLib() 2 | % GCO_LoadLib Attempt to load the GCO_MATLAB library. 3 | % GCO_LoadLib is used internally by all other GCO_MATLAB commands 4 | % to compile (if necessary), load, and bind the wrapper library. 5 | 6 | if (isempty(getenv('GCO_MATLAB'))) 7 | GCO_BuildLib(struct('Force',false)); 8 | if (exist('gco_matlab') ~= 3) 9 | error('Failed to load gco_matlab library'); 10 | end 11 | warning on GCO:int32; 12 | setenv('GCO_MATLAB','LOADED'); % environment variables 10x faster than 'exists' 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_SetLabelOrder.m: -------------------------------------------------------------------------------- 1 | function GCO_SetLabelOrder(Handle,Order) 2 | % GCO_SetLabelOrder Set label order for Expansion/Swap moves. 3 | % GCO_SetLabelOrder(Handle,Order) tells Expansion/Swap to select labels 4 | % in a specific order when Order contains integers from 1..NumLabels. 5 | % By default, Expansion/Swap use a consistent, prescribed order of labels 6 | % in until convergence. 7 | % Example: 8 | % GCO_SetLabelOrder(Handle,5:10); % only operate on labels 5..10 9 | % GCO_SetLabelOrder(Handle,randperm(NumLabels)); % random label order 10 | % 11 | 12 | GCO_LoadLib(); 13 | gco_matlab('gco_setlabelorder',Handle,int32(Order)); 14 | end 15 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_SetLabeling.m: -------------------------------------------------------------------------------- 1 | function GCO_SetLabeling(Handle,Labeling) 2 | % GCO_SetLabeling Sets the current labeling 3 | % GCO_SetLabeling(Handle,Labeling) sets the entire labeling. 4 | 5 | GCO_LoadLib(); 6 | if (isnumeric(Labeling)) 7 | NumSites = gco_matlab('gco_getnumsites',Handle); 8 | NumLabels = gco_matlab('gco_getnumlabels',Handle); 9 | if (length(Labeling) ~= NumSites) 10 | error('Labeling must be of length NumSites'); 11 | end 12 | if (~isa(Labeling,'int32')) 13 | if (any(floor(Labeling) ~= Labeling)) 14 | error('Labeling was not integer valued'); 15 | end 16 | Labeling = int32(Labeling); 17 | end 18 | if (min(Labeling) < 1 || max(Labeling) > NumLabels) 19 | error('Label must be in range 1..NumLabels'); 20 | end 21 | gco_matlab('gco_setlabeling',Handle,Labeling); 22 | end 23 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_SetNeighbors.m: -------------------------------------------------------------------------------- 1 | function GCO_SetNeighbors(Handle,Weights) 2 | % GCO_SetNeighbors Set (weighted) pairwise connectivity of all sites. 3 | % GCO_SetNeighbors(Handle,Weights) determines which sites are neighbors 4 | % and thereby have a SmoothCost associated with them. Weights is a 5 | % sparse NumSites-by-NumSites matrix, where Weights(i,j) > 0 indicates 6 | % that sites i and j are neighbors. If Weights is a 0-1 matrix, smooth 7 | % costs are spatially invariant. See SetSmoothCost for more. 8 | % 9 | % SetNeighbors cannot be called after Expansion. 10 | % Note: only the upper-triangular area of Weights is consulted 11 | % because the connectivity is undirected. 12 | 13 | GCO_LoadLib(); 14 | NumSites = gco_matlab('gco_getnumsites',Handle); 15 | if (size(Weights) ~= [ NumSites NumSites ]) 16 | error('Neighbors must be of size [ NumSites NumSites ]'); 17 | end 18 | if (~issparse(Weights)) 19 | if (NumSites > 100) 20 | warning('Sparsifying the Neighbors matrix (performance warning)'); 21 | end 22 | if (~isa(Weights,'double')) 23 | error('Neighbors matrix must be of type double, but with integral values'); 24 | end 25 | Weights = sparse(Weights); 26 | end 27 | gco_matlab('gco_setneighbors',Handle,Weights); 28 | end 29 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_SetSmoothCost.m: -------------------------------------------------------------------------------- 1 | function GCO_SetSmoothCost(Handle,SmoothCost) 2 | % GCO_SetSmoothCost Set the smooth cost of neighboring sites. 3 | % GCO_SetSmoothCost(Handle,SmoothCost) with a NumLabels-by-NumLabels 4 | % integer matrix makes SmoothCost(k,l) the unweighted cost 5 | % of assigning labels k and l to any neighboring sites. 6 | % For particular neighboring sites i,j the final, weighted cost 7 | % is actually Weights(i,j)*SmoothCost(k,l). The spatially-varying 8 | % weights are determined by GCO_SetNeighbors. 9 | % 10 | % If SetSmoothCost is never called, Potts model is used by default. 11 | % i.e. SmoothCost(k,l) = { 0 if k==l, 1 otherwise } 12 | % 13 | % SetSmoothCost can be called repeatedly, even after Expansion. 14 | 15 | GCO_LoadLib(); 16 | if (nargin < 2) 17 | error('Expected 2 arguments'); 18 | end 19 | if (~isnumeric(SmoothCost)) 20 | error('SmoothCost must be numeric'); 21 | end 22 | NumLabels = gco_matlab('gco_getnumlabels',Handle); 23 | if (size(SmoothCost) ~= [ NumLabels NumLabels ]) 24 | error('SmoothCost size must be [ NumLabels NumLabels ]'); 25 | end 26 | EnergyTermClass = gco_matlab('gco_get_energyterm_class'); 27 | SmoothCostClass = class(SmoothCost); 28 | if (~strcmp(SmoothCostClass,EnergyTermClass)) 29 | OldSmoothCost = SmoothCost; 30 | SmoothCost = cast(OldSmoothCost,EnergyTermClass); 31 | if (NumLabels > 50 || any(any(cast(SmoothCost, SmoothCostClass) ~= OldSmoothCost))) 32 | warning('GCO:type',['SmoothCost converted to ' EnergyTermClass]); 33 | end 34 | end 35 | if (any(SmoothCost ~= SmoothCost')) 36 | error('SmoothCost must be symmetric'); 37 | end 38 | gco_matlab('gco_setsmoothcost',Handle,SmoothCost); 39 | end 40 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_SetVerbosity.m: -------------------------------------------------------------------------------- 1 | function GCO_SetVerbosity(Handle,Level) 2 | % GCO_SetVerbosity Print status messages during Expansion/Swap. 3 | % Level 0 prints no output (full speed). 4 | % Level 1 prints cycle-level status messages. 5 | % Level 2 prints expansion/swap-level status messages. 6 | % The current energy is printed as 7 | % E=Total (E=DataCost+SmoothCost+LabelCost) 8 | % At level 2, the size of each binary graph cut problem is also 9 | % printed (# vars). 10 | % 11 | % Note that printing may have an effect on overall run time (tic/toc) 12 | % though the internal computation times are printed in milliseconds 13 | % and exclude the time to print. 14 | % 15 | % Example: 16 | % >> GCO_SetVerbosity(Handle,2); % Level 2 output 17 | % >> GCO_Expansion(Handle); 18 | % gco>> starting alpha-expansion w/ adaptive cycles 19 | % gco>> initial energy: E=18 (E=17+0+1) 20 | % gco>> after expansion(3): E=17 (E=14+1+2); 4 vars; (1 of 8); 0.003 ms 21 | % gco>> after expansion(7): E=15 (E=11+1+3); 2 vars; (2 of 8); 0.002 ms 22 | % ... 23 | % gco>> after cycle 1: E=12 (E=6+2+4); 8 expansions(s); 24 | 25 | GCO_LoadLib(); 26 | gco_matlab('gco_setverbosity',Handle,int32(Level)); 27 | end 28 | -------------------------------------------------------------------------------- /Src/gco/matlab/GCO_Swap.m: -------------------------------------------------------------------------------- 1 | function Energy = GCO_Swap(Handle,MaxIter) 2 | % GCO_Swap Run alpha-beta-swap algorithm. 3 | % GCO_Swap(Handle) runs alpha-beta-swap until convergence. 4 | % GCO_Swap(Handle,MaxIter) runs at most MaxIter swap cycles. 5 | % Returns the energy of the computed labeling. 6 | % The labeling itself can be retrieved via GCO_GetLabeling. 7 | % The order of expansion can be influenced by GCO_SetLabelOrder. 8 | % 9 | % Note that neither label costs nor sparse data costs are currently 10 | % implement for alpha-beta-swap. 11 | 12 | GCO_LoadLib(); 13 | if (nargin < 1), error('Swap requires handle to GCO instance'); end 14 | if (nargin < 2), MaxIter = 1000000; end 15 | Energy = gco_matlab('gco_swap',Handle,int32(MaxIter)); 16 | end 17 | -------------------------------------------------------------------------------- /Src/gte/Applications/GLX/GteWICFileIO.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | // The supported texture types are DF_R8G8B8A8_UNORM, DF_R8_UNORM, and 14 | // DF_R8G8_UNORM (gray+alpha). 15 | 16 | namespace gte 17 | { 18 | 19 | class GTE_IMPEXP WICFileIO 20 | { 21 | public: 22 | // Support for loading from PNG. If the load is not successful, the 23 | // function returns a null object. 24 | static std::shared_ptr Load(std::string const& filename, 25 | bool wantMipmaps); 26 | 27 | // Support for saving to PNG format. The function returns true when 28 | // successful. 29 | static bool SaveToPNG(std::string const& filename, 30 | std::shared_ptr const& texture); 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Src/gte/Applications/GteEnvironment.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace gte 16 | { 17 | 18 | class GTE_IMPEXP Environment 19 | { 20 | public: 21 | // Construction and destruction. 22 | ~Environment(); 23 | Environment(); 24 | 25 | // Get the string corresponding to an environment variable. 26 | std::string GetVariable(std::string const& name); 27 | 28 | // Support for paths to locate files. For platform independence, use 29 | // "/" for the path separator. The input 'directory' will automatically 30 | // be appended with a trailing "/" if it does not end in '/' or '\\'. 31 | // The Insert*/Remove* functions return 'true' iff the operation was 32 | // successful. 33 | int GetNumDirectories() const; 34 | std::string Get(int i) const; 35 | bool Insert(std::string const& directory); 36 | bool Remove(std::string const& directory); 37 | void RemoveAll(); 38 | 39 | // The GetPath function searches the list of directories and returns the 40 | // fully decorated file name if the file exists and can be opened for 41 | // reading. 42 | std::string GetPath(std::string const& name) const; 43 | 44 | private: 45 | // The list of directories for GetPath to search. 46 | std::vector mDirectories; 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Applications/GteOnIdleTimer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace gte 16 | { 17 | 18 | class GTE_IMPEXP OnIdleTimer 19 | { 20 | public: 21 | // The 'frequency' is how many calls of OnIdle() occur before the 22 | // high-frequency clock is called. 23 | OnIdleTimer(int64_t frequency = 30); 24 | 25 | // Restart the timer from zero. This is useful to call after the 26 | // application has "warmed up." 27 | void Reset(); 28 | 29 | // Call this function at the beginning of OnIdle(). 30 | void Measure(); 31 | 32 | // Call this function at the end of OnIdle(); 33 | inline void UpdateFrameCount(); 34 | 35 | // Report the rates. 36 | double GetFramesPerSecond() const; 37 | double GetSecondsPerFrame() const; 38 | int64_t GetMillisecondsPerFrame() const; 39 | 40 | // For convenience in displaying a formatted frames-per-second string. 41 | std::string GetFPS() const; 42 | 43 | private: 44 | // The accumulated time is measured in milliseconds. 45 | int64_t mFrequency, mCallCount; 46 | int64_t mFrameCount, mAccumulatedFrameCount, mAccumulatedTime; 47 | std::chrono::high_resolution_clock::time_point mTime0, mTime1; 48 | }; 49 | 50 | 51 | inline void OnIdleTimer::UpdateFrameCount() 52 | { 53 | ++mFrameCount; 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Src/gte/Applications/GteTextureIO.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #if defined(__MSWINDOWS__) 13 | #include 14 | #endif 15 | 16 | #if defined(__LINUX__) 17 | #include 18 | #endif 19 | -------------------------------------------------------------------------------- /Src/gte/Applications/MSW/DX11/GteWindow.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP Window : public MSWWindow 18 | { 19 | public: 20 | struct GTE_IMPEXP Parameters : public MSWWindow::Parameters 21 | { 22 | Parameters(); 23 | 24 | Parameters(std::wstring const& inTitle, 25 | int inXOrigin, int inYOrigin, int inXSize, int inYSize); 26 | 27 | UINT deviceCreationFlags; 28 | D3D_FEATURE_LEVEL featureLevel; 29 | }; 30 | 31 | protected: 32 | // Abstract base class. Only WindowSystem may create windows. 33 | Window(Parameters& parameters); 34 | public: 35 | virtual ~Window(); 36 | 37 | protected: 38 | // This is assigned mBaseEngine, which allows development of the DX12 39 | // engine independently of DX11 and WGL. 40 | std::shared_ptr mEngine; 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Src/gte/Applications/MSW/DX11/GteWindowSystem.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP WindowSystem : public MSWWindowSystem 17 | { 18 | public: 19 | virtual ~WindowSystem(); 20 | WindowSystem(); 21 | 22 | private: 23 | virtual void CreateEngineAndProgramFactory(MSWWindow::Parameters& parameters) override; 24 | }; 25 | 26 | extern GTE_IMPEXP WindowSystem TheWindowSystem; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Src/gte/Applications/MSW/WGL/GteWindow.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2017/06/23) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP Window : public MSWWindow 17 | { 18 | public: 19 | struct GTE_IMPEXP Parameters : public MSWWindow::Parameters 20 | { 21 | Parameters(); 22 | 23 | Parameters(std::wstring const& inTitle, 24 | int inXOrigin, int inYOrigin, int inXSize, int inYSize); 25 | 26 | // The default value is 0. When bit 0 is set to 1, a text file 27 | // is generated that contains the OpenGL driver information. 28 | UINT deviceCreationFlags; 29 | }; 30 | 31 | protected: 32 | // Abstract base class. Only WindowSystem may create windows. 33 | Window(Parameters& parameters); 34 | public: 35 | virtual ~Window(); 36 | 37 | protected: 38 | // This is assigned mBaseEngine, which allows development of the DX12 39 | // engine independently of DX11 and WGL. 40 | std::shared_ptr mEngine; 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Src/gte/Applications/MSW/WGL/GteWindowSystem.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP WindowSystem : public MSWWindowSystem 17 | { 18 | public: 19 | virtual ~WindowSystem(); 20 | WindowSystem(); 21 | 22 | private: 23 | virtual void CreateEngineAndProgramFactory(MSWWindow::Parameters& parameters) override; 24 | }; 25 | 26 | extern GTE_IMPEXP WindowSystem TheWindowSystem; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Src/gte/GTApplications.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | -------------------------------------------------------------------------------- /Src/gte/GTEngine.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.3 (2016/11/14) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #if !defined(__APPLE__) 15 | #include 16 | #include 17 | #endif 18 | 19 | #if defined(__MSWINDOWS__) 20 | #if defined(GTE_DEV_OPENGL) 21 | #include 22 | #elif defined(GTE_USE_DX12) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | #endif 28 | 29 | #if defined(__LINUX__) 30 | #include 31 | #endif 32 | 33 | #if !defined(__APPLE__) 34 | #include 35 | #endif 36 | -------------------------------------------------------------------------------- /Src/gte/GTEnginePCH.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | // Define GTE_DISABLE_PCH to turn off the precompiled header system. 9 | #ifndef GTE_DISABLE_PCH 10 | #include 11 | #endif 12 | 13 | 14 | -------------------------------------------------------------------------------- /Src/gte/GTGraphicsDX12.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.3.0 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | -------------------------------------------------------------------------------- /Src/gte/GTImagics.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | -------------------------------------------------------------------------------- /Src/gte/GTLowLevel.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | // DataTypes 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | // Logger 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #if defined(__MSWINDOWS__) 30 | #include 31 | #include 32 | #endif 33 | 34 | // Timer 35 | #include 36 | -------------------------------------------------------------------------------- /Src/gte/GTPhysics.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | // Fluid2 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | // Fluid3 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | // Intersection 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | // ParticleSystems 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | // RigidBody 47 | #include 48 | #include 49 | -------------------------------------------------------------------------------- /Src/gte/GTWindows.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #if defined(__MSWINDOWS__) 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #if defined(GTE_DEV_OPENGL) 19 | #include 20 | #include 21 | #elif defined(GTE_USE_DX12) 22 | #include 23 | #include 24 | #else 25 | #include 26 | #include 27 | #endif 28 | 29 | #endif 30 | 31 | #if defined(__LINUX__) 32 | #include 33 | #include 34 | #include 35 | #endif 36 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11BlendState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11BlendState : public DX11DrawingState 17 | { 18 | public: 19 | // Construction. 20 | DX11BlendState(ID3D11Device* device, BlendState const* blendState); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline BlendState* GetBlendState(); 25 | inline ID3D11BlendState* GetDXBlendState(); 26 | 27 | // Enable the blend state. 28 | void Enable(ID3D11DeviceContext* context); 29 | 30 | private: 31 | // Conversions from GTEngine values to DX11 values. 32 | static D3D11_BLEND const msMode[]; 33 | static D3D11_BLEND_OP const msOperation[]; 34 | }; 35 | 36 | inline BlendState* DX11BlendState::GetBlendState() 37 | { 38 | return static_cast(mGTObject); 39 | } 40 | 41 | inline ID3D11BlendState* DX11BlendState::GetDXBlendState() 42 | { 43 | return static_cast(mDXObject); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11ConstantBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11ConstantBuffer : public DX11Buffer 17 | { 18 | public: 19 | // Construction. 20 | DX11ConstantBuffer(ID3D11Device* device, ConstantBuffer const* cbuffer); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline ConstantBuffer* GetConstantBuffer() const; 25 | }; 26 | 27 | inline ConstantBuffer* DX11ConstantBuffer::GetConstantBuffer() const 28 | { 29 | return static_cast(mGTObject); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11DepthStencilState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11DepthStencilState : public DX11DrawingState 17 | { 18 | public: 19 | // Construction. 20 | DX11DepthStencilState(ID3D11Device* device, DepthStencilState const* depthStencilState); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline DepthStencilState* GetDepthStencilState(); 25 | inline ID3D11DepthStencilState* GetDXDepthStencilState(); 26 | 27 | // Enable the depth-stencil state. 28 | void Enable(ID3D11DeviceContext* context); 29 | 30 | private: 31 | // Conversions from GTEngine values to DX11 values. 32 | static D3D11_DEPTH_WRITE_MASK const msWriteMask[]; 33 | static D3D11_COMPARISON_FUNC const msComparison[]; 34 | static D3D11_STENCIL_OP const msOperation[]; 35 | }; 36 | 37 | inline DepthStencilState* DX11DepthStencilState::GetDepthStencilState() 38 | { 39 | return static_cast(mGTObject); 40 | } 41 | 42 | inline ID3D11DepthStencilState* DX11DepthStencilState::GetDXDepthStencilState() 43 | { 44 | return static_cast(mDXObject); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11DrawingState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11DrawingState : public DX11GraphicsObject 17 | { 18 | protected: 19 | // Abstract base class. 20 | DX11DrawingState(DrawingState const* gtState); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11GraphicsObject.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11GraphicsObject : public GEObject 17 | { 18 | public: 19 | // Abstract base class. 20 | virtual ~DX11GraphicsObject(); 21 | protected: 22 | DX11GraphicsObject(GraphicsObject const* gtObject); 23 | 24 | public: 25 | // Member access. 26 | inline ID3D11DeviceChild* GetDXDeviceChild() const; 27 | 28 | // Support for the DX11 debug layer. Set the name if you want to have 29 | // ID3D11DeviceChild destruction messages show your name rather than 30 | // "". The typical usage is 31 | // std::shared_ptr texture = std::make_shared(...); 32 | // engine->Bind(texture)->SetName("MyTexture"); 33 | // The virtual override is used to allow derived classes to use the 34 | // same name for associated resources. 35 | virtual void SetName(std::string const& name) override; 36 | 37 | protected: 38 | ID3D11DeviceChild* mDXObject; 39 | }; 40 | 41 | inline ID3D11DeviceChild* DX11GraphicsObject::GetDXDeviceChild() const 42 | { 43 | return mDXObject; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11IndexBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11IndexBuffer : public DX11Buffer 17 | { 18 | public: 19 | // Construction. 20 | DX11IndexBuffer(ID3D11Device* device, IndexBuffer const* vbuffer); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline IndexBuffer* GetIndexBuffer() const; 25 | 26 | // Drawing support. 27 | void Enable(ID3D11DeviceContext* context); 28 | void Disable(ID3D11DeviceContext* context); 29 | 30 | private: 31 | DXGI_FORMAT mFormat; 32 | }; 33 | 34 | inline IndexBuffer* DX11IndexBuffer::GetIndexBuffer() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11IndirectArgumentsBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11IndirectArgumentsBuffer : public DX11Buffer 17 | { 18 | public: 19 | // Construction. 20 | DX11IndirectArgumentsBuffer(ID3D11Device* device, IndirectArgumentsBuffer const* iabuffer); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline IndirectArgumentsBuffer* GetIndirectArgumentsBuffer() const; 25 | }; 26 | 27 | inline IndirectArgumentsBuffer* DX11IndirectArgumentsBuffer::GetIndirectArgumentsBuffer() const 28 | { 29 | return static_cast(mGTObject); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11InputLayout.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP DX11InputLayout 18 | { 19 | public: 20 | // Construction and destruction. 21 | ~DX11InputLayout(); 22 | DX11InputLayout(ID3D11Device* device, VertexBuffer const* vbuffer, 23 | Shader const* vshader); 24 | 25 | // Support for drawing geometric primitives. 26 | void Enable(ID3D11DeviceContext* context); 27 | void Disable(ID3D11DeviceContext* context); 28 | 29 | // Support for the DX11 debug layer; see comments in the file 30 | // GteDX11GraphicsObject.h about usage. 31 | HRESULT SetName(std::string const& name); 32 | inline std::string const& GetName() const; 33 | 34 | private: 35 | ID3D11InputLayout* mLayout; 36 | int mNumElements; 37 | D3D11_INPUT_ELEMENT_DESC mElements[VA_MAX_ATTRIBUTES]; 38 | std::string mName; 39 | 40 | // Conversions from GTEngine values to DX11 values. 41 | static char const* msSemantic[VA_NUM_SEMANTICS]; 42 | }; 43 | 44 | inline std::string const& DX11InputLayout::GetName() const 45 | { 46 | return mName; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11InputLayoutManager.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP DX11InputLayoutManager : public GEInputLayoutManager 18 | { 19 | public: 20 | // Construction and destruction. 21 | virtual ~DX11InputLayoutManager(); 22 | DX11InputLayoutManager(); 23 | 24 | // Management functions. The Unbind(vbuffer) removes all pairs that 25 | // involve vbuffer. The Unbind(vshader) removes all pairs that involve 26 | // vshader. 27 | DX11InputLayout* Bind(ID3D11Device* device, VertexBuffer const* vbuffer, Shader const* vshader); 28 | virtual bool Unbind(VertexBuffer const* vbuffer) override; 29 | virtual bool Unbind(Shader const* vshader) override; 30 | virtual void UnbindAll() override; 31 | virtual bool HasElements() const override; 32 | 33 | private: 34 | typedef std::pair VBSPair; 35 | 36 | class LayoutMap : public ThreadSafeMap> 37 | { 38 | public: 39 | virtual ~LayoutMap(); 40 | LayoutMap(); 41 | 42 | void GatherMatch(VertexBuffer const* vbuffer, std::vector& matches); 43 | void GatherMatch(Shader const* vshader, std::vector& matches); 44 | }; 45 | 46 | LayoutMap mMap; 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11PerformanceCounter.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // Support for coarse-level GPU timing. 16 | 17 | class GTE_IMPEXP DX11PerformanceCounter 18 | { 19 | public: 20 | // Construction and destruction. 21 | ~DX11PerformanceCounter(); 22 | DX11PerformanceCounter(ID3D11Device* device); 23 | 24 | // Performance measurements. 25 | int64_t GetTicks() const; 26 | double GetSeconds() const; 27 | 28 | // Get the time for the specified number of ticks. 29 | double GetSeconds(int64_t numTicks) const; 30 | 31 | // Get the number of ticks for the specified time. 32 | int64_t GetTicks(double seconds) const; 33 | 34 | // For average performance measurements. 35 | void ResetAccumulateTime(); 36 | void AccumulateTime(); 37 | double GetAverageSeconds() const; 38 | unsigned int GetNumMeasurements() const; 39 | 40 | private: 41 | // Allow the engine to access the members directly to avoid exposing 42 | // internals via the public interface. 43 | friend class DX11Engine; 44 | 45 | D3D11_QUERY_DATA_TIMESTAMP_DISJOINT mTimeStamp; 46 | ID3D11Query* mFrequencyQuery; 47 | ID3D11Query* mStartTimeQuery; 48 | ID3D11Query* mFinalTimeQuery; 49 | double mFrequency, mInvFrequency; 50 | int64_t mStartTime, mFinalTime; 51 | double mTotalSeconds; 52 | unsigned int mNumMeasurements; 53 | }; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11RasterizerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11RasterizerState : public DX11DrawingState 17 | { 18 | public: 19 | // Construction. 20 | DX11RasterizerState(ID3D11Device* device, RasterizerState const* rasterizerState); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline RasterizerState* GetRasterizerState(); 25 | inline ID3D11RasterizerState* GetDXRasterizerState(); 26 | 27 | // Enable the rasterizer state. 28 | void Enable(ID3D11DeviceContext* context); 29 | 30 | private: 31 | // Conversions from GTEngine values to DX11 values. 32 | static D3D11_FILL_MODE const msFillMode[]; 33 | static D3D11_CULL_MODE const msCullMode[]; 34 | }; 35 | 36 | inline RasterizerState* DX11RasterizerState::GetRasterizerState() 37 | { 38 | return static_cast(mGTObject); 39 | } 40 | 41 | inline ID3D11RasterizerState* DX11RasterizerState::GetDXRasterizerState() 42 | { 43 | return static_cast(mDXObject); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11RawBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11RawBuffer : public DX11Buffer 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~DX11RawBuffer(); 21 | DX11RawBuffer(ID3D11Device* device, RawBuffer const* rbuffer); 22 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline RawBuffer* GetRawBuffer() const; 26 | inline ID3D11ShaderResourceView* GetSRView() const; 27 | inline ID3D11UnorderedAccessView* GetUAView() const; 28 | 29 | // Support for the DX11 debug layer; see comments in the file 30 | // GteDX11GraphicsObject.h about usage. 31 | virtual void SetName(std::string const& name); 32 | 33 | private: 34 | // Support for construction. 35 | void CreateSRView(ID3D11Device* device); 36 | void CreateUAView(ID3D11Device* device); 37 | 38 | ID3D11ShaderResourceView* mSRView; 39 | ID3D11UnorderedAccessView* mUAView; 40 | }; 41 | 42 | inline RawBuffer* DX11RawBuffer::GetRawBuffer() const 43 | { 44 | return static_cast(mGTObject); 45 | } 46 | 47 | inline ID3D11ShaderResourceView* DX11RawBuffer::GetSRView() const 48 | { 49 | return mSRView; 50 | } 51 | 52 | inline ID3D11UnorderedAccessView* DX11RawBuffer::GetUAView() const 53 | { 54 | return mUAView; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11SamplerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11SamplerState : public DX11DrawingState 17 | { 18 | public: 19 | // Construction. 20 | DX11SamplerState(ID3D11Device* device, SamplerState const* samplerState); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline SamplerState* GetSamplerState(); 25 | inline ID3D11SamplerState* GetDXSamplerState(); 26 | 27 | private: 28 | // Conversions from GTEngine values to DX11 values. 29 | static D3D11_FILTER const msFilter[]; 30 | static D3D11_TEXTURE_ADDRESS_MODE const msMode[]; 31 | static D3D11_COMPARISON_FUNC const msComparison[]; 32 | }; 33 | 34 | inline SamplerState* DX11SamplerState::GetSamplerState() 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | inline ID3D11SamplerState* DX11SamplerState::GetDXSamplerState() 40 | { 41 | return static_cast(mDXObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11Texture1.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11Texture1 : public DX11TextureSingle 17 | { 18 | public: 19 | // Construction. 20 | DX11Texture1(ID3D11Device* device, Texture1 const* texture); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline Texture1* GetTexture() const; 25 | inline ID3D11Texture1D* GetDXTexture() const; 26 | 27 | private: 28 | // Support for construction. 29 | void CreateStaging(ID3D11Device* device, D3D11_TEXTURE1D_DESC const& tx); 30 | void CreateSRView(ID3D11Device* device, D3D11_TEXTURE1D_DESC const& tx); 31 | void CreateUAView(ID3D11Device* device, D3D11_TEXTURE1D_DESC const& tx); 32 | }; 33 | 34 | inline Texture1* DX11Texture1::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | inline ID3D11Texture1D* DX11Texture1::GetDXTexture() const 40 | { 41 | return static_cast(mDXObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11Texture1Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11Texture1Array : public DX11TextureArray 17 | { 18 | public: 19 | // Construction. 20 | DX11Texture1Array(ID3D11Device* device, Texture1Array const* textureArray); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline Texture1Array* GetTextureArray() const; 25 | inline ID3D11Texture1D* GetDXTextureArray() const; 26 | 27 | private: 28 | // Support for construction. 29 | void CreateStaging(ID3D11Device* device, D3D11_TEXTURE1D_DESC const& tx); 30 | void CreateSRView(ID3D11Device* device, D3D11_TEXTURE1D_DESC const& tx); 31 | void CreateUAView(ID3D11Device* device, D3D11_TEXTURE1D_DESC const& tx); 32 | }; 33 | 34 | inline Texture1Array* DX11Texture1Array::GetTextureArray() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | inline ID3D11Texture1D* DX11Texture1Array::GetDXTextureArray() const 40 | { 41 | return static_cast(mDXObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11Texture2Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11Texture2Array : public DX11TextureArray 17 | { 18 | public: 19 | // Construction. 20 | DX11Texture2Array(ID3D11Device* device, Texture2Array const* textureArray); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline Texture2Array* GetTextureArray() const; 25 | inline ID3D11Texture2D* GetDXTextureArray() const; 26 | 27 | private: 28 | // Support for construction. 29 | void CreateStaging(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 30 | void CreateSRView(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 31 | void CreateUAView(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 32 | }; 33 | 34 | inline Texture2Array* DX11Texture2Array::GetTextureArray() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | inline ID3D11Texture2D* DX11Texture2Array::GetDXTextureArray() const 40 | { 41 | return static_cast(mDXObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11Texture3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11Texture3 : public DX11TextureSingle 17 | { 18 | public: 19 | // Construction. 20 | DX11Texture3(ID3D11Device* device, Texture3 const* texture); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline Texture3* GetTexture() const; 25 | inline ID3D11Texture3D* GetDXTexture() const; 26 | 27 | private: 28 | // Support for construction. 29 | void CreateStaging(ID3D11Device* device, D3D11_TEXTURE3D_DESC const& tx); 30 | void CreateSRView(ID3D11Device* device, D3D11_TEXTURE3D_DESC const& tx); 31 | void CreateUAView(ID3D11Device* device, D3D11_TEXTURE3D_DESC const& tx); 32 | }; 33 | 34 | inline Texture3* DX11Texture3::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | inline ID3D11Texture3D* DX11Texture3::GetDXTexture() const 40 | { 41 | return static_cast(mDXObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11TextureArray.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11TextureArray : public DX11Texture 17 | { 18 | protected: 19 | // Abstract base class, a shim to distinguish between single textures and 20 | // texture arrays. 21 | DX11TextureArray(TextureArray const* gtTextureArray); 22 | 23 | public: 24 | // Member access. 25 | inline TextureArray* GetTextureArray() const; 26 | }; 27 | 28 | inline TextureArray* DX11TextureArray::GetTextureArray() const 29 | { 30 | return static_cast(mGTObject); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11TextureBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11TextureBuffer : public DX11Buffer 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~DX11TextureBuffer(); 21 | DX11TextureBuffer(ID3D11Device* device, TextureBuffer const* tbuffer); 22 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline TextureBuffer* GetTextureBuffer() const; 26 | inline ID3D11ShaderResourceView* GetSRView() const; 27 | 28 | // Support for the DX11 debug layer; see comments in the file 29 | // GteDX11GraphicsObject.h about usage. 30 | virtual void SetName(std::string const& name); 31 | 32 | private: 33 | // Support for construction. 34 | void CreateSRView(ID3D11Device* device); 35 | 36 | ID3D11ShaderResourceView* mSRView; 37 | }; 38 | 39 | inline TextureBuffer* DX11TextureBuffer::GetTextureBuffer() const 40 | { 41 | return static_cast(mGTObject); 42 | } 43 | 44 | inline ID3D11ShaderResourceView* DX11TextureBuffer::GetSRView() const 45 | { 46 | return mSRView; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11TextureCube.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11TextureCube : public DX11TextureArray 17 | { 18 | public: 19 | // Construction. 20 | DX11TextureCube(ID3D11Device* device, TextureCube const* textureCube); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline TextureCube* GetTexture() const; 25 | inline ID3D11Texture2D* GetDXTexture() const; 26 | 27 | private: 28 | // Support for construction. 29 | void CreateStaging(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 30 | void CreateSRView(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 31 | void CreateUAView(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 32 | }; 33 | 34 | inline TextureCube* DX11TextureCube::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | inline ID3D11Texture2D* DX11TextureCube::GetDXTexture() const 40 | { 41 | return static_cast(mDXObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11TextureCubeArray.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11TextureCubeArray : public DX11TextureArray 17 | { 18 | public: 19 | // Construction. 20 | DX11TextureCubeArray(ID3D11Device* device, TextureCubeArray const* textureCubeArray); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline TextureCubeArray* GetTextureArray() const; 25 | inline ID3D11Texture2D* GetDXTextureArray() const; 26 | 27 | private: 28 | // Support for construction. 29 | void CreateStaging(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 30 | void CreateSRView(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 31 | void CreateUAView(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 32 | }; 33 | 34 | inline TextureCubeArray* DX11TextureCubeArray::GetTextureArray() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | inline ID3D11Texture2D* DX11TextureCubeArray::GetDXTextureArray() const 40 | { 41 | return static_cast(mDXObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11TextureDS.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/11/13) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11TextureDS : public DX11Texture2 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~DX11TextureDS(); 21 | DX11TextureDS(ID3D11Device* device, TextureDS const* texture); 22 | DX11TextureDS(ID3D11Device* device, DX11TextureDS const* dxSharedTexture); 23 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 24 | 25 | // Member access. 26 | inline ID3D11DepthStencilView* GetDSView() const; 27 | 28 | // Support for the DX11 debug layer; see comments in the file 29 | // GteDX11GraphicsObject.h about usage. 30 | virtual void SetName(std::string const& name); 31 | 32 | private: 33 | // Support for construction. 34 | void CreateDSView(ID3D11Device* device); 35 | void CreateDSSRView(ID3D11Device* device); 36 | DXGI_FORMAT GetDepthResourceFormat(DXGI_FORMAT depthFormat); 37 | DXGI_FORMAT GetDepthSRVFormat(DXGI_FORMAT depthFormat); 38 | 39 | ID3D11DepthStencilView* mDSView; 40 | }; 41 | 42 | inline ID3D11DepthStencilView* DX11TextureDS::GetDSView() const 43 | { 44 | return mDSView; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11TextureRT.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11TextureRT : public DX11Texture2 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~DX11TextureRT(); 21 | DX11TextureRT(ID3D11Device* device, TextureRT const* texture); 22 | DX11TextureRT(ID3D11Device* device, DX11TextureRT const* dxSharedTexture); 23 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 24 | 25 | // Member access. 26 | inline ID3D11RenderTargetView* GetRTView() const; 27 | 28 | // Support for the DX11 debug layer; see comments in the file 29 | // GteDX11GraphicsObject.h about usage. 30 | virtual void SetName(std::string const& name); 31 | 32 | private: 33 | // Support for construction. 34 | void CreateRTView(ID3D11Device* device, D3D11_TEXTURE2D_DESC const& tx); 35 | 36 | ID3D11RenderTargetView* mRTView; 37 | }; 38 | 39 | inline ID3D11RenderTargetView* DX11TextureRT::GetRTView() const 40 | { 41 | return mRTView; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11TextureSingle.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11TextureSingle : public DX11Texture 17 | { 18 | protected: 19 | // Abstract base class, a shim to distinguish between single textures and 20 | // texture arrays. 21 | DX11TextureSingle(TextureSingle const* gtTextureSingle); 22 | 23 | public: 24 | // Member access. 25 | inline TextureSingle* GetTextureSingle() const; 26 | }; 27 | 28 | inline TextureSingle* DX11TextureSingle::GetTextureSingle() const 29 | { 30 | return static_cast(mGTObject); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDX11VertexBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP DX11VertexBuffer : public DX11Buffer 17 | { 18 | public: 19 | // Construction. 20 | DX11VertexBuffer(ID3D11Device* device, VertexBuffer const* vbuffer); 21 | static std::shared_ptr Create(void* device, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline VertexBuffer* GetVertexBuffer() const; 25 | 26 | // Drawing support. 27 | void Enable(ID3D11DeviceContext* context); 28 | void Disable(ID3D11DeviceContext* context); 29 | }; 30 | 31 | inline VertexBuffer* DX11VertexBuffer::GetVertexBuffer() const 32 | { 33 | return static_cast(mGTObject); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDXGIAdapter.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // A simple wrapper for IDXGIAdapter1 objects and enumeration of them. 16 | 17 | class GTE_IMPEXP DXGIAdapter 18 | { 19 | public: 20 | // Construction and destruction. 21 | ~DXGIAdapter(); 22 | DXGIAdapter(DXGIAdapter const& object); 23 | DXGIAdapter(IDXGIAdapter1* adapter = nullptr); 24 | 25 | // Assignment. 26 | DXGIAdapter& operator=(DXGIAdapter const& object); 27 | 28 | // Member access. 29 | IDXGIAdapter1* GetAdapter() const; 30 | DXGI_ADAPTER_DESC1 const& GetDescription() const; 31 | std::vector const& GetOutputs() const; 32 | 33 | // Enumeration of adapters on a machine. 34 | static void Enumerate(std::vector& adapters); 35 | 36 | private: 37 | IDXGIAdapter1* mAdapter; 38 | DXGI_ADAPTER_DESC1 mDescription; 39 | std::vector mOutputs; 40 | }; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteDXGIOutput.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | // A simple wrapper for IDXGIOutput objects and enumeration of them. 17 | 18 | class GTE_IMPEXP DXGIOutput 19 | { 20 | public: 21 | // Construction and destruction. 22 | ~DXGIOutput(); 23 | DXGIOutput(DXGIOutput const& object); 24 | DXGIOutput(IDXGIOutput* output = nullptr); 25 | 26 | // Assignment. 27 | DXGIOutput& operator=(DXGIOutput const& object); 28 | 29 | // Member access. 30 | IDXGIOutput* GetOutput() const; 31 | DXGI_OUTPUT_DESC const& GetDescription() const; 32 | 33 | // Queries for information about the output/monitor. The modes that 34 | // support the format are returned, possibly an empty list. The returned 35 | // HRESULT is one of the DXGI_ERROR values. 36 | HRESULT GetDisplayModes(DXGI_FORMAT format, 37 | std::vector& modeDescriptions); 38 | 39 | // Find a mode that matches as closely as possible the requested mode. 40 | // The returned HRESULT is one of the DXGI_ERROR values. 41 | HRESULT FindClosestMatchingMode(DXGI_MODE_DESC const& requested, 42 | DXGI_MODE_DESC& closest); 43 | 44 | private: 45 | IDXGIOutput* mOutput; 46 | DXGI_OUTPUT_DESC mDescription; 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLBaseBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace gte 17 | { 18 | 19 | class GTE_IMPEXP HLSLBaseBuffer : public HLSLResource 20 | { 21 | public: 22 | typedef std::pair Member; 23 | 24 | // Construction and destruction. 25 | virtual ~HLSLBaseBuffer(); 26 | 27 | HLSLBaseBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 28 | unsigned int numBytes, std::vector const& members); 29 | 30 | HLSLBaseBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 31 | unsigned int index, unsigned int numBytes, 32 | std::vector const& members); 33 | 34 | // Member access. 35 | std::vector const& GetMembers() const; 36 | 37 | // Print to a text file for human readability. 38 | virtual void Print(std::ofstream& output) const; 39 | 40 | // Generation of lookup tables for member layout. 41 | void GenerateLayout(std::vector& layout) const; 42 | 43 | private: 44 | void GenerateLayout(HLSLShaderType const& type, unsigned int parentOffset, 45 | std::string const& parentName, 46 | std::vector& layout) const; 47 | 48 | std::vector mMembers; 49 | }; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLByteAddressBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLByteAddressBuffer : public HLSLResource 16 | { 17 | public: 18 | // Construction and destruction. 19 | virtual ~HLSLByteAddressBuffer(); 20 | 21 | HLSLByteAddressBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc); 22 | 23 | HLSLByteAddressBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 24 | unsigned int index); 25 | 26 | // Member access. 27 | bool IsGpuWritable() const; 28 | 29 | private: 30 | bool mGpuWritable; 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLComputeProgram.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLComputeProgram : public ComputeProgram 16 | { 17 | public: 18 | // A simple stub to add HLSL as part of the program type. This allows 19 | // polymorphism for the program factory classes, which in turn allows 20 | // us to hide the graphics-API-dependent program factory used by the 21 | // Window class (have a member mProgramFactory similar to mEngine that 22 | // is created according to the desired graphics API). 23 | virtual ~HLSLComputeProgram(); 24 | HLSLComputeProgram(); 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLConstantBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLConstantBuffer : public HLSLBaseBuffer 16 | { 17 | public: 18 | // TODO: Global constants in the HLSL file are placed as variables into 19 | // an implicit constant buffer named $Global. We need to modify 20 | // Variable to store number of bytes and default values (if any). 21 | // 1. If the application writer must create the constant buffer and 22 | // attach, how do we get the default data into the buffer? 23 | // 2. Maybe $Global needs to be created implicitly, filled with 24 | // default values, then application queries for it to modify. The 25 | // idea of shader->Set("SomeCBuffer",cbuffer) was to allow sharing 26 | // of constant buffers between shaders. 27 | 28 | // Construction and destruction. 29 | virtual ~HLSLConstantBuffer(); 30 | 31 | HLSLConstantBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 32 | unsigned int numBytes, std::vector const& members); 33 | 34 | HLSLConstantBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 35 | unsigned int index, unsigned int numBytes, 36 | std::vector const& members); 37 | }; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLFactory.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLResourceBindInfo.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLResourceBindInfo : public HLSLBaseBuffer 16 | { 17 | public: 18 | // Construction and destruction. 19 | virtual ~HLSLResourceBindInfo(); 20 | 21 | HLSLResourceBindInfo(D3D_SHADER_INPUT_BIND_DESC const& desc, 22 | unsigned int numBytes, std::vector const& members); 23 | 24 | HLSLResourceBindInfo(D3D_SHADER_INPUT_BIND_DESC const& desc, 25 | unsigned int index, unsigned int numBytes, 26 | std::vector const& members); 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLSamplerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLSamplerState : public HLSLResource 16 | { 17 | public: 18 | // Construction and destruction. 19 | virtual ~HLSLSamplerState(); 20 | 21 | HLSLSamplerState(D3D_SHADER_INPUT_BIND_DESC const& desc); 22 | 23 | HLSLSamplerState(D3D_SHADER_INPUT_BIND_DESC const& desc, 24 | unsigned int index); 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLStructuredBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLStructuredBuffer : public HLSLResource 16 | { 17 | public: 18 | enum GTE_IMPEXP Type 19 | { 20 | SBT_INVALID, 21 | SBT_BASIC, 22 | SBT_APPEND, 23 | SBT_CONSUME, 24 | SBT_COUNTER 25 | }; 26 | 27 | // Construction and destruction. 28 | virtual ~HLSLStructuredBuffer(); 29 | 30 | HLSLStructuredBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc); 31 | 32 | HLSLStructuredBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 33 | unsigned int index); 34 | 35 | // Member access. 36 | Type GetType() const; 37 | bool IsGpuWritable() const; 38 | 39 | private: 40 | void Initialize(D3D_SHADER_INPUT_BIND_DESC const& desc); 41 | 42 | Type mType; 43 | bool mGpuWritable; 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLTexture.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLTexture : public HLSLResource 16 | { 17 | public: 18 | // Construction and destruction. 19 | virtual ~HLSLTexture(); 20 | 21 | HLSLTexture(D3D_SHADER_INPUT_BIND_DESC const& desc); 22 | 23 | HLSLTexture(D3D_SHADER_INPUT_BIND_DESC const& desc, unsigned int index); 24 | 25 | // Member access. 26 | unsigned int GetNumComponents() const; 27 | unsigned int GetNumDimensions() const; 28 | bool IsGpuWritable() const; 29 | 30 | private: 31 | void Initialize(D3D_SHADER_INPUT_BIND_DESC const& desc); 32 | 33 | unsigned int mNumComponents; 34 | unsigned int mNumDimensions; 35 | bool mGpuWritable; 36 | }; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLTextureArray.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLTextureArray : public HLSLResource 16 | { 17 | public: 18 | // Construction and destruction. 19 | virtual ~HLSLTextureArray(); 20 | 21 | HLSLTextureArray(D3D_SHADER_INPUT_BIND_DESC const& desc); 22 | 23 | HLSLTextureArray(D3D_SHADER_INPUT_BIND_DESC const& desc, 24 | unsigned int index); 25 | 26 | // Member access. 27 | unsigned int GetNumComponents() const; 28 | unsigned int GetNumDimensions() const; 29 | bool IsGpuWritable() const; 30 | 31 | private: 32 | void Initialize(D3D_SHADER_INPUT_BIND_DESC const& desc); 33 | 34 | unsigned int mNumComponents; 35 | unsigned int mNumDimensions; 36 | bool mGpuWritable; 37 | }; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLTextureBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/09/12) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLTextureBuffer : public HLSLBaseBuffer 16 | { 17 | public: 18 | // Construction and destruction. 19 | virtual ~HLSLTextureBuffer(); 20 | 21 | HLSLTextureBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 22 | unsigned int numBytes, std::vector const& members); 23 | 24 | HLSLTextureBuffer(D3D_SHADER_INPUT_BIND_DESC const& desc, 25 | unsigned int index, unsigned int numBytes, 26 | std::vector const& members); 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Src/gte/Graphics/DX11/GteHLSLVisualProgram.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP HLSLVisualProgram : public VisualProgram 16 | { 17 | public: 18 | // A simple stub to add HLSL as part of the program type. This allows 19 | // polymorphism for the program factory classes, which in turn allows 20 | // us to hide the graphics-API-dependent program factory used by the 21 | // Window class (have a member mProgramFactory similar to mEngine that 22 | // is created according to the desired graphics API). 23 | virtual ~HLSLVisualProgram(); 24 | HLSLVisualProgram(); 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4AtomicCounterBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4AtomicCounterBuffer : public GL4Buffer 17 | { 18 | public: 19 | // Construction. 20 | GL4AtomicCounterBuffer(RawBuffer const* cbuffer); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline RawBuffer* GetRawBuffer() const; 25 | 26 | // Bind the raw buffer data to the specified atomic counter buffer unit. 27 | void AttachToUnit(GLint atomicCounterBufferUnit); 28 | }; 29 | 30 | 31 | inline RawBuffer* GL4AtomicCounterBuffer::GetRawBuffer() const 32 | { 33 | return static_cast(mGTObject); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4BlendState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4BlendState : public GL4DrawingState 17 | { 18 | public: 19 | // Construction. 20 | GL4BlendState(BlendState const* blendState); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline BlendState* GetBlendState(); 25 | 26 | // Enable the blend state. 27 | void Enable(); 28 | 29 | private: 30 | struct Target 31 | { 32 | GLboolean enable; 33 | GLenum srcColor; 34 | GLenum dstColor; 35 | GLenum opColor; 36 | GLenum srcAlpha; 37 | GLenum dstAlpha; 38 | GLenum opAlpha; 39 | GLboolean rMask; 40 | GLboolean gMask; 41 | GLboolean bMask; 42 | GLboolean aMask; 43 | }; 44 | 45 | bool mEnableAlphaToCoverage; 46 | bool mEnableIndependentBlend; 47 | Target mTarget[BlendState::NUM_TARGETS]; 48 | Vector4 mBlendColor; 49 | unsigned int mSampleMask; 50 | 51 | // Conversions from GTEngine values to GL4 values. 52 | static GLenum const msMode[]; 53 | static GLenum const msOperation[]; 54 | }; 55 | 56 | inline BlendState* GL4BlendState::GetBlendState() 57 | { 58 | return static_cast(mGTObject); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4Buffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Buffer : public GL4Resource 17 | { 18 | protected: 19 | // Abstract base class. 20 | virtual ~GL4Buffer(); 21 | GL4Buffer(Buffer const* buffer, GLenum type); 22 | 23 | // Must be called by constructor. 24 | virtual void Initialize(); 25 | 26 | public: 27 | // Member access. 28 | inline Buffer* GetBuffer() const; 29 | inline GLenum GetType() const; 30 | inline GLenum GetUsage() const; 31 | 32 | // TODO: TENTATIVE INTERFACE (modify as needed). Do we really need 33 | // these to be virtual? Revisit the DX11 code and investigate why the 34 | // choice was made there. 35 | virtual bool Update(); 36 | virtual bool CopyCpuToGpu(); 37 | virtual bool CopyGpuToCpu(); 38 | 39 | protected: 40 | GLenum mType; 41 | GLenum mUsage; 42 | }; 43 | 44 | inline Buffer* GL4Buffer::GetBuffer() const 45 | { 46 | return static_cast(mGTObject); 47 | } 48 | 49 | inline GLenum GL4Buffer::GetType() const 50 | { 51 | return mType; 52 | } 53 | 54 | inline GLenum GL4Buffer::GetUsage() const 55 | { 56 | return mUsage; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4ConstantBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4ConstantBuffer : public GL4Buffer 17 | { 18 | public: 19 | // Construction. 20 | GL4ConstantBuffer(ConstantBuffer const* cbuffer); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline ConstantBuffer* GetConstantBuffer() const; 25 | 26 | // Bind the constant buffer data to the specified uniform buffer unit. 27 | void AttachToUnit(GLint uniformBufferUnit); 28 | }; 29 | 30 | inline ConstantBuffer* GL4ConstantBuffer::GetConstantBuffer() const 31 | { 32 | return static_cast(mGTObject); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4DepthStencilState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4DepthStencilState : public GL4DrawingState 17 | { 18 | public: 19 | // Construction. 20 | GL4DepthStencilState(DepthStencilState const* depthStencilState); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline DepthStencilState* GetDepthStencilState(); 25 | 26 | // Enable the depth-stencil state. 27 | void Enable(); 28 | 29 | private: 30 | struct Face 31 | { 32 | GLenum onFail; 33 | GLenum onZFail; 34 | GLenum onZPass; 35 | GLenum comparison; 36 | }; 37 | 38 | GLboolean mDepthEnable; 39 | GLboolean mWriteMask; 40 | GLenum mComparison; 41 | GLboolean mStencilEnable; 42 | GLuint mStencilReadMask; 43 | GLuint mStencilWriteMask; 44 | Face mFrontFace; 45 | Face mBackFace; 46 | GLuint mReference; 47 | 48 | // Conversions from GTEngine values to GL4 values. 49 | static GLboolean const msWriteMask[]; 50 | static GLenum const msComparison[]; 51 | static GLenum const msOperation[]; 52 | }; 53 | 54 | inline DepthStencilState* GL4DepthStencilState::GetDepthStencilState() 55 | { 56 | return static_cast(mGTObject); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4DrawTarget.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP GL4DrawTarget : public GEDrawTarget 18 | { 19 | public: 20 | // Construction and destruction. 21 | virtual ~GL4DrawTarget(); 22 | GL4DrawTarget(DrawTarget const* target, 23 | std::vector& rtTextures, GL4TextureDS* dsTexture); 24 | static std::shared_ptr Create(DrawTarget const* target, 25 | std::vector& rtTextures, GEObject* dsTexture); 26 | 27 | // Member access. 28 | inline GL4TextureRT* GetRTTexture(unsigned int i) const; 29 | inline GL4TextureDS* GetDSTexture() const; 30 | 31 | // Used in the Renderer::Draw function. 32 | void Enable(); 33 | void Disable(); 34 | 35 | private: 36 | std::vector mRTTextures; 37 | GL4TextureDS* mDSTexture; 38 | 39 | GLuint mFrameBuffer; 40 | 41 | // Temporary storage during enable/disable of targets. 42 | GLint mSaveViewportX; 43 | GLint mSaveViewportY; 44 | GLsizei mSaveViewportWidth; 45 | GLsizei mSaveViewportHeight; 46 | GLdouble mSaveViewportNear; 47 | GLdouble mSaveViewportFar; 48 | }; 49 | 50 | inline GL4TextureRT* GL4DrawTarget::GetRTTexture(unsigned int i) const 51 | { 52 | return mRTTextures[i]; 53 | } 54 | 55 | inline GL4TextureDS* GL4DrawTarget::GetDSTexture() const 56 | { 57 | return mDSTexture; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4DrawingState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4DrawingState : public GL4GraphicsObject 17 | { 18 | protected: 19 | // Abstract base class. 20 | GL4DrawingState(DrawingState const* gtState); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4GraphicsObject.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4GraphicsObject : public GEObject 17 | { 18 | protected: 19 | // Abstract base class. 20 | GL4GraphicsObject(GraphicsObject const* gtObject); 21 | 22 | public: 23 | // Member access. 24 | inline GLuint GetGLHandle() const; 25 | 26 | // Support for debugging. 27 | virtual void SetName(std::string const& name) override; 28 | 29 | protected: 30 | GLuint mGLHandle; 31 | }; 32 | 33 | inline GLuint GL4GraphicsObject::GetGLHandle() const 34 | { 35 | return mGLHandle; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4IndexBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4IndexBuffer : public GL4Buffer 17 | { 18 | public: 19 | // Construction. 20 | GL4IndexBuffer(IndexBuffer const* ibuffer); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline IndexBuffer* GetIndexBuffer() const; 25 | 26 | // Support for drawing geometric primitives. 27 | void Enable(); 28 | void Disable(); 29 | }; 30 | 31 | inline IndexBuffer* GL4IndexBuffer::GetIndexBuffer() const 32 | { 33 | return static_cast(mGTObject); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4InputLayout.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4InputLayout 17 | { 18 | public: 19 | // Construction and destruction. 20 | ~GL4InputLayout(); 21 | GL4InputLayout(GLuint programHandle, GLuint vbufferHandle, 22 | VertexBuffer const* vbuffer); 23 | 24 | // Support for drawing geometric primitives. 25 | void Enable(); 26 | void Disable(); 27 | 28 | private: 29 | GLuint mProgramHandle; 30 | GLuint mVBufferHandle; 31 | GLuint mVArrayHandle; 32 | 33 | struct Attribute 34 | { 35 | VASemantic semantic; 36 | GLint numChannels; 37 | GLint channelType; 38 | GLboolean normalize; 39 | GLint location; 40 | GLintptr offset; 41 | GLsizei stride; 42 | }; 43 | 44 | int mNumAttributes; 45 | Attribute mAttributes[VA_MAX_ATTRIBUTES]; 46 | 47 | // Conversions from GTEngine values to GL4 values. 48 | static GLenum const msChannelType[]; 49 | }; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4InputLayoutManager.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP GL4InputLayoutManager : public GEInputLayoutManager 18 | { 19 | public: 20 | // Construction and destruction. 21 | virtual ~GL4InputLayoutManager(); 22 | GL4InputLayoutManager(); 23 | 24 | // Management functions. The Unbind(vbuffer) removes all layouts that 25 | // involve vbuffer. The Unbind(vshader) is stubbed out because GL4 does 26 | // not require it, but we wish to have Unbind(GraphicsObject const*) as 27 | // a base-class GraphicsEngine function. 28 | GL4InputLayout* Bind(GLuint programHandle, GLuint vbufferHandle, VertexBuffer const* vbuffer); 29 | virtual bool Unbind(VertexBuffer const* vbuffer) override; 30 | virtual bool Unbind(Shader const* vshader) override; 31 | virtual void UnbindAll() override; 32 | virtual bool HasElements() const override; 33 | 34 | private: 35 | typedef std::pair VBPPair; 36 | 37 | class LayoutMap : public ThreadSafeMap> 38 | { 39 | public: 40 | virtual ~LayoutMap(); 41 | LayoutMap(); 42 | 43 | void GatherMatch(VertexBuffer const* vbuffer, std::vector& matches); 44 | }; 45 | 46 | LayoutMap mMap; 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4RasterizerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4RasterizerState : public GL4DrawingState 17 | { 18 | public: 19 | // Construction. 20 | GL4RasterizerState(RasterizerState const* rasterizerState); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline RasterizerState* GetRasterizerState(); 25 | 26 | // Enable the rasterizer state. 27 | void Enable(); 28 | 29 | private: 30 | GLenum mFillMode; 31 | GLenum mCullFace; 32 | GLenum mFrontFace; 33 | float mDepthScale; 34 | float mDepthBias; 35 | GLboolean mEnableScissor; 36 | 37 | // TODO: D3D11_RASTERIZER_DESC has the following. We need to determine 38 | // how to handle these in OpenGL. 39 | // DepthBiasClamp 40 | // DepthClipEnable 41 | // MultisampleEnable 42 | // AntialiasedLineEnable 43 | 44 | // Conversions from GTEngine values to GL4 values. 45 | static GLenum const msFillMode[]; 46 | static GLenum const msCullFace[]; 47 | }; 48 | 49 | inline RasterizerState* GL4RasterizerState::GetRasterizerState() 50 | { 51 | return static_cast(mGTObject); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4Resource.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP GL4Resource : public GL4GraphicsObject 18 | { 19 | protected: 20 | // Abstract base class. 21 | GL4Resource(Resource const* gtResource); 22 | 23 | public: 24 | // Member access. 25 | inline Resource* GetResource() const; 26 | 27 | // TODO: TENTATIVE INTERFACE (modify as needed). Make these pure 28 | // virtual latter (if relevant). 29 | void* MapForWrite(GLenum target); 30 | void Unmap(GLenum target); 31 | virtual bool Update() { return false; } 32 | virtual bool CopyCpuToGpu() { return false; } 33 | virtual bool CopyGpuToCpu() { return false; } 34 | 35 | virtual void CopyGpuToGpu(GL4Resource* target) 36 | { 37 | (void)target; 38 | LogError("Not yet implemented."); 39 | } 40 | 41 | protected: 42 | // Support for copying between CPU and GPU. 43 | bool PreparedForCopy(GLenum access) const; 44 | }; 45 | 46 | inline Resource* GL4Resource::GetResource() const 47 | { 48 | return static_cast(mGTObject); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4SamplerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4SamplerState : public GL4DrawingState 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4SamplerState(); 21 | GL4SamplerState(SamplerState const* samplerState); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline SamplerState* GetSamplerState(); 26 | 27 | private: 28 | // Conversions from GTEngine values to GL4 values. 29 | static GLint const msMode[]; 30 | }; 31 | 32 | inline SamplerState* GL4SamplerState::GetSamplerState() 33 | { 34 | return static_cast(mGTObject); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4Texture1.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Texture1 : public GL4TextureSingle 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4Texture1(); 21 | GL4Texture1(Texture1 const* texture); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline Texture1* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline Texture1* GL4Texture1::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4Texture1Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Texture1Array : public GL4TextureArray 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4Texture1Array(); 21 | GL4Texture1Array(Texture1Array const* textureArray); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline Texture1Array* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline Texture1Array* GL4Texture1Array::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4Texture2.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Texture2 : public GL4TextureSingle 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4Texture2(); 21 | GL4Texture2(Texture2 const* texture); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline Texture2* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline Texture2* GL4Texture2::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4Texture2Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Texture2Array : public GL4TextureArray 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4Texture2Array(); 21 | GL4Texture2Array(Texture2Array const* texture); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline Texture2Array* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline Texture2Array* GL4Texture2Array::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4Texture3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Texture3 : public GL4TextureSingle 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4Texture3(); 21 | GL4Texture3(Texture3 const* texture); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline Texture3* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline Texture3* GL4Texture3::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4TextureCube.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4TextureCube : public GL4TextureArray 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4TextureCube(); 21 | GL4TextureCube(TextureCube const* textureArray); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline TextureCube* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline TextureCube* GL4TextureCube::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4TextureCubeArray.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4TextureCubeArray : public GL4TextureArray 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4TextureCubeArray(); 21 | GL4TextureCubeArray(TextureCubeArray const* texture); 22 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline TextureCubeArray* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline TextureCubeArray* GL4TextureCubeArray::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4TextureDS.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4TextureDS : public GL4Texture2 17 | { 18 | public: 19 | // Construction. 20 | GL4TextureDS(TextureDS const* texture); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline TextureDS* GetTexture() const; 25 | 26 | // Returns true of mipmaps need to be generated. 27 | virtual bool CanAutoGenerateMipmaps() const override; 28 | 29 | private: 30 | }; 31 | 32 | inline TextureDS* GL4TextureDS::GetTexture() const 33 | { 34 | return static_cast(mGTObject); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4TextureRT.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4TextureRT : public GL4Texture2 17 | { 18 | public: 19 | // Construction. 20 | GL4TextureRT(TextureRT const* texture); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline TextureRT* GetTexture() const; 25 | 26 | // Returns true of mipmaps need to be generated. 27 | virtual bool CanAutoGenerateMipmaps() const override; 28 | }; 29 | 30 | inline TextureRT* GL4TextureRT::GetTexture() const 31 | { 32 | return static_cast(mGTObject); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGL4VertexBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4VertexBuffer : public GL4Buffer 17 | { 18 | public: 19 | // Construction. 20 | GL4VertexBuffer(VertexBuffer const* vbuffer); 21 | static std::shared_ptr Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline VertexBuffer* GetVertexBuffer() const; 25 | 26 | // TODO: Drawing support? Currently, the enable/disable is in the 27 | // GL4InputLayout class, which assumes OpenGL 4.3 or later. What if the 28 | // application machine does not have OpenGL 4.3? Fall back to the 29 | // glBindBuffer paradigm? 30 | }; 31 | 32 | inline VertexBuffer* GL4VertexBuffer::GetVertexBuffer() const 33 | { 34 | return static_cast(mGTObject); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteGLSLComputeProgram.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GLSLComputeProgram : public ComputeProgram 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GLSLComputeProgram(); 21 | GLSLComputeProgram(GLuint programHandle, GLuint cshaderHandle); 22 | 23 | // Member access. GLEngine needs the program handle for enabling and 24 | // disabling the program. TODO: Do we need the GetCShaderHandle 25 | // function? 26 | inline GLuint GetProgramHandle() const; 27 | inline GLuint GetCShaderHandle() const; 28 | inline GLSLReflection const& GetReflector() const; 29 | 30 | private: 31 | GLuint mProgramHandle, mCShaderHandle; 32 | GLSLReflection mReflector; 33 | }; 34 | 35 | inline GLuint GLSLComputeProgram::GetProgramHandle() const 36 | { 37 | return mProgramHandle; 38 | } 39 | 40 | inline GLuint GLSLComputeProgram::GetCShaderHandle() const 41 | { 42 | return mCShaderHandle; 43 | } 44 | 45 | inline GLSLReflection const& GLSLComputeProgram::GetReflector() const 46 | { 47 | return mReflector; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GL4/GteOpenGLHelper.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteAmbientLightEffect.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP AmbientLightEffect : public LightingEffect 16 | { 17 | public: 18 | // Construction. 19 | AmbientLightEffect(std::shared_ptr const& factory, 20 | BufferUpdater const& updater, std::shared_ptr const& material, 21 | std::shared_ptr const& lighting); 22 | 23 | // After you set or modify 'material' or 'lighting', call the update to 24 | // inform any listener that the corresponding constant buffer has changed. 25 | virtual void UpdateMaterialConstant(); 26 | virtual void UpdateLightingConstant(); 27 | 28 | private: 29 | struct InternalMaterial 30 | { 31 | Vector4 emissive; 32 | Vector4 ambient; 33 | }; 34 | 35 | struct InternalLighting 36 | { 37 | Vector4 ambient; 38 | Vector4 attenuation; 39 | }; 40 | 41 | // Shader source code as strings. 42 | static std::string const msGLSLVSSource; 43 | static std::string const msGLSLPSSource; 44 | static std::string const msHLSLSource; 45 | static std::string const* msVSSource[ProgramFactory::PF_NUM_API]; 46 | static std::string const* msPSSource[ProgramFactory::PF_NUM_API]; 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteBillboardNode.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP BillboardNode : public Node 16 | { 17 | public: 18 | // The model space of the billboard has an up vector of (0,1,0) that is 19 | // chosen to be the billboard's axis of rotation. 20 | 21 | // Construction. 22 | BillboardNode(std::shared_ptr const& camera); 23 | 24 | // The camera to which the billboard is aligned. 25 | inline void AlignTo(std::shared_ptr const& camera); 26 | 27 | protected: 28 | // Support for the geometric update. 29 | virtual void UpdateWorldData(double applicationTime); 30 | 31 | std::shared_ptr mCamera; 32 | }; 33 | 34 | 35 | inline void BillboardNode::AlignTo(std::shared_ptr const& camera) 36 | { 37 | mCamera = camera; 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP Buffer : public Resource 17 | { 18 | protected: 19 | // Abstract base class. 20 | Buffer(unsigned int numElements, size_t elementSize, 21 | bool createStorage = true); 22 | }; 23 | 24 | typedef std::function const&)> BufferUpdater; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteComputeProgram.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP ComputeProgram 16 | { 17 | public: 18 | // HLSL uses the class as is. GLSL derives from the class to store 19 | // the shader and program handles. 20 | virtual ~ComputeProgram(); 21 | ComputeProgram(); 22 | 23 | // Member access. 24 | inline std::shared_ptr const& GetCShader() const; 25 | 26 | public: 27 | // INTERNAL USE ONLY. This is used during factory creation of shaders 28 | // and programs. The graphics engines need only const-access to the 29 | // shader objects. 30 | inline void SetCShader(std::shared_ptr const& shader); 31 | 32 | private: 33 | std::shared_ptr mCShader; 34 | }; 35 | 36 | 37 | inline std::shared_ptr const& ComputeProgram::GetCShader() 38 | const 39 | { 40 | return mCShader; 41 | } 42 | 43 | inline void ComputeProgram::SetCShader( 44 | std::shared_ptr const& shader) 45 | { 46 | mCShader = shader; 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteComputeShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP ComputeShader : public Shader 16 | { 17 | public: 18 | // Construction. 19 | #if defined(GTE_DEV_OPENGL) 20 | ComputeShader(GLSLReflection const& reflector); 21 | #else 22 | ComputeShader(HLSLShader const& program); 23 | #endif 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteControlledObject.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP ControlledObject 18 | { 19 | protected: 20 | // Abstract base class. 21 | ControlledObject(); 22 | public: 23 | virtual ~ControlledObject(); 24 | 25 | // Access to the controllers that control this object. 26 | typedef std::list> List; 27 | inline List const& GetControllers() const; 28 | void AttachController(std::shared_ptr const& controller); 29 | void DetachController(std::shared_ptr const& controller); 30 | void DetachAllControllers(); 31 | bool UpdateControllers(double applicationTime); 32 | 33 | private: 34 | List mControllers; 35 | }; 36 | 37 | 38 | inline ControlledObject::List const& ControlledObject::GetControllers() const 39 | { 40 | return mControllers; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteDrawingState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP DrawingState : public GraphicsObject 16 | { 17 | protected: 18 | // Abstract base class for grouping state classes. This supports 19 | // simplification and reduction of member functions in the graphics engine 20 | // code. 21 | DrawingState(); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteFontArialW400H18.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP FontArialW400H18 : public Font 16 | { 17 | public: 18 | // Construction. This is an embedded font that is generated by the 19 | // BitmapFontCreator tool. 20 | FontArialW400H18(std::shared_ptr const& factory, int maxMessageLength); 21 | 22 | private: 23 | static int msWidth; 24 | static int msHeight; 25 | static unsigned char msTexels[]; 26 | static float msCharacterData[]; 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteGEDrawTarget.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP GEDrawTarget 16 | { 17 | public: 18 | // Abstract base class. 19 | virtual ~GEDrawTarget(); 20 | protected: 21 | GEDrawTarget(DrawTarget const* gtTarget); 22 | 23 | public: 24 | // Member access. 25 | inline DrawTarget* GetDrawTarget() const; 26 | 27 | protected: 28 | DrawTarget* mTarget; 29 | }; 30 | 31 | inline DrawTarget* GEDrawTarget::GetDrawTarget() const 32 | { 33 | return mTarget; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteGEInputLayoutManager.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class Shader; 16 | class VertexBuffer; 17 | 18 | class GTE_IMPEXP GEInputLayoutManager 19 | { 20 | public: 21 | // Abstract base interface. 22 | virtual ~GEInputLayoutManager() {} 23 | GEInputLayoutManager() {} 24 | 25 | virtual bool Unbind(VertexBuffer const* vbuffer) = 0; 26 | virtual bool Unbind(Shader const* vshader) = 0; 27 | virtual void UnbindAll() = 0; 28 | virtual bool HasElements() const = 0; 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteGEObject.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP GEObject 16 | { 17 | public: 18 | // Abstract base class. 19 | virtual ~GEObject(); 20 | protected: 21 | GEObject(GraphicsObject const* gtObject); 22 | 23 | public: 24 | // Member access. 25 | inline GraphicsObject* GetGraphicsObject() const; 26 | 27 | // Support for debugging. 28 | virtual void SetName(std::string const& name) = 0; 29 | inline std::string const& GetName() const; 30 | 31 | protected: 32 | GraphicsObject* mGTObject; 33 | std::string mName; 34 | }; 35 | 36 | inline GraphicsObject* GEObject::GetGraphicsObject() const 37 | { 38 | return mGTObject; 39 | } 40 | 41 | inline std::string const& GEObject::GetName() const 42 | { 43 | return mName; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteGeometryShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP GeometryShader : public Shader 16 | { 17 | public: 18 | // Construction. 19 | #if defined(GTE_DEV_OPENGL) 20 | GeometryShader(GLSLReflection const& reflector); 21 | #else 22 | GeometryShader(HLSLShader const& program); 23 | #endif 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteIndexFormat.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/12/09) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // Types of primitives supported by index buffers. 16 | enum GTE_IMPEXP IPType 17 | { 18 | IP_NONE = 0xFFFFFFFF, 19 | IP_POLYPOINT = 0x00000001, 20 | IP_POLYSEGMENT_DISJOINT = 0x00000002, 21 | IP_POLYSEGMENT_CONTIGUOUS = 0x00000004, 22 | IP_TRIMESH = 0x00000008, 23 | IP_TRISTRIP = 0x00000010, 24 | IP_POLYSEGMENT_DISJOINT_ADJ = 0x00000020, 25 | IP_POLYSEGMENT_CONTIGUOUS_ADJ = 0x00000040, 26 | IP_TRIMESH_ADJ = 0x00000080, 27 | IP_TRISTRIP_ADJ = 0x00000100, 28 | 29 | IP_HAS_POINTS = IP_POLYPOINT, 30 | 31 | IP_HAS_SEGMENTS = IP_POLYSEGMENT_DISJOINT | IP_POLYSEGMENT_CONTIGUOUS 32 | | IP_POLYSEGMENT_DISJOINT_ADJ | IP_POLYSEGMENT_CONTIGUOUS_ADJ, 33 | 34 | IP_HAS_TRIANGLES = IP_TRIMESH | IP_TRISTRIP 35 | | IP_TRIMESH_ADJ | IP_TRISTRIP_ADJ, 36 | 37 | IP_NUM_TYPES = 9 // IP_POLYPOINT through IP_TRISTRIP_ADJ 38 | }; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteIndirectArgumentsBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP IndirectArgumentsBuffer : public Buffer 16 | { 17 | public: 18 | // Construction. Each element is a 4-byte value. For storing a 19 | // single set of input parameters to a draw call, the layout of 20 | // the buffer should be as shown next. The parameters are in the 21 | // order expected by the Draw* call without the 'Indirect' suffix. 22 | // 23 | // DrawInstancedIndirect: 24 | // UINT VertexCountPerInstance; 25 | // UINT InstanceCount; 26 | // UINT StartVertexLocation; 27 | // UINT StartInstanceLocation; 28 | // 29 | // DrawIndexedInstancedIndirect: 30 | // UINT IndexCountPerInstance; 31 | // UINT InstanceCount; 32 | // UINT StartIndexLocation; 33 | // INT BaseVertexLocation; 34 | // UINT StartInstanceLocation; 35 | // 36 | // DispatchIndirect: 37 | // UINT ThreadsGroupCountX; 38 | // UINT ThreadsGroupCountY; 39 | // UINT ThreadsGroupCountZ; 40 | 41 | IndirectArgumentsBuffer(unsigned int numElements, 42 | bool createStorage = true); 43 | }; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteLight.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP Light : public ViewVolume 18 | { 19 | public: 20 | // Construction. The depth range for DirectX is [0,1] and for OpenGL is 21 | // [-1,1]. For DirectX, set isDepthRangeZeroToOne to true. For OpenGL, 22 | // set isDepthRangeZeroOne to false. 23 | Light(bool isPerspective, bool isDepthRangeZeroOne); 24 | 25 | std::shared_ptr lighting; 26 | }; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteLightCameraGeometry.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | struct GTE_IMPEXP LightCameraGeometry 16 | { 17 | // Construction. 18 | LightCameraGeometry(); 19 | 20 | Vector4 lightModelPosition; // default: (0,0,0,1) 21 | Vector4 lightModelDirection; // default: (0,0,-1,0) 22 | Vector4 lightModelUp; // default: (0,1,0,0) 23 | Vector4 lightModelRight; // default: (1,0,0,0) 24 | 25 | Vector4 cameraModelPosition; // default: (0,0,0,1) 26 | Vector4 cameraModelDirection; // default: (0,0,-1,0) 27 | Vector4 cameraModelUp; // default: (0,1,0,0) 28 | Vector4 cameraModelRight; // default: (1,0,0,0) 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteLighting.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | struct GTE_IMPEXP Lighting 16 | { 17 | // Construction. The defaults are listed for each member. The '*' 18 | // channels are not used but are included to match shader-constant 19 | // packing rules. 20 | Lighting(); 21 | 22 | // (r,g,b,*): default (1,1,1,1) 23 | Vector4 ambient; 24 | 25 | // (r,g,b,*): default (1,1,1,1) 26 | Vector4 diffuse; 27 | 28 | // (r,g,b,*): default (1,1,1,1) 29 | Vector4 specular; 30 | 31 | // (angle,cosAngle,sinAngle,exponent): default (pi/2,0,1,1) 32 | Vector4 spotCutoff; 33 | 34 | // Attenuation is: intensity/(constant + linear * (d + quadratic * d) 35 | // where d is the distance from the light position to the vertex position. 36 | // The distance is in model space. If the transformation from model space 37 | // to world space involves uniform scaling, you can include the scaling 38 | // factor in the 'intensity' component (by multiplication). 39 | // 40 | // (constant,linear,quadratic,intensity): default (1,0,0,1) 41 | Vector4 attenuation; 42 | }; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteMaterial.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Material 16 | { 17 | public: 18 | // Construction. 19 | Material(); 20 | 21 | // (r,g,b,*): default (0,0,0,1) 22 | Vector4 emissive; 23 | 24 | // (r,g,b,*): default (0,0,0,1) 25 | Vector4 ambient; 26 | 27 | // (r,g,b,a): default (0,0,0,1) 28 | Vector4 diffuse; 29 | 30 | // (r,g,b,specularPower): default (0,0,0,1) 31 | Vector4 specular; 32 | }; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteMemberLayout.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | // Support for generation of lookup tables for constant buffers and texture 18 | // buffers. Given the name of a member of a buffer, get the offset into the 19 | // buffer memory where the member lives. The layout is specific to the 20 | // shading language (HLSL, GLSL). 21 | struct GTE_IMPEXP MemberLayout 22 | { 23 | std::string name; 24 | unsigned int offset; 25 | unsigned int numElements; 26 | }; 27 | 28 | typedef std::vector BufferLayout; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GtePixelShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP PixelShader : public Shader 16 | { 17 | public: 18 | // Construction. 19 | #if defined(GTE_DEV_OPENGL) 20 | PixelShader(GLSLReflection const& reflector); 21 | #else 22 | PixelShader(HLSLShader const& program); 23 | #endif 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteRasterizerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP RasterizerState : public DrawingState 16 | { 17 | public: 18 | enum GTE_IMPEXP FillMode 19 | { 20 | FILL_SOLID, 21 | FILL_WIREFRAME 22 | }; 23 | 24 | enum GTE_IMPEXP CullMode 25 | { 26 | CULL_NONE, 27 | CULL_FRONT, 28 | CULL_BACK 29 | }; 30 | 31 | // Construction. 32 | RasterizerState(); 33 | 34 | // Member access. The members are intended to be write-once before 35 | // you create an associated graphics state. 36 | FillMode fillMode; // default: FILL_SOLID 37 | CullMode cullMode; // default: CULL_BACK 38 | bool frontCCW; // default: true 39 | int depthBias; // default: 0 40 | float depthBiasClamp; // default: 0 41 | float slopeScaledDepthBias; // default: 0 42 | bool enableDepthClip; // default: true 43 | bool enableScissor; // default: false 44 | bool enableMultisample; // default: false 45 | bool enableAntialiasedLine; // default: false 46 | }; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteRawBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP RawBuffer : public Buffer 16 | { 17 | public: 18 | // Construction. The element size is always 4 bytes. 19 | RawBuffer(unsigned int numElements, bool createStorage = true); 20 | 21 | public: 22 | // For use by the Shader class for storing reflection information. 23 | static int const shaderDataLookup = 3; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTextEffect.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace gte 18 | { 19 | 20 | class GTE_IMPEXP TextEffect : public VisualEffect 21 | { 22 | public: 23 | // Construction. 24 | TextEffect(std::shared_ptr const& factory, 25 | std::shared_ptr const& texture); 26 | 27 | // Support for typesetting. 28 | std::shared_ptr const& GetTranslate() const; 29 | std::shared_ptr const& GetColor() const; 30 | void SetTranslate(float x, float y); 31 | void SetColor(Vector4 const& color); 32 | 33 | private: 34 | std::shared_ptr mTranslate; 35 | std::shared_ptr mColor; 36 | std::shared_ptr mSamplerState; 37 | 38 | // Shader source code as strings. 39 | static std::string const msGLSLVSSource; 40 | static std::string const msGLSLPSSource; 41 | static std::string const msHLSLSource; 42 | static std::string const* msVSSource[ProgramFactory::PF_NUM_API]; 43 | static std::string const* msPSSource[ProgramFactory::PF_NUM_API]; 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTexture1.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture1 : public TextureSingle 16 | { 17 | public: 18 | // Construction. 19 | Texture1(DFType format, unsigned int length, bool hasMipmaps = false, 20 | bool createStorage = true); 21 | 22 | // Texture dimensions. 23 | unsigned int GetLength() const; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTexture1Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture1Array : public TextureArray 16 | { 17 | public: 18 | // Construction. 19 | Texture1Array(unsigned int numItems, DFType format, unsigned int length, 20 | bool hasMipmaps = false, bool createStorage = true); 21 | 22 | // Texture dimensions. 23 | unsigned int GetLength() const; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTexture2.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture2 : public TextureSingle 16 | { 17 | public: 18 | // Construction. 19 | Texture2(DFType format, unsigned int width, unsigned int height, 20 | bool hasMipmaps = false, bool createStorage = true); 21 | 22 | // Texture dimensions. 23 | unsigned int GetWidth() const; 24 | unsigned int GetHeight() const; 25 | 26 | // If you intend to share this texture among DX11Engine objects, call this 27 | // function before binding the texture to the engine. The Texture2 usage 28 | // must be Resource::GPU_RW. 29 | void MakeShared(); 30 | bool IsShared() const; 31 | 32 | protected: 33 | bool mShared; 34 | }; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTexture2Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture2Array : public TextureArray 16 | { 17 | public: 18 | // Construction. 19 | Texture2Array(unsigned int numItems, DFType format, unsigned int width, 20 | unsigned int height, bool hasMipmaps = false, 21 | bool createStorage = true); 22 | 23 | // Texture dimensions. 24 | unsigned int GetWidth() const; 25 | unsigned int GetHeight() const; 26 | }; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTexture3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture3 : public TextureSingle 16 | { 17 | public: 18 | // Construction. 19 | Texture3(DFType format, unsigned int width, unsigned int height, 20 | unsigned int thickness, bool hasMipmaps = false, 21 | bool createStorage = true); 22 | 23 | // Texture dimensions. 24 | unsigned int GetWidth() const; 25 | unsigned int GetHeight() const; 26 | unsigned int GetThickness() const; 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTextureCube.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TextureCube : public TextureArray 16 | { 17 | public: 18 | // Construction. Cube maps must be square; the 'length' parameter is the 19 | // shared value for width and height. 20 | TextureCube(DFType format, unsigned int length, bool hasMipmaps = false, 21 | bool createStorage = true); 22 | 23 | // The texture width and height are the same value. 24 | unsigned int GetLength() const; 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTextureDS.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2016/11/13) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TextureDS : public Texture2 16 | { 17 | public: 18 | // Construction for depth-stencil textures. 19 | TextureDS(DFType format, unsigned int width, unsigned int height, 20 | bool createStorage = true); 21 | 22 | void MakeShaderInput(); 23 | bool IsShaderInput() const; 24 | 25 | private: 26 | bool mShaderInput; 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTextureRT.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TextureRT : public Texture2 16 | { 17 | public: 18 | // Construction for render targets. 19 | TextureRT(DFType format, unsigned int width, unsigned int height, 20 | bool hasMipmaps = false, bool createStorage = true); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTransformController.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP TransformController : public Controller 17 | { 18 | public: 19 | TransformController(Transform const& localTransform); 20 | 21 | // Member access. 22 | inline void SetTransform(Transform const& localTransform); 23 | inline Transform const& GetTransform() const; 24 | 25 | // The animation update. The application time is in milliseconds. 26 | // The update simply copies mLocalTransform to the Spatial mObject's 27 | // LocalTransform. In this sense, TransformController represents a 28 | // transform that is constant for all time. 29 | virtual bool Update(double applicationTime); 30 | 31 | protected: 32 | Transform mLocalTransform; 33 | }; 34 | 35 | 36 | inline void TransformController::SetTransform(Transform const& localTransform) 37 | { 38 | mLocalTransform = localTransform; 39 | } 40 | 41 | inline Transform const& TransformController::GetTransform() const 42 | { 43 | return mLocalTransform; 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteTypedBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TypedBuffer : public Buffer 16 | { 17 | protected: 18 | // Abstract base class. 19 | TypedBuffer(unsigned int numElements, size_t elementSize, 20 | bool createStorage = true); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteVertexShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP VertexShader : public Shader 16 | { 17 | public: 18 | // Construction. 19 | #if defined(GTE_DEV_OPENGL) 20 | VertexShader(GLSLReflection const& reflector); 21 | #else 22 | VertexShader(HLSLShader const& program); 23 | #endif 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/Graphics/GteVisualEffect.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP VisualEffect 16 | { 17 | public: 18 | // Construction and destruction. 19 | virtual ~VisualEffect(); 20 | VisualEffect(std::shared_ptr const& program); 21 | 22 | // Member access. 23 | inline std::shared_ptr const& GetProgram() const; 24 | inline std::shared_ptr const& GetVertexShader() const; 25 | inline std::shared_ptr const& GetPixelShader() const; 26 | inline std::shared_ptr const& GetGeometryShader() const; 27 | 28 | protected: 29 | // For derived classes to defer construction because they want to create 30 | // programs via a factory. 31 | VisualEffect(); 32 | 33 | std::shared_ptr mProgram; 34 | BufferUpdater mBufferUpdater; 35 | TextureUpdater mTextureUpdater; 36 | TextureArrayUpdater mTextureArrayUpdater; 37 | }; 38 | 39 | 40 | inline std::shared_ptr const& VisualEffect::GetProgram() const 41 | { 42 | return mProgram; 43 | } 44 | 45 | inline std::shared_ptr const& VisualEffect::GetVertexShader() const 46 | { 47 | return mProgram->GetVShader(); 48 | } 49 | 50 | inline std::shared_ptr const& VisualEffect::GetPixelShader() const 51 | { 52 | return mProgram->GetPShader(); 53 | } 54 | 55 | inline std::shared_ptr const& VisualEffect::GetGeometryShader() const 56 | { 57 | return mProgram->GetGShader(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /Src/gte/Imagics/GteMarchingCubesTable.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | extern GTE_IMPEXP int const gMarchingCubesTable[256][41]; 15 | } 16 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteAtomicMinMax.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | // Implementations of atomic minimum and atomic maximum computations. These 15 | // are based on std::atomic_compare_exchange_strong. 16 | 17 | namespace gte 18 | { 19 | 20 | template 21 | T AtomicMin(std::atomic& v0, T const& v1); 22 | 23 | template 24 | T AtomicMax(std::atomic& v0, T const& v1); 25 | 26 | 27 | template 28 | T AtomicMin(std::atomic& v0, T const& v1) 29 | { 30 | T vInitial, vMin; 31 | do 32 | { 33 | vInitial = v0; 34 | vMin = std::min(vInitial, v1); 35 | } while (!std::atomic_compare_exchange_strong(&v0, &vInitial, vMin)); 36 | return vInitial; 37 | } 38 | 39 | template 40 | T AtomicMax(std::atomic& v0, T const& v1) 41 | { 42 | T vInitial, vMax; 43 | do 44 | { 45 | vInitial = v0; 46 | vMax = std::max(vInitial, v1); 47 | } while (!std::atomic_compare_exchange_strong(&v0, &vInitial, vMax)); 48 | return vInitial; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteLogReporter.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #if defined(__MSWINDOWS__) 13 | #include 14 | #include 15 | #endif 16 | #include 17 | 18 | namespace gte 19 | { 20 | 21 | class GTE_IMPEXP LogReporter 22 | { 23 | public: 24 | // Construction and destruction. Create one of these objects in an 25 | // application for logging. The GenerateProject tool creates such code. 26 | // If you do not want a particular logger, set the flags to 27 | // LISTEN_FOR_NOTHING and set logFile to "" if you do not want a file. 28 | ~LogReporter(); 29 | 30 | LogReporter(std::string const& logFile, int logFileFlags, int logStdoutFlags, 31 | int logMessageBoxFlags = 0, int logOutputWindowFlags = 0); 32 | 33 | private: 34 | std::unique_ptr mLogToFile; 35 | std::unique_ptr mLogToStdout; 36 | 37 | #if defined(__MSWINDOWS__) 38 | std::unique_ptr mLogToMessageBox; 39 | std::unique_ptr mLogToOutputWindow; 40 | #endif 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteLogToFile.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP LogToFile : public Logger::Listener 16 | { 17 | public: 18 | LogToFile(std::string const& filename, int flags); 19 | 20 | private: 21 | virtual void Report(std::string const& message); 22 | 23 | std::string mFilename; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteLogToStdout.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP LogToStdout : public Logger::Listener 16 | { 17 | public: 18 | LogToStdout(int flags); 19 | 20 | private: 21 | virtual void Report(std::string const& message); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteLogToStringArray.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP LogToStringArray : public Logger::Listener 17 | { 18 | public: 19 | LogToStringArray(std::string const& name, int flags); 20 | 21 | std::string const& GetName() const; 22 | std::vector const& GetMessages() const; 23 | std::vector& GetMessages(); 24 | 25 | private: 26 | virtual void Report(std::string const& message); 27 | 28 | std::string mName; 29 | std::vector mMessages; 30 | }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteRangeIteration.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | // For information on range-based for-loops, see 15 | // http://en.cppreference.com/w/cpp/language/range-for 16 | 17 | namespace gte 18 | { 19 | 20 | // The function gte::reverse supports reverse iteration in range-based 21 | // for-loops using the auto keyword. For example, 22 | // 23 | // std::vector numbers(4); 24 | // int i = 0; 25 | // for (auto& number : numbers) 26 | // { 27 | // number = i++; 28 | // std::cout << number << ' '; 29 | // } 30 | // // Output: 0 1 2 3 31 | // 32 | // for (auto& number : gte::reverse(numbers)) 33 | // { 34 | // std::cout << number << ' '; 35 | // } 36 | // // Output: 3 2 1 0 37 | 38 | template 39 | class ReversalObject 40 | { 41 | public: 42 | ReversalObject(Iterator begin, Iterator end) 43 | : 44 | mBegin(begin), 45 | mEnd(end) 46 | { 47 | } 48 | 49 | Iterator begin() const { return mBegin; } 50 | Iterator end() const { return mEnd; } 51 | 52 | private: 53 | Iterator mBegin, mEnd; 54 | }; 55 | 56 | template 57 | < 58 | typename Iterable, 59 | typename Iterator = decltype(std::begin(std::declval())), 60 | typename ReverseIterator = std::reverse_iterator 61 | > 62 | ReversalObject reverse(Iterable&& range) 63 | { 64 | return ReversalObject( 65 | ReverseIterator(std::end(range)), 66 | ReverseIterator(std::begin(range))); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteTimer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | #if defined(__MSWINDOWS__) && _MSC_VER < 1900 14 | // MSVS 2013 has an implementation of std::chrono::high_resolution_clock 15 | // that does not use a 64-bit clock (QueryPerformanceCounter). Instead, 16 | // it appears to use a file-system clock that is 24 bits. To obtain 17 | // accurate measurements, we need the 64-bit clock. However, MSVS 2015 18 | // does use a 64-bit clock. 19 | #define GTE_NEEDS_64_BIT_CLOCK 20 | #endif 21 | 22 | #if !defined(GTE_NEEDS_64_BIT_CLOCK) 23 | #include 24 | #endif 25 | 26 | namespace gte 27 | { 28 | 29 | class GTE_IMPEXP Timer 30 | { 31 | public: 32 | // Construction of a high-resolution timer (64-bit). 33 | Timer(); 34 | 35 | // Get the current time relative to the initial time. 36 | int64_t GetNanoseconds() const; 37 | int64_t GetMicroseconds() const; 38 | int64_t GetMilliseconds() const; 39 | double GetSeconds() const; 40 | 41 | // Reset so that the current time is the initial time. 42 | void Reset(); 43 | 44 | private: 45 | #if defined(GTE_NEEDS_64_BIT_CLOCK) 46 | // Internally use QueryPerformanceCounter. 47 | int64_t GetTicks() const; 48 | 49 | int64_t mFrequency, mInitialTicks; 50 | double mInvFrequency; 51 | #else 52 | std::chrono::high_resolution_clock::time_point mInitialTime; 53 | #endif 54 | }; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/GteWrapper.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | // Wrappers around platform-specific low-level library calls. 14 | 15 | namespace gte 16 | { 17 | 18 | void Memcpy(void* target, void const* source, size_t count); 19 | void Memcpy(wchar_t* target, wchar_t const* source, size_t count); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/MSW/GteLogToMessageBox.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP LogToMessageBox : public Logger::Listener 16 | { 17 | public: 18 | LogToMessageBox(int flags); 19 | 20 | private: 21 | virtual void Report(std::string const& message); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Src/gte/LowLevel/MSW/GteLogToOutputWindow.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP LogToOutputWindow : public Logger::Listener 16 | { 17 | public: 18 | LogToOutputWindow(int flags); 19 | 20 | private: 21 | virtual void Report(std::string const& message); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteASinEstimate.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | // Approximations to asin(x) of the form f(x) = pi/2 - sqrt(1-x)*p(x) 13 | // where the polynomial p(x) of degree D minimizes the quantity 14 | // maximum{|acos(x)/sqrt(1-x) - p(x)| : x in [0,1]} over all 15 | // polynomials of degree D. We use the identity asin(x) = pi/2 - acos(x). 16 | 17 | namespace gte 18 | { 19 | 20 | template 21 | class ASinEstimate 22 | { 23 | public: 24 | // The input constraint is x in [0,1]. For example, 25 | // float x; // in [0,1] 26 | // float result = ASinEstimate::Degree<3>(x); 27 | template 28 | inline static Real Degree(Real x); 29 | }; 30 | 31 | 32 | template 33 | template 34 | inline Real ASinEstimate::Degree(Real x) 35 | { 36 | return (Real)GTE_C_HALF_PI - ACosEstimate::Degree(x); 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteAxisAngle.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // Axis-angle representation for N = 3 or N = 4. When N = 4, the axis 16 | // must be a vector of the form (x,y,z,0) [affine representation of the 17 | // 3-tuple direction]. 18 | 19 | template 20 | class AxisAngle 21 | { 22 | public: 23 | AxisAngle(); 24 | AxisAngle(Vector const& inAxis, Real inAngle); 25 | 26 | Vector axis; 27 | Real angle; 28 | }; 29 | 30 | 31 | template 32 | AxisAngle::AxisAngle() 33 | { 34 | static_assert(N == 3 || N == 4, "Dimension must be 3 or 4."); 35 | // Uninitialized. 36 | } 37 | 38 | template 39 | AxisAngle::AxisAngle(Vector const& inAxis, Real inAngle) 40 | : 41 | axis(inAxis), 42 | angle(inAngle) 43 | { 44 | static_assert(N == 3 || N == 4, "Dimension must be 3 or 4."); 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteBitHacks.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.1 (2017/07/04) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | GTE_IMPEXP bool IsPowerOfTwo(uint32_t value); 17 | GTE_IMPEXP bool IsPowerOfTwo(int32_t value); 18 | 19 | GTE_IMPEXP uint32_t Log2OfPowerOfTwo(uint32_t powerOfTwo); 20 | GTE_IMPEXP int32_t Log2OfPowerOfTwo(int32_t powerOfTwo); 21 | 22 | // Call these only for nonzero values. If value is zero, then GetLeadingBit 23 | // and GetTrailingBit return zero. 24 | GTE_IMPEXP int32_t GetLeadingBit(uint32_t value); 25 | GTE_IMPEXP int32_t GetLeadingBit(int32_t value); 26 | GTE_IMPEXP int32_t GetLeadingBit(uint64_t value); 27 | GTE_IMPEXP int32_t GetLeadingBit(int64_t value); 28 | GTE_IMPEXP int32_t GetTrailingBit(uint32_t value); 29 | GTE_IMPEXP int32_t GetTrailingBit(int32_t value); 30 | GTE_IMPEXP int32_t GetTrailingBit(uint64_t value); 31 | GTE_IMPEXP int32_t GetTrailingBit(int64_t value); 32 | 33 | // Round up to a power of two. If input is zero, the return is 1. If input 34 | // is larger than 2^{31}, the return is 2^{32}. 35 | GTE_IMPEXP uint64_t RoundUpToPowerOfTwo(uint32_t value); 36 | 37 | // Round down to a power of two. If input is zero, the return is 0. 38 | GTE_IMPEXP uint32_t RoundDownToPowerOfTwo(uint32_t value); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteDCPQuery.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // Distance and closest-point queries. 16 | template 17 | class DCPQuery 18 | { 19 | public: 20 | struct Result 21 | { 22 | // A DCPQuery-base class B must define a B::Result struct with member 23 | // 'Real distance'. A DCPQuery-derived class D must also derive a 24 | // D::Result from B:Result but may have no members. The idea is to 25 | // allow Result to store closest-point information in addition to the 26 | // distance. The operator() is non-const to allow DCPQuery to store 27 | // and modify private state that supports the query. 28 | }; 29 | Result operator()(Type0 const& primitive0, Type1 const& primitive1); 30 | }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteDistPoint3Plane3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | template 18 | class DCPQuery, Plane3> 19 | { 20 | public: 21 | struct Result 22 | { 23 | Real distance, signedDistance; 24 | Vector3 planeClosestPoint; 25 | }; 26 | 27 | Result operator()(Vector3 const& point, Plane3 const& plane); 28 | }; 29 | 30 | 31 | template 32 | typename DCPQuery, Plane3>::Result 33 | DCPQuery, Plane3>::operator()( 34 | Vector3 const& point, Plane3 const& plane) 35 | { 36 | Result result; 37 | result.signedDistance = Dot(plane.normal, point) - plane.constant; 38 | result.distance = std::abs(result.signedDistance); 39 | result.planeClosestPoint = point - result.signedDistance*plane.normal; 40 | return result; 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteDistPointLine.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | template 17 | class DCPQuery, Line> 18 | { 19 | public: 20 | struct Result 21 | { 22 | Real distance, sqrDistance; 23 | Real lineParameter; // t in (-infinity,+infinity) 24 | Vector lineClosest; // origin + t * direction 25 | }; 26 | 27 | Result operator()(Vector const& point, 28 | Line const& line); 29 | }; 30 | 31 | // Template aliases for convenience. 32 | template 33 | using DCPPointLine = 34 | DCPQuery, Line>; 35 | 36 | template 37 | using DCPPoint2Line2 = DCPPointLine<2, Real>; 38 | 39 | template 40 | using DCPPoint3Line3 = DCPPointLine<3, Real>; 41 | 42 | 43 | template 44 | typename DCPQuery, Line>::Result 45 | DCPQuery, Line>::operator()( 46 | Vector const& point, Line const& line) 47 | { 48 | Result result; 49 | 50 | Vector diff = point - line.origin; 51 | result.lineParameter = Dot(line.direction, diff); 52 | result.lineClosest = line.origin + result.lineParameter*line.direction; 53 | 54 | diff = point - result.lineClosest; 55 | result.sqrDistance = Dot(diff, diff); 56 | result.distance = sqrt(result.sqrDistance); 57 | 58 | return result; 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteEdgeKey.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | template 16 | class EdgeKey : public FeatureKey<2, Ordered> 17 | { 18 | public: 19 | // An ordered edge has (V[0],V[1]) = (v0,v1). An unordered edge has 20 | // (V[0],V[1]) = (min(V[0],V[1]),max(V[0],V[1])). 21 | EdgeKey(int v0 = -1, int v1 = -1); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteExpEstimate.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | // Minimax polynomial approximations to 2^x. The polynomial p(x) of 13 | // degree D minimizes the quantity maximum{|2^x - p(x)| : x in [0,1]} 14 | // over all polynomials of degree D. The natural exponential is 15 | // computed using exp(x) = 2^{x log(2)}, where log(2) is the natural 16 | // logarithm of 2. 17 | 18 | namespace gte 19 | { 20 | 21 | template 22 | class ExpEstimate 23 | { 24 | public: 25 | // The input constraint is x in [0,1]. For example, 26 | // float x; // in [0,1] 27 | // float result = ExpEstimate::Degree<3>(x); 28 | template 29 | inline static Real Degree(Real x); 30 | 31 | // The input x can be any real number. Range reduction is used to 32 | // generate a value y in [0,1], call Degree(y), and combine the output 33 | // with the proper exponent to obtain the approximation. For example, 34 | // float x; // x >= 0 35 | // float result = ExpEstimate::DegreeRR<3>(x); 36 | template 37 | inline static Real DegreeRR(Real x); 38 | }; 39 | 40 | 41 | template 42 | template 43 | inline Real ExpEstimate::Degree(Real x) 44 | { 45 | return Exp2Estimate::Degree((Real)GTE_C_LN_2 * x); 46 | } 47 | 48 | template 49 | template 50 | inline Real ExpEstimate::DegreeRR(Real x) 51 | { 52 | return Exp2Estimate::DegreeRR((Real)GTE_C_LN_2 * x); 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteFIQuery.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // Find-intersection queries. 16 | 17 | template 18 | class FIQuery 19 | { 20 | public: 21 | struct Result 22 | { 23 | // A FIQuery-base class B must define a B::Result struct with member 24 | // 'bool intersect'. A FIQuery-derived class D must also derive a 25 | // D::Result from B:Result but may have no members. The member 26 | // 'intersect' is 'true' iff the primitives intersect. The operator() 27 | // is non-const to allow FIQuery to store and modify private state 28 | // that supports the query. 29 | }; 30 | Result operator()(Type0 const& primitive0, Type1 const& primitive1); 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteIntrCapsule3Capsule3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | template 18 | class TIQuery, Capsule3> 19 | { 20 | public: 21 | struct Result 22 | { 23 | bool intersect; 24 | }; 25 | 26 | Result operator()(Capsule3 const& capsule0, 27 | Capsule3 const& capsule1); 28 | }; 29 | 30 | 31 | template 32 | typename TIQuery, Capsule3>::Result 33 | TIQuery, Capsule3>::operator()( 34 | Capsule3 const& capsule0, Capsule3 const& capsule1) 35 | { 36 | Result result; 37 | DCPQuery, Segment3> ssQuery; 38 | auto ssResult = ssQuery(capsule0.segment, capsule1.segment); 39 | Real rSum = capsule0.radius + capsule1.radius; 40 | result.intersect = (ssResult.distance <= rSum); 41 | return result; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteIntrHalfspace3Capsule3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // Queries for intersection of objects with halfspaces. These are useful for 16 | // containment testing, object culling, and clipping. 17 | 18 | namespace gte 19 | { 20 | 21 | template 22 | class TIQuery, Capsule3> 23 | { 24 | public: 25 | struct Result 26 | { 27 | bool intersect; 28 | }; 29 | 30 | Result operator()(Halfspace3 const& halfspace, 31 | Capsule3 const& capsule); 32 | }; 33 | 34 | 35 | template 36 | typename TIQuery, Capsule3>::Result 37 | TIQuery, Capsule3>::operator()( 38 | Halfspace3 const& halfspace, Capsule3 const& capsule) 39 | { 40 | Result result; 41 | 42 | // Project the capsule onto the normal line. The plane of the halfspace 43 | // occurs at the origin (zero) of the normal line. 44 | Real e0 = 45 | Dot(halfspace.normal, capsule.segment.p[0]) - halfspace.constant; 46 | Real e1 = 47 | Dot(halfspace.normal, capsule.segment.p[1]) - halfspace.constant; 48 | 49 | // The capsule and halfspace intersect when the projection interval 50 | // maximum is nonnegative. 51 | result.intersect = (std::max(e0, e1) + capsule.radius >= (Real)0); 52 | return result; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteIntrHalfspace3Sphere3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // Queries for intersection of objects with halfspaces. These are useful for 16 | // containment testing, object culling, and clipping. 17 | 18 | namespace gte 19 | { 20 | 21 | template 22 | class TIQuery, Sphere3> 23 | { 24 | public: 25 | struct Result 26 | { 27 | bool intersect; 28 | }; 29 | 30 | Result operator()(Halfspace3 const& halfspace, 31 | Sphere3 const& sphere); 32 | }; 33 | 34 | 35 | template 36 | typename TIQuery, Sphere3>::Result 37 | TIQuery, Sphere3>::operator()( 38 | Halfspace3 const& halfspace, Sphere3 const& sphere) 39 | { 40 | Result result; 41 | 42 | // Project the sphere center onto the normal line. The plane of the 43 | // halfspace occurs at the origin (zero) of the normal line. 44 | Real center = Dot(halfspace.normal, sphere.center) - halfspace.constant; 45 | 46 | // The sphere and halfspace intersect when the projection interval 47 | // maximum is nonnegative. 48 | result.intersect = (center + sphere.radius >= (Real)0); 49 | return result; 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteIntrPlane3Capsule3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | template 18 | class TIQuery, Capsule3> 19 | { 20 | public: 21 | struct Result 22 | { 23 | bool intersect; 24 | }; 25 | 26 | Result operator()(Plane3 const& plane, 27 | Capsule3 const& capsule); 28 | }; 29 | 30 | 31 | template 32 | typename TIQuery, Capsule3>::Result 33 | TIQuery, Capsule3>::operator()( 34 | Plane3 const& plane, Capsule3 const& capsule) 35 | { 36 | Result result; 37 | 38 | DCPQuery, Plane3> vpQuery; 39 | Real sdistance0 = vpQuery(capsule.segment.p[0], plane).signedDistance; 40 | Real sdistance1 = vpQuery(capsule.segment.p[1], plane).signedDistance; 41 | if (sdistance0 * sdistance1 <= (Real)0) 42 | { 43 | // A capsule segment endpoint is on the plane or the two endpoints 44 | // are on opposite sides of the plane. 45 | result.intersect = true; 46 | return result; 47 | } 48 | 49 | // The endpoints on same side of plane, but the endpoint spheres might 50 | // intersect the plane. 51 | result.intersect = 52 | std::abs(sdistance0) <= capsule.radius || 53 | std::abs(sdistance1) <= capsule.radius; 54 | return result; 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteIntrPlane3Ellipsoid3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace gte 16 | { 17 | 18 | template 19 | class TIQuery, Ellipsoid3> 20 | { 21 | public: 22 | struct Result 23 | { 24 | bool intersect; 25 | }; 26 | 27 | Result operator()(Plane3 const& plane, 28 | Ellipsoid3 const& ellipsoid); 29 | }; 30 | 31 | 32 | template 33 | typename TIQuery, Ellipsoid3>::Result 34 | TIQuery, Ellipsoid3>::operator()( 35 | Plane3 const& plane, Ellipsoid3 const& ellipsoid) 36 | { 37 | Result result; 38 | Matrix3x3 MInverse; 39 | ellipsoid.GetMInverse(MInverse); 40 | Real discr = Dot(plane.normal, MInverse * plane.normal); 41 | Real root = sqrt(std::max(discr, (Real)0)); 42 | DCPQuery, Plane3> vpQuery; 43 | Real distance = vpQuery(ellipsoid.center, plane).distance; 44 | result.intersect = (distance <= root); 45 | return result; 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteIntrPlane3OrientedBox3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace gte 16 | { 17 | 18 | template 19 | class TIQuery, OrientedBox3> 20 | { 21 | public: 22 | struct Result 23 | { 24 | bool intersect; 25 | }; 26 | 27 | Result operator()(Plane3 const& plane, 28 | OrientedBox3 const& box); 29 | }; 30 | 31 | 32 | template 33 | typename TIQuery, OrientedBox3>::Result 34 | TIQuery, OrientedBox3>::operator()( 35 | Plane3 const& plane, OrientedBox3 const& box) 36 | { 37 | Result result; 38 | 39 | Real radius = 40 | std::abs(box.extent[0] * Dot(plane.normal, box.axis[0])) + 41 | std::abs(box.extent[1] * Dot(plane.normal, box.axis[1])) + 42 | std::abs(box.extent[2] * Dot(plane.normal, box.axis[2])); 43 | 44 | DCPQuery, Plane3> ppQuery; 45 | auto ppResult = ppQuery(box.center, plane); 46 | result.intersect = (ppResult.distance <= radius); 47 | return result; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteIntrSphere3Frustum3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | template 18 | class TIQuery, Frustum3> 19 | { 20 | public: 21 | struct Result 22 | { 23 | bool intersect; 24 | }; 25 | 26 | Result operator()(Sphere3 const& sphere, 27 | Frustum3 const& frustum); 28 | }; 29 | 30 | 31 | template 32 | typename TIQuery, Frustum3>::Result 33 | TIQuery, Frustum3>::operator()( 34 | Sphere3 const& sphere, Frustum3 const& frustum) 35 | { 36 | Result result; 37 | DCPQuery, Frustum3> vfQuery; 38 | Real distance = vfQuery(sphere.center, frustum).distance; 39 | result.intersect = (distance <= sphere.radius); 40 | return result; 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteLogEstimate.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | // Minimax polynomial approximations to log2(x). The polynomial p(x) of 13 | // degree D minimizes the quantity maximum{|log2(x) - p(x)| : x in [1,2]} 14 | // over all polynomials of degree D. The natural logarithm is computed 15 | // using log(x) = log2(x)/log2(e) = log2(x)*log(2). 16 | 17 | namespace gte 18 | { 19 | 20 | template 21 | class LogEstimate 22 | { 23 | public: 24 | // The input constraint is x in [1,2]. For example, 25 | // float x; // in [1,2] 26 | // float result = LogEstimate::Degree<3>(x); 27 | template 28 | inline static Real Degree(Real x); 29 | 30 | // The input constraint is x > 0. Range reduction is used to generate a 31 | // value y in (0,1], call Degree(y), and add the exponent for the power 32 | // of two in the binary scientific representation of x. For example, 33 | // float x; // x > 0 34 | // float result = LogEstimate::DegreeRR<3>(x); 35 | template 36 | inline static Real DegreeRR(Real x); 37 | }; 38 | 39 | 40 | template 41 | template 42 | inline Real LogEstimate::Degree(Real x) 43 | { 44 | return Log2Estimate::Degree(x) * (Real)GTE_C_INV_LN_2; 45 | } 46 | 47 | template 48 | template 49 | inline Real LogEstimate::DegreeRR(Real x) 50 | { 51 | return Log2Estimate::DegreeRR(x) * (Real)GTE_C_INV_LN_2; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteMinimumAreaCircle2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/gte/Mathematics/GteMinimumAreaCircle2.h -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteMinimumVolumeSphere3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/Src/gte/Mathematics/GteMinimumVolumeSphere3.h -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteTIQuery.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // Test-intersection queries. 16 | 17 | template 18 | class TIQuery 19 | { 20 | public: 21 | struct Result 22 | { 23 | // A TIQuery-base class B must define a B::Result struct with member 24 | // 'bool intersect'. A TIQuery-derived class D must also derive a 25 | // D::Result from B:Result but may have no members. The member 26 | // 'intersect' is 'true' iff the primitives intersect. The operator() 27 | // is non-const to allow TIQuery to store and modify private state 28 | // that supports the query. 29 | }; 30 | Result operator()(Type0 const& primitive0, Type1 const& primitive1); 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteTriangleKey.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | template 16 | class TriangleKey : public FeatureKey<3, Ordered> 17 | { 18 | public: 19 | // An ordered triangle has V[0] = min(v0,v1,v2). Choose (V[0],V[1],V[2]) 20 | // to be a permutation of (v0,v1,v2) so that the final storage is one of 21 | // (v0,v1,v2), (v1,v2,v0), (v2,v0,v1) 22 | // The idea is that if v0 corresponds to (1,0,0), v1 corresponds to 23 | // (0,1,0), and v2 corresponds to (0,0,1), the ordering (v0,v1,v2) 24 | // corresponds to the 3x3 identity matrix I; the rows are the specified 25 | // 3-tuples. The permutation (V[0],V[1],V[2]) induces a permutation of 26 | // the rows of the identity matrix to form a permutation matrix P with 27 | // det(P) = 1 = det(I). 28 | // 29 | // An unordered triangle stores a permutation of (v0,v1,v2) so that 30 | // V[0] < V[1] < V[2]. 31 | TriangleKey(int v0 = -1, int v1 = -1, int v2 = -1); 32 | }; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Src/gte/Mathematics/GteVertexAttribute.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.3.0 (2016/08/29) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | struct VertexAttribute 17 | { 18 | inline VertexAttribute(); 19 | inline VertexAttribute(std::string const& inSemantic, void* inSource, size_t inStride); 20 | 21 | // The 'semantic' string allows you to query for a specific vertex 22 | // attribute and use the 'source' and 'stride' to access the data 23 | // of the attribute. For example, you might use the semantics 24 | // "position" (px,py,pz), "normal" (nx,ny,nz), "tcoord" (texture 25 | // coordinates (u,v)), "dpdu" (derivative of position with respect 26 | // to u), or "dpdv" (derivative of position with respect to v) for 27 | // mesh vertices. 28 | // 29 | // The source pointer must be 4-byte aligned. The stride must be 30 | // positive and a multiple of 4. The pointer alignment constraint is 31 | // guaranteed on 32-bit and 64-bit architectures. The stride constraint 32 | // is reasonable given that (usually) geometric attributes are usually 33 | // arrays of 'float' or 'double'. 34 | 35 | std::string semantic; 36 | void* source; 37 | size_t stride; 38 | }; 39 | 40 | inline VertexAttribute::VertexAttribute() 41 | : 42 | semantic(""), 43 | source(nullptr), 44 | stride(0) 45 | { 46 | } 47 | 48 | inline VertexAttribute::VertexAttribute(std::string const& inSemantic, void* inSource, size_t inStride) 49 | : 50 | semantic(inSemantic), 51 | source(inSource), 52 | stride(inStride) 53 | { 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Src/gte/Physics/GteFluid2AdjustVelocity.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace gte 16 | { 17 | 18 | class GraphicsEngine; 19 | 20 | class GTE_IMPEXP Fluid2AdjustVelocity 21 | { 22 | public: 23 | // Construction. Adjust the velocities using the solution to the Poisson equation. 24 | Fluid2AdjustVelocity(std::shared_ptr const& factory, 25 | int xSize, int ySize, int numXThreads, int numYThreads, 26 | std::shared_ptr const& parameters); 27 | 28 | // Update the state for the fluid simulation. 29 | void Execute(std::shared_ptr const& engine, 30 | std::shared_ptr const& inState, 31 | std::shared_ptr const& poisson, 32 | std::shared_ptr const& outState); 33 | 34 | private: 35 | int mNumXGroups, mNumYGroups; 36 | std::shared_ptr mAdjustVelocity; 37 | 38 | // Shader source code as strings. 39 | static std::string const msGLSLSource; 40 | static std::string const msHLSLSource; 41 | static std::string const* msSource[ProgramFactory::PF_NUM_API]; 42 | }; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Src/gte/Physics/GteFluid2Parameters.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | struct GTE_IMPEXP Fluid2Parameters 16 | { 17 | Vector4 spaceDelta; // (dx, dy, 0, 0) 18 | Vector4 halfDivDelta; // (0.5/dx, 0.5/dy, 0, 0) 19 | Vector4 timeDelta; // (dt/dx, dt/dy, 0, dt) 20 | Vector4 viscosityX; // (velVX, velVX, 0, denVX) 21 | Vector4 viscosityY; // (velVY, velVY, 0, denVY) 22 | Vector4 epsilon; // (epsX, epsY, 0, eps0) 23 | }; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Src/gte/Physics/GteFluid3AdjustVelocity.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace gte 16 | { 17 | 18 | class GraphicsEngine; 19 | 20 | class GTE_IMPEXP Fluid3AdjustVelocity 21 | { 22 | public: 23 | // Construction. Adjust the velocities using the solution to the 24 | // Poisson equation. 25 | Fluid3AdjustVelocity(std::shared_ptr const& factory, 26 | int xSize, int ySize, int zSize, int numXThreads, int numYThreads, int numZThreads, 27 | std::shared_ptr const& parameters); 28 | 29 | // Update the state for the fluid simulation. 30 | void Execute(std::shared_ptr const& engine, 31 | std::shared_ptr const& inState, 32 | std::shared_ptr const& poisson, 33 | std::shared_ptr const& outState); 34 | 35 | private: 36 | int mNumXGroups, mNumYGroups, mNumZGroups; 37 | std::shared_ptr mAdjustVelocity; 38 | 39 | // Shader source code as strings. 40 | static std::string const msGLSLSource; 41 | static std::string const msHLSLSource; 42 | static std::string const* msSource[ProgramFactory::PF_NUM_API]; 43 | }; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Src/gte/Physics/GteFluid3Parameters.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2017 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 3.0.0 (2016/06/19) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | struct GTE_IMPEXP Fluid3Parameters 16 | { 17 | Vector4 spaceDelta; // (dx, dy, dz, 0) 18 | Vector4 halfDivDelta; // (0.5/dx, 0.5/dy, 0.5/dz, 0) 19 | Vector4 timeDelta; // (dt/dx, dt/dy, dt/dz, dt) 20 | Vector4 viscosityX; // (velVX, velVX, velVX, denVX) 21 | Vector4 viscosityY; // (velVX, velVY, velVY, denVY) 22 | Vector4 viscosityZ; // (velVZ, velVZ, velVZ, denVZ) 23 | Vector4 epsilon; // (epsX, epsY, epsZ, eps0) 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Src/obj2ply.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJ2PLY_H_FILE_ 2 | #define _OBJ2PLY_H_FILE_ 3 | 4 | #include "MeshDoc.h" 5 | 6 | bool obj2ply( 7 | const std::string &inputObjFolder, 8 | const std::string &outputPlyFolder, 9 | const unsigned int number_sample, 10 | const unsigned int noise_loc_dis = 0U, 11 | const unsigned int noise_norm_ang = 0U); 12 | int savePly( 13 | const std::string &plyPath, 14 | const std::vector &V, 15 | const std::vector &N, 16 | const std::vector &C); 17 | bool addPlyNoise( 18 | const std::string &plyPath, 19 | const unsigned int noise_loc_dis, 20 | const unsigned int noise_norm_ang); 21 | 22 | #endif // !_OBJ2PLY_H_FILE_ 23 | 24 | -------------------------------------------------------------------------------- /Src/struct2ply.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJ2PLY_H_FILE_ 2 | #define _OBJ2PLY_H_FILE_ 3 | 4 | #include "MeshDoc.h" 5 | 6 | int PlyPts(const std::string &plyFile); 7 | bool struct2ply( 8 | const std::string &StructFile, 9 | const unsigned int number_sample, 10 | const std::string &PlyFile = ""); 11 | int savePly( 12 | const std::string &plyPath, 13 | const std::vector &V, 14 | const std::vector &N, 15 | const std::vector &C); 16 | 17 | #endif // !_OBJ2PLY_H_FILE_ 18 | 19 | -------------------------------------------------------------------------------- /Src/ultitool.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTITOOL_H_FILE_ 2 | #define _ULTITOOL_H_FILE_ 3 | 4 | #include "MeshDoc.h" 5 | #include 6 | #include 7 | 8 | double tri_area(const vcg::Point3f &p1, const vcg::Point3f &p2, const vcg::Point3f &p3); 9 | vcg::Point3f tri_norm(const vcg::Point3f &p1, const vcg::Point3f &p2, const vcg::Point3f &p3); 10 | void tri_random( 11 | vcg::Point3f &p, vcg::Color4b &c, 12 | const vcg::Point3f &p1, const vcg::Point3f &p2, const vcg::Point3f &p3, 13 | const vcg::Color4b &c1, const vcg::Color4b &c2, const vcg::Color4b &c3 14 | ); 15 | void RandomTranslate( 16 | vcg::Point3f &p, const double t, 17 | vcg::math::MarsenneTwisterRNG &rnd, 18 | std::default_random_engine &grnd); 19 | void RandomRotate( 20 | vcg::Point3f &n, const double r, 21 | vcg::math::MarsenneTwisterRNG &rnd, 22 | std::default_random_engine &grnd); 23 | 24 | #endif // !_ULTITOOL_H_FILE_ 25 | 26 | -------------------------------------------------------------------------------- /Src/utility/flog.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOG_UTILITY_H_FILE_ 2 | #define _LOG_UTILITY_H_FILE_ 3 | 4 | #include 5 | #include 6 | 7 | //#define USE_FLOG_NAMESPACE 8 | 9 | #if defined(USE_FLOG_NAMESPACE) 10 | namespace FLOG { 11 | #endif 12 | 13 | bool isLogFileOpened(); 14 | 15 | bool setDefaultLogFile(); 16 | bool setLogFile(const char *logFile); 17 | const char* getLogFile(); 18 | 19 | void setAppendMode(); 20 | void setWriteMode(); 21 | 22 | int flog(const char *format, ...); 23 | 24 | 25 | class FLogCout 26 | { 27 | friend bool _closeLog(bool cleanPath); 28 | friend bool _openLog(const char *logFile); 29 | public: 30 | FLogCout() { setDefaultLogFile(); } 31 | ~FLogCout() { 32 | if (_m_log_file_.is_open()) 33 | _m_log_file_.close(); 34 | } 35 | 36 | template 37 | FLogCout& operator << (const T a) 38 | { 39 | std::cout << a; 40 | if (_m_log_file_.is_open()) { 41 | _m_log_file_ << a; 42 | _m_log_file_.flush(); 43 | } 44 | return *this; 45 | } 46 | private: 47 | std::ofstream _m_log_file_; 48 | }; 49 | 50 | extern FLogCout clog; 51 | 52 | #if defined(USE_FLOG_NAMESPACE) 53 | } 54 | #endif 55 | 56 | #endif // !_LOG_UTILITY_H_FILE_ 57 | -------------------------------------------------------------------------------- /Src/utility/melody.h: -------------------------------------------------------------------------------- 1 | #ifndef _MELODY_H_FILE_ 2 | #define _MELODY_H_FILE_ 3 | 4 | #include 5 | #include 6 | 7 | #include "melodyNotes.h" 8 | 9 | void MelodyPlay_CIS(); // Castle in the Sky 10 | void MelodyPlay_Notice(); 11 | 12 | #endif // !_MELODY_H_FILE_ 13 | -------------------------------------------------------------------------------- /Src/utility/melodyNotes.h: -------------------------------------------------------------------------------- 1 | #ifndef _MELODY_NOTES_H_FILE_ 2 | #define _MELODY_NOTES_H_FILE_ 3 | 4 | #define note_qdo 262 5 | #define note_qre 294 6 | #define note_qmi 330 7 | #define note_qfa 349 8 | #define note_qso 392 9 | #define note_qla 440 10 | #define note_qsi 494 11 | #define note_do 523 12 | #define note_re 578 13 | #define note_mi 659 14 | #define note_fa 698 15 | #define note_so 784 16 | #define note_la 880 17 | #define note_si 988 18 | #define note_do1 1046 19 | #define note_re1 1175 20 | #define note_mi1 1318 21 | #define note_fa1 1480 22 | #define note_so1 1568 23 | #define note_la1 1760 24 | #define note_si1 1976 25 | #define note_sqdo 277 26 | #define note_sqre 311 27 | #define note_sqfa 370 28 | #define note_sqso 415 29 | #define note_sqla 466 30 | #define note_sdo 554 31 | #define note_sre 622 32 | #define note_sfa 740 33 | #define note_sso 831 34 | #define note_sla 932 35 | #define note_sdo1 1046 36 | #define note_sre1 1245 37 | #define note_sfa1 1480 38 | #define note_sso1 1661 39 | #define note_sla1 1865 40 | 41 | #endif // !_MELODY_NOTES_H_FILE_ 42 | -------------------------------------------------------------------------------- /Struct2Ply/main.cpp: -------------------------------------------------------------------------------- 1 | #include "struct2ply.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | //const string InDir = "../TestData/Ply/Recon"; 9 | //const string OutDir = "../TestData/Ply/Recon"; 10 | 11 | const string InDir = "../TestData/Ply/Syn/50K_00U_00D"; 12 | const string OutDir = "../TestData/Ply/Syn/50K_00U_00D"; 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | 17 | const string szPath = InDir + "/*.struct"; 18 | intptr_t hFile = 0; 19 | struct _finddata_t fileinfo; 20 | if ((hFile = _findfirst(szPath.c_str(), &fileinfo)) != -1) 21 | { 22 | do 23 | { 24 | if ((fileinfo.attrib & _A_ARCH)) 25 | { 26 | const string FileName = fileinfo.name; 27 | const string BaseName = FileName.substr(0, FileName.rfind('.')); 28 | const string inFile = InDir + "/" + FileName; 29 | const string plyFile = OutDir + "/" + BaseName + "_Opt.ply"; 30 | const string outFile = OutDir + "/" + BaseName + "_sample.ply"; 31 | //---- 32 | int K = PlyPts(plyFile); 33 | struct2ply(inFile, K, outFile); 34 | //---- 35 | } 36 | } while (_findnext(hFile, &fileinfo) == 0); 37 | } 38 | system("pause"); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /TestData/Ply/Syn/50K_00U_00D/ReadMe.md: -------------------------------------------------------------------------------- 1 | 50K_00U_00D : 2 | Generated by WeiQM 3 | ------------------------------------------- 4 | 5 | ../TestData/Obj/dsp.obj --> ../TestData/Ply/Syn/50K_00U_00D/dsp.ply 6 | >> # Number of Points : 47053 7 | ../TestData/Obj/radarsat.obj --> ../TestData/Ply/Syn/50K_00U_00D/radarsat.ply 8 | >> # Number of Points : 48293 9 | -------------------------------------------------------------------------------- /TestData/Result.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weiquanmao/PCF/6b0c58143b1f443b11c1de8313b725ab37278a47/TestData/Result.jpg --------------------------------------------------------------------------------