├── .gitignore ├── Karma ├── Karma.pro ├── kaabbboundingvolume.cpp ├── kaabbboundingvolume.h ├── kabstractboundingvolume.cpp ├── kabstractboundingvolume.h ├── kabstracthdrparser.cpp ├── kabstracthdrparser.h ├── kabstractlexer.cpp ├── kabstractlexer.h ├── kabstractmesh.h ├── kabstractobjparser.cpp ├── kabstractobjparser.h ├── kabstractreader.h ├── kabstractwriter.h ├── kaccessor.h ├── kadaptiveoctree.cpp ├── kadaptiveoctree.h ├── kbsptree.cpp ├── kbsptree.h ├── kbufferedbinaryfilereader.cpp ├── kbufferedbinaryfilereader.h ├── kbufferedfilereader.cpp ├── kbufferedfilereader.h ├── kcamera3d.cpp ├── kcamera3d.h ├── kcolor.h ├── kcommon.h ├── kdebug.h ├── kdebugvertex.h ├── kelapsedtimer.h ├── kellipsoidboundingvolume.cpp ├── kellipsoidboundingvolume.h ├── kepossphere.cpp ├── kepossphere.h ├── kfilereader.cpp ├── kfilereader.h ├── kfrustum.cpp ├── kfrustum.h ├── kgeometrycloud.cpp ├── kgeometrycloud.h ├── kgesture.h ├── khalfedgemesh.cpp ├── khalfedgemesh.h ├── khalfedgeobjparser.cpp ├── khalfedgeobjparser.h ├── kimage.cpp ├── kimage.h ├── kindexcloud.h ├── kinputmanager.cpp ├── kinputmanager.h ├── kintermediateiterator.h ├── klinq.h ├── kmacros.h ├── kmath.cpp ├── kmath.h ├── kmatrix3x3.cpp ├── kmatrix3x3.h ├── kmatrix4x4.h ├── knullable.h ├── korientedboundingvolume.cpp ├── korientedboundingvolume.h ├── kpangesture.h ├── kparsetoken.h ├── kpinchgesture.h ├── kplane.h ├── kpoint.h ├── kpointcloud.h ├── kpointf.h ├── kquaternion.h ├── krect.h ├── krectf.h ├── ksharedpointer.h ├── ksize.h ├── ksizef.h ├── ksphereboundingvolume.cpp ├── ksphereboundingvolume.h ├── kstack.h ├── kstandardaccessor.h ├── kstaticgeometry.cpp ├── kstaticgeometry.h ├── kstring.h ├── kstringwriter.h ├── ktouchpoint.h ├── ktransform3d.cpp ├── ktransform3d.h ├── ktranslationiterator.h ├── ktriangleindexcloud.h ├── ktriangleindexiterator.h ├── ktrianglepartition.h ├── ktrianglepointiterator.h ├── ktypetraits.h ├── kuniquepointer.h ├── kvector2d.h ├── kvector3d.h ├── kvector4d.h └── kvertex.h ├── KarmaView ├── KarmaView.pro ├── compositionpass.cpp ├── compositionpass.h ├── debuggbufferpass.cpp ├── debuggbufferpass.h ├── environmentpass.cpp ├── environmentpass.h ├── gbufferpass.cpp ├── gbufferpass.h ├── lightaccumulationpass.cpp ├── lightaccumulationpass.h ├── main.cpp ├── main.h ├── mainwidget.cpp ├── mainwidget.h ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── motionblurpass.cpp ├── motionblurpass.h ├── preparepresentationpass.cpp ├── preparepresentationpass.h ├── renderpasses.h ├── samplescene.cpp ├── samplescene.h ├── screenspaceambientocclusion.cpp ├── screenspaceambientocclusion.h ├── shadowedlightaccumulationpass.cpp ├── shadowedlightaccumulationpass.h ├── viewportpresentationpass.cpp └── viewportpresentationpass.h ├── OpenGL ├── OpenGL.pro ├── openglabstractlightgroup.cpp ├── openglabstractlightgroup.h ├── openglarealight.cpp ├── openglarealight.h ├── openglarealightdata.h ├── openglarealightgroup.h ├── openglbindings.h ├── openglblurdata.cpp ├── openglblurdata.h ├── openglbuffer.h ├── openglcommon.h ├── openglcontext.h ├── opengldebugdraw.cpp ├── opengldebugdraw.h ├── opengldirectionlight.cpp ├── opengldirectionlight.h ├── opengldirectionlightdata.h ├── opengldirectionlightgroup.cpp ├── opengldirectionlightgroup.h ├── opengldynamicbuffer.h ├── opengldynamicuniformbufferobject.h ├── openglelementtype.cpp ├── openglelementtype.h ├── openglenvironment.cpp ├── openglenvironment.h ├── openglerror.cpp ├── openglerror.h ├── openglframebufferobject.cpp ├── openglframebufferobject.h ├── openglframeresults.cpp ├── openglframeresults.h ├── openglframetimer.cpp ├── openglframetimer.h ├── openglfunctions.cpp ├── openglfunctions.h ├── openglfunctions_3_3_core.h ├── openglfunctions_4_3_core.h ├── openglfunctions_es3_0.h ├── openglhammersleydata.cpp ├── openglhammersleydata.h ├── openglhdrtexture.cpp ├── openglhdrtexture.h ├── openglinstance.cpp ├── openglinstance.h ├── openglinstancedata.h ├── openglinstancemanager.cpp ├── openglinstancemanager.h ├── opengllight.cpp ├── opengllight.h ├── opengllightdata.h ├── opengllightgroup.h ├── opengllightmanager.cpp ├── opengllightmanager.h ├── openglmarkerresult.cpp ├── openglmarkerresult.h ├── openglmarkerscoped.h ├── openglmaterial.cpp ├── openglmaterial.h ├── openglmaterialdata.h ├── openglmesh.cpp ├── openglmesh.h ├── openglmeshmanager.cpp ├── openglmeshmanager.h ├── openglpointlight.cpp ├── openglpointlight.h ├── openglpointlightdata.h ├── openglpointlightgroup.cpp ├── openglpointlightgroup.h ├── openglprofiler.cpp ├── openglprofiler.h ├── openglprofilervisualizer.cpp ├── openglprofilervisualizer.h ├── openglrectanglelight.cpp ├── openglrectanglelight.h ├── openglrectanglelightgroup.cpp ├── openglrectanglelightgroup.h ├── openglrenderblock.cpp ├── openglrenderblock.h ├── openglrenderblockdata.h ├── openglrenderbufferobject.cpp ├── openglrenderbufferobject.h ├── openglrenderer.cpp ├── openglrenderer.h ├── openglrenderpass.cpp ├── openglrenderpass.h ├── openglrenderpassqueue.cpp ├── openglrenderpassqueue.h ├── openglrenderview.cpp ├── openglrenderview.h ├── openglscene.cpp ├── openglscene.h ├── openglscenemanager.cpp ├── openglscenemanager.h ├── openglshaderprogram.cpp ├── openglshaderprogram.h ├── openglshadowcastingspotlightgroup.h ├── openglslparser.cpp ├── openglslparser.h ├── openglspherelight.cpp ├── openglspherelight.h ├── openglspherelightgroup.cpp ├── openglspherelightgroup.h ├── openglspotlight.cpp ├── openglspotlight.h ├── openglspotlightdata.h ├── openglspotlightgroup.cpp ├── openglspotlightgroup.h ├── openglstorage.h ├── opengltexture.cpp ├── opengltexture.h ├── opengltonemappingfunction.cpp ├── opengltonemappingfunction.h ├── opengltranslationlight.h ├── opengluniformbuffermanager.cpp ├── opengluniformbuffermanager.h ├── opengluniformbufferobject.cpp ├── opengluniformbufferobject.h ├── openglupdateevent.cpp ├── openglupdateevent.h ├── openglvertexarrayobject.h ├── openglviewport.cpp ├── openglviewport.h ├── openglwidget.cpp └── openglwidget.h ├── QtOpenGL.pro ├── README.md ├── config.pri ├── images.qrc ├── include ├── Karma │ ├── CompositionPass │ ├── DebugGBufferPass │ ├── EnvironmentPass │ ├── GBufferPass │ ├── KAabbBoundingVolume │ ├── KAbstractBoundingVolume │ ├── KAbstractHdrParser │ ├── KAbstractLexer │ ├── KAbstractMesh │ ├── KAbstractObjParser │ ├── KAbstractReader │ ├── KAbstractWriter │ ├── KAccessor │ ├── KAdaptiveOctree │ ├── KBspTree │ ├── KBufferedBinaryFileReader │ ├── KBufferedFileReader │ ├── KCamera3D │ ├── KColor │ ├── KCommon │ ├── KDebug │ ├── KDebugVertex │ ├── KElapsedTimer │ ├── KEllipsoidBoundingVolume │ ├── KEposSphere │ ├── KFileReader │ ├── KFrustum │ ├── KGeometryCloud │ ├── KGesture │ ├── KHalfEdgeMesh │ ├── KHalfEdgeObjParser │ ├── KIndexCloud │ ├── KInputManager │ ├── KIntermediateIterator │ ├── KLinq │ ├── KMacros │ ├── KMath │ ├── KMatrix3x3 │ ├── KMatrix4x4 │ ├── KNullable │ ├── KOrientedBoundingVolume │ ├── KPanGesture │ ├── KParseToken │ ├── KPinchGesture │ ├── KPlane │ ├── KPoint │ ├── KPointCloud │ ├── KPointF │ ├── KQuaternion │ ├── KRect │ ├── KRectF │ ├── KSharedPointer │ ├── KSize │ ├── KSizeF │ ├── KSphereBoundingVolume │ ├── KStack │ ├── KStandardAccessor │ ├── KStaticGeometry │ ├── KString │ ├── KTouchPoint │ ├── KTransform3D │ ├── KTranslationIterator │ ├── KTriangleIndexCloud │ ├── KTriangleIndexIterator │ ├── KTrianglePartition │ ├── KTrianglePointIterator │ ├── KTypeTraits │ ├── KUniquePointer │ ├── KVector2D │ ├── KVector3D │ ├── KVector4D │ ├── KVertex │ ├── LightAccumulationPass │ ├── MotionBlurPass │ ├── OpenGLAbstractLightGroup │ ├── OpenGLAreaLight │ ├── OpenGLAreaLightData │ ├── OpenGLAreaLightGroup │ ├── OpenGLBindings │ ├── OpenGLBlurData │ ├── OpenGLBuffer │ ├── OpenGLCommon │ ├── OpenGLContext │ ├── OpenGLDebugDraw │ ├── OpenGLDirectionLight │ ├── OpenGLDirectionLightData │ ├── OpenGLDirectionLightGroup │ ├── OpenGLDynamicBuffer │ ├── OpenGLDynamicUniformBufferObject │ ├── OpenGLElementType │ ├── OpenGLEnvironment │ ├── OpenGLError │ ├── OpenGLFrameResults │ ├── OpenGLFrameTimer │ ├── OpenGLFramebufferObject │ ├── OpenGLFunctions │ ├── OpenGLFunctions_3_3_Core │ ├── OpenGLFunctions_4_3_Core │ ├── OpenGLFunctions_ES3_0 │ ├── OpenGLHammersleyData │ ├── OpenGLHdrTexture │ ├── OpenGLInstance │ ├── OpenGLInstanceData │ ├── OpenGLInstanceManager │ ├── OpenGLLight │ ├── OpenGLLightData │ ├── OpenGLLightGroup │ ├── OpenGLLightManager │ ├── OpenGLMarkerResult │ ├── OpenGLMarkerScoped │ ├── OpenGLMaterial │ ├── OpenGLMaterialData │ ├── OpenGLMesh │ ├── OpenGLMeshManager │ ├── OpenGLPointLight │ ├── OpenGLPointLightData │ ├── OpenGLPointLightGroup │ ├── OpenGLProfiler │ ├── OpenGLProfilerVisualizer │ ├── OpenGLRectangleLight │ ├── OpenGLRectangleLightGroup │ ├── OpenGLRenderBlock │ ├── OpenGLRenderBlockData │ ├── OpenGLRenderPass │ ├── OpenGLRenderPassQueue │ ├── OpenGLRenderView │ ├── OpenGLRenderbufferObject │ ├── OpenGLRenderer │ ├── OpenGLSLParser │ ├── OpenGLScene │ ├── OpenGLSceneManager │ ├── OpenGLShaderProgram │ ├── OpenGLSphereLight │ ├── OpenGLSphereLightGroup │ ├── OpenGLSpotLight │ ├── OpenGLSpotLightData │ ├── OpenGLSpotLightGroup │ ├── OpenGLStorage │ ├── OpenGLTexture │ ├── OpenGLToneMappingFunction │ ├── OpenGLTranslationLight │ ├── OpenGLUniformBufferObject │ ├── OpenGLUniformManager │ ├── OpenGLUpdateEvent │ ├── OpenGLVertexArrayObject │ ├── OpenGLViewport │ ├── OpenGLWidget │ ├── PreparePresentationPass │ ├── RenderPasses │ ├── SampleScene │ ├── ScreenSpaceAmbientOcclusion │ ├── ShadowedLightAccumulationPass │ └── ViewportPresentationPass └── glm │ ├── CMakeLists.txt │ ├── common.hpp │ ├── detail │ ├── _features.hpp │ ├── _fixes.hpp │ ├── _noise.hpp │ ├── _swizzle.hpp │ ├── _swizzle_func.hpp │ ├── _vectorize.hpp │ ├── dummy.cpp │ ├── func_common.hpp │ ├── func_common.inl │ ├── func_exponential.hpp │ ├── func_exponential.inl │ ├── func_geometric.hpp │ ├── func_geometric.inl │ ├── func_integer.hpp │ ├── func_integer.inl │ ├── func_matrix.hpp │ ├── func_matrix.inl │ ├── func_noise.hpp │ ├── func_noise.inl │ ├── func_packing.hpp │ ├── func_packing.inl │ ├── func_trigonometric.hpp │ ├── func_trigonometric.inl │ ├── func_vector_relational.hpp │ ├── func_vector_relational.inl │ ├── glm.cpp │ ├── intrinsic_common.hpp │ ├── intrinsic_common.inl │ ├── intrinsic_exponential.hpp │ ├── intrinsic_exponential.inl │ ├── intrinsic_geometric.hpp │ ├── intrinsic_geometric.inl │ ├── intrinsic_integer.hpp │ ├── intrinsic_integer.inl │ ├── intrinsic_matrix.hpp │ ├── intrinsic_matrix.inl │ ├── intrinsic_trigonometric.hpp │ ├── intrinsic_trigonometric.inl │ ├── intrinsic_vector_relational.hpp │ ├── intrinsic_vector_relational.inl │ ├── precision.hpp │ ├── setup.hpp │ ├── type_float.hpp │ ├── type_gentype.hpp │ ├── type_gentype.inl │ ├── type_half.hpp │ ├── type_half.inl │ ├── type_int.hpp │ ├── type_mat.hpp │ ├── type_mat.inl │ ├── type_mat2x2.hpp │ ├── type_mat2x2.inl │ ├── type_mat2x3.hpp │ ├── type_mat2x3.inl │ ├── type_mat2x4.hpp │ ├── type_mat2x4.inl │ ├── type_mat3x2.hpp │ ├── type_mat3x2.inl │ ├── type_mat3x3.hpp │ ├── type_mat3x3.inl │ ├── type_mat3x4.hpp │ ├── type_mat3x4.inl │ ├── type_mat4x2.hpp │ ├── type_mat4x2.inl │ ├── type_mat4x3.hpp │ ├── type_mat4x3.inl │ ├── type_mat4x4.hpp │ ├── type_mat4x4.inl │ ├── type_vec.hpp │ ├── type_vec.inl │ ├── type_vec1.hpp │ ├── type_vec1.inl │ ├── type_vec2.hpp │ ├── type_vec2.inl │ ├── type_vec3.hpp │ ├── type_vec3.inl │ ├── type_vec4.hpp │ ├── type_vec4.inl │ ├── type_vec4_avx.inl │ ├── type_vec4_avx2.inl │ └── type_vec4_sse2.inl │ ├── exponential.hpp │ ├── ext.hpp │ ├── fwd.hpp │ ├── geometric.hpp │ ├── glm.hpp │ ├── gtc │ ├── bitfield.hpp │ ├── bitfield.inl │ ├── constants.hpp │ ├── constants.inl │ ├── epsilon.hpp │ ├── epsilon.inl │ ├── integer.hpp │ ├── integer.inl │ ├── matrix_access.hpp │ ├── matrix_access.inl │ ├── matrix_integer.hpp │ ├── matrix_inverse.hpp │ ├── matrix_inverse.inl │ ├── matrix_transform.hpp │ ├── matrix_transform.inl │ ├── noise.hpp │ ├── noise.inl │ ├── packing.hpp │ ├── packing.inl │ ├── quaternion.hpp │ ├── quaternion.inl │ ├── random.hpp │ ├── random.inl │ ├── reciprocal.hpp │ ├── reciprocal.inl │ ├── round.hpp │ ├── round.inl │ ├── type_precision.hpp │ ├── type_precision.inl │ ├── type_ptr.hpp │ ├── type_ptr.inl │ ├── ulp.hpp │ ├── ulp.inl │ ├── vec1.hpp │ └── vec1.inl │ ├── gtx │ ├── associated_min_max.hpp │ ├── associated_min_max.inl │ ├── bit.hpp │ ├── bit.inl │ ├── closest_point.hpp │ ├── closest_point.inl │ ├── color_space.hpp │ ├── color_space.inl │ ├── color_space_YCoCg.hpp │ ├── color_space_YCoCg.inl │ ├── common.hpp │ ├── common.inl │ ├── compatibility.hpp │ ├── compatibility.inl │ ├── component_wise.hpp │ ├── component_wise.inl │ ├── dual_quaternion.hpp │ ├── dual_quaternion.inl │ ├── euler_angles.hpp │ ├── euler_angles.inl │ ├── extend.hpp │ ├── extend.inl │ ├── extented_min_max.hpp │ ├── extented_min_max.inl │ ├── fast_exponential.hpp │ ├── fast_exponential.inl │ ├── fast_square_root.hpp │ ├── fast_square_root.inl │ ├── fast_trigonometry.hpp │ ├── fast_trigonometry.inl │ ├── gradient_paint.hpp │ ├── gradient_paint.inl │ ├── handed_coordinate_space.hpp │ ├── handed_coordinate_space.inl │ ├── integer.hpp │ ├── integer.inl │ ├── intersect.hpp │ ├── intersect.inl │ ├── io.hpp │ ├── io.inl │ ├── log_base.hpp │ ├── log_base.inl │ ├── matrix_cross_product.hpp │ ├── matrix_cross_product.inl │ ├── matrix_decompose.hpp │ ├── matrix_decompose.inl │ ├── matrix_interpolation.hpp │ ├── matrix_interpolation.inl │ ├── matrix_major_storage.hpp │ ├── matrix_major_storage.inl │ ├── matrix_operation.hpp │ ├── matrix_operation.inl │ ├── matrix_query.hpp │ ├── matrix_query.inl │ ├── matrix_transform_2d.hpp │ ├── matrix_transform_2d.inl │ ├── mixed_product.hpp │ ├── mixed_product.inl │ ├── multiple.hpp │ ├── multiple.inl │ ├── norm.hpp │ ├── norm.inl │ ├── normal.hpp │ ├── normal.inl │ ├── normalize_dot.hpp │ ├── normalize_dot.inl │ ├── number_precision.hpp │ ├── number_precision.inl │ ├── optimum_pow.hpp │ ├── optimum_pow.inl │ ├── orthonormalize.hpp │ ├── orthonormalize.inl │ ├── perpendicular.hpp │ ├── perpendicular.inl │ ├── polar_coordinates.hpp │ ├── polar_coordinates.inl │ ├── projection.hpp │ ├── projection.inl │ ├── quaternion.hpp │ ├── quaternion.inl │ ├── range.hpp │ ├── raw_data.hpp │ ├── raw_data.inl │ ├── rotate_normalized_axis.hpp │ ├── rotate_normalized_axis.inl │ ├── rotate_vector.hpp │ ├── rotate_vector.inl │ ├── scalar_multiplication.hpp │ ├── scalar_relational.hpp │ ├── scalar_relational.inl │ ├── simd_mat4.hpp │ ├── simd_mat4.inl │ ├── simd_quat.hpp │ ├── simd_quat.inl │ ├── simd_vec4.hpp │ ├── simd_vec4.inl │ ├── spline.hpp │ ├── spline.inl │ ├── std_based_type.hpp │ ├── std_based_type.inl │ ├── string_cast.hpp │ ├── string_cast.inl │ ├── transform.hpp │ ├── transform.inl │ ├── transform2.hpp │ ├── transform2.inl │ ├── type_aligned.hpp │ ├── type_aligned.inl │ ├── vector_angle.hpp │ ├── vector_angle.inl │ ├── vector_query.hpp │ ├── vector_query.inl │ ├── wrap.hpp │ └── wrap.inl │ ├── integer.hpp │ ├── mat2x2.hpp │ ├── mat2x3.hpp │ ├── mat2x4.hpp │ ├── mat3x2.hpp │ ├── mat3x3.hpp │ ├── mat3x4.hpp │ ├── mat4x2.hpp │ ├── mat4x3.hpp │ ├── mat4x4.hpp │ ├── matrix.hpp │ ├── packing.hpp │ ├── trigonometric.hpp │ ├── vec2.hpp │ ├── vec3.hpp │ ├── vec4.hpp │ └── vector_relational.hpp ├── qtbaseExt ├── gui │ └── opengl │ │ ├── QOpenGLFunctions_ES3_0 │ │ ├── qopenglfunctions_es3_0.cpp │ │ └── qopenglfunctions_es3_0.h └── qtbaseExt.pro ├── resources.qrc ├── resources ├── images │ ├── AlexsApt.hdr │ └── AlexsApt_Env.hdr ├── objects │ ├── floor.obj │ ├── pointLight.obj │ ├── quad.obj │ ├── sphere.obj │ └── spotLight.obj └── shaders │ ├── Bindings.glsl │ ├── EncodeDecode.glsl │ ├── GBuffer.ubo │ ├── Math.glsl │ ├── ToneMapping.glsl │ ├── compute │ ├── bilateralBlur.comp │ └── gaussianBlur.comp │ ├── debug │ ├── screen.frag │ ├── screen.vert │ ├── texture.frag │ ├── texture.vert │ ├── world.frag │ └── world.vert │ ├── gbuffer.frag │ ├── gbuffer.vert │ ├── gbuffer │ ├── ambient.frag │ ├── backbuffer.frag │ ├── composition.frag │ ├── depth.frag │ ├── diffuse.frag │ ├── lightbuffer.frag │ ├── linearDepth.frag │ ├── main.vert │ ├── metallic.frag │ ├── motion.frag │ ├── motionBlur.frag │ ├── normal.frag │ ├── position.frag │ ├── roughness.frag │ ├── specular.frag │ ├── specularExponent.frag │ ├── velocity.frag │ ├── viewport.frag │ └── viewport.vert │ ├── lighting │ ├── Physical.glsl │ ├── ambientOcclusion.frag │ ├── ambientOcclusion.vert │ ├── directionLight.frag │ ├── directionLight.vert │ ├── environment.frag │ ├── environment.vert │ ├── mapSpotLight.frag │ ├── mapSpotLight.vert │ ├── mapSpotLightExponential.frag │ ├── pointLight.frag │ ├── pointLight.vert │ ├── rectangleLight.frag │ ├── rectangleLight.vert │ ├── shadowDirectionLight.frag │ ├── shadowDirectionLight.vert │ ├── shadowPointLight.frag │ ├── shadowPointLight.vert │ ├── shadowSpotLight.frag │ ├── shadowSpotLight.vert │ ├── shadowSpotLightExponential.frag │ ├── sphereLight.frag │ ├── sphereLight.vert │ ├── spotLight.frag │ └── spotLight.vert │ └── ubo │ ├── AreaLightBuffer.ubo │ ├── GlobalBuffer.ubo │ ├── Hammersley.ubo │ ├── LightBuffer.ubo │ ├── Material.ubo │ └── Object.ubo └── scripts └── GenHeaders.pl /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *~ 3 | *.user 4 | -------------------------------------------------------------------------------- /Karma/kabstractboundingvolume.cpp: -------------------------------------------------------------------------------- 1 | #include "kabstractboundingvolume.h" 2 | 3 | KAbstractBoundingVolume::KAbstractBoundingVolume() 4 | { 5 | 6 | } 7 | 8 | KAbstractBoundingVolume::~KAbstractBoundingVolume() 9 | { 10 | 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Karma/kabstractboundingvolume.h: -------------------------------------------------------------------------------- 1 | #ifndef KABSTRACTBOUNDINGVOLUME_H 2 | #define KABSTRACTBOUNDINGVOLUME_H KAbstractBoundingVolume 3 | 4 | class KColor; 5 | class KTransform3D; 6 | 7 | class KAbstractBoundingVolume 8 | { 9 | public: 10 | KAbstractBoundingVolume(); 11 | virtual ~KAbstractBoundingVolume(); 12 | virtual void draw(KTransform3D &t, KColor const &color) const = 0; 13 | }; 14 | 15 | #endif // KABSTRACTBOUNDINGVOLUME_H 16 | -------------------------------------------------------------------------------- /Karma/kabstracthdrparser.h: -------------------------------------------------------------------------------- 1 | #ifndef KABSTRACTHDRPARSER_H 2 | #define KABSTRACTHDRPARSER_H KAbstractHdrParser 3 | 4 | class KAbstractReader; 5 | 6 | class KAbstractHdrParserPrivate; 7 | class KAbstractHdrParser 8 | { 9 | public: 10 | 11 | typedef unsigned char Byte; 12 | enum PixelOrder 13 | { 14 | Negative, 15 | Positive 16 | }; 17 | 18 | KAbstractHdrParser(KAbstractReader *reader); 19 | ~KAbstractHdrParser(); 20 | void initialize(); 21 | bool parse(); 22 | protected: 23 | virtual void onKeyValue(char const *key, char const *value) = 0; 24 | virtual void onResolution(PixelOrder xOrder, PixelOrder yOrder, int width, int height) = 0; 25 | virtual float *beginData() = 0; 26 | virtual void endData() = 0; 27 | private: 28 | KAbstractHdrParserPrivate *m_private; 29 | friend class KAbstractHdrParserPrivate; 30 | }; 31 | 32 | #endif // KABSTRACTHDRPARSER_H 33 | -------------------------------------------------------------------------------- /Karma/kabstractmesh.h: -------------------------------------------------------------------------------- 1 | #ifndef KABSTRACTMESH_H 2 | #define KABSTRACTMESH_H KAbstractMesh 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class KAbstractMesh : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | typedef KAbstractObjParser::index_type index_type; 13 | typedef KAbstractObjParser::index_pair index_pair; 14 | typedef KAbstractObjParser::index_array index_array; 15 | explicit KAbstractMesh(QObject *parent = 0); 16 | signals: 17 | 18 | public slots: 19 | }; 20 | 21 | inline KAbstractMesh::KAbstractMesh(QObject *parent) : 22 | QObject(parent) 23 | { 24 | // Intentionally Empty 25 | } 26 | 27 | #endif // KABSTRACTMESH_H 28 | -------------------------------------------------------------------------------- /Karma/kabstractobjparser.h: -------------------------------------------------------------------------------- 1 | #ifndef KABSTRACTOBJPARSER_H 2 | #define KABSTRACTOBJPARSER_H KAbstractObjParser 3 | 4 | #include 5 | #include 6 | 7 | class KAbstractReader; 8 | 9 | class KAbstractObjParserPrivate; 10 | class KAbstractObjParser 11 | { 12 | public: 13 | typedef uint32_t index_type; 14 | typedef uint64_t index_pair; 15 | typedef uint64_t size_type; 16 | typedef std::array index_array; 17 | KAbstractObjParser(KAbstractReader *reader); 18 | bool parse(); 19 | void initialize(); 20 | protected: 21 | virtual void onVertex(float vertex[4]) = 0; 22 | virtual void onTexture(float texture[3]) = 0; 23 | virtual void onNormal(float normal[3]) = 0; 24 | virtual void onParameter(float parameter[3]) = 0; 25 | virtual void onFace(index_array indices[], size_type count) = 0; 26 | virtual void onGroup(char *group) = 0; 27 | virtual void onMaterial(char *file) = 0; 28 | virtual void onUseMaterial(char *file) = 0; 29 | virtual void onObject(char *obj) = 0; 30 | virtual void onSmooth(char *obj) = 0; 31 | private: 32 | KAbstractObjParserPrivate *m_private; 33 | friend class KAbstractObjParserPrivate; 34 | }; 35 | 36 | #endif // KABSTRACTOBJPARSER_H 37 | -------------------------------------------------------------------------------- /Karma/kabstractreader.h: -------------------------------------------------------------------------------- 1 | #ifndef KABSTRACTREADER_H 2 | #define KABSTRACTREADER_H KAbstractReader 3 | 4 | class KAbstractReader 5 | { 6 | public: 7 | static const int EndOfFile = -1; 8 | virtual int next() = 0; 9 | }; 10 | 11 | #endif // KABSTRACTREADER_H 12 | -------------------------------------------------------------------------------- /Karma/kabstractwriter.h: -------------------------------------------------------------------------------- 1 | #ifndef KABSTRACTWRITER_H 2 | #define KABSTRACTWRITER_H KAbstractWriter 3 | 4 | class KAbstractWriter 5 | { 6 | public: 7 | virtual void append(char const *buffer) = 0; 8 | virtual void push_back(char c) = 0; 9 | }; 10 | 11 | #endif // KABSTRACTWRITER_H 12 | -------------------------------------------------------------------------------- /Karma/kaccessor.h: -------------------------------------------------------------------------------- 1 | #ifndef KACCESSOR_H 2 | #define KACCESSOR_H KAccessor 3 | 4 | #include 5 | 6 | template 7 | class KAccessor : public std::unary_function 8 | { 9 | public: 10 | typedef Ret ReturnType; 11 | typedef Inp ContainedType; 12 | }; 13 | 14 | #endif // KACCESSOR_H 15 | 16 | -------------------------------------------------------------------------------- /Karma/kadaptiveoctree.h: -------------------------------------------------------------------------------- 1 | #ifndef KADAPTIVEOCTREE_H 2 | #define KADAPTIVEOCTREE_H KAdaptiveOctree 3 | 4 | class KColor; 5 | class KHalfEdgeMesh; 6 | class KTransform3D; 7 | #include 8 | #include 9 | #include 10 | 11 | class KAdaptiveOctreePrivate; 12 | class KAdaptiveOctree : public KGeometryCloud 13 | { 14 | public: 15 | KAdaptiveOctree(); 16 | ~KAdaptiveOctree(); 17 | 18 | void clear(); 19 | size_t depth() const; 20 | void build(BuildMethod method, TerminationPred pred); 21 | void debugDraw(size_t min = 0, size_t max = std::numeric_limits::max()); 22 | void debugDraw(KTransform3D &trans, size_t min = 0, size_t max = std::numeric_limits::max()); 23 | 24 | private: 25 | KSharedPointer m_private; 26 | }; 27 | 28 | #endif // KADAPTIVEOCTREE_H 29 | -------------------------------------------------------------------------------- /Karma/kbsptree.h: -------------------------------------------------------------------------------- 1 | #ifndef KBSPTREE_H 2 | #define KBSPTREE_H KBspTree 3 | 4 | class KColor; 5 | class KHalfEdgeMesh; 6 | class KTransform3D; 7 | #include 8 | #include 9 | 10 | class KBspTreePrivate; 11 | class KBspTree : public KGeometryCloud 12 | { 13 | public: 14 | KBspTree(); 15 | ~KBspTree(); 16 | 17 | void clear(); 18 | size_t depth() const; 19 | void build(BuildMethod method, TerminationPred pred); 20 | void debugDraw(size_t min = 0, size_t max = std::numeric_limits::max()); 21 | void debugDraw(KTransform3D &trans, size_t min = 0, size_t max = std::numeric_limits::max()); 22 | 23 | private: 24 | KSharedPointer m_private; 25 | }; 26 | 27 | #endif // KBSPTREE_H 28 | -------------------------------------------------------------------------------- /Karma/kbufferedbinaryfilereader.h: -------------------------------------------------------------------------------- 1 | #ifndef KBUFFEREDBINARYFILEREADER_H 2 | #define KBUFFEREDBINARYFILEREADER_H KBufferedBinaryFileReader 3 | 4 | #include 5 | #include 6 | class QString; 7 | 8 | class KBufferedBinaryFileReaderPrivate; 9 | class KBufferedBinaryFileReader : public KAbstractReader 10 | { 11 | public: 12 | KBufferedBinaryFileReader(); 13 | KBufferedBinaryFileReader(const QString &fileName, size_t buffsize); 14 | ~KBufferedBinaryFileReader(); 15 | int next(); 16 | bool valid(); 17 | private: 18 | QScopedPointer m_private; 19 | }; 20 | 21 | #endif // KBUFFEREDBINARYFILEREADER_H 22 | -------------------------------------------------------------------------------- /Karma/kbufferedfilereader.h: -------------------------------------------------------------------------------- 1 | #ifndef KBUFFEREDFILEREADER_H 2 | #define KBUFFEREDFILEREADER_H KBufferedFileReader 3 | 4 | #include 5 | #include 6 | class QString; 7 | 8 | class KBufferedFileReaderPrivate; 9 | class KBufferedFileReader : public KAbstractReader 10 | { 11 | public: 12 | KBufferedFileReader(); 13 | KBufferedFileReader(const QString &fileName, size_t buffsize); 14 | ~KBufferedFileReader(); 15 | int next(); 16 | bool valid(); 17 | private: 18 | QScopedPointer m_private; 19 | }; 20 | 21 | #endif // KBUFFEREDFILEREADER_H 22 | -------------------------------------------------------------------------------- /Karma/kcolor.h: -------------------------------------------------------------------------------- 1 | #ifndef KCOLOR_H 2 | #define KCOLOR_H KColor 3 | 4 | #include 5 | 6 | class KColor : public QColor 7 | { 8 | public: 9 | KColor() : QColor() {} 10 | KColor(QColor const& rhs) : QColor(rhs) {} 11 | KColor(Qt::GlobalColor color) : QColor(color) {} 12 | KColor(int r, int g, int b, int a = 255) : QColor(r,g,b,a) {} 13 | KColor(float r, float g, float b, float a = 1.0f) : QColor(r * 255, g * 255, b * 255, a * 255) {} 14 | KColor(QRgb rgb) : QColor(rgb) {} 15 | KColor(const QString& name) : QColor(name) {} 16 | KColor(const char *name) : QColor(name) {} 17 | KColor(Spec spec) : QColor(spec) {} 18 | }; 19 | 20 | #endif // KCOLOR_H 21 | 22 | -------------------------------------------------------------------------------- /Karma/kcommon.h: -------------------------------------------------------------------------------- 1 | #ifndef KCOMMON_H 2 | #define KCOMMON_H KCommon 3 | 4 | #include 5 | 6 | namespace Karma 7 | { 8 | 9 | inline static bool isUpper(int c) 10 | { 11 | return (c >= 'A' && c <= 'Z'); 12 | } 13 | 14 | inline static bool isLower(int c) 15 | { 16 | return (c >= 'a' && c <= 'z'); 17 | } 18 | 19 | inline static int toLower(int c) 20 | { 21 | if (isUpper(c)) 22 | { 23 | return c + ('a' - 'A'); 24 | } 25 | return c; 26 | } 27 | 28 | inline static int toUpper(int c) 29 | { 30 | if (isLower(c)) 31 | { 32 | return c - ('a' - 'A'); 33 | } 34 | return c; 35 | } 36 | 37 | inline static bool isAlpha(int c) 38 | { 39 | return (c >= 'A' && c <= 'z'); 40 | } 41 | 42 | inline static bool isNumeric(int c) 43 | { 44 | return (c >= '0' && c <= '9') || c == '-'; 45 | } 46 | 47 | inline static int ctoi(int c) 48 | { 49 | return c - '0'; 50 | } 51 | 52 | inline static float ctof(int c) 53 | { 54 | return static_cast(ctoi(c)); 55 | } 56 | 57 | inline static int round(float f) 58 | { 59 | return static_cast(std::floor(f + 0.5f)); 60 | } 61 | 62 | inline static int round(double d) 63 | { 64 | return static_cast(std::floor(d + 0.5)); 65 | } 66 | 67 | } 68 | 69 | #endif // KCOMMON_H 70 | 71 | -------------------------------------------------------------------------------- /Karma/kdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef KDEBUG_H 2 | #define KDEBUG_H KDebug 3 | 4 | #include 5 | #define kDebug() qDebug() 6 | 7 | #endif // KDEBUG_H 8 | 9 | -------------------------------------------------------------------------------- /Karma/kelapsedtimer.h: -------------------------------------------------------------------------------- 1 | #ifndef KELAPSEDTIMER_H 2 | #define KELAPSEDTIMER_H KElapsedTimer 3 | 4 | #include 5 | 6 | class KElapsedTimer : public QElapsedTimer 7 | { 8 | // Intentionally Empty 9 | }; 10 | 11 | #endif // KELAPSEDTIMER_H 12 | 13 | -------------------------------------------------------------------------------- /Karma/kellipsoidboundingvolume.h: -------------------------------------------------------------------------------- 1 | #ifndef KELLIPSOIDBOUNDINGVOLUME_H 2 | #define KELLIPSOIDBOUNDINGVOLUME_H KEllipsoidBoundingVolume 3 | 4 | #include 5 | class KHalfEdgeMesh; 6 | 7 | class KEllipsoidBoundingVolumePrivate; 8 | class KEllipsoidBoundingVolume : public KAbstractBoundingVolume 9 | { 10 | public: 11 | enum Method 12 | { 13 | PcaMethod 14 | }; 15 | 16 | KEllipsoidBoundingVolume(); 17 | KEllipsoidBoundingVolume(KHalfEdgeMesh const &mesh, Method method); 18 | ~KEllipsoidBoundingVolume(); 19 | void draw(KTransform3D &t, KColor const &color) const; 20 | private: 21 | KEllipsoidBoundingVolumePrivate *m_private; 22 | }; 23 | 24 | #endif // KELLIPSOIDBOUNDINGVOLUME_H 25 | -------------------------------------------------------------------------------- /Karma/kepossphere.cpp: -------------------------------------------------------------------------------- 1 | #include "kepossphere.h" 2 | 3 | struct Sphere 4 | { 5 | Sphere(Sphere const &a, Sphere const &b); 6 | Sphere(KVector3D const &a, KVector3D const &b); 7 | float radius; 8 | KVector3D origin; 9 | }; 10 | 11 | Sphere::Sphere(const Sphere &a, const Sphere &b) 12 | { 13 | // Distance to A 14 | KVector3D aNormal = (a.origin - b.origin); 15 | float dist = aNormal.length(); 16 | aNormal /= dist; 17 | 18 | // Find two extrenal points 19 | KVector3D pointA = a.origin + aNormal * a.radius; 20 | KVector3D pointB = b.origin - aNormal * b.radius; 21 | 22 | // Solve for sphere 23 | origin = (pointA + pointB) / 2.0f; 24 | radius = (pointA - pointB).length() / 2.0f; 25 | } 26 | 27 | Sphere::Sphere(const KVector3D &a, const KVector3D &b) 28 | { 29 | origin = (a + b) / 2.0f; 30 | radius = (a - b).length() / 2.0f; 31 | } 32 | 33 | Sphere WelzlSphere(KMinMaxVectorCloud::const_iterator begin, KMinMaxVectorCloud::const_iterator end) 34 | { 35 | size_t numPoints = std::distance(begin, end); 36 | if (numPoints == 1) 37 | { 38 | return Sphere(begin[0].max, begin[0].min); 39 | } 40 | 41 | KMinMaxVectorCloud::const_iterator halfWay = begin + numPoints / 2; 42 | return Sphere(WelzlSphere(begin, halfWay), WelzlSphere(halfWay, end)); 43 | } 44 | 45 | void KEposSphere::calculateMinimumSphere(const_iterator begin, const_iterator end) 46 | { 47 | Sphere s = WelzlSphere(begin, end); 48 | centroid = s.origin; 49 | radius = s.radius; 50 | } 51 | -------------------------------------------------------------------------------- /Karma/kepossphere.h: -------------------------------------------------------------------------------- 1 | #ifndef KEPOSSPHERE_H 2 | #define KEPOSSPHERE_H KEposSphere 3 | 4 | #include 5 | typedef std::vector KMinMaxVectorCloud; 6 | 7 | class KEposSphere 8 | { 9 | public: 10 | 11 | typedef KMinMaxVectorCloud::const_iterator const_iterator; 12 | 13 | template , typename AxisAccessor = Karma::DefaultAccessor> 14 | KEposSphere(It1 bVec, It1 eVec, It2 bAxis, It2 eAxis, VecAccessor vAccessor = Karma::DefaultAccessor(), AxisAccessor aAccessor = Karma::DefaultAccessor()); 15 | void calculateMinimumSphere(const_iterator begin, const_iterator end); 16 | 17 | float radius; 18 | KVector3D centroid; 19 | }; 20 | 21 | template 22 | KEposSphere::KEposSphere(It1 bVec, It1 eVec, It2 bAxis, It2 eAxis, VecAccessor vAccessor, AxisAccessor aAccessor) 23 | { 24 | KMinMaxVectorCloud extremalVerts = Karma::findExtremalPointsAlongAxes(bVec, eVec, bAxis, eAxis, vAccessor, aAccessor); 25 | calculateMinimumSphere(extremalVerts.begin(), extremalVerts.end()); 26 | } 27 | 28 | #endif // KEPOSSPHERE_H 29 | -------------------------------------------------------------------------------- /Karma/kfilereader.cpp: -------------------------------------------------------------------------------- 1 | #include "kfilereader.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /******************************************************************************* 8 | * KFileReaderPrivate 9 | ******************************************************************************/ 10 | class KFileReaderPrivate 11 | { 12 | public: 13 | inline KFileReaderPrivate(); 14 | inline KFileReaderPrivate(FILE *file); 15 | inline KFileReaderPrivate(const QString &fileName); 16 | inline int next(); 17 | QFile m_file; 18 | char m_currChar; 19 | }; 20 | 21 | inline KFileReaderPrivate::KFileReaderPrivate() : 22 | m_file() 23 | { 24 | // Intentionally Empty 25 | } 26 | 27 | inline KFileReaderPrivate::KFileReaderPrivate(const QString &fileName) : 28 | m_file(fileName) 29 | { 30 | m_file.open(QFile::ReadOnly | QFile::Text); 31 | } 32 | 33 | inline int KFileReaderPrivate::next() 34 | { 35 | if (!m_file.getChar(&m_currChar)) 36 | return KFileReader::EndOfFile; 37 | return m_currChar; 38 | } 39 | 40 | /******************************************************************************* 41 | * KFileReader 42 | ******************************************************************************/ 43 | 44 | 45 | KFileReader::KFileReader() : 46 | m_private(new KFileReaderPrivate()) 47 | { 48 | // Intentionally Empty 49 | } 50 | 51 | KFileReader::KFileReader(const QString &fileName) : 52 | m_private(new KFileReaderPrivate(fileName)) 53 | { 54 | // Intentionally Empty 55 | } 56 | 57 | KFileReader::~KFileReader() 58 | { 59 | // Intentionally Empty 60 | } 61 | 62 | int KFileReader::next() 63 | { 64 | P(KFileReaderPrivate); 65 | return p.next(); 66 | } 67 | -------------------------------------------------------------------------------- /Karma/kfilereader.h: -------------------------------------------------------------------------------- 1 | #ifndef KFILEREADER_H 2 | #define KFILEREADER_H KFileReader 3 | 4 | #include 5 | #include 6 | class QString; 7 | 8 | class KFileReaderPrivate; 9 | class KFileReader : public KAbstractReader 10 | { 11 | public: 12 | KFileReader(); 13 | KFileReader(const QString &fileName); 14 | ~KFileReader(); 15 | int next(); 16 | private: 17 | QScopedPointer m_private; 18 | }; 19 | 20 | #endif // KFILEREADER_H 21 | -------------------------------------------------------------------------------- /Karma/kfrustum.h: -------------------------------------------------------------------------------- 1 | #ifndef KFRUSTUM_H 2 | #define KFRUSTUM_H KFrustum 3 | 4 | class KMatrix4x4; 5 | #include 6 | #include 7 | 8 | class KFrustum 9 | { 10 | public: 11 | KFrustum(); 12 | KFrustum(KMatrix4x4 const &viewProj); 13 | void setFrustum(KMatrix4x4 const &viewProj); 14 | 15 | bool intersects(KAabbBoundingVolume const &aabb) const; 16 | 17 | private: 18 | KPlane m_planes[6]; 19 | }; 20 | 21 | #endif // KFRUSTUM_H 22 | -------------------------------------------------------------------------------- /Karma/kgeometrycloud.h: -------------------------------------------------------------------------------- 1 | #ifndef KGEOMETRYCLOUD_H 2 | #define KGEOMETRYCLOUD_H KGeometryCloud 3 | 4 | class KHalfEdgeMesh; 5 | class KTransform3D; 6 | class KPointCloud; 7 | class KTriangleIndexCloud; 8 | #include 9 | 10 | class KGeometryCloudPrivate; 11 | class KGeometryCloud 12 | { 13 | public: 14 | KGeometryCloud(); 15 | ~KGeometryCloud(); 16 | 17 | enum BuildMethod 18 | { 19 | TopDownMethod, 20 | BottomUpMethod 21 | }; 22 | typedef bool (*TerminationPred)(size_t numTriangles, size_t depth); 23 | 24 | void addGeometry(KHalfEdgeMesh const &mesh); 25 | void addGeometry(KHalfEdgeMesh const &mesh, KTransform3D const &trans); 26 | virtual void build(BuildMethod method, TerminationPred pred); 27 | 28 | void clear(); 29 | bool dirty() const; 30 | 31 | KPointCloud const &pointCloud() const; 32 | KTriangleIndexCloud const &triangleIndexCloud() const; 33 | KPointCloud &pointCloud(); 34 | KTriangleIndexCloud &triangleIndexCloud(); 35 | private: 36 | KSharedPointer m_private; 37 | }; 38 | 39 | #endif // KGEOMETRYCLOUD_H 40 | -------------------------------------------------------------------------------- /Karma/kgesture.h: -------------------------------------------------------------------------------- 1 | #ifndef KGESTURE_H 2 | #define KGESTURE_H KGesture 3 | 4 | #include 5 | #include 6 | 7 | class KGesture 8 | { 9 | public: 10 | KGesture(); 11 | KGesture(QGesture const &rhs); 12 | inline Qt::GestureState state() const; 13 | inline KPointF hotSpot() const; 14 | inline bool hasHotSpot() const; 15 | private: 16 | bool m_hasHotSpot; 17 | KPointF m_hotSpot; 18 | Qt::GestureState m_gestureState; 19 | }; 20 | 21 | inline KGesture::KGesture() : m_gestureState(Qt::NoGesture) {} 22 | inline KGesture::KGesture(QGesture const &rhs) : m_hasHotSpot(rhs.hasHotSpot()), m_hotSpot(rhs.hotSpot()), m_gestureState(rhs.state()) {} 23 | inline Qt::GestureState KGesture::state() const { return m_gestureState; } 24 | inline KPointF KGesture::hotSpot() const { return m_hotSpot; } 25 | inline bool KGesture::hasHotSpot() const { return m_hasHotSpot; } 26 | 27 | #endif // KGESTURE_H 28 | -------------------------------------------------------------------------------- /Karma/khalfedgeobjparser.h: -------------------------------------------------------------------------------- 1 | #ifndef KHALFEDGEOBJPARSER_H 2 | #define KHALFEDGEOBJPARSER_H KHalfEdgeObjParser 3 | 4 | #include 5 | 6 | class KHalfEdgeMesh; 7 | 8 | class KHalfEdgeObjParser : public KAbstractObjParser 9 | { 10 | public: 11 | KHalfEdgeObjParser(KHalfEdgeMesh *mesh, KAbstractReader *reader); 12 | protected: 13 | virtual void onVertex(float vertex[4]); 14 | virtual void onTexture(float texture[3]); 15 | virtual void onNormal(float normal[3]); 16 | virtual void onParameter(float parameter[3]); 17 | virtual void onFace(index_array indices[], size_type count); 18 | void triangulateFace(index_array indices[], size_type count); 19 | virtual void onGroup(char *group); 20 | virtual void onMaterial(char *file); 21 | virtual void onUseMaterial(char *mat); 22 | virtual void onObject(char *obj); 23 | virtual void onSmooth(char *smooth); 24 | private: 25 | KHalfEdgeMesh *m_mesh; 26 | }; 27 | 28 | #endif // KHALFEDGEOBJPARSER_H 29 | -------------------------------------------------------------------------------- /Karma/kimage.cpp: -------------------------------------------------------------------------------- 1 | #include "kimage.h" 2 | 3 | #include 4 | 5 | static size_t FormatSize(KImage::Format fmt) 6 | { 7 | switch (fmt) 8 | { 9 | case KImage::Float: 10 | return sizeof(float); 11 | } 12 | return 0; 13 | } 14 | 15 | class KImagePrivate 16 | { 17 | public: 18 | KImagePrivate(); 19 | ~KImagePrivate(); 20 | KImage::Byte *m_data; 21 | }; 22 | 23 | KImagePrivate::KImagePrivate() : 24 | m_data(0) 25 | { 26 | // Intentionally Empty 27 | } 28 | 29 | KImagePrivate::~KImagePrivate() 30 | { 31 | delete [] m_data; 32 | } 33 | 34 | KImage::KImage() : 35 | m_private(new KImagePrivate) 36 | { 37 | // Intentionally Empty 38 | } 39 | 40 | KImage::~KImage() 41 | { 42 | // Intentionally Empty 43 | } 44 | 45 | void KImage::allocate(int width, int height, KImage::Format fmt, int channels) 46 | { 47 | m_private = new KImagePrivate; 48 | m_private->m_data = new Byte[FormatSize(fmt)*width*height*channels]; 49 | } 50 | -------------------------------------------------------------------------------- /Karma/kimage.h: -------------------------------------------------------------------------------- 1 | #ifndef KIMAGE_H 2 | #define KIMAGE_H 3 | 4 | #include 5 | 6 | class KImagePrivate; 7 | class KImage 8 | { 9 | public: 10 | KImage(); 11 | ~KImage(); 12 | 13 | typedef unsigned char Byte; 14 | 15 | enum Format 16 | { 17 | Float 18 | }; 19 | 20 | void allocate(int width, int height, Format fmt, int channels); 21 | Byte const *data() const; 22 | 23 | private: 24 | KSharedPointer m_private; 25 | }; 26 | 27 | #endif // KIMAGE_H 28 | -------------------------------------------------------------------------------- /Karma/kindexcloud.h: -------------------------------------------------------------------------------- 1 | #ifndef KINDEXCLOUD_H 2 | #define KINDEXCLOUD_H KIndexCloud 3 | 4 | #include 5 | #include 6 | 7 | class KIndexCloud 8 | { 9 | public: 10 | typedef size_t ElementType; 11 | typedef std::vector ContainerType; 12 | 13 | void reserve(size_t count); 14 | void emplace_back(ElementType elm); 15 | private: 16 | ContainerType m_container; 17 | }; 18 | 19 | inline void KIndexCloud::reserve(size_t count) 20 | { 21 | m_container.reserve(count); 22 | } 23 | 24 | inline void KIndexCloud::emplace_back(ElementType elm) 25 | { 26 | m_container.emplace_back(elm); 27 | } 28 | 29 | #endif // KINDEXCLOUD_H 30 | 31 | -------------------------------------------------------------------------------- /Karma/kmatrix3x3.cpp: -------------------------------------------------------------------------------- 1 | #include "kmatrix3x3.h" 2 | 3 | #include 4 | 5 | KMatrix3x3::KMatrix3x3(const QMatrix4x4 &rhs) 6 | { 7 | for (int i = 0; i < 3; ++i) 8 | for (int j = 0; j < 3; ++j) 9 | (*this)[i][j] = rhs(i, j); 10 | } 11 | -------------------------------------------------------------------------------- /Karma/kmatrix3x3.h: -------------------------------------------------------------------------------- 1 | #ifndef KMATRIX3X3_H 2 | #define KMATRIX3X3_H KMatrix3x3 3 | 4 | #include 5 | #include 6 | 7 | class KMatrix3x3 : public QMatrix3x3 8 | { 9 | public: 10 | inline KMatrix3x3() : QMatrix3x3() {} 11 | inline KMatrix3x3(QMatrix3x3 const &rhs) : QMatrix3x3(rhs) {} 12 | explicit KMatrix3x3(const float *values) : QMatrix3x3(values) {} 13 | explicit KMatrix3x3(QMatrix4x4 const &rhs); 14 | 15 | template 16 | explicit KMatrix3x3(const QGenericMatrix& matrix) : QMatrix3x3(matrix) {} 17 | 18 | float* operator[](int i) { return data() + i * 3; } 19 | float const* operator[](int i) const { return constData() + i * 3; } 20 | void operator*=(KMatrix3x3 const &rhs) { (*this) = (*this) * rhs; } 21 | KVector3D operator*(KVector3D const &rhs) const 22 | { 23 | return 24 | KVector3D( 25 | (*this)[0][0] * rhs.x() + (*this)[0][1] * rhs.y() + (*this)[0][2] * rhs.z(), 26 | (*this)[1][0] * rhs.x() + (*this)[1][1] * rhs.y() + (*this)[1][2] * rhs.z(), 27 | (*this)[2][0] * rhs.x() + (*this)[2][1] * rhs.y() + (*this)[2][2] * rhs.z() 28 | ); 29 | } 30 | }; 31 | 32 | #endif // KMATRIX3X3_H 33 | 34 | -------------------------------------------------------------------------------- /Karma/kmatrix4x4.h: -------------------------------------------------------------------------------- 1 | #ifndef KMATRIX4X4_H 2 | #define KMATRIX4X4_H KMatrix4x4 3 | 4 | #include 5 | 6 | class KMatrix4x4 : public QMatrix4x4 7 | { 8 | public: 9 | inline KMatrix4x4() : QMatrix4x4() {} 10 | inline KMatrix4x4(QMatrix4x4 const &rhs) : QMatrix4x4(rhs) {} 11 | explicit KMatrix4x4(const float *values) : QMatrix4x4(values) {} 12 | inline KMatrix4x4(float m11, float m12, float m13, float m14, 13 | float m21, float m22, float m23, float m24, 14 | float m31, float m32, float m33, float m34, 15 | float m41, float m42, float m43, float m44) : 16 | QMatrix4x4(m11, m12, m13, m14, 17 | m21, m22, m23, m24, 18 | m31, m32, m33, m34, 19 | m41, m42, m43, m44) {} 20 | 21 | template 22 | explicit KMatrix4x4(const QGenericMatrix& matrix) : QMatrix4x4(matrix) {} 23 | 24 | KMatrix4x4(const float *values, int cols, int rows) : QMatrix4x4(values, cols, rows) {} 25 | KMatrix4x4(const QTransform& transform) : QMatrix4x4(transform) {} 26 | KMatrix4x4(const QMatrix& matrix) : QMatrix4x4(matrix) {} 27 | }; 28 | 29 | #endif // KMATRIX4X4_H 30 | -------------------------------------------------------------------------------- /Karma/korientedboundingvolume.h: -------------------------------------------------------------------------------- 1 | #ifndef KORIENTEDBOUNDINGVOLUME_H 2 | #define KORIENTEDBOUNDINGVOLUME_H KOrientedBoundingVolume 3 | 4 | #include 5 | class KHalfEdgeMesh; 6 | 7 | class KOrientedBoundingVolumePrivate; 8 | class KOrientedBoundingVolume : public KAbstractBoundingVolume 9 | { 10 | public: 11 | 12 | // Construction Methods 13 | enum Method 14 | { 15 | PcaMethod 16 | }; 17 | 18 | // Constructors / Destructor 19 | KOrientedBoundingVolume(); 20 | KOrientedBoundingVolume(KHalfEdgeMesh const &mesh, Method method); 21 | ~KOrientedBoundingVolume(); 22 | 23 | // Virtual Implementaiton 24 | void draw(KTransform3D &t, KColor const &color) const; 25 | 26 | private: 27 | KOrientedBoundingVolumePrivate *m_private; 28 | }; 29 | 30 | #endif // KORIENTEDBOUNDINGVOLUME_H 31 | -------------------------------------------------------------------------------- /Karma/kpangesture.h: -------------------------------------------------------------------------------- 1 | #ifndef KPANGESTURE_H 2 | #define KPANGESTURE_H KPanGesture 3 | 4 | #include 5 | #include 6 | 7 | class KPanGesture : public KGesture 8 | { 9 | public: 10 | KPanGesture(); 11 | KPanGesture(QPanGesture const &rhs); 12 | inline KPointF lastOffset() const; 13 | inline KPointF offset() const; 14 | inline KPointF delta() const; 15 | inline qreal acceleration() const; 16 | private: 17 | qreal m_acceleration; 18 | KPointF m_offset; 19 | KPointF m_lastOffset; 20 | }; 21 | 22 | inline KPanGesture::KPanGesture() {} 23 | inline KPanGesture::KPanGesture(QPanGesture const &rhs) : KGesture(rhs), m_acceleration(rhs.acceleration()), m_offset(rhs.offset()), m_lastOffset(rhs.lastOffset()) {} 24 | inline KPointF KPanGesture::lastOffset() const { return m_lastOffset; } 25 | inline KPointF KPanGesture::offset() const { return m_offset; } 26 | inline KPointF KPanGesture::delta() const { return m_offset - m_lastOffset; } 27 | inline qreal KPanGesture::acceleration() const { return m_acceleration; } 28 | 29 | #endif // KPANGESTURE_H 30 | -------------------------------------------------------------------------------- /Karma/kparsetoken.h: -------------------------------------------------------------------------------- 1 | #ifndef KPARSETOKEN_H 2 | #define KPARSETOKEN_H KParseToken 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | union KDefaultAttribs 9 | { 10 | int asInteger; 11 | float asFloat; 12 | }; 13 | 14 | struct KParseCompare : public std::binary_function 15 | { 16 | inline bool operator()(char const* lhs, char const* rhs) const 17 | { 18 | return std::strcmp(lhs, rhs) < 0; 19 | } 20 | }; 21 | 22 | template 23 | using KParseMap = std::map; 24 | 25 | template 26 | class KParseToken 27 | { 28 | public: 29 | 30 | typedef IdType token_id; 31 | typedef AttribType attrib_type; 32 | 33 | token_id m_token; 34 | attrib_type m_attribute; 35 | std::string m_lexicon; 36 | inline KParseToken(); 37 | inline operator token_id() const; 38 | private: 39 | inline KParseToken(KParseToken const &rhs); 40 | inline KParseToken(KParseToken &&rhs); 41 | inline void operator=(KParseToken const &rhs); 42 | inline void operator=(KParseToken &&rhs); 43 | }; 44 | 45 | template 46 | inline KParseToken::KParseToken() : 47 | m_token(static_cast(0)) 48 | { 49 | // Intentionally Empty 50 | } 51 | 52 | template 53 | inline KParseToken::operator token_id() const 54 | { 55 | return m_token; 56 | } 57 | 58 | #endif // KPARSETOKEN_H 59 | -------------------------------------------------------------------------------- /Karma/kpoint.h: -------------------------------------------------------------------------------- 1 | #ifndef KPOINT_H 2 | #define KPOINT_H KPoint 3 | 4 | #include 5 | 6 | class KPoint : public QPoint 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KPoint() : QPoint() {} 10 | Q_DECL_CONSTEXPR KPoint(QPoint const &rhs) : QPoint(rhs) {} 11 | Q_DECL_CONSTEXPR KPoint(int xpos, int ypos) : QPoint(xpos, ypos) {} 12 | }; 13 | 14 | #endif // KPOINT_H 15 | 16 | -------------------------------------------------------------------------------- /Karma/kpointcloud.h: -------------------------------------------------------------------------------- 1 | #ifndef KPOINTCLOUD_H 2 | #define KPOINTCLOUD_H KPointCloud 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class KPointCloud 9 | { 10 | public: 11 | typedef KVector3D ElementType; 12 | typedef std::vector ContainerType; 13 | typedef KStandardAccessor AccessorType; 14 | typedef ContainerType::const_iterator ConstIterator; 15 | 16 | void emplace_back(ElementType const &elm); 17 | ElementType &operator[](size_t elm); 18 | ElementType const &operator[](size_t elm) const; 19 | size_t size() const; 20 | bool empty() const; 21 | void clear(); 22 | void reserve(size_t count); 23 | 24 | // Iterators 25 | ConstIterator cend() const; 26 | private: 27 | ContainerType m_container; 28 | }; 29 | 30 | inline void KPointCloud::emplace_back(ElementType const &elm) 31 | { 32 | m_container.emplace_back(elm); 33 | } 34 | 35 | inline auto KPointCloud::operator[](size_t elm) -> ElementType& 36 | { 37 | return m_container[elm]; 38 | } 39 | 40 | inline auto KPointCloud::operator[](size_t elm) const -> ElementType const& 41 | { 42 | return m_container[elm]; 43 | } 44 | 45 | inline size_t KPointCloud::size() const 46 | { 47 | return m_container.size(); 48 | } 49 | 50 | inline bool KPointCloud::empty() const 51 | { 52 | return m_container.empty(); 53 | } 54 | 55 | inline void KPointCloud::clear() 56 | { 57 | m_container.clear(); 58 | } 59 | 60 | inline void KPointCloud::reserve(size_t count) 61 | { 62 | m_container.reserve(count); 63 | } 64 | 65 | inline auto KPointCloud::cend() const -> ConstIterator 66 | { 67 | return m_container.cend(); 68 | } 69 | 70 | #endif // KPOINTCLOUD_H 71 | -------------------------------------------------------------------------------- /Karma/kpointf.h: -------------------------------------------------------------------------------- 1 | #ifndef KPOINTF_H 2 | #define KPOINTF_H KPointF 3 | 4 | #include 5 | 6 | class KPointF : public QPointF 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KPointF() : QPointF() {} 10 | Q_DECL_CONSTEXPR KPointF(const QPoint &p) : QPointF(p) {} 11 | Q_DECL_CONSTEXPR KPointF(const QPointF &p) : QPointF(p) {} 12 | Q_DECL_CONSTEXPR KPointF(qreal xpos, qreal ypos) : QPointF(xpos, ypos) {} 13 | }; 14 | 15 | #endif // KPOINTF_H 16 | -------------------------------------------------------------------------------- /Karma/kquaternion.h: -------------------------------------------------------------------------------- 1 | #ifndef KQUATERNION_H 2 | #define KQUATERNION_H KQuaternion 3 | 4 | #include 5 | #include 6 | 7 | class KQuaternion : public QQuaternion 8 | { 9 | public: 10 | KQuaternion() : QQuaternion() {} 11 | KQuaternion(QQuaternion const& rhs) : QQuaternion(rhs) {} 12 | KQuaternion(float scalar, float xpos, float ypos, float zpos) : QQuaternion(scalar, xpos, ypos, zpos) {} 13 | #ifndef QT_NO_VECTOR3D 14 | KQuaternion(float scalar, const KVector3D& vector) : QQuaternion(scalar, vector) {} 15 | #endif 16 | }; 17 | 18 | #endif // KQUATERNION_H 19 | 20 | -------------------------------------------------------------------------------- /Karma/krect.h: -------------------------------------------------------------------------------- 1 | #ifndef KRECT_H 2 | #define KRECT_H KRect 3 | 4 | #include 5 | 6 | class KRect : public QRect 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KRect() : QRect() {} 10 | Q_DECL_CONSTEXPR KRect(const QPoint &topleft, const QPoint &bottomright) : QRect(topleft, bottomright) {} 11 | Q_DECL_CONSTEXPR KRect(const QPoint &topleft, const QSize &size) : QRect(topleft, size) {} 12 | Q_DECL_CONSTEXPR KRect(int left, int top, int width, int height) : QRect(left, top, width, height) {} 13 | }; 14 | 15 | #endif // KRECT_H 16 | 17 | -------------------------------------------------------------------------------- /Karma/krectf.h: -------------------------------------------------------------------------------- 1 | #ifndef KRECTF_H 2 | #define KRECTF_H KRectF 3 | 4 | #include 5 | 6 | class KRectF : public QRectF 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KRectF() : QRectF() {} 10 | Q_DECL_CONSTEXPR KRectF(const QRectF &rect) : QRectF(rect) {} 11 | Q_DECL_CONSTEXPR KRectF(const QPointF &topleft, const QSizeF &size) : QRectF(topleft, size) {} 12 | Q_DECL_CONSTEXPR KRectF(const QPointF &topleft, const QPointF &bottomRight) : QRectF(topleft, bottomRight) {} 13 | Q_DECL_CONSTEXPR KRectF(qreal left, qreal top, qreal width, qreal height) : QRectF(left, top, width, height) {} 14 | Q_DECL_CONSTEXPR KRectF(const QRect &rect) : QRectF(rect) {} 15 | }; 16 | 17 | #endif // KRECTF_H 18 | -------------------------------------------------------------------------------- /Karma/ksize.h: -------------------------------------------------------------------------------- 1 | #ifndef KSIZE_H 2 | #define KSIZE_H KSize 3 | 4 | #include 5 | 6 | class KSize : public QSize 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KSize() : QSize() {} 10 | Q_DECL_CONSTEXPR KSize(QSize const &rhs) : QSize(rhs) {} 11 | Q_DECL_CONSTEXPR KSize(int w, int h) : QSize(w,h) {} 12 | }; 13 | 14 | #endif // KSIZE_H 15 | -------------------------------------------------------------------------------- /Karma/ksizef.h: -------------------------------------------------------------------------------- 1 | #ifndef KSIZEF_H 2 | #define KSIZEF_H KSizeF 3 | 4 | #include 5 | 6 | class KSizeF : public QSizeF 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KSizeF() : QSizeF() {} 10 | Q_DECL_CONSTEXPR KSizeF(const QSize &sz) : QSizeF(sz) {} 11 | Q_DECL_CONSTEXPR KSizeF(const QSizeF &sz) : QSizeF(sz) {} 12 | Q_DECL_CONSTEXPR KSizeF(qreal w, qreal h) : QSizeF(w,h) {} 13 | }; 14 | 15 | #endif // KSIZEF_H 16 | -------------------------------------------------------------------------------- /Karma/ksphereboundingvolume.h: -------------------------------------------------------------------------------- 1 | #ifndef KSPHEREBOUNDINGVOLUME_H 2 | #define KSPHEREBOUNDINGVOLUME_H KSphereBoundingVolume 3 | 4 | #include 5 | class KHalfEdgeMesh; 6 | 7 | class KSphereBoundingVolumePrivate; 8 | class KSphereBoundingVolume : public KAbstractBoundingVolume 9 | { 10 | public: 11 | 12 | // Construction Methods 13 | enum Method 14 | { 15 | CentroidMethod, 16 | RittersMethod, 17 | LarssonsMethod, 18 | PcaMethod 19 | }; 20 | 21 | // Constuctors / Destructor 22 | KSphereBoundingVolume(); 23 | KSphereBoundingVolume(KHalfEdgeMesh const &mesh, Method method); 24 | ~KSphereBoundingVolume(); 25 | 26 | // Virtual Implementation 27 | void draw(KTransform3D &t, KColor const &color) const; 28 | 29 | private: 30 | KSphereBoundingVolumePrivate *m_private; 31 | }; 32 | 33 | #endif // KSPHEREBOUNDINGVOLUME_H 34 | -------------------------------------------------------------------------------- /Karma/kstack.h: -------------------------------------------------------------------------------- 1 | #ifndef KSTACK_H 2 | #define KSTACK_H KStack 3 | 4 | #include 5 | 6 | template 7 | class KStack : public QStack 8 | { 9 | // Intentionally Empty 10 | }; 11 | 12 | #endif // KSTACK_H 13 | 14 | -------------------------------------------------------------------------------- /Karma/kstandardaccessor.h: -------------------------------------------------------------------------------- 1 | #ifndef KSTANDARDACCESSOR_H 2 | #define KSTANDARDACCESSOR_H KStandardAccessor 3 | 4 | #include 5 | 6 | template 7 | class KStandardAccessor : public KAccessor 8 | { 9 | public: 10 | typedef typename KAccessor::ReturnType ReturnType; 11 | typedef typename KAccessor::ContainedType ContainedType; 12 | ReturnType const &operator()(ContainedType const &elm) const; 13 | }; 14 | 15 | template 16 | auto KStandardAccessor::operator()(ContainedType const &elm) const -> ReturnType const & 17 | { 18 | return elm; 19 | } 20 | 21 | #endif // KSTANDARDACCESSOR_H 22 | 23 | -------------------------------------------------------------------------------- /Karma/kstaticgeometry.h: -------------------------------------------------------------------------------- 1 | #ifndef KSTATICGEOMETRY_H 2 | #define KSTATICGEOMETRY_H KStaticGeometry 3 | 4 | class KColor; 5 | class KHalfEdgeMesh; 6 | class KTransform3D; 7 | #include 8 | #include 9 | #include 10 | 11 | class KStaticGeometryPrivate; 12 | class KStaticGeometry : public KGeometryCloud 13 | { 14 | public: 15 | KStaticGeometry(); 16 | ~KStaticGeometry(); 17 | 18 | void clear(); 19 | size_t depth() const; 20 | void build(BuildMethod method, TerminationPred pred); 21 | void drawAabbs(KTransform3D &trans, KColor const &color); 22 | void drawAabbs(KTransform3D &trans, KColor const &color, size_t min); 23 | void drawAabbs(KTransform3D &trans, KColor const &color, size_t min, size_t max); 24 | 25 | private: 26 | KSharedPointer m_private; 27 | }; 28 | 29 | #endif // KSTATICGEOMETRY_H 30 | -------------------------------------------------------------------------------- /Karma/kstring.h: -------------------------------------------------------------------------------- 1 | #ifndef KSTRING_H 2 | #define KSTRING_H KString 3 | 4 | #include 5 | 6 | class KString : public QString 7 | { 8 | public: 9 | inline KString() : QString() {} 10 | inline KString(QString const &rhs) : QString(rhs) {} 11 | explicit KString(const QChar *unicode, int size = -1) : QString(unicode, size) {} 12 | KString(QChar c) : QString(c) {} 13 | KString(int size, QChar c) : QString(size, c) {} 14 | inline KString(QLatin1String latin1) : QString(latin1) {} 15 | }; 16 | 17 | #endif // KSTRING_H 18 | -------------------------------------------------------------------------------- /Karma/kstringwriter.h: -------------------------------------------------------------------------------- 1 | #ifndef KSTRINGWRITER_H 2 | #define KSTRINGWRITER_H 3 | #define GENHEADER KStringWriter 4 | 5 | #include 6 | 7 | #include 8 | 9 | class KStringWriterPrivate; 10 | class KStringWriter : public KAbstractWriter 11 | { 12 | public: 13 | KStringWriter(std::string &ref); 14 | virtual void append(char const *buffer); 15 | virtual void push_back(char c); 16 | private: 17 | std::string &m_reference; 18 | }; 19 | 20 | inline KStringWriter::KStringWriter(std::string &ref) : 21 | m_reference(ref) 22 | { 23 | // Intentionally Empty 24 | } 25 | 26 | inline void KStringWriter::append(char const *buffer) 27 | { 28 | m_reference.append(buffer); 29 | } 30 | 31 | inline void KStringWriter::push_back(char c) 32 | { 33 | m_reference.push_back(c); 34 | } 35 | 36 | #endif // KSTRINGWRITER_H 37 | -------------------------------------------------------------------------------- /Karma/ktouchpoint.h: -------------------------------------------------------------------------------- 1 | #ifndef KTOUCHPOINT_H 2 | #define KTOUCHPOINT_H KTouchPoint 3 | 4 | #include 5 | 6 | class KTouchPoint : public QTouchEvent::TouchPoint 7 | { 8 | public: 9 | explicit KTouchPoint(int id = -1) : QTouchEvent::TouchPoint(id) {} 10 | KTouchPoint(const QTouchEvent::TouchPoint &other) : QTouchEvent::TouchPoint(other) {} 11 | }; 12 | 13 | #endif // KTOUCHPOINT_H 14 | -------------------------------------------------------------------------------- /Karma/ktranslationiterator.h: -------------------------------------------------------------------------------- 1 | #ifndef KTRANSLATIONITERATOR_H 2 | #define KTRANSLATIONITERATOR_H KTranslationIterator 3 | 4 | template 5 | class KTranslationIterator 6 | { 7 | public: 8 | typedef It IteratorType; 9 | typedef T ValueType; 10 | }; 11 | 12 | #endif // KTRANSLATIONITERATOR_H 13 | -------------------------------------------------------------------------------- /Karma/ktriangleindexiterator.h: -------------------------------------------------------------------------------- 1 | #ifndef KTRIANGLEINDEXITERATOR_H 2 | #define KTRIANGLEINDEXITERATOR_H KTriangleIndexIterator 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class KTriangleIndexIterator : public KIntermediateIterator 9 | { 10 | public: 11 | KTriangleIndexIterator(FromIterator it); 12 | KTriangleIndexIterator(FromIteratorConst it); 13 | void operator++(); 14 | void validate(); 15 | }; 16 | 17 | inline KTriangleIndexIterator::KTriangleIndexIterator(FromIterator it) : 18 | KIntermediateIterator(it) 19 | { 20 | // Intentionally Empty 21 | } 22 | 23 | inline KTriangleIndexIterator::KTriangleIndexIterator(FromIteratorConst it) : 24 | KIntermediateIterator(it) 25 | { 26 | // Intentionally Empty 27 | } 28 | 29 | inline void KTriangleIndexIterator::operator++() 30 | { 31 | ++m_to; 32 | if (m_to == m_from->indices.cend()) 33 | { 34 | ++m_from; 35 | invalidate(); 36 | } 37 | } 38 | 39 | inline void KTriangleIndexIterator::validate() 40 | { 41 | m_to = m_from->indices.cbegin(); 42 | } 43 | 44 | namespace std 45 | { 46 | inline KTriangleIndexIterator::difference_type 47 | distance(KTriangleIndexIterator const & begin, KTriangleIndexIterator const &end) 48 | { 49 | return 3 * std::distance(begin.fromIterator(), end.fromIterator()); 50 | } 51 | } 52 | 53 | #endif // KTRIANGLEINDEXITERATOR_H 54 | -------------------------------------------------------------------------------- /Karma/ktrianglepointiterator.h: -------------------------------------------------------------------------------- 1 | #ifndef KTRIANGLEPOINTITERATOR_H 2 | #define KTRIANGLEPOINTITERATOR_H KTrianglePointIterator 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class KTrianglePointIterator : public KTranslationIterator 10 | { 11 | public: 12 | KTrianglePointIterator(IteratorType it, KPointCloud const &cloud); 13 | void operator++(); 14 | bool operator!=(KTrianglePointIterator const &rhs) const; 15 | ValueType const &operator*(); 16 | private: 17 | KPointCloud const &m_cloud; 18 | IteratorType m_iterator; 19 | }; 20 | 21 | inline KTrianglePointIterator::KTrianglePointIterator(KTriangleIndexIterator it, KPointCloud const &cloud) : 22 | m_cloud(cloud), m_iterator(it) 23 | { 24 | // Intentionally Empty 25 | } 26 | 27 | inline void KTrianglePointIterator::operator++() 28 | { 29 | ++m_iterator; 30 | } 31 | 32 | inline bool KTrianglePointIterator::operator!=(KTrianglePointIterator const &rhs) const 33 | { 34 | return (m_iterator != rhs.m_iterator); 35 | } 36 | 37 | inline auto KTrianglePointIterator::operator*() -> ValueType const & 38 | { 39 | // Reminder: FaceIndices start from 1 40 | return m_cloud[static_cast((*m_iterator) - 1)]; 41 | } 42 | 43 | #endif // KTRIANGLEPOINTITERATOR_H 44 | -------------------------------------------------------------------------------- /Karma/ktypetraits.h: -------------------------------------------------------------------------------- 1 | #ifndef KTYPETRAITS_H 2 | #define KTYPETRAITS_H KTypeTraits 3 | 4 | #include 5 | #include 6 | 7 | namespace Karma 8 | { 9 | 10 | /*! 11 | * The template `has_destructor` exports a 12 | * boolean constant `value that is true iff `T` has 13 | * a public destructor. 14 | * 15 | * N.B. A compile error will occur if T has non-public destructor. 16 | * \see http://stackoverflow.com/questions/10711952/how-to-detect-existence-of-a-class-using-sfinae 17 | */ 18 | template< typename T> 19 | struct has_destructor 20 | { 21 | /* Has destructor :) */ 22 | template 23 | static std::true_type test(decltype(std::declval().~A()) *) { 24 | return std::true_type(); 25 | } 26 | 27 | /* Has no destructor :( */ 28 | template 29 | static std::false_type test(...) { 30 | return std::false_type(); 31 | } 32 | 33 | /* This will be either `std::true_type` or `std::false_type` */ 34 | typedef decltype(test(0)) type; 35 | 36 | static const bool value = type::value; /* Which is it? */ 37 | }; 38 | 39 | template 40 | struct is_defined : has_destructor {}; 41 | 42 | template 43 | inline typename std::enable_if::value>::type safeDelete(T *data) 44 | { 45 | delete data; 46 | } 47 | 48 | template 49 | inline typename std::enable_if::value>::type safeDelete(T *data) 50 | { 51 | (void)data; 52 | qFatal("Attempted to delete a variable which was not defined!"); 53 | } 54 | 55 | } 56 | 57 | #endif // KTYPETRAITS_H 58 | 59 | -------------------------------------------------------------------------------- /Karma/kvector2d.h: -------------------------------------------------------------------------------- 1 | #ifndef KVECTOR2D_H 2 | #define KVECTOR2D_H KVector2D 3 | 4 | #include 5 | 6 | class KVector2D : public QVector2D 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KVector2D() : QVector2D() {} 10 | Q_DECL_CONSTEXPR KVector2D(QVector2D const& rhs) : QVector2D(rhs) {} 11 | Q_DECL_CONSTEXPR KVector2D(float xpos, float ypos) : QVector2D(xpos, ypos) {} 12 | }; 13 | 14 | #endif // KVECTOR2D_H 15 | 16 | -------------------------------------------------------------------------------- /Karma/kvector3d.h: -------------------------------------------------------------------------------- 1 | #ifndef KVECTOR3D_H 2 | #define KVECTOR3D_H KVector3D 3 | 4 | #include 5 | 6 | class KVector3D : public QVector3D 7 | { 8 | public: 9 | Q_DECL_CONSTEXPR KVector3D() : QVector3D() {} 10 | Q_DECL_CONSTEXPR KVector3D(QVector3D const& rhs) : QVector3D(rhs) {} 11 | explicit Q_DECL_CONSTEXPR KVector3D(float k) : QVector3D(k, k, k) {} 12 | Q_DECL_CONSTEXPR KVector3D(float xpos, float ypos, float zpos) : QVector3D(xpos, ypos, zpos) {} 13 | KVector3D operator/(KVector3D const &rhs) 14 | { 15 | return KVector3D(x() / rhs.x(), y() / rhs.y(), z() / rhs.z()); 16 | } 17 | }; 18 | 19 | #endif // KVECTOR3D_H 20 | 21 | -------------------------------------------------------------------------------- /Karma/kvector4d.h: -------------------------------------------------------------------------------- 1 | #ifndef KVECTOR4D_H 2 | #define KVECTOR4D_H KVector4D 3 | 4 | #include 5 | 6 | class KVector4D : public QVector4D 7 | { 8 | public: 9 | KVector4D() : QVector4D() {} 10 | KVector4D(QVector4D const &rhs) : QVector4D(rhs) {} 11 | operator QVector4D() const; 12 | void set(float x, float y, float z, float w); 13 | }; 14 | 15 | inline void KVector4D::set(float x, float y, float z, float w) 16 | { 17 | setX(x); 18 | setY(y); 19 | setZ(z); 20 | setW(w); 21 | } 22 | 23 | inline KVector4D::operator QVector4D() const 24 | { 25 | return static_cast(*this); 26 | } 27 | 28 | #endif // KVECTOR4D_H 29 | -------------------------------------------------------------------------------- /KarmaView/KarmaView.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2015-01-11T15:14:10 4 | # 5 | #------------------------------------------------- 6 | 7 | TEMPLATE = app 8 | CONFIG -= app_bundle 9 | QT += core gui widgets 10 | QT -= console 11 | TARGET = KarmaView 12 | include(../config.pri) 13 | 14 | LIBS += $${KARMA_LIB} 15 | LIBS += $${OPENGL_LIB} 16 | LIBS += $${QTBASEEXT_LIB} 17 | 18 | PRE_TARGETDEPS += $${KARMA_DEP} 19 | PRE_TARGETDEPS += $${OPENGL_DEP} 20 | PRE_TARGETDEPS += $${QTBASEEXT_DEP} 21 | 22 | SOURCES += \ 23 | main.cpp \ 24 | mainwidget.cpp \ 25 | gbufferpass.cpp \ 26 | compositionpass.cpp \ 27 | samplescene.cpp \ 28 | lightaccumulationpass.cpp \ 29 | viewportpresentationpass.cpp \ 30 | motionblurpass.cpp \ 31 | preparepresentationpass.cpp \ 32 | shadowedlightaccumulationpass.cpp \ 33 | debuggbufferpass.cpp \ 34 | environmentpass.cpp \ 35 | screenspaceambientocclusion.cpp \ 36 | mainwindow.cpp 37 | 38 | HEADERS += \ 39 | mainwidget.h \ 40 | gbufferpass.h \ 41 | compositionpass.h \ 42 | renderpasses.h \ 43 | samplescene.h \ 44 | lightaccumulationpass.h \ 45 | viewportpresentationpass.h \ 46 | motionblurpass.h \ 47 | preparepresentationpass.h \ 48 | shadowedlightaccumulationpass.h \ 49 | debuggbufferpass.h \ 50 | environmentpass.h \ 51 | screenspaceambientocclusion.h \ 52 | mainwindow.h \ 53 | main.h 54 | 55 | RESOURCES += \ 56 | ../resources.qrc \ 57 | ../images.qrc 58 | 59 | FORMS += \ 60 | mainwindow.ui 61 | -------------------------------------------------------------------------------- /KarmaView/compositionpass.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPOSITIONPASS_H 2 | #define COMPOSITIONPASS_H CompositionPass 3 | 4 | #include 5 | #include 6 | 7 | class CompositionPassPrivate; 8 | class CompositionPass : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | virtual void initialize(); 12 | virtual void resize(int width, int height); 13 | virtual void stage(); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | private: 18 | CompositionPassPrivate *m_private; 19 | }; 20 | 21 | #endif // COMPOSITIONPASS_H 22 | -------------------------------------------------------------------------------- /KarmaView/debuggbufferpass.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUGGBUFFERPASS_H 2 | #define DEBUGGBUFFERPASS_H DebugGBufferPass 3 | #include 4 | #include 5 | 6 | class DebugGBufferPassPrivate; 7 | class DebugGBufferPass : public OpenGLRenderPassImpl 8 | { 9 | public: 10 | DebugGBufferPass(); 11 | virtual void initialize(); 12 | virtual void resize(int width, int height); 13 | virtual void commit(OpenGLViewport &view); 14 | virtual void render(OpenGLScene &scene); 15 | virtual void teardown(); 16 | private: 17 | DebugGBufferPassPrivate *m_private; 18 | }; 19 | 20 | #endif // DEBUGGBUFFERPASS_H 21 | -------------------------------------------------------------------------------- /KarmaView/environmentpass.h: -------------------------------------------------------------------------------- 1 | #ifndef ENVIRONMENTPASS_H 2 | #define ENVIRONMENTPASS_H EnvironmentPass 3 | 4 | #include 5 | #include 6 | 7 | class EnvironmentPassPrivate; 8 | class EnvironmentPass : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | EnvironmentPass(); 12 | virtual void initialize(); 13 | virtual void resize(int width, int height); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | private: 18 | EnvironmentPassPrivate *m_private; 19 | }; 20 | 21 | #endif // ENVIRONMENTPASS_H 22 | -------------------------------------------------------------------------------- /KarmaView/gbufferpass.h: -------------------------------------------------------------------------------- 1 | #ifndef GBUFFERPASS_H 2 | #define GBUFFERPASS_H GBufferPass 3 | 4 | #include 5 | #include 6 | 7 | class GBufferPassPrivate; 8 | class GBufferPass : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | GBufferPass(); 12 | virtual void initialize(); 13 | virtual void resize(int width, int height); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | private: 18 | GBufferPassPrivate *m_private; 19 | }; 20 | 21 | #endif // GBUFFERPASS_H 22 | -------------------------------------------------------------------------------- /KarmaView/lightaccumulationpass.cpp: -------------------------------------------------------------------------------- 1 | #include "lightaccumulationpass.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class LightAccumulationPassPrivate 14 | { 15 | public: 16 | }; 17 | 18 | LightAccumulationPass::LightAccumulationPass() : 19 | m_private(0) 20 | { 21 | // Intentionally Empty 22 | } 23 | 24 | void LightAccumulationPass::initialize() 25 | { 26 | m_private = new LightAccumulationPassPrivate; 27 | } 28 | 29 | void LightAccumulationPass::resize(int, int) 30 | { 31 | // Intentionally Empty 32 | } 33 | 34 | void LightAccumulationPass::commit(OpenGLViewport &view) 35 | { 36 | // Unused 37 | (void)view; 38 | } 39 | 40 | void LightAccumulationPass::render(OpenGLScene &scene) 41 | { 42 | (void)scene; 43 | OpenGLMarkerScoped _("Light Accumulation Pass"); 44 | 45 | GL::glDisable(GL_DEPTH_TEST); 46 | GL::glDepthMask(GL_FALSE); 47 | GL::glEnable(GL_BLEND); 48 | GL::glBlendFunc(GL_ONE, GL_ONE); 49 | 50 | scene.renderLights(); 51 | 52 | GL::glDisable(GL_BLEND); 53 | GL::glDepthMask(GL_TRUE); 54 | GL::glEnable(GL_DEPTH_TEST); 55 | } 56 | 57 | void LightAccumulationPass::teardown() 58 | { 59 | delete m_private; 60 | } 61 | -------------------------------------------------------------------------------- /KarmaView/lightaccumulationpass.h: -------------------------------------------------------------------------------- 1 | #ifndef LIGHTACCUMULATIONPASS_H 2 | #define LIGHTACCUMULATIONPASS_H LightAccumulationPass 3 | 4 | #include 5 | #include 6 | 7 | class OpenGLSpotLight; 8 | class OpenGLPointLight; 9 | class OpenGLDirectionLight; 10 | class OpenGLSpotLightGroup; 11 | class OpenGLPointLightGroup; 12 | class OpenGLDirectionLightGroup; 13 | 14 | class LightAccumulationPassPrivate; 15 | class LightAccumulationPass : public OpenGLRenderPassImpl 16 | { 17 | public: 18 | LightAccumulationPass(); 19 | virtual void initialize(); 20 | virtual void resize(int width, int height); 21 | virtual void commit(OpenGLViewport &view); 22 | virtual void render(OpenGLScene &scene); 23 | virtual void teardown(); 24 | private: 25 | LightAccumulationPassPrivate *m_private; 26 | }; 27 | 28 | #endif // LIGHTACCUMULATIONPASS_H 29 | -------------------------------------------------------------------------------- /KarmaView/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | class QPlainTextEdit; 5 | extern QPlainTextEdit *sg_console; 6 | 7 | #endif // MAIN_H 8 | -------------------------------------------------------------------------------- /KarmaView/mainwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWIDGET_H 2 | #define MAINWIDGET_H 3 | #include 4 | #include 5 | 6 | class OpenGLScene; 7 | class OpenGLUpdateEvent; 8 | class SampleScene; 9 | class OpenGLRenderer; 10 | 11 | class MainWidgetPrivate; 12 | class MainWidget : public OpenGLWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | MainWidget(QWidget *parent = 0); 18 | ~MainWidget(); 19 | void setScene(OpenGLScene *scene); 20 | bool isReady() const; 21 | SampleScene* sampleScene(); 22 | OpenGLRenderer* renderer(); 23 | 24 | protected: 25 | 26 | // OpenGL Methods 27 | void initializeGL(); 28 | void resizeGL(int width, int height); 29 | void paintGL(); 30 | 31 | // Events 32 | void updateEvent(OpenGLUpdateEvent *event); 33 | 34 | private: 35 | MainWidgetPrivate *m_private; 36 | }; 37 | 38 | #endif // MAINWIDGET_H 39 | -------------------------------------------------------------------------------- /KarmaView/motionblurpass.h: -------------------------------------------------------------------------------- 1 | #ifndef MOTIONBLURPASS_H 2 | #define MOTIONBLURPASS_H MotionBlurPass 3 | 4 | #include 5 | #include 6 | 7 | class MotionBlurPassPrivate; 8 | class MotionBlurPass : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | MotionBlurPass(); 12 | virtual void initialize(); 13 | virtual void resize(int width, int height); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | void setPower(float p); 18 | void setMaxSamples(int s); 19 | private: 20 | MotionBlurPassPrivate *m_private; 21 | }; 22 | 23 | #endif // MOTIONBLURPASS_H 24 | -------------------------------------------------------------------------------- /KarmaView/preparepresentationpass.h: -------------------------------------------------------------------------------- 1 | #ifndef PREPAREPRESENTATIONPASS_H 2 | #define PREPAREPRESENTATIONPASS_H PreparePresentationPass 3 | 4 | #include 5 | #include 6 | 7 | class PreparePresentationPassPrivate; 8 | class PreparePresentationPass : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | PreparePresentationPass(); 12 | virtual void initialize(); 13 | virtual void resize(int width, int height); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | private: 18 | PreparePresentationPassPrivate *m_private; 19 | }; 20 | 21 | #endif // PREPAREPRESENTATIONPASS_H 22 | -------------------------------------------------------------------------------- /KarmaView/renderpasses.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDERPASSES_H 2 | #define RENDERPASSES_H RenderPasses 3 | 4 | enum RenderPassId 5 | { 6 | GBufferPassId, 7 | PreparePresentationPassId, 8 | LightAccumulationPassId, 9 | ShadowedLightAccumulationPassId, 10 | MotionBlurPassId, 11 | ViewportPresentationPassId, 12 | DebugGBufferPassId, 13 | ScreenSpaceAmbientOcclusionPassId, 14 | EnvironmentPassId 15 | }; 16 | 17 | #endif // RENDERPASSES_H 18 | -------------------------------------------------------------------------------- /KarmaView/samplescene.h: -------------------------------------------------------------------------------- 1 | #ifndef SAMPLESCENE_H 2 | #define SAMPLESCENE_H SampleScene 3 | 4 | #include 5 | #include 6 | 7 | class SampleScenePrivate; 8 | class SampleScene : public OpenGLScene 9 | { 10 | public: 11 | SampleScene(); 12 | ~SampleScene(); 13 | void start(); 14 | void update(OpenGLUpdateEvent *event); 15 | void end(); 16 | void openMesh(); 17 | void setMaterial(float r, float g, float b, float metal, float rough); 18 | void setRenderer(int fresnel, int geometric, int dist, int sample); 19 | void setFloorActive(bool f); 20 | void setFloorMaterial(float r, float g, float b, float metal, float rough); 21 | void setInstance(int metal, int rough, float mSep, float rSep); 22 | void setLightsAnimated(bool a); 23 | void setLights(int count, int baseTemp, int stepTemp, float intensity, float height, float radius); 24 | void setSphereLightsAnimated(bool a); 25 | void setSphereLights(int count, int baseTemp, int stepTemp, float intensity, float height, float radius, float vRadius); 26 | void setRectLightsAnimated(bool a); 27 | void setRectLights(int count, int baseTemp, int stepTemp, float intensity, float height, float radius, float vWidth, float vHeight); 28 | void setBvAabb(bool bv); 29 | void setBvObb(bool bv); 30 | void setBvSphereRitters(bool bv); 31 | void setBvSpherePca(bool bv); 32 | void setBvSphereCentroid(bool bv); 33 | void setBvEllipse(bool bv); 34 | void setBvSphereLarssons(bool bv); 35 | void setObjectRotation(float x, float y, float z); 36 | private: 37 | KUniquePointer m_private; 38 | }; 39 | 40 | #endif // SAMPLESCENE_H 41 | -------------------------------------------------------------------------------- /KarmaView/screenspaceambientocclusion.h: -------------------------------------------------------------------------------- 1 | #ifndef SCREENSPACEAMBIENTOCCLUSION_H 2 | #define SCREENSPACEAMBIENTOCCLUSION_H ScreenSpaceAmbientOcclusion 3 | 4 | #include 5 | #include 6 | 7 | class ScreenSpaceAmbientOcclusionPrivate; 8 | class ScreenSpaceAmbientOcclusion : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | ScreenSpaceAmbientOcclusion(); 12 | virtual void initialize(); 13 | virtual void resize(int width, int height); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | void setContrast(float k); 18 | void setPower(float c); 19 | void setRadius(float r); 20 | void setThreshold(float t); 21 | void setSamples(int s); 22 | void setBlur(bool b); 23 | private: 24 | ScreenSpaceAmbientOcclusionPrivate *m_private; 25 | }; 26 | 27 | #endif // SCREENSPACEAMBIENTOCCLUSION_H 28 | -------------------------------------------------------------------------------- /KarmaView/shadowedlightaccumulationpass.cpp: -------------------------------------------------------------------------------- 1 | #include "shadowedlightaccumulationpass.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class ShadowedLightAccumulationPassPrivate 9 | { 10 | public: 11 | }; 12 | 13 | ShadowedLightAccumulationPass::ShadowedLightAccumulationPass() : 14 | m_private(0) 15 | { 16 | // Intentionally Empty 17 | } 18 | 19 | void ShadowedLightAccumulationPass::initialize() 20 | { 21 | 22 | } 23 | 24 | void ShadowedLightAccumulationPass::resize(int, int) 25 | { 26 | 27 | } 28 | 29 | void ShadowedLightAccumulationPass::commit(OpenGLViewport &) 30 | { 31 | 32 | } 33 | 34 | void ShadowedLightAccumulationPass::render(OpenGLScene &scene) 35 | { 36 | OpenGLMarkerScoped _("Shadow-Casting Light Accumulation Pass"); 37 | scene.renderShadowedLights(); 38 | } 39 | 40 | void ShadowedLightAccumulationPass::teardown() 41 | { 42 | 43 | } 44 | -------------------------------------------------------------------------------- /KarmaView/shadowedlightaccumulationpass.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADOWEDLIGHTACCUMULATIONPASS_H 2 | #define SHADOWEDLIGHTACCUMULATIONPASS_H ShadowedLightAccumulationPass 3 | 4 | #include 5 | #include 6 | 7 | class ShadowedLightAccumulationPassPrivate; 8 | class ShadowedLightAccumulationPass : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | ShadowedLightAccumulationPass(); 12 | virtual void initialize(); 13 | virtual void resize(int width, int height); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | private: 18 | ShadowedLightAccumulationPassPrivate *m_private; 19 | }; 20 | 21 | #endif // SHADOWEDLIGHTACCUMULATIONPASS_H 22 | -------------------------------------------------------------------------------- /KarmaView/viewportpresentationpass.h: -------------------------------------------------------------------------------- 1 | #ifndef VIEWPORTPRESENTATIONPASS_H 2 | #define VIEWPORTPRESENTATIONPASS_H ViewportPresentationPass 3 | 4 | #include 5 | #include 6 | 7 | class ViewportPresentationPassPrivate; 8 | class ViewportPresentationPass : public OpenGLRenderPassImpl 9 | { 10 | public: 11 | ViewportPresentationPass(); 12 | virtual void initialize(); 13 | virtual void resize(int width, int height); 14 | virtual void commit(OpenGLViewport &view); 15 | virtual void render(OpenGLScene &scene); 16 | virtual void teardown(); 17 | void setValues(float A, float B, float C, float D, float E, float F, float W); 18 | void setExposureBias(float eb); 19 | void setExposure(float e); 20 | private: 21 | ViewportPresentationPassPrivate *m_private; 22 | }; 23 | 24 | #endif // VIEWPORTPRESENTATIONPASS_H 25 | -------------------------------------------------------------------------------- /OpenGL/openglarealight.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLAREALIGHT_H 2 | #define OPENGLAREALIGHT_H OpenGLAreaLight 3 | 4 | #include 5 | #include 6 | 7 | class OpenGLAreaLight 8 | { 9 | public: 10 | OpenGLAreaLight(); 11 | 12 | // Translate 13 | void translate(float x, float y, float z); 14 | void translate(KVector3D const &trans); 15 | void setTranslation(float x, float y, float z); 16 | void setTranslation(KVector3D const &pos); 17 | KVector3D const &translation() const; 18 | 19 | // Rotation 20 | void rotate(float angle, float x, float y, float z); 21 | void rotate(float angle, const KVector3D &axis); 22 | void rotate(const KQuaternion &quat); 23 | void setRotation(float angle, float x, float y, float z); 24 | void setRotation(float angle, const KVector3D &axis); 25 | void setRotation(const KQuaternion &quat); 26 | const KQuaternion &rotation() const; 27 | void setDirection(const KVector3D &dir); 28 | void setDirection(const KVector3D &dir, const KVector3D &up); 29 | void setDirection(float x, float y, float z); 30 | KVector3D direction() const; 31 | 32 | // Smooth Attenuation 33 | void setRadius(float r); 34 | float radius() const; 35 | 36 | // Orientation 37 | KVector3D forward() const; 38 | KVector3D up() const; 39 | KVector3D right() const; 40 | 41 | void setTemperature(float temp); 42 | void setIntensity(float lm); 43 | float temperature() const; 44 | float intensity() const; 45 | KMatrix4x4 const& toMatrix() const; 46 | void setActive(bool a); 47 | bool active() const; 48 | 49 | KVector3D color() const; 50 | private: 51 | bool m_active; 52 | float m_radius; 53 | float m_temperature; 54 | float m_intensity; 55 | KTransform3D m_transform; 56 | }; 57 | 58 | #endif // OPENGLAREALIGHT_H 59 | -------------------------------------------------------------------------------- /OpenGL/openglarealightdata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLAREALIGHTDATA_H 2 | #define OPENGLAREALIGHTDATA_H OpenGLAreaLightData 3 | 4 | #include 5 | 6 | class OpenGLAreaLightData 7 | { 8 | public: 9 | glm::mat4 m_modelToPersp; 10 | glm::mat4 m_viewToLightPersp; 11 | glm::vec3 v_viewPosition; 12 | float f_radius; 13 | glm::vec3 v_color; 14 | float f_intensity; 15 | glm::vec4 v_data0; 16 | glm::vec4 v_data1; 17 | glm::vec4 v_data2; 18 | glm::vec4 v_data3; 19 | }; 20 | 21 | #endif // OPENGLAREALIGHTDATA_H 22 | 23 | -------------------------------------------------------------------------------- /OpenGL/openglarealightgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLAREALIGHTGROUP_H 2 | #define OPENGLAREALIGHTGROUP_H OpenGLAreaLightGroup 3 | 4 | class OpenGLAreaLightGroup 5 | { 6 | public: 7 | OpenGLAreaLightGroup(); 8 | ~OpenGLAreaLightGroup(); 9 | }; 10 | 11 | #endif // OPENGLAREALIGHTGROUP_H 12 | -------------------------------------------------------------------------------- /OpenGL/openglbindings.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLBINDINGS_H 2 | #define OPENGLBINDINGS_H OpenGLBindings 3 | 4 | #include 5 | 6 | #endif // OPENGLBINDINGS_H 7 | 8 | -------------------------------------------------------------------------------- /OpenGL/openglblurdata.cpp: -------------------------------------------------------------------------------- 1 | #include "openglblurdata.h" 2 | 3 | #include 4 | 5 | OpenGLBlurData::OpenGLBlurData(int width, float deviation) : 6 | m_blurWidth(width) 7 | { 8 | float total = 0.0f, current; 9 | 10 | // Make sure the BlurData is within the valid range. 11 | if (m_blurWidth < 1) m_blurWidth = 1; 12 | if (m_blurWidth > 32) m_blurWidth = 32; 13 | m_blurWidth2 = 2 * m_blurWidth; 14 | 15 | // Calculate the original normal distribution. 16 | for (int i = 0; i < m_blurWidth; ++i) 17 | { 18 | current = Karma::normalDist(float(m_blurWidth - i), 0.0f, deviation); 19 | m_weights[i] = m_weights[(m_blurWidth2 - i)] = current; 20 | total += 2.0f * current; 21 | } 22 | m_weights[m_blurWidth] = Karma::normalDist(0.0f, 0.0f, deviation); 23 | total += m_weights[m_blurWidth]; 24 | 25 | // Normalize the values so that they sum to 1 26 | for (int i = 0; i <= m_blurWidth2; ++i) 27 | { 28 | m_weights[i] /= total; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /OpenGL/openglblurdata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLBLURDATA_H 2 | #define OPENGLBLURDATA_H OpenGLBlurData 3 | 4 | class OpenGLBlurData 5 | { 6 | public: 7 | OpenGLBlurData(int width, float deviation = 1.0f); 8 | //private: 9 | int m_blurWidth; 10 | int m_blurWidth2; 11 | float m_weights[65]; 12 | }; 13 | 14 | #endif // OPENGLBLURDATA_H 15 | 16 | -------------------------------------------------------------------------------- /OpenGL/openglcontext.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLCONTEXT_H 2 | #define OPENGLCONTEXT_H OpenGLContext 3 | 4 | #include 5 | 6 | class OpenGLContext : public QOpenGLContext 7 | { 8 | // Intentionally Empty 9 | }; 10 | 11 | #endif // OPENGLCONTEXT_H 12 | -------------------------------------------------------------------------------- /OpenGL/opengldirectionlight.cpp: -------------------------------------------------------------------------------- 1 | #include "opengldirectionlight.h" 2 | 3 | OpenGLDirectionLight::OpenGLDirectionLight() : 4 | m_direction(-0.57735f, -0.57735f, -0.57735f) 5 | { 6 | // Intentionally Empty 7 | } 8 | -------------------------------------------------------------------------------- /OpenGL/opengldirectionlight.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLDIRECTIONLIGHT_H 2 | #define OPENGLDIRECTIONLIGHT_H OpenGLDirectionLight 3 | 4 | #include 5 | #include 6 | 7 | class OpenGLDirectionLight : public OpenGLLight 8 | { 9 | public: 10 | OpenGLDirectionLight(); 11 | 12 | //Light Settings 13 | void setDirection(float x, float y, float z); 14 | void setDirection(KVector3D const &dir); 15 | const KVector3D &direction() const; 16 | 17 | private: 18 | KVector3D m_direction; 19 | }; 20 | 21 | inline void OpenGLDirectionLight::setDirection(float x, float y, float z) 22 | { 23 | setDirection(KVector3D(x, y ,z)); 24 | } 25 | 26 | inline void OpenGLDirectionLight::setDirection(KVector3D const &dir) 27 | { 28 | m_direction = dir.normalized(); 29 | } 30 | 31 | inline const KVector3D &OpenGLDirectionLight::direction() const 32 | { 33 | return m_direction; 34 | } 35 | 36 | #endif // OPENGLDIRECTIONLIGHT_H 37 | -------------------------------------------------------------------------------- /OpenGL/opengldirectionlightdata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLDIRECTIONLIGHTDATA_H 2 | #define OPENGLDIRECTIONLIGHTDATA_H OpenGLDirectionLightData 3 | 4 | #include 5 | 6 | class OpenGLDirectionLightData 7 | { 8 | public: 9 | static int DirectionOffset(); 10 | static int DiffuseOffset(); 11 | static int SpecularOffset(); 12 | glm::vec3 m_direction; 13 | glm::vec3 m_diffuse; 14 | glm::vec3 m_specular; 15 | }; 16 | 17 | inline int OpenGLDirectionLightData::DirectionOffset() 18 | { 19 | return offsetof(OpenGLDirectionLightData, m_direction); 20 | } 21 | 22 | inline int OpenGLDirectionLightData::DiffuseOffset() 23 | { 24 | return offsetof(OpenGLDirectionLightData, m_diffuse); 25 | } 26 | 27 | inline int OpenGLDirectionLightData::SpecularOffset() 28 | { 29 | return offsetof(OpenGLDirectionLightData, m_specular); 30 | } 31 | 32 | #endif // OPENGLDIRECTIONLIGHTDATA_H 33 | 34 | -------------------------------------------------------------------------------- /OpenGL/opengldirectionlightgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLDIRECTIONLIGHTGROUP_H 2 | #define OPENGLDIRECTIONLIGHTGROUP_H OpenGLDirectionLightGroup 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class KMatrix4x4; 9 | class OpenGLMesh; 10 | 11 | class OpenGLDirectionLightGroup : public OpenGLLightGroup 12 | { 13 | public: 14 | bool create(); 15 | void initializeMesh(OpenGLMesh &mesh); 16 | void translateBuffer(const OpenGLRenderBlock &stats, DataPointer data, ConstLightIterator begin, ConstLightIterator end); 17 | void translateUniforms(const OpenGLRenderBlock &stats, Byte *data, SizeType step, ConstLightIterator begin, ConstLightIterator end); 18 | }; 19 | 20 | #endif // OPENGLDIRECTIONLIGHTGROUP_H 21 | -------------------------------------------------------------------------------- /OpenGL/opengldynamicuniformbufferobject.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLDYNAMICUNIFORMBUFFEROBJECT_H 2 | #define OPENGLDYNAMICUNIFORMBUFFEROBJECT_H OpenGLDynamicUniformBufferObject 3 | 4 | #include 5 | 6 | template 7 | class OpenGLDynamicUniformBufferObject : public OpenGLUniformBufferObject 8 | { 9 | public: 10 | typedef T ElementType; 11 | bool create(); 12 | void reserve(int count); 13 | int skipSize() const; 14 | private: 15 | int m_elementSize; 16 | }; 17 | 18 | template 19 | inline bool OpenGLDynamicUniformBufferObject::create() 20 | { 21 | int elementSize = sizeof(ElementType); 22 | int alignment = OpenGLUniformBufferObject::alignmentOffset(); 23 | m_elementSize = std::ceil(float(elementSize) / alignment) * alignment; 24 | return OpenGLUniformBufferObject::create(); 25 | } 26 | 27 | template 28 | inline void OpenGLDynamicUniformBufferObject::reserve(int count) 29 | { 30 | int requested = m_elementSize * count; 31 | if (size() < requested) 32 | { 33 | OpenGLUniformBufferObject::allocate(requested); 34 | } 35 | } 36 | 37 | template 38 | inline int OpenGLDynamicUniformBufferObject::skipSize() const 39 | { 40 | return m_elementSize; 41 | } 42 | 43 | #endif // OPENGLDYNAMICUNIFORMBUFFEROBJECT_H 44 | 45 | -------------------------------------------------------------------------------- /OpenGL/openglelementtype.cpp: -------------------------------------------------------------------------------- 1 | #include "openglelementtype.h" 2 | 3 | size_t OpenGLElementSize(OpenGLElementType type) 4 | { 5 | switch(type) 6 | { 7 | case OpenGLElementType::Byte: 8 | return sizeof(int8_t); 9 | case OpenGLElementType::UnsignedByte: 10 | return sizeof(uint8_t); 11 | case OpenGLElementType::Short: 12 | return sizeof(int16_t); 13 | case OpenGLElementType::UnsignedShort: 14 | return sizeof(uint16_t); 15 | case OpenGLElementType::Integer: 16 | return sizeof(int32_t); 17 | case OpenGLElementType::UnsignedInteger: 18 | return sizeof(uint32_t); 19 | case OpenGLElementType::Float: 20 | return sizeof(float); 21 | case OpenGLElementType::TwoBytes: 22 | return sizeof(int8_t) * 2; 23 | case OpenGLElementType::ThreeBytes: 24 | return sizeof(int8_t) * 3; 25 | case OpenGLElementType::FourBytes: 26 | return sizeof(int8_t) * 4; 27 | case OpenGLElementType::Double: 28 | return sizeof(double); 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /OpenGL/openglelementtype.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLELEMENTTYPE_H 2 | #define OPENGLELEMENTTYPE_H OpenGLElementType 3 | 4 | #include 5 | #include 6 | 7 | enum class OpenGLElementType 8 | { 9 | Byte = 0x1400, 10 | UnsignedByte = 0x1401, 11 | Short = 0x1402, 12 | UnsignedShort = 0x1403, 13 | Integer = 0x1404, 14 | UnsignedInteger = 0x1405, 15 | Float = 0x1406, 16 | TwoBytes = 0x1407, 17 | ThreeBytes = 0x1408, 18 | FourBytes = 0x1409, 19 | Double = 0x140A 20 | }; 21 | 22 | size_t OpenGLElementSize(OpenGLElementType type); 23 | 24 | #endif // OPENGLELEMENTTYPE_H 25 | -------------------------------------------------------------------------------- /OpenGL/openglenvironment.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLENVIRONMENT_H 2 | #define OPENGLENVIRONMENT_H OpenGLEnvironment 3 | 4 | class KSize; 5 | class OpenGLTexture; 6 | #include 7 | 8 | class OpenGLEnvrionmentPrivate; 9 | class OpenGLEnvironment 10 | { 11 | public: 12 | OpenGLEnvironment(); 13 | ~OpenGLEnvironment(); 14 | void create(); 15 | void setDirect(char const *filePath); 16 | void setIndirect(char const *filePath); 17 | void setToneMappingFunction(OpenGLToneMappingFunction *fnc); 18 | OpenGLTexture &direct(); 19 | OpenGLTexture &indirect(); 20 | KSize const &directSize() const; 21 | private: 22 | OpenGLEnvrionmentPrivate *m_private; 23 | }; 24 | 25 | #endif // OPENGLENVIRONMENT_H 26 | -------------------------------------------------------------------------------- /OpenGL/openglerror.cpp: -------------------------------------------------------------------------------- 1 | #include "openglerror.h" 2 | #include 3 | #include 4 | #include 5 | 6 | /******************************************************************************* 7 | * OpenGLError static types 8 | ******************************************************************************/ 9 | QStack OpenGLError::m_errorHandler; 10 | 11 | /******************************************************************************* 12 | * OpenGLError methods 13 | ******************************************************************************/ 14 | QEvent::Type OpenGLError::type() 15 | { 16 | static QEvent::Type customEventType = 17 | static_cast(QEvent::registerEventType()); 18 | return customEventType; 19 | } 20 | 21 | bool OpenGLError::sendEvent(OpenGLError *event) 22 | { 23 | if (m_errorHandler.empty()) 24 | { 25 | qWarning("Set OpenGLError::setErrorHandler() before calling any GL_DEBUG OpenGL functions!"); 26 | return false; 27 | } 28 | return QCoreApplication::sendEvent(m_errorHandler.top(), event); 29 | } 30 | 31 | void OpenGLError::pushErrorHandler(QObject *obj) 32 | { 33 | #ifdef GL_DEBUG 34 | qDebug() << "GL_DEBUG Error Handler (" << obj << ")"; 35 | #endif // GL_DEBUG 36 | m_errorHandler.push(obj); 37 | } 38 | 39 | void OpenGLError::popErrorHandler() 40 | { 41 | m_errorHandler.pop(); 42 | } 43 | -------------------------------------------------------------------------------- /OpenGL/openglframeresults.cpp: -------------------------------------------------------------------------------- 1 | #include "openglframeresults.h" 2 | #include 3 | 4 | OpenGLFrameResults::OpenGLFrameResults() 5 | { 6 | // Intentionally Empty 7 | } 8 | 9 | OpenGLFrameResults::OpenGLFrameResults(OpenGLFrameResults &&rhs) : 10 | m_maxDepth(rhs.m_maxDepth), m_startTime(rhs.m_startTime), m_endTime(rhs.m_endTime), 11 | m_gpuResults(std::move(rhs.m_gpuResults)) 12 | { 13 | // Intentionally Empty 14 | } 15 | 16 | OpenGLFrameResults::OpenGLFrameResults(size_t maxDepth, quint64 startTime, quint64 endTime) : 17 | m_maxDepth(maxDepth), m_startTime(startTime), m_endTime(endTime) 18 | { 19 | // Intentionally Empty 20 | } 21 | 22 | void OpenGLFrameResults::addGpuResult(const QString &name, size_t depth, quint64 startTime, quint64 endTime) 23 | { 24 | OpenGLMarkerResult res; 25 | res.setName(name); 26 | res.setDepth(static_cast(depth)); 27 | res.setStartTime(startTime); 28 | res.setEndTime(endTime); 29 | m_gpuResults.push_back(res); 30 | } 31 | 32 | void OpenGLFrameResults::operator=(OpenGLFrameResults const &rhs) 33 | { 34 | m_maxDepth = rhs.m_maxDepth; 35 | m_startTime = rhs.m_startTime; 36 | m_endTime = rhs.m_endTime; 37 | m_gpuResults = rhs.m_gpuResults; 38 | } 39 | 40 | void OpenGLFrameResults::operator=(OpenGLFrameResults &&rhs) 41 | { 42 | m_maxDepth = rhs.m_maxDepth; 43 | m_startTime = rhs.m_startTime; 44 | m_endTime = rhs.m_endTime; 45 | m_gpuResults = std::move(rhs.m_gpuResults); 46 | } 47 | 48 | QDebug &operator<<(QDebug &dbg, const OpenGLFrameResults &results) 49 | { 50 | foreach (OpenGLMarkerResult const& result, results.gpuResults()) 51 | { 52 | dbg << result; 53 | } 54 | return dbg; 55 | } 56 | -------------------------------------------------------------------------------- /OpenGL/openglframeresults.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLFRAMERESULTS_H 2 | #define OPENGLFRAMERESULTS_H OpenGLFrameResults 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class OpenGLFrameResults 9 | { 10 | public: 11 | // Constructors / Destructors 12 | OpenGLFrameResults(); 13 | OpenGLFrameResults(OpenGLFrameResults &&rhs); 14 | OpenGLFrameResults(size_t maxDepth, quint64 startTime, quint64 endTime); 15 | 16 | // Public Methods 17 | void addGpuResult(const QString &name, size_t depth, quint64 startTime, quint64 endTime); 18 | 19 | // Operators 20 | void operator=(OpenGLFrameResults const &rhs); 21 | void operator=(OpenGLFrameResults &&rhs); 22 | 23 | // Query Methods 24 | inline size_t maxDepth() const; 25 | inline quint64 startTime() const; 26 | inline quint64 endTime() const; 27 | inline const OpenGLMarkerResults &gpuResults() const; 28 | 29 | private: 30 | size_t m_maxDepth; 31 | quint64 m_startTime, m_endTime; 32 | OpenGLMarkerResults m_gpuResults; 33 | }; 34 | 35 | inline size_t OpenGLFrameResults::maxDepth() const { return m_maxDepth; } 36 | inline quint64 OpenGLFrameResults::startTime() const { return m_startTime; } 37 | inline quint64 OpenGLFrameResults::endTime() const { return m_endTime; } 38 | inline const OpenGLMarkerResults &OpenGLFrameResults::gpuResults() const { return m_gpuResults; } 39 | 40 | // Qt Streams 41 | #ifndef QT_NO_DEBUG_STREAM 42 | QDebug &operator<<(QDebug &dbg, const OpenGLFrameResults &results); 43 | #endif 44 | 45 | #endif // OPENGLFRAMERESULTS_H 46 | -------------------------------------------------------------------------------- /OpenGL/openglframetimer.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLFRAMETIMER_H 2 | #define OPENGLFRAMETIMER_H OpenGLFrameTimer 3 | 4 | #include 5 | 6 | class OpenGLFrameTimerPrivate; 7 | class OpenGLFrameTimer : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | 12 | // Constructors / Destructor 13 | explicit OpenGLFrameTimer(QObject *parent = 0); 14 | ~OpenGLFrameTimer(); 15 | 16 | // Public Methods 17 | void setFrequency(int hz); 18 | int frequency() const; 19 | 20 | signals: 21 | void timeout(float fps); 22 | 23 | public slots: 24 | void frameSwapped(); 25 | 26 | private: 27 | OpenGLFrameTimerPrivate *m_private; 28 | }; 29 | 30 | #endif // OPENGLFRAMETIMER_H 31 | -------------------------------------------------------------------------------- /OpenGL/openglfunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "openglfunctions.h" 2 | #include 3 | #include 4 | 5 | OpenGLFunctions *GL::m_functions; 6 | KRect sg_currViewport; 7 | KStack sg_viewportStack; 8 | 9 | OpenGLFunctions *GL::getInstance() 10 | { 11 | return GL::m_functions; 12 | } 13 | 14 | void GL::setInstance(OpenGLFunctions *f) 15 | { 16 | GL::m_functions = f; 17 | } 18 | 19 | int GL::getInteger(GLenum property) 20 | { 21 | GLint value; 22 | GL::glGetIntegerv(property, &value); 23 | return static_cast(value); 24 | } 25 | 26 | void GL::pushViewport() 27 | { 28 | sg_viewportStack.push(sg_currViewport); 29 | } 30 | 31 | void GL::popViewport() 32 | { 33 | sg_currViewport = sg_viewportStack.pop(); 34 | GL::getInstance()->glViewport (sg_currViewport.x(), sg_currViewport.y(), sg_currViewport.width(), sg_currViewport.height()); 35 | } 36 | 37 | void GL::glViewport(GLint x, GLint y, GLsizei width, GLsizei height) 38 | { 39 | sg_currViewport = KRect(x, y, width, height); 40 | GL::getInstance()->glViewport (x, y, width, height); 41 | } 42 | -------------------------------------------------------------------------------- /OpenGL/openglhammersleydata.cpp: -------------------------------------------------------------------------------- 1 | #include "openglhammersleydata.h" 2 | 3 | #include 4 | 5 | OpenGLHammersleyData::OpenGLHammersleyData(int n) : 6 | N(float(n)) 7 | { 8 | float p = 0; 9 | float u = 0; 10 | int pos = 0;int kk; 11 | 12 | for (int k=0; k>= 1) 14 | if (kk & 1) 15 | u += p; 16 | float v = (k + 0.5) / N; 17 | data[pos].setX(u); 18 | data[pos].setY(v); 19 | data[pos].setZ(0.0f); 20 | data[pos].setW(0.0f); 21 | ++pos; 22 | } 23 | Q_ASSERT(pos == n); 24 | } 25 | -------------------------------------------------------------------------------- /OpenGL/openglhammersleydata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLHAMMERSLEYDATA_H 2 | #define OPENGLHAMMERSLEYDATA_H OpenGLHammersleyData 3 | 4 | #include 5 | 6 | class OpenGLHammersleyData 7 | { 8 | public: 9 | OpenGLHammersleyData(int n); 10 | private: 11 | // Note: vec4 because each element is padded 12 | KVector4D data[60]; 13 | float N; 14 | }; 15 | 16 | #endif // OPENGLHAMMERSLEYDATA_H 17 | -------------------------------------------------------------------------------- /OpenGL/openglhdrtexture.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLHDRTEXTURE_H 2 | #define OPENGLHDRTEXTURE_H OpenGLHdrTexture 3 | 4 | class OpenGLTexture; 5 | class OpenGLToneMappingFunction; 6 | #include 7 | 8 | class OpenGLHdrTextureLoaderPrivate; 9 | class OpenGLHdrTextureLoader : public KAbstractHdrParser 10 | { 11 | public: 12 | OpenGLHdrTextureLoader(KAbstractReader *reader, OpenGLTexture *texture); 13 | bool parse(OpenGLToneMappingFunction *toneMap); 14 | protected: 15 | virtual void onKeyValue(char const *key, char const *value); 16 | virtual void onResolution(PixelOrder xOrder, PixelOrder yOrder, int width, int height); 17 | virtual float *beginData(); 18 | virtual void endData(); 19 | private: 20 | OpenGLHdrTextureLoaderPrivate *m_private; 21 | }; 22 | 23 | #endif // OPENGLHDRTEXTURE_H 24 | -------------------------------------------------------------------------------- /OpenGL/openglinstance.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLINSTANCE_H 2 | #define OPENGLINSTANCE_H OpenGLInstance 3 | 4 | class KTransform3D; 5 | class OpenGLMaterial; 6 | class KHalfEdgeMesh; 7 | class OpenGLMesh; 8 | #include 9 | #include 10 | class OpenGLViewport; 11 | 12 | class OpenGLInstancePrivate; 13 | class OpenGLInstance 14 | { 15 | public: 16 | OpenGLInstance(); 17 | ~OpenGLInstance(); 18 | 19 | // OpenGL 20 | void bind(); 21 | void commit(OpenGLViewport const &viewport); 22 | void release(); 23 | 24 | KTransform3D &transform(); 25 | KTransform3D ¤tTransform(); 26 | KTransform3D &previousTransform(); 27 | void setMesh(const OpenGLMesh &mesh); 28 | const OpenGLMesh &mesh() const; 29 | OpenGLMesh &mesh(); 30 | void setMaterial(OpenGLMaterial const &mat); 31 | OpenGLMaterial &material(); 32 | OpenGLMaterial const &material() const; 33 | void update(); 34 | KAabbBoundingVolume aabb() const; 35 | void setVisible(bool v); 36 | bool visible() const; 37 | private: 38 | OpenGLInstancePrivate *m_private; 39 | }; 40 | 41 | #endif // OPENGLINSTANCE_H 42 | -------------------------------------------------------------------------------- /OpenGL/openglinstancedata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLINSTANCEDATA_H 2 | #define OPENGLINSTANCEDATA_H OpenGLInstanceData 3 | 4 | #include 5 | 6 | class OpenGLInstanceData 7 | { 8 | public: 9 | glm::mat4 m_currModelView; 10 | glm::mat4 m_prevModelView; 11 | glm::mat4 m_normalTransform; 12 | }; 13 | 14 | #endif // OPENGLINSTANCEDATA_H 15 | 16 | -------------------------------------------------------------------------------- /OpenGL/openglinstancemanager.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLINSTANCEMANAGER_H 2 | #define OPENGLINSTANCEMANAGER_H OpenGLInstanceManager 3 | 4 | class OpenGLInstance; 5 | class OpenGLViewport; 6 | #include 7 | 8 | class OpenGLInstanceManagerPrivate; 9 | class OpenGLInstanceManager 10 | { 11 | public: 12 | OpenGLInstanceManager(); 13 | ~OpenGLInstanceManager(); 14 | void create(); 15 | void commit(const OpenGLViewport &view); 16 | void render() const; 17 | void renderAll() const; 18 | OpenGLInstance *createInstance(); 19 | private: 20 | KUniquePointer m_private; 21 | }; 22 | 23 | #endif // OPENGLINSTANCEMANAGER_H 24 | -------------------------------------------------------------------------------- /OpenGL/opengllight.cpp: -------------------------------------------------------------------------------- 1 | #include "opengllight.h" 2 | 3 | OpenGLLight::OpenGLLight() : 4 | m_active(true) 5 | , m_shadowCasting(false) 6 | , m_attenuation(1.0f, 0.01f, 0.1f) 7 | , m_diffuse(0.8f, 0.8f, 0.8f) 8 | , m_specular(1.0f, 1.0f, 1.0f) 9 | { 10 | // Intentionally Empty 11 | } 12 | 13 | void OpenGLLight::setActive(bool b) 14 | { 15 | m_active = b; 16 | } 17 | 18 | bool OpenGLLight::active() const 19 | { 20 | return m_active; 21 | } 22 | -------------------------------------------------------------------------------- /OpenGL/opengllightmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLLIGHTMANAGER_H 2 | #define OPENGLLIGHTMANAGER_H OpenGLLightManager 3 | 4 | class OpenGLPointLight; 5 | class OpenGLSpotLight; 6 | class OpenGLDirectionLight; 7 | class OpenGLSphereLight; 8 | class OpenGLRectangleLight; 9 | class OpenGLPointLightGroup; 10 | class OpenGLSpotLightGroup; 11 | class OpenGLDirectionLightGroup; 12 | class OpenGLSphereLightGroup; 13 | class OpenGLRectangleLightGroup; 14 | class OpenGLScene; 15 | class OpenGLViewport; 16 | #include 17 | 18 | class OpenGLLightManagerPrivate; 19 | class OpenGLLightManager 20 | { 21 | public: 22 | OpenGLLightManager(); 23 | ~OpenGLLightManager(); 24 | void create(); 25 | void commit(const OpenGLViewport &view); 26 | void render(); 27 | void renderShadowed(OpenGLScene &scene); 28 | OpenGLPointLight *createPointLight(); 29 | OpenGLSpotLight *createSpotLight(); 30 | OpenGLDirectionLight *createDirectionLight(); 31 | OpenGLSphereLight *createSphereLight(); 32 | OpenGLRectangleLight *createRectangleLight(); 33 | OpenGLPointLightGroup &pointLights(); 34 | OpenGLSpotLightGroup &spotLights(); 35 | OpenGLDirectionLightGroup &directionLights(); 36 | OpenGLSphereLightGroup &sphereLights(); 37 | OpenGLRectangleLightGroup &rectangleLights(); 38 | private: 39 | KUniquePointer m_private; 40 | }; 41 | 42 | #endif // OPENGLLIGHTMANAGER_H 43 | -------------------------------------------------------------------------------- /OpenGL/openglmarkerresult.cpp: -------------------------------------------------------------------------------- 1 | #include "openglmarkerresult.h" 2 | #include 3 | 4 | QDebug &operator<<(QDebug &dbg, const OpenGLMarkerResult &result) 5 | { 6 | return dbg << qPrintable(result.name()) << ": " << result.elapsedMilliseconds() << "\n"; 7 | } 8 | -------------------------------------------------------------------------------- /OpenGL/openglmarkerscoped.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLMARKERSCOPE_H 2 | #define OPENGLMARKERSCOPE_H OpenGLMarkerScoped 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class OpenGLMarkerScoped 9 | { 10 | public: 11 | OpenGLMarkerScoped(const char *name); 12 | OpenGLMarkerScoped(const std::string &name); 13 | OpenGLMarkerScoped(const KString &name); 14 | ~OpenGLMarkerScoped(); 15 | }; 16 | 17 | inline OpenGLMarkerScoped::OpenGLMarkerScoped(const char *name) { OpenGLProfiler::PushGpuMarker(name); } 18 | inline OpenGLMarkerScoped::OpenGLMarkerScoped(const KString &name) { OpenGLProfiler::PushGpuMarker(qPrintable(name)); } 19 | inline OpenGLMarkerScoped::OpenGLMarkerScoped(const std::string &name) { OpenGLProfiler::PushGpuMarker(name.c_str()); } 20 | inline OpenGLMarkerScoped::~OpenGLMarkerScoped() { OpenGLProfiler::PopGpuMarker(); } 21 | 22 | #endif // OPENGLMARKERSCOPE_H 23 | 24 | -------------------------------------------------------------------------------- /OpenGL/openglmaterial.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLMATERIAL_H 2 | #define OPENGLMATERIAL_H OpenGLMaterial 3 | 4 | class KVector3D; 5 | #include 6 | 7 | class OpenGLMaterialPrivate; 8 | class OpenGLMaterial 9 | { 10 | public: 11 | 12 | OpenGLMaterial(); 13 | ~OpenGLMaterial(); 14 | 15 | // OpenGL 16 | void create(); 17 | void bind(); 18 | void commit(); 19 | void release(); 20 | int objectId() const; 21 | 22 | // Base Color 23 | void setBaseColor(float rgb); 24 | void setBaseColor(float r, float g, float b); 25 | void setBaseColor(KVector3D const &color); 26 | KVector3D const &baseColor() const; 27 | 28 | // Metallic 29 | void setMetallic(float m); 30 | float metallic() const; 31 | 32 | // Roughness 33 | void setRoughness(float r); 34 | float roughness() const; 35 | 36 | 37 | private: 38 | KSharedPointer m_private; 39 | }; 40 | 41 | #endif // OPENGLMATERIAL_H 42 | -------------------------------------------------------------------------------- /OpenGL/openglmaterialdata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLMATERIALDATA_H 2 | #define OPENGLMATERIALDATA_H OpenGLMaterialData 3 | 4 | #include 5 | 6 | class OpenGLMaterialData 7 | { 8 | public: 9 | glm::vec3 m_baseColor; 10 | float m_metallic; 11 | float m_roughness; 12 | float padding0; 13 | float padding1; 14 | float padding2; 15 | }; 16 | 17 | #endif // OPENGLMATERIALDATA_H 18 | 19 | -------------------------------------------------------------------------------- /OpenGL/openglmesh.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLMESH_H 2 | #define OPENGLMESH_H OpenGLMesh 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class KHalfEdgeMesh; 10 | class KAabbBoundingVolume; 11 | 12 | class OpenGLMeshPrivate; 13 | class OpenGLMesh 14 | { 15 | public: 16 | 17 | typedef OpenGLBuffer::UsagePattern UsagePattern; 18 | 19 | // Constructors / Destructor 20 | OpenGLMesh(); 21 | ~OpenGLMesh(); 22 | 23 | // Public Methods 24 | void bind(); 25 | void setUsagePattern(UsagePattern pattern); 26 | void create(const char *filename); 27 | void create(const KHalfEdgeMesh &mesh); 28 | void draw(); 29 | void drawInstanced(size_t begin, size_t end); 30 | void vertexAttribPointer(int location, int elements, OpenGLElementType type, bool normalized, int stride, int offset); 31 | void vertexAttribPointer(int location, int elements, int count, OpenGLElementType type, bool normalized, int stride, int offset); 32 | void vertexAttribPointerDivisor(int location, int elements, OpenGLElementType type, bool normalized, int stride, int offset, int divisor); 33 | void vertexAttribPointerDivisor(int location, int elements, int count, OpenGLElementType type, bool normalized, int stride, int offset, int divisor); 34 | void release(); 35 | bool isCreated() const; 36 | int objectId() const; 37 | KAabbBoundingVolume const &aabb() const; 38 | 39 | private: 40 | KSharedPointer m_private; 41 | }; 42 | 43 | #endif // OPENGLMESH_H 44 | -------------------------------------------------------------------------------- /OpenGL/openglmeshmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "openglmeshmanager.h" 2 | 3 | #include 4 | #include 5 | 6 | typedef std::unordered_map OpenGLMeshMap; 7 | static OpenGLMeshMap sg_meshMap; 8 | 9 | const OpenGLMesh &OpenGLMeshManager::mesh(const std::string &name) 10 | { 11 | return sg_meshMap[name]; 12 | } 13 | 14 | void OpenGLMeshManager::setMesh(const std::string &name, const OpenGLMesh &mesh) 15 | { 16 | sg_meshMap[name] = mesh; 17 | } 18 | -------------------------------------------------------------------------------- /OpenGL/openglmeshmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLMESHMANAGER_H 2 | #define OPENGLMESHMANAGER_H OpenGLMeshManager 3 | 4 | #include 5 | class OpenGLMesh; 6 | 7 | class OpenGLMeshManager 8 | { 9 | public: 10 | static const OpenGLMesh &mesh(const std::string &name); 11 | static void setMesh(const std::string &name, const OpenGLMesh &mesh); 12 | }; 13 | 14 | #endif // OPENGLMESHMANAGER_H 15 | -------------------------------------------------------------------------------- /OpenGL/openglpointlight.cpp: -------------------------------------------------------------------------------- 1 | #include "openglpointlight.h" 2 | 3 | #include 4 | 5 | OpenGLPointLight::OpenGLPointLight() : 6 | m_radius(20.0f) 7 | { 8 | // Intentionally Empty 9 | } 10 | 11 | float OpenGLPointLight::CalculateScalar(int segments, int rings) 12 | { 13 | if (rings % 2) 14 | 15 | // Even Number of rings 16 | return 17 | std::sqrt( 18 | std::pow(Karma::sec(Karma::Pi / segments ), 2.0f) 19 | * std::pow(Karma::sec(Karma::Pi / (2*rings)), 2.0f) 20 | ); 21 | 22 | // Odd number of rings 23 | return 24 | Karma::Sqrt2 25 | * std::sqrt 26 | ( 27 | 1.0f / 28 | ( 29 | 1.0f 30 | + std::cos(Karma::TwoPi / segments) 31 | * std::cos(Karma::Pi / rings) 32 | ) 33 | ); 34 | } 35 | 36 | void OpenGLPointLight::setRadius(float r) 37 | { 38 | m_radius = r; 39 | m_transform.setScale(r * OpenGLPointLight::CalculateScalar(12, 8)); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /OpenGL/openglpointlight.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLPOINTLIGHT_H 2 | #define OPENGLPOINTLIGHT_H OpenGLPointLight 3 | 4 | #include 5 | 6 | class OpenGLPointLightPrivate; 7 | class OpenGLPointLight : public OpenGLTranslationLight 8 | { 9 | public: 10 | OpenGLPointLight(); 11 | 12 | // Static Scalar 13 | static float CalculateScalar(int segments, int rings); 14 | 15 | // Point Light settings 16 | float radius() const; 17 | void setRadius(float r); 18 | 19 | private: 20 | float m_radius; 21 | }; 22 | 23 | inline float OpenGLPointLight::radius() const 24 | { 25 | return m_radius; 26 | } 27 | 28 | #endif // OPENGLPOINTLIGHT_H 29 | -------------------------------------------------------------------------------- /OpenGL/openglpointlightdata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLPOINTLIGHTDATA_H 2 | #define OPENGLPOINTLIGHTDATA_H OpenGLPointLightData 3 | 4 | #include 5 | 6 | class OpenGLPointLightData 7 | { 8 | public: 9 | static int TranslationOffset(); 10 | static int AttenuationOffset(); 11 | static int DiffuseOffset(); 12 | static int SpecularOffset(); 13 | static int PerpectiveOffset(); 14 | glm::vec3 m_viewTrans; // { x, y, z } 15 | glm::vec4 m_attenuation; // { k, d, d^2, radius } 16 | glm::vec3 m_diffuse; // { r, g, b } 17 | glm::vec3 m_specular; // { r, g, b } 18 | glm::mat4 m_perspTrans; // { Model->View->Persp } 19 | }; 20 | 21 | inline int OpenGLPointLightData::TranslationOffset() 22 | { 23 | return offsetof(OpenGLPointLightData, m_viewTrans); 24 | } 25 | 26 | inline int OpenGLPointLightData::AttenuationOffset() 27 | { 28 | return offsetof(OpenGLPointLightData, m_attenuation); 29 | } 30 | 31 | inline int OpenGLPointLightData::DiffuseOffset() 32 | { 33 | return offsetof(OpenGLPointLightData, m_diffuse); 34 | } 35 | 36 | inline int OpenGLPointLightData::SpecularOffset() 37 | { 38 | return offsetof(OpenGLPointLightData, m_specular); 39 | } 40 | 41 | inline int OpenGLPointLightData::PerpectiveOffset() 42 | { 43 | return offsetof(OpenGLPointLightData, m_perspTrans); 44 | } 45 | 46 | #endif // OPENGLPOINTLIGHTDATA_H 47 | -------------------------------------------------------------------------------- /OpenGL/openglpointlightgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLPOINTLIGHTGROUP_H 2 | #define OPENGLPOINTLIGHTGROUP_H OpenGLPointLightGroup 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | extern KMatrix4x4 testView; 10 | extern KMatrix4x4 testPerspective; 11 | 12 | class KMatrix4x4; 13 | class OpenGLMesh; 14 | class OpenGLRenderBlock; 15 | 16 | class OpenGLPointLightGroupPrivate; 17 | class OpenGLPointLightGroup : public OpenGLLightGroup 18 | { 19 | public: 20 | bool create(); 21 | void initializeMesh(OpenGLMesh &mesh); 22 | void translateBuffer(const OpenGLRenderBlock &stats, DataPointer data, ConstLightIterator begin, ConstLightIterator end); 23 | void translateUniforms(const OpenGLRenderBlock &stats, Byte *data, SizeType step, ConstLightIterator begin, ConstLightIterator end); 24 | }; 25 | 26 | #endif // OPENGLPOINTLIGHTGROUP_H 27 | -------------------------------------------------------------------------------- /OpenGL/openglprofiler.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLPROFILER_H 2 | #define OPENGLPROFILER_H OpenGLProfiler 3 | 4 | #include 5 | class OpenGLFrameResults; 6 | 7 | class OpenGLProfilerPrivate; 8 | class OpenGLProfiler : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | // Constructors / Destructors 13 | explicit OpenGLProfiler(QObject *parent = 0); 14 | ~OpenGLProfiler(); 15 | 16 | // Profiler Actions 17 | bool initialize(); 18 | void beginFrame(); 19 | void pushGpuMarker(char const *name); 20 | void popGpuMarker(); 21 | void endFrame(); 22 | 23 | // Global Profiler Action 24 | inline static void BeginFrame(); 25 | inline static void PushGpuMarker(char const *name); 26 | inline static void PopGpuMarker(); 27 | inline static void EndFrame(); 28 | 29 | // Global Settings 30 | static OpenGLProfiler* profiler(); 31 | static void setProfiler(OpenGLProfiler *profiler); 32 | 33 | signals: 34 | void frameResultsAvailable(const OpenGLFrameResults& result); 35 | 36 | private: 37 | OpenGLProfilerPrivate *m_private; 38 | }; 39 | 40 | #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) 41 | inline void OpenGLProfiler::BeginFrame() { profiler()->beginFrame(); } 42 | inline void OpenGLProfiler::PushGpuMarker(char const *name) { profiler()->pushGpuMarker(name); } 43 | inline void OpenGLProfiler::PopGpuMarker() { profiler()->popGpuMarker(); } 44 | inline void OpenGLProfiler::EndFrame() { profiler()->endFrame(); } 45 | #else 46 | inline void OpenGLProfiler::BeginFrame() { } 47 | inline void OpenGLProfiler::PushGpuMarker(char const *name) { (void)name; } 48 | inline void OpenGLProfiler::PopGpuMarker() { } 49 | inline void OpenGLProfiler::EndFrame() { } 50 | #endif 51 | 52 | #endif // OPENGLPROFILER_H 53 | -------------------------------------------------------------------------------- /OpenGL/openglprofilervisualizer.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLPROFILERVISUALIZER_H 2 | #define OPENGLPROFILERVISUALIZER_H OpenGLProfilerVisualizer 3 | 4 | #include 5 | 6 | class QMoveEvent; 7 | class OpenGLFrameResults; 8 | 9 | class OpenGLProfilerVisualizerPrivate; 10 | class OpenGLProfilerVisualizer : public QObject 11 | { 12 | Q_OBJECT 13 | public: 14 | 15 | // Constructors / Destructors 16 | explicit OpenGLProfilerVisualizer(QObject *parent = 0); 17 | ~OpenGLProfilerVisualizer(); 18 | 19 | // Public Methods 20 | void setBorder(int left, int right, int top, int bottom); 21 | void setOffset(float left, float right, float top, float bottom); 22 | 23 | // OpenGL Methods 24 | void resizeGL(int width, int height); 25 | void paintGL(); 26 | 27 | // Events 28 | void moveEvent(const QMoveEvent *ev); 29 | 30 | public slots: 31 | void frameResultsAvailable(OpenGLFrameResults const &results); 32 | 33 | private: 34 | OpenGLProfilerVisualizerPrivate *m_private; 35 | }; 36 | 37 | #endif // OPENGLPROFILERVISUALIZER_H 38 | -------------------------------------------------------------------------------- /OpenGL/openglrectanglelight.cpp: -------------------------------------------------------------------------------- 1 | #include "openglrectanglelight.h" 2 | 3 | OpenGLRectangleLight::OpenGLRectangleLight() : 4 | m_halfWidth(0.5f), m_halfHeight(0.5f) 5 | { 6 | // Intentionally Empty 7 | } 8 | 9 | void OpenGLRectangleLight::setWidth(float w) 10 | { 11 | m_halfWidth = w / 2.0f; 12 | } 13 | 14 | void OpenGLRectangleLight::setHalfWidth(float hw) 15 | { 16 | m_halfWidth = hw; 17 | } 18 | 19 | void OpenGLRectangleLight::setHeight(float h) 20 | { 21 | m_halfHeight = h / 2.0f; 22 | } 23 | 24 | void OpenGLRectangleLight::setHalfHeight(float hh) 25 | { 26 | m_halfHeight = hh; 27 | } 28 | 29 | void OpenGLRectangleLight::setDimensions(float w, float h) 30 | { 31 | m_halfWidth = w / 2.0f; 32 | m_halfHeight = h / 2.0f; 33 | } 34 | 35 | void OpenGLRectangleLight::setHalfDimensions(float hw, float hh) 36 | { 37 | m_halfWidth = hw; 38 | m_halfHeight = hh; 39 | } 40 | 41 | float OpenGLRectangleLight::width() const 42 | { 43 | return 2.0 * m_halfWidth; 44 | } 45 | 46 | float OpenGLRectangleLight::halfWidth() const 47 | { 48 | return m_halfWidth; 49 | } 50 | 51 | float OpenGLRectangleLight::height() const 52 | { 53 | return 2.0 * m_halfHeight; 54 | } 55 | 56 | float OpenGLRectangleLight::halfHeight() const 57 | { 58 | return m_halfHeight; 59 | } 60 | -------------------------------------------------------------------------------- /OpenGL/openglrectanglelight.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRECTANGLELIGHT_H 2 | #define OPENGLRECTANGLELIGHT_H OpenGLRectangleLight 3 | 4 | #include 5 | 6 | class OpenGLRectangleLight : public OpenGLAreaLight 7 | { 8 | public: 9 | OpenGLRectangleLight(); 10 | 11 | void setWidth(float w); 12 | void setHalfWidth(float hw); 13 | void setHeight(float h); 14 | void setHalfHeight(float hh); 15 | void setDimensions(float w, float h); 16 | void setHalfDimensions(float hw, float hh); 17 | float width() const; 18 | float halfWidth() const; 19 | float height() const; 20 | float halfHeight() const; 21 | 22 | private: 23 | float m_halfWidth; 24 | float m_halfHeight; 25 | }; 26 | 27 | #endif // OPENGLRECTANGLELIGHT_H 28 | -------------------------------------------------------------------------------- /OpenGL/openglrectanglelightgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRECTANGLELIGHTGROUP_H 2 | #define OPENGLRECTANGLELIGHTGROUP_H OpenGLRectangleLightGroup 3 | 4 | class OpenGLViewport; 5 | class OpenGLRectangleLight; 6 | #include 7 | #include 8 | #include 9 | 10 | class OpenGLRectangleLightGroupPrivate; 11 | class OpenGLRectangleLightGroup 12 | { 13 | public: 14 | typedef std::vector LightContainer; 15 | typedef LightContainer::size_type SizeType; 16 | OpenGLRectangleLightGroup(); 17 | ~OpenGLRectangleLightGroup(); 18 | 19 | bool create(); 20 | void commit(const OpenGLViewport &view); 21 | void draw(); 22 | OpenGLRectangleLight *createLight(); 23 | 24 | LightContainer::iterator begin(); 25 | LightContainer::iterator end(); 26 | SizeType size() const; 27 | OpenGLRectangleLight *operator[](int idx); 28 | private: 29 | KUniquePointer m_private; 30 | }; 31 | 32 | #endif // OPENGLRECTANGLELIGHTGROUP_H 33 | -------------------------------------------------------------------------------- /OpenGL/openglrenderblock.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRENDERBLOCK_H 2 | #define OPENGLRENDERBLOCK_H OpenGLRenderBlock 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class KMatrix4x4; 9 | class KSize; 10 | class KVector2D; 11 | 12 | class OpenGLRenderBlockPrivate; 13 | class OpenGLRenderBlock : public OpenGLUniformBufferObject 14 | { 15 | public: 16 | 17 | // Constructors / Destructor 18 | OpenGLRenderBlock(); 19 | ~OpenGLRenderBlock(); 20 | 21 | // Render Block Properties 22 | void setViewMatrix(const KMatrix4x4 &view); 23 | void setPerspectiveMatrix(const KMatrix4x4 &perspective); 24 | void setOrigin(const KVector2D &origin); 25 | void setNearFar(float nearPlane, float farPlane); 26 | void setDimensions(int width, int height); 27 | void setDimensions(const KSize &size); 28 | void setExposure(float e); 29 | 30 | // Access Render Block Properties 31 | const glm::mat4 &worldToView() const; 32 | const glm::mat4 &viewToWorld() const; 33 | const glm::mat4 &worldToPersp() const; 34 | const glm::mat4 &perspToWorld() const; 35 | const glm::mat4 &viewToPersp() const; 36 | const glm::mat4 &perspToView() const; 37 | float nearPlane() const; 38 | float farPlane() const; 39 | float diffPlane() const; 40 | float sumPlane() const; 41 | int width() const; 42 | int height() const; 43 | 44 | // Public Methods 45 | void update(); 46 | void allocate(); 47 | bool dirty() const; 48 | 49 | private: 50 | KUniquePointer m_private; 51 | }; 52 | 53 | #endif // OPENGLRENDERBLOCK_H 54 | -------------------------------------------------------------------------------- /OpenGL/openglrenderblockdata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRENDERBLOCKDATA_H 2 | #define OPENGLRENDERBLOCKDATA_H OpenGLRenderBlockData 3 | 4 | #include 5 | 6 | class OpenGLRenderBlockData 7 | { 8 | public: 9 | // Most frequent to change 10 | glm::mat4 m_view; 11 | glm::mat4 i_view; 12 | 13 | // Co-dependant 14 | glm::mat4 m_viewProjection; 15 | glm::mat4 i_viewProjection; 16 | 17 | // Least frequent to change 18 | glm::mat4 m_projection; 19 | glm::mat4 i_projection; 20 | 21 | // Render Settings 22 | glm::vec2 v_dimensions; 23 | glm::vec2 v_offset; 24 | float f_nearPlane; 25 | float f_farPlane; 26 | float f_diffPlane; 27 | float f_sumPlane; 28 | float f_exposure; 29 | }; 30 | 31 | #endif // OPENGLRENDERBLOCKDATA_H 32 | -------------------------------------------------------------------------------- /OpenGL/openglrenderbufferobject.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRENDERBUFFEROBJECT_H 2 | #define OPENGLRENDERBUFFEROBJECT_H OpenGLRenderbufferObject 3 | 4 | #include 5 | 6 | class KSize; 7 | 8 | class OpenGLRenderbufferObjectPrivate; 9 | class OpenGLRenderbufferObject 10 | { 11 | public: 12 | OpenGLRenderbufferObject(); 13 | ~OpenGLRenderbufferObject(); 14 | 15 | void create(); 16 | void bind(); 17 | void release(); 18 | void setInternalFormat(OpenGLInternalFormat storage); 19 | OpenGLInternalFormat internalFormat() const; 20 | OpenGLFormat format() const; 21 | OpenGLType texelType() const; 22 | void setSize(int width, int height); 23 | void setSize(KSize const &size); 24 | KSize const& size() const; 25 | int objectId(); 26 | void allocate(); 27 | 28 | private: 29 | OpenGLRenderbufferObjectPrivate *m_private; 30 | void removeReference(); 31 | }; 32 | 33 | #endif // OPENGLRENDERBUFFEROBJECT_H 34 | -------------------------------------------------------------------------------- /OpenGL/openglrenderer.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRENDERER_H 2 | #define OPENGLRENDERER_H OpenGLRenderer 3 | 4 | class OpenGLScene; 5 | class OpenGLRenderBlock; 6 | class OpenGLRenderPass; 7 | class OpenGLViewport; 8 | 9 | class OpenGLRendererPrivate; 10 | class OpenGLRenderer 11 | { 12 | public: 13 | OpenGLRenderer(); 14 | 15 | // Render Passes 16 | void bind(); 17 | void create(); 18 | void resize(int width, int height); 19 | void render(OpenGLScene &scene); 20 | void teardown(); 21 | void release(); 22 | 23 | // Object Manipulation 24 | void pause(bool p); 25 | bool isPaused() const; 26 | 27 | // Pass Manipulation 28 | template 29 | T *addPass(); 30 | template 31 | T *pass(); 32 | 33 | OpenGLRenderPass *pass(int id); 34 | void registerViewport(OpenGLViewport *view); 35 | static void activateViewport(OpenGLViewport *view); 36 | 37 | private: 38 | void addPass(OpenGLRenderPass *pass); 39 | OpenGLRendererPrivate *m_private; 40 | }; 41 | 42 | template 43 | T *OpenGLRenderer::addPass() 44 | { 45 | T *pass = new T; 46 | addPass(pass); 47 | return pass; 48 | } 49 | 50 | template 51 | T *OpenGLRenderer::pass() 52 | { 53 | return pass(T::passId()); 54 | } 55 | 56 | #endif // OPENGLRENDERER_H 57 | -------------------------------------------------------------------------------- /OpenGL/openglrenderpass.cpp: -------------------------------------------------------------------------------- 1 | #include "openglrenderpass.h" 2 | 3 | OpenGLRenderPass::OpenGLRenderPass() : 4 | m_active(true) 5 | { 6 | // Intentionally Empty 7 | } 8 | 9 | void OpenGLRenderPass::setActive(bool a) 10 | { 11 | m_active = a; 12 | } 13 | 14 | bool OpenGLRenderPass::active() const 15 | { 16 | return m_active; 17 | } 18 | -------------------------------------------------------------------------------- /OpenGL/openglrenderpass.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRENDERPASS_H 2 | #define OPENGLRENDERPASS_H OpenGLRenderPass 3 | 4 | class OpenGLScene; 5 | class OpenGLViewport; 6 | class OpenGLRenderer; 7 | 8 | class OpenGLRenderPass 9 | { 10 | public: 11 | OpenGLRenderPass(); 12 | virtual unsigned id() const = 0; 13 | virtual void initialize() = 0; 14 | virtual void resize(int width, int height) = 0; 15 | virtual void commit(OpenGLViewport &view) = 0; 16 | virtual void render(OpenGLScene &scene) = 0; 17 | virtual void teardown() = 0; 18 | virtual OpenGLRenderPass *clone() const = 0; 19 | void setActive(bool a); 20 | bool active() const; 21 | private: 22 | bool m_active; 23 | }; 24 | 25 | template 26 | class OpenGLRenderPassImpl : public OpenGLRenderPass 27 | { 28 | public: 29 | virtual unsigned id() const; 30 | virtual OpenGLRenderPass *clone() const; 31 | static unsigned passId(); 32 | }; 33 | 34 | template 35 | unsigned OpenGLRenderPassImpl::id() const 36 | { 37 | return ID; 38 | } 39 | 40 | template 41 | unsigned OpenGLRenderPassImpl::passId() 42 | { 43 | return ID; 44 | } 45 | 46 | template 47 | OpenGLRenderPass *OpenGLRenderPassImpl::clone() const 48 | { 49 | return new PASS(); 50 | } 51 | 52 | #endif // OPENGLRENDERPASS_H 53 | -------------------------------------------------------------------------------- /OpenGL/openglrenderpassqueue.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRENDERPASSQUEUE_H 2 | #define OPENGLRENDERPASSQUEUE_H OpenGLRenderPassQueue 3 | 4 | class KSize; 5 | class OpenGLRenderPass; 6 | class OpenGLScene; 7 | class OpenGLViewport; 8 | 9 | #include 10 | #include 11 | 12 | class OpenGLRenderPassQueuePrivate; 13 | class OpenGLRenderPassQueue 14 | { 15 | public: 16 | 17 | typedef std::vector RenderPassContainer; 18 | typedef const std::vector ConstRenderPassContainer; 19 | 20 | OpenGLRenderPassQueue(); 21 | ~OpenGLRenderPassQueue(); 22 | 23 | void create(); 24 | void create(const OpenGLRenderPassQueue &queue); 25 | void resize(const KSize &size); 26 | void resize(int width, int height); 27 | void commit(OpenGLViewport &view); 28 | void render(OpenGLScene &scene); 29 | void teardown(); 30 | 31 | OpenGLRenderPass *pass(unsigned id); 32 | RenderPassContainer &passes(); 33 | void addPass(OpenGLRenderPass *pass); 34 | ConstRenderPassContainer &passes() const; 35 | 36 | private: 37 | KSharedPointer m_private; 38 | }; 39 | 40 | #endif // OPENGLRENDERPASSQUEUE_H 41 | -------------------------------------------------------------------------------- /OpenGL/openglrenderview.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLRENDERVIEW_H 2 | #define OPENGLRENDERVIEW_H OpenGLRenderView 3 | 4 | #include 5 | 6 | class KSize; 7 | class OpenGLRenderPassQueue; 8 | class OpenGLViewport; 9 | class OpenGLScene; 10 | 11 | class OpenGLRenderViewPrivate; 12 | class OpenGLRenderView 13 | { 14 | public: 15 | 16 | // Constructors / Destructor 17 | OpenGLRenderView(); 18 | ~OpenGLRenderView(); 19 | 20 | // Render Pass Queue 21 | void create(const OpenGLRenderPassQueue &queue, OpenGLViewport &view); 22 | void bind(); 23 | void resize(const KSize &size); 24 | void resize(int width, int height); 25 | void commit(OpenGLScene &scene); 26 | void render(OpenGLScene &scene); 27 | void teardown(); 28 | void release(); 29 | OpenGLRenderPassQueue *passes(); 30 | 31 | private: 32 | KSharedPointer m_private; 33 | }; 34 | 35 | #endif // OPENGLRENDERVIEW_H 36 | -------------------------------------------------------------------------------- /OpenGL/openglscene.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSCENE_H 2 | #define OPENGLSCENE_H OpenGLScene 3 | 4 | class OpenGLUpdateEvent; 5 | class OpenGLInstance; 6 | class OpenGLPointLight; 7 | class OpenGLSphereLight; 8 | class OpenGLRectangleLight; 9 | class OpenGLSpotLight; 10 | class OpenGLDirectionLight; 11 | class OpenGLPointLightGroup; 12 | class OpenGLSphereLightGroup; 13 | class OpenGLSpotLightGroup; 14 | class OpenGLDirectionLightGroup; 15 | class OpenGLRectangleLightGroup; 16 | class OpenGLViewport; 17 | class OpenGLEnvironment; 18 | #include 19 | 20 | class OpenGLScenePrivate; 21 | class OpenGLScene 22 | { 23 | public: 24 | 25 | // Constructors / Destructor 26 | OpenGLScene(); 27 | virtual ~OpenGLScene(); 28 | 29 | // Virtual Scene functions 30 | virtual void start(); 31 | virtual void update(OpenGLUpdateEvent *event); 32 | virtual void end(); 33 | 34 | // Object Creation 35 | OpenGLInstance *createInstance(); 36 | OpenGLPointLight *createPointLight(); 37 | OpenGLSpotLight *createSpotLight(); 38 | OpenGLSphereLight *createSphereLight(); 39 | OpenGLRectangleLight *createRectangleLight(); 40 | OpenGLDirectionLight *createDirectionLight(); 41 | OpenGLPointLightGroup &pointLights(); 42 | OpenGLSpotLightGroup &spotLights(); 43 | OpenGLDirectionLightGroup &directionLights(); 44 | OpenGLSphereLightGroup &sphereLights(); 45 | OpenGLRectangleLightGroup &rectangleLights(); 46 | void renderGeometry(); 47 | void renderAllGeometry(); 48 | void renderLights(); 49 | void renderShadowedLights(); 50 | void commit(const OpenGLViewport &view); 51 | 52 | // Scene stats 53 | OpenGLEnvironment *environment(); 54 | 55 | private: 56 | KUniquePointer m_private; 57 | }; 58 | 59 | #endif // OPENGLSCENE_H 60 | -------------------------------------------------------------------------------- /OpenGL/openglscenemanager.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSCENEMANAGER_H 2 | #define OPENGLSCENEMANAGER_H OpenGLSceneManager 3 | 4 | #include 5 | class OpenGLUpdateEvent; 6 | class OpenGLScene; 7 | 8 | class OpenGLSceneManagerPrivate; 9 | class OpenGLSceneManager 10 | { 11 | public: 12 | OpenGLSceneManager(); 13 | ~OpenGLSceneManager(); 14 | OpenGLScene *currentScene(); 15 | void setScene(OpenGLScene *scene); 16 | void pushScene(OpenGLScene *scene); 17 | void popScene(); 18 | void update(OpenGLUpdateEvent *event); 19 | bool empty(); 20 | bool activeScene(); 21 | private: 22 | KUniquePointer m_private; 23 | }; 24 | 25 | #endif // OPENGLSCENEMANAGER_H 26 | -------------------------------------------------------------------------------- /OpenGL/openglshadowcastingspotlightgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSHADOWCASTINGSPOTLIGHTGROUP_H 2 | #define OPENGLSHADOWCASTINGSPOTLIGHTGROUP_H 3 | 4 | #include 5 | #include 6 | 7 | class OpenGLShadowCastingSpotLightGroup 8 | { 9 | public: 10 | OpenGLShadowCastingSpotLightGroup(); 11 | ~OpenGLShadowCastingSpotLightGroup(); 12 | 13 | OpenGLSpotLight *createLight(); 14 | void update(); 15 | void draw(); 16 | 17 | private: 18 | std::vector m_lights; 19 | }; 20 | 21 | #endif // OPENGLSHADOWCASTINGSPOTLIGHTGROUP_H 22 | -------------------------------------------------------------------------------- /OpenGL/openglslparser.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSLPARSER_H 2 | #define OPENGLSLPARSER_H OpenGLSLParser 3 | 4 | #include 5 | #include 6 | 7 | class KAbstractWriter; 8 | 9 | class OpenGLSLParserPrivate; 10 | class OpenGLSLParser 11 | { 12 | public: 13 | typedef std::vector Autoresolver; 14 | typedef std::vector Autosampler; 15 | OpenGLSLParser(KAbstractReader *reader, KAbstractWriter *writer); 16 | virtual ~OpenGLSLParser(); 17 | 18 | void initialize(); 19 | void setFilePath(char const *filePath); 20 | void setAutoresolver(Autoresolver *a); 21 | void setAutosampler(Autosampler *a); 22 | void addIncludePath(char const *path); 23 | static void addSharedIncludePath(char const *path); 24 | bool parse(); 25 | 26 | private: 27 | OpenGLSLParserPrivate *m_private; 28 | }; 29 | 30 | 31 | #endif // OPENGLSLPARSER_H 32 | -------------------------------------------------------------------------------- /OpenGL/openglspherelight.cpp: -------------------------------------------------------------------------------- 1 | #include "openglspherelight.h" 2 | 3 | OpenGLSphereLight::OpenGLSphereLight() : 4 | m_radius(0.5f) 5 | { 6 | // Intentionally Empty 7 | } 8 | 9 | void OpenGLSphereLight::setRadius(float r) 10 | { 11 | m_radius = r; 12 | } 13 | 14 | float OpenGLSphereLight::radius() const 15 | { 16 | return m_radius; 17 | } 18 | -------------------------------------------------------------------------------- /OpenGL/openglspherelight.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSPHERELIGHT_H 2 | #define OPENGLSPHERELIGHT_H OpenGLSphereLight 3 | 4 | #include 5 | 6 | class OpenGLSphereLight : public OpenGLAreaLight 7 | { 8 | public: 9 | OpenGLSphereLight(); 10 | 11 | void setRadius(float r); 12 | float radius() const; 13 | 14 | private: 15 | float m_radius; 16 | }; 17 | 18 | #endif // OPENGLSPHERELIGHT_H 19 | -------------------------------------------------------------------------------- /OpenGL/openglspherelightgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSPHERELIGHTGROUP_H 2 | #define OPENGLSPHERELIGHTGROUP_H OpenGLSphereLightGroup 3 | 4 | class OpenGLViewport; 5 | class OpenGLSphereLight; 6 | #include 7 | #include 8 | 9 | class OpenGLSphereLightGroupPrivate; 10 | class OpenGLSphereLightGroup 11 | { 12 | public: 13 | typedef std::vector LightContainer; 14 | typedef LightContainer::size_type SizeType; 15 | OpenGLSphereLightGroup(); 16 | ~OpenGLSphereLightGroup(); 17 | 18 | bool create(); 19 | void commit(const OpenGLViewport &view); 20 | void draw(); 21 | OpenGLSphereLight *createLight(); 22 | 23 | LightContainer::iterator begin(); 24 | LightContainer::iterator end(); 25 | OpenGLSphereLight *operator[](int idx); 26 | SizeType size() const; 27 | private: 28 | KUniquePointer m_private; 29 | }; 30 | 31 | #endif // OPENGLSPHERELIGHTGROUP_H 32 | -------------------------------------------------------------------------------- /OpenGL/openglspotlight.cpp: -------------------------------------------------------------------------------- 1 | #include "openglspotlight.h" 2 | 3 | #include 4 | 5 | OpenGLSpotLight::OpenGLSpotLight() : 6 | m_depth(20.0f) 7 | { 8 | setInnerAngle(15.0f); 9 | setOuterAngle(30.0f); 10 | } 11 | 12 | float OpenGLSpotLight::CalculateScalar(int segments) 13 | { 14 | float segArcLength = Karma::Pi / segments; 15 | float yAxisLength = Karma::sec(segArcLength); 16 | return std::abs(yAxisLength); 17 | } 18 | 19 | void OpenGLSpotLight::setInnerAngle(float angle) 20 | { 21 | angle /= 2.0f; 22 | float rads = Karma::DegreesToRads(angle); 23 | m_innerAngle = std::cos(rads); 24 | } 25 | 26 | void OpenGLSpotLight::setOuterAngle(float angle) 27 | { 28 | angle /= 2.0f; 29 | float rads = Karma::DegreesToRads(angle); 30 | m_outerAngle = std::cos(rads); 31 | m_angleOfInfluence = rads; 32 | } 33 | 34 | void OpenGLSpotLight::setDepth(float d) 35 | { 36 | float dz = d * std::tan(m_angleOfInfluence) * CalculateScalar(32); 37 | m_depth = d; 38 | m_transform.setScaleX(dz); 39 | m_transform.setScaleY(dz); 40 | m_transform.setScaleZ(d); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /OpenGL/openglspotlight.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSPOTLIGHT_H 2 | #define OPENGLSPOTLIGHT_H OpenGLSpotLight 3 | 4 | #include 5 | 6 | class OpenGLSpotLightPrivate; 7 | class OpenGLSpotLight : public OpenGLTranslationLight 8 | { 9 | public: 10 | OpenGLSpotLight(); 11 | 12 | // Static Scalar 13 | static float CalculateScalar(int segments); 14 | 15 | // Spotlight Settings 16 | void setInnerAngle(float angle); 17 | float innerAngle() const; 18 | void setOuterAngle(float angle); 19 | float outerAngle() const; 20 | void setDepth(float d); 21 | float depth() const; 22 | 23 | private: 24 | float m_depth; 25 | float m_innerAngle; 26 | float m_outerAngle; 27 | float m_angleOfInfluence; 28 | }; 29 | 30 | inline float OpenGLSpotLight::innerAngle() const 31 | { 32 | return m_innerAngle; 33 | } 34 | 35 | inline float OpenGLSpotLight::outerAngle() const 36 | { 37 | return m_outerAngle; 38 | } 39 | 40 | inline float OpenGLSpotLight::depth() const 41 | { 42 | return m_depth; 43 | } 44 | 45 | #endif // OPENGLSPOTLIGHT_H 46 | -------------------------------------------------------------------------------- /OpenGL/openglspotlightdata.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSPOTLIGHTDATA_H 2 | #define OPENGLSPOTLIGHTDATA_H OpenGLSpotLightData 3 | 4 | #include 5 | 6 | class OpenGLSpotLightData 7 | { 8 | public: 9 | static int TranslationOffset(); 10 | static int DirectionOffset(); 11 | static int AttenuationOffset(); 12 | static int DiffuseOffset(); 13 | static int SpecularOffset(); 14 | static int PerpectiveOffset(); 15 | glm::mat4 m_perspTrans; // { Model->View->Persp } 16 | glm::vec4 m_attenuation; // { k, d, d^2, radius } 17 | glm::vec3 m_viewTrans; // { x, y, z } 18 | float m_innerAngle; // { inner } 19 | glm::vec3 m_direction; // { x, y, z } 20 | float m_outerAngle; // { outer } 21 | glm::vec3 m_diffuse; // { r, g, b } 22 | float m_diffAngle; // { outer - inner } 23 | glm::vec3 m_specular; // { r, g, b } 24 | }; 25 | 26 | inline int OpenGLSpotLightData::TranslationOffset() 27 | { 28 | return offsetof(OpenGLSpotLightData, m_viewTrans); 29 | } 30 | 31 | inline int OpenGLSpotLightData::DirectionOffset() 32 | { 33 | return offsetof(OpenGLSpotLightData, m_direction); 34 | } 35 | 36 | inline int OpenGLSpotLightData::AttenuationOffset() 37 | { 38 | return offsetof(OpenGLSpotLightData, m_attenuation); 39 | } 40 | 41 | inline int OpenGLSpotLightData::DiffuseOffset() 42 | { 43 | return offsetof(OpenGLSpotLightData, m_diffuse); 44 | } 45 | 46 | inline int OpenGLSpotLightData::SpecularOffset() 47 | { 48 | return offsetof(OpenGLSpotLightData, m_specular); 49 | } 50 | 51 | inline int OpenGLSpotLightData::PerpectiveOffset() 52 | { 53 | return offsetof(OpenGLSpotLightData, m_perspTrans); 54 | } 55 | 56 | #endif // OPENGLSPOTLIGHTDATA_H 57 | -------------------------------------------------------------------------------- /OpenGL/openglspotlightgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLSPOTLIGHTGROUP_H 2 | #define OPENGLSPOTLIGHTGROUP_H OpenGLSpotLightGroup 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class KMatrix4x4; 9 | class OpenGLMesh; 10 | 11 | class OpenGLSpotLightGroup : public OpenGLLightGroup 12 | { 13 | public: 14 | bool create(); 15 | void initializeMesh(OpenGLMesh &mesh); 16 | void translateBuffer(const OpenGLRenderBlock &stats, DataPointer data, ConstLightIterator begin, ConstLightIterator end); 17 | void translateUniforms(const OpenGLRenderBlock &stats, Byte *data, SizeType step, ConstLightIterator begin, ConstLightIterator end); 18 | }; 19 | 20 | #endif // OPENGLSPOTLIGHTGROUP_H 21 | -------------------------------------------------------------------------------- /OpenGL/opengltonemappingfunction.cpp: -------------------------------------------------------------------------------- 1 | #include "opengltonemappingfunction.h" 2 | 3 | OpenGLStandardToneMapping::OpenGLStandardToneMapping(float exposure, float contrast) : 4 | m_exposure(exposure), m_contrast(contrast) 5 | { 6 | // Intentionally Empty 7 | } 8 | 9 | RgbF OpenGLStandardToneMapping::operator()(RgbF input) const 10 | { 11 | RgbF eC = m_exposure * input; 12 | return std::pow(eC / (eC + 1.0f), m_contrast / 2.2); 13 | } 14 | 15 | 16 | 17 | RgbF OpenGLDefaultToneMapping::operator()(RgbF input) const 18 | { 19 | return input; 20 | } 21 | -------------------------------------------------------------------------------- /OpenGL/opengluniformbuffermanager.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLUNIFORMMANAGER_H 2 | #define OPENGLUNIFORMMANAGER_H OpenGLUniformManager 3 | 4 | #include 5 | 6 | class OpenGLShaderProgram; 7 | class OpenGLUniformBufferObject; 8 | 9 | class OpenGLUniformManager 10 | { 11 | public: 12 | static void setTextureSampler(std::string const &name, unsigned textureId); 13 | static void setUniformBufferIndex(std::string const &name, unsigned index); 14 | static void registerTextureSamplerCallbacks(std::string const &name, OpenGLShaderProgram &program); 15 | static void registerUniformBufferCallbacks(std::string const &name, OpenGLShaderProgram &program); 16 | }; 17 | 18 | #endif // OPENGLUNIFORMMANAGER_H 19 | -------------------------------------------------------------------------------- /OpenGL/opengluniformbufferobject.cpp: -------------------------------------------------------------------------------- 1 | #include "opengluniformbufferobject.h" 2 | #include 3 | 4 | static GLuint sg_bindings[GL_MAX_UNIFORM_BUFFER_BINDINGS] = { 0 }; 5 | 6 | class OpenGLUniformBufferObjectPrivate 7 | { 8 | public: 9 | // Reserved for future use 10 | }; 11 | 12 | OpenGLUniformBufferObject::OpenGLUniformBufferObject() : 13 | OpenGLBuffer(OpenGLBuffer::UniformBuffer) 14 | ,m_private(new OpenGLUniformBufferObjectPrivate) 15 | { 16 | // Intentionally Empty 17 | } 18 | 19 | OpenGLUniformBufferObject::~OpenGLUniformBufferObject() 20 | { 21 | delete m_private; 22 | } 23 | 24 | void OpenGLUniformBufferObject::bindBase(unsigned uniformIndex) 25 | { 26 | sg_bindings[uniformIndex] = bufferId(); 27 | GL::glBindBufferBase(GL_UNIFORM_BUFFER, uniformIndex, sg_bindings[uniformIndex]); 28 | } 29 | 30 | void OpenGLUniformBufferObject::release() 31 | { 32 | this->OpenGLBuffer::release(); 33 | } 34 | 35 | GLuint OpenGLUniformBufferObject::boundBufferId(unsigned index) 36 | { 37 | return sg_bindings[index]; 38 | } 39 | 40 | void OpenGLUniformBufferObject::bindBufferId(unsigned index, GLuint buffer) 41 | { 42 | sg_bindings[index] = buffer; 43 | } 44 | 45 | int OpenGLUniformBufferObject::getAlignment() 46 | { 47 | GLint offset; 48 | GL::glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &offset); 49 | return int(offset); 50 | } 51 | 52 | int OpenGLUniformBufferObject::alignmentOffset() 53 | { 54 | const static int alignmentOffset = getAlignment(); 55 | return alignmentOffset; 56 | } 57 | -------------------------------------------------------------------------------- /OpenGL/openglupdateevent.cpp: -------------------------------------------------------------------------------- 1 | #include "openglupdateevent.h" 2 | 3 | /******************************************************************************* 4 | * OpenGLError methods 5 | ******************************************************************************/ 6 | QEvent::Type OpenGLUpdateEvent::eventType() 7 | { 8 | static QEvent::Type customEventType = 9 | static_cast(QEvent::registerEventType()); 10 | return customEventType; 11 | } 12 | -------------------------------------------------------------------------------- /OpenGL/openglupdateevent.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLUPDATEEVENT_H 2 | #define OPENGLUPDATEEVENT_H OpenGLUpdateEvent 3 | 4 | #include 5 | 6 | class OpenGLUpdateEvent : public QEvent 7 | { 8 | public: 9 | OpenGLUpdateEvent(); 10 | // Static Access 11 | static QEvent::Type eventType(); 12 | }; 13 | 14 | inline OpenGLUpdateEvent::OpenGLUpdateEvent() : QEvent(OpenGLUpdateEvent::eventType()) {} 15 | 16 | #endif // OPENGLUPDATEEVENT_H 17 | -------------------------------------------------------------------------------- /OpenGL/openglvertexarrayobject.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLVERTEXARRAYOBJECT_H 2 | #define OPENGLVERTEXARRAYOBJECT_H OpenGLVertexArrayObject 3 | 4 | #include 5 | #include 6 | 7 | // Register to check OpenGLVertexArrayObject 8 | class OpenGLVertexArrayObjectChecked : public QOpenGLVertexArrayObject 9 | { 10 | public: 11 | explicit OpenGLVertexArrayObjectChecked(QObject *parent = 0) : QOpenGLVertexArrayObject(parent) {} 12 | GL_CHECK(QOpenGLVertexArrayObject,create); 13 | }; 14 | 15 | // Register to profile OpenGLVertexArrayObject 16 | class OpenGLVertexArrayObjectProfiled : public OpenGLVertexArrayObjectChecked 17 | { 18 | public: 19 | explicit OpenGLVertexArrayObjectProfiled(QObject *parent = 0) : OpenGLVertexArrayObjectChecked(parent) {} 20 | GL_PROFILE(OpenGLVertexArrayObjectChecked,bind); 21 | GL_PROFILE(OpenGLVertexArrayObjectChecked,create); 22 | GL_PROFILE(OpenGLVertexArrayObjectChecked,destroy); 23 | GL_PROFILE_CONST(OpenGLVertexArrayObjectChecked,isCreated); 24 | GL_PROFILE_CONST(OpenGLVertexArrayObjectChecked,objectId); 25 | GL_PROFILE(OpenGLVertexArrayObjectChecked,release); 26 | }; 27 | 28 | // Final class 29 | class OpenGLVertexArrayObject : public OpenGLVertexArrayObjectProfiled 30 | { 31 | public: 32 | explicit OpenGLVertexArrayObject(QObject *parent = 0) : OpenGLVertexArrayObjectProfiled(parent) {} 33 | }; 34 | 35 | #endif // OPENGLVERTEXARRAYOBJECT_H 36 | -------------------------------------------------------------------------------- /OpenGL/openglviewport.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLVIEWPORT_H 2 | #define OPENGLVIEWPORT_H OpenGLViewport 3 | 4 | class KCamera3D; 5 | class KSize; 6 | class KSizeF; 7 | class KVector2D; 8 | class OpenGLRenderBlock; 9 | class KFrustum; 10 | #include 11 | 12 | class OpenGLViewportPrivate; 13 | class OpenGLViewport 14 | { 15 | public: 16 | OpenGLViewport(); 17 | ~OpenGLViewport(); 18 | void create(); 19 | void bind(); 20 | void release(); 21 | void resize(int width, int height); 22 | void resize(const KSize &size); 23 | void setCamera(const KCamera3D &camera); 24 | void setNearFar(float nearPlane, float farPlane); 25 | void setRegion(float x, float y, float w, float h); 26 | const KSize &size() const; 27 | const KSize &screenSize() const; 28 | const KVector2D &origin() const; 29 | const KSizeF ®ion() const; 30 | const KFrustum &frustum() const; 31 | void commit(); 32 | void activate(); 33 | const OpenGLRenderBlock ¤t() const; 34 | const OpenGLRenderBlock &previous() const; 35 | const KCamera3D &camera() const; 36 | private: 37 | KSharedPointer m_private; 38 | }; 39 | 40 | #endif // OPENGLVIEWPORT_H 41 | -------------------------------------------------------------------------------- /QtOpenGL.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # QtOpenGL Root Subdirs 3 | #------------------------------------------------------------------------------- 4 | 5 | TEMPLATE = subdirs 6 | CONFIG += ordered 7 | 8 | # Write the output binary path to a configuration file. 9 | system(echo Creating config.pri.user... && echo BINARY_ROOT = \"$${OUT_PWD}\" > \"$${PWD}/config.pri.user\") 10 | 11 | # Execute perl script to generate headers if perl is installed 12 | system(where /q perl && cd $${PWD} && perl scripts/GenHeaders.pl) 13 | 14 | SUBDIRS = \ 15 | qtbaseExt \ 16 | Karma \ 17 | OpenGL \ 18 | KarmaView 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QtOpenGL 2 | A sample application which implements several advanced OpenGL rendering routines. 3 | Mostly this exists as a playground for OpenGL 3.3+ and OpenGL ES 3.0+. 4 | 5 | # Tutorials 6 | For those of you coming here from my Qt5+ OpenGL Tutorials, please checkout the alternative branch (tutorial-series). 7 | The master branche is reserved for playing with advanced OpenGL features, and may or may not contain runtime issues. 8 | 9 | # Warning 10 | Though I attempt to do as much as I can in as clean of an implementation as possible, sometimes corners must be cut. 11 | Because of this, never assume - unless stated otherwise - that I have rigorously tested and assure that any of the 12 | information provided in either the master branch or tutorial-series branch is accurate. I have, to the best of my 13 | ability, attempted to keep the tutorial-series branch relatively simple. But I have discontinued work on it because 14 | I didn't sense that there was a strong demand past getting OpenGL up-and-running. After you have a Qt5+ project with 15 | OpenGL rendering, it's basically an OpenGL playground at that point. Whether you're working in Qt or not, you should 16 | be able to implement any OpenGL functionality. 17 | -------------------------------------------------------------------------------- /config.pri: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # QtOpenGL Build Configuration 3 | #------------------------------------------------------------------------------- 4 | 5 | CONFIG += c++11 6 | SOURCE_ROOT = $${PWD} 7 | include($${SOURCE_ROOT}/config.pri.user) 8 | 9 | SHARED_INCLUDES = \ 10 | $${PWD} \ 11 | $${SOURCE_ROOT}/include \ 12 | $${SOURCE_ROOT}/include/Karma \ 13 | $${SOURCE_ROOT}/Karma \ 14 | $${SOURCE_ROOT}/OpenGL \ 15 | $${SOURCE_ROOT}/qtbaseExt/gui/opengl 16 | 17 | android { 18 | DEFINES += "QT_OPENGL_ES_3" 19 | } 20 | 21 | win32:CONFIG(release, debug|release): OUT_SUBDIR = release/ 22 | win32:CONFIG(debug, debug|release): OUT_SUBDIR = debug/ 23 | 24 | win32 { 25 | LIB_EXT = .lib 26 | } else { 27 | LIB_PREFIX = lib 28 | LIB_EXT = .a 29 | } 30 | 31 | defineReplace(defineLib) { 32 | return(-L$${BINARY_ROOT}/$$1/$${OUT_SUBDIR} -l$$1) 33 | } 34 | 35 | defineReplace(defineDep) { 36 | return ($${BINARY_ROOT}/$${1}/$${OUT_SUBDIR}$${LIB_PREFIX}$${1}$${LIB_EXT}) 37 | } 38 | 39 | KARMA_LIB = $$defineLib(Karma) 40 | OPENGL_LIB = $$defineLib(OpenGL) 41 | QTBASEEXT_LIB = $$defineLib(qtbaseExt) 42 | 43 | KARMA_DEP = $$defineDep(Karma) 44 | OPENGL_DEP = $$defineDep(OpenGL) 45 | QTBASEEXT_DEP = $$defineDep(qtbaseExt) 46 | 47 | INCLUDEPATH += $${SHARED_INCLUDES} 48 | 49 | RESOURCES += \ 50 | $$PWD/resources.qrc 51 | 52 | HEADERS += 53 | 54 | SOURCES += 55 | -------------------------------------------------------------------------------- /images.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | resources/images/AlexsApt.hdr 4 | resources/images/AlexsApt_Env.hdr 5 | 6 | 7 | -------------------------------------------------------------------------------- /include/Karma/CompositionPass: -------------------------------------------------------------------------------- 1 | #include "compositionpass.h" -------------------------------------------------------------------------------- /include/Karma/DebugGBufferPass: -------------------------------------------------------------------------------- 1 | #include "debuggbufferpass.h" -------------------------------------------------------------------------------- /include/Karma/EnvironmentPass: -------------------------------------------------------------------------------- 1 | #include "environmentpass.h" -------------------------------------------------------------------------------- /include/Karma/GBufferPass: -------------------------------------------------------------------------------- 1 | #include "gbufferpass.h" -------------------------------------------------------------------------------- /include/Karma/KAabbBoundingVolume: -------------------------------------------------------------------------------- 1 | #include "kaabbboundingvolume.h" -------------------------------------------------------------------------------- /include/Karma/KAbstractBoundingVolume: -------------------------------------------------------------------------------- 1 | #include "kabstractboundingvolume.h" -------------------------------------------------------------------------------- /include/Karma/KAbstractHdrParser: -------------------------------------------------------------------------------- 1 | #include "kabstracthdrparser.h" -------------------------------------------------------------------------------- /include/Karma/KAbstractLexer: -------------------------------------------------------------------------------- 1 | #include "kabstractlexer.h" -------------------------------------------------------------------------------- /include/Karma/KAbstractMesh: -------------------------------------------------------------------------------- 1 | #include "kabstractmesh.h" -------------------------------------------------------------------------------- /include/Karma/KAbstractObjParser: -------------------------------------------------------------------------------- 1 | #include "kabstractobjparser.h" -------------------------------------------------------------------------------- /include/Karma/KAbstractReader: -------------------------------------------------------------------------------- 1 | #include "kabstractreader.h" -------------------------------------------------------------------------------- /include/Karma/KAbstractWriter: -------------------------------------------------------------------------------- 1 | #include "kabstractwriter.h" -------------------------------------------------------------------------------- /include/Karma/KAccessor: -------------------------------------------------------------------------------- 1 | #include "kaccessor.h" -------------------------------------------------------------------------------- /include/Karma/KAdaptiveOctree: -------------------------------------------------------------------------------- 1 | #include "kadaptiveoctree.h" -------------------------------------------------------------------------------- /include/Karma/KBspTree: -------------------------------------------------------------------------------- 1 | #include "kbsptree.h" -------------------------------------------------------------------------------- /include/Karma/KBufferedBinaryFileReader: -------------------------------------------------------------------------------- 1 | #include "kbufferedbinaryfilereader.h" -------------------------------------------------------------------------------- /include/Karma/KBufferedFileReader: -------------------------------------------------------------------------------- 1 | #include "kbufferedfilereader.h" -------------------------------------------------------------------------------- /include/Karma/KCamera3D: -------------------------------------------------------------------------------- 1 | #include "kcamera3d.h" -------------------------------------------------------------------------------- /include/Karma/KColor: -------------------------------------------------------------------------------- 1 | #include "kcolor.h" -------------------------------------------------------------------------------- /include/Karma/KCommon: -------------------------------------------------------------------------------- 1 | #include "kcommon.h" -------------------------------------------------------------------------------- /include/Karma/KDebug: -------------------------------------------------------------------------------- 1 | #include "kdebug.h" -------------------------------------------------------------------------------- /include/Karma/KDebugVertex: -------------------------------------------------------------------------------- 1 | #include "kdebugvertex.h" -------------------------------------------------------------------------------- /include/Karma/KElapsedTimer: -------------------------------------------------------------------------------- 1 | #include "kelapsedtimer.h" -------------------------------------------------------------------------------- /include/Karma/KEllipsoidBoundingVolume: -------------------------------------------------------------------------------- 1 | #include "kellipsoidboundingvolume.h" -------------------------------------------------------------------------------- /include/Karma/KEposSphere: -------------------------------------------------------------------------------- 1 | #include "kepossphere.h" -------------------------------------------------------------------------------- /include/Karma/KFileReader: -------------------------------------------------------------------------------- 1 | #include "kfilereader.h" -------------------------------------------------------------------------------- /include/Karma/KFrustum: -------------------------------------------------------------------------------- 1 | #include "kfrustum.h" -------------------------------------------------------------------------------- /include/Karma/KGeometryCloud: -------------------------------------------------------------------------------- 1 | #include "kgeometrycloud.h" -------------------------------------------------------------------------------- /include/Karma/KGesture: -------------------------------------------------------------------------------- 1 | #include "kgesture.h" -------------------------------------------------------------------------------- /include/Karma/KHalfEdgeMesh: -------------------------------------------------------------------------------- 1 | #include "khalfedgemesh.h" -------------------------------------------------------------------------------- /include/Karma/KHalfEdgeObjParser: -------------------------------------------------------------------------------- 1 | #include "khalfedgeobjparser.h" -------------------------------------------------------------------------------- /include/Karma/KIndexCloud: -------------------------------------------------------------------------------- 1 | #include "kindexcloud.h" -------------------------------------------------------------------------------- /include/Karma/KInputManager: -------------------------------------------------------------------------------- 1 | #include "kinputmanager.h" -------------------------------------------------------------------------------- /include/Karma/KIntermediateIterator: -------------------------------------------------------------------------------- 1 | #include "kintermediateiterator.h" -------------------------------------------------------------------------------- /include/Karma/KLinq: -------------------------------------------------------------------------------- 1 | #include "klinq.h" -------------------------------------------------------------------------------- /include/Karma/KMacros: -------------------------------------------------------------------------------- 1 | #include "kmacros.h" -------------------------------------------------------------------------------- /include/Karma/KMath: -------------------------------------------------------------------------------- 1 | #include "kmath.h" -------------------------------------------------------------------------------- /include/Karma/KMatrix3x3: -------------------------------------------------------------------------------- 1 | #include "kmatrix3x3.h" -------------------------------------------------------------------------------- /include/Karma/KMatrix4x4: -------------------------------------------------------------------------------- 1 | #include "kmatrix4x4.h" -------------------------------------------------------------------------------- /include/Karma/KNullable: -------------------------------------------------------------------------------- 1 | #include "knullable.h" -------------------------------------------------------------------------------- /include/Karma/KOrientedBoundingVolume: -------------------------------------------------------------------------------- 1 | #include "korientedboundingvolume.h" -------------------------------------------------------------------------------- /include/Karma/KPanGesture: -------------------------------------------------------------------------------- 1 | #include "kpangesture.h" -------------------------------------------------------------------------------- /include/Karma/KParseToken: -------------------------------------------------------------------------------- 1 | #include "kparsetoken.h" -------------------------------------------------------------------------------- /include/Karma/KPinchGesture: -------------------------------------------------------------------------------- 1 | #include "kpinchgesture.h" -------------------------------------------------------------------------------- /include/Karma/KPlane: -------------------------------------------------------------------------------- 1 | #include "kplane.h" -------------------------------------------------------------------------------- /include/Karma/KPoint: -------------------------------------------------------------------------------- 1 | #include "kpoint.h" -------------------------------------------------------------------------------- /include/Karma/KPointCloud: -------------------------------------------------------------------------------- 1 | #include "kpointcloud.h" -------------------------------------------------------------------------------- /include/Karma/KPointF: -------------------------------------------------------------------------------- 1 | #include "kpointf.h" -------------------------------------------------------------------------------- /include/Karma/KQuaternion: -------------------------------------------------------------------------------- 1 | #include "kquaternion.h" -------------------------------------------------------------------------------- /include/Karma/KRect: -------------------------------------------------------------------------------- 1 | #include "krect.h" -------------------------------------------------------------------------------- /include/Karma/KRectF: -------------------------------------------------------------------------------- 1 | #include "krectf.h" -------------------------------------------------------------------------------- /include/Karma/KSharedPointer: -------------------------------------------------------------------------------- 1 | #include "ksharedpointer.h" -------------------------------------------------------------------------------- /include/Karma/KSize: -------------------------------------------------------------------------------- 1 | #include "ksize.h" -------------------------------------------------------------------------------- /include/Karma/KSizeF: -------------------------------------------------------------------------------- 1 | #include "ksizef.h" -------------------------------------------------------------------------------- /include/Karma/KSphereBoundingVolume: -------------------------------------------------------------------------------- 1 | #include "ksphereboundingvolume.h" -------------------------------------------------------------------------------- /include/Karma/KStack: -------------------------------------------------------------------------------- 1 | #include "kstack.h" -------------------------------------------------------------------------------- /include/Karma/KStandardAccessor: -------------------------------------------------------------------------------- 1 | #include "kstandardaccessor.h" -------------------------------------------------------------------------------- /include/Karma/KStaticGeometry: -------------------------------------------------------------------------------- 1 | #include "kstaticgeometry.h" -------------------------------------------------------------------------------- /include/Karma/KString: -------------------------------------------------------------------------------- 1 | #include "kstring.h" -------------------------------------------------------------------------------- /include/Karma/KTouchPoint: -------------------------------------------------------------------------------- 1 | #include "ktouchpoint.h" -------------------------------------------------------------------------------- /include/Karma/KTransform3D: -------------------------------------------------------------------------------- 1 | #include "ktransform3d.h" -------------------------------------------------------------------------------- /include/Karma/KTranslationIterator: -------------------------------------------------------------------------------- 1 | #include "ktranslationiterator.h" -------------------------------------------------------------------------------- /include/Karma/KTriangleIndexCloud: -------------------------------------------------------------------------------- 1 | #include "ktriangleindexcloud.h" -------------------------------------------------------------------------------- /include/Karma/KTriangleIndexIterator: -------------------------------------------------------------------------------- 1 | #include "ktriangleindexiterator.h" -------------------------------------------------------------------------------- /include/Karma/KTrianglePartition: -------------------------------------------------------------------------------- 1 | #include "ktrianglepartition.h" -------------------------------------------------------------------------------- /include/Karma/KTrianglePointIterator: -------------------------------------------------------------------------------- 1 | #include "ktrianglepointiterator.h" -------------------------------------------------------------------------------- /include/Karma/KTypeTraits: -------------------------------------------------------------------------------- 1 | #include "ktypetraits.h" -------------------------------------------------------------------------------- /include/Karma/KUniquePointer: -------------------------------------------------------------------------------- 1 | #include "kuniquepointer.h" -------------------------------------------------------------------------------- /include/Karma/KVector2D: -------------------------------------------------------------------------------- 1 | #include "kvector2d.h" -------------------------------------------------------------------------------- /include/Karma/KVector3D: -------------------------------------------------------------------------------- 1 | #include "kvector3d.h" -------------------------------------------------------------------------------- /include/Karma/KVector4D: -------------------------------------------------------------------------------- 1 | #include "kvector4d.h" -------------------------------------------------------------------------------- /include/Karma/KVertex: -------------------------------------------------------------------------------- 1 | #include "kvertex.h" -------------------------------------------------------------------------------- /include/Karma/LightAccumulationPass: -------------------------------------------------------------------------------- 1 | #include "lightaccumulationpass.h" -------------------------------------------------------------------------------- /include/Karma/MotionBlurPass: -------------------------------------------------------------------------------- 1 | #include "motionblurpass.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLAbstractLightGroup: -------------------------------------------------------------------------------- 1 | #include "openglabstractlightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLAreaLight: -------------------------------------------------------------------------------- 1 | #include "openglarealight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLAreaLightData: -------------------------------------------------------------------------------- 1 | #include "openglarealightdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLAreaLightGroup: -------------------------------------------------------------------------------- 1 | #include "openglarealightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLBindings: -------------------------------------------------------------------------------- 1 | #include "openglbindings.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLBlurData: -------------------------------------------------------------------------------- 1 | #include "openglblurdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLBuffer: -------------------------------------------------------------------------------- 1 | #include "openglbuffer.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLCommon: -------------------------------------------------------------------------------- 1 | #include "openglcommon.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLContext: -------------------------------------------------------------------------------- 1 | #include "openglcontext.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLDebugDraw: -------------------------------------------------------------------------------- 1 | #include "opengldebugdraw.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLDirectionLight: -------------------------------------------------------------------------------- 1 | #include "opengldirectionlight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLDirectionLightData: -------------------------------------------------------------------------------- 1 | #include "opengldirectionlightdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLDirectionLightGroup: -------------------------------------------------------------------------------- 1 | #include "opengldirectionlightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLDynamicBuffer: -------------------------------------------------------------------------------- 1 | #include "opengldynamicbuffer.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLDynamicUniformBufferObject: -------------------------------------------------------------------------------- 1 | #include "opengldynamicuniformbufferobject.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLElementType: -------------------------------------------------------------------------------- 1 | #include "openglelementtype.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLEnvironment: -------------------------------------------------------------------------------- 1 | #include "openglenvironment.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLError: -------------------------------------------------------------------------------- 1 | #include "openglerror.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLFrameResults: -------------------------------------------------------------------------------- 1 | #include "openglframeresults.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLFrameTimer: -------------------------------------------------------------------------------- 1 | #include "openglframetimer.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLFramebufferObject: -------------------------------------------------------------------------------- 1 | #include "openglframebufferobject.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLFunctions: -------------------------------------------------------------------------------- 1 | #include "openglfunctions.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLFunctions_3_3_Core: -------------------------------------------------------------------------------- 1 | #include "openglfunctions_3_3_core.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLFunctions_4_3_Core: -------------------------------------------------------------------------------- 1 | #include "openglfunctions_4_3_core.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLFunctions_ES3_0: -------------------------------------------------------------------------------- 1 | #include "openglfunctions_es3_0.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLHammersleyData: -------------------------------------------------------------------------------- 1 | #include "openglhammersleydata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLHdrTexture: -------------------------------------------------------------------------------- 1 | #include "openglhdrtexture.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLInstance: -------------------------------------------------------------------------------- 1 | #include "openglinstance.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLInstanceData: -------------------------------------------------------------------------------- 1 | #include "openglinstancedata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLInstanceManager: -------------------------------------------------------------------------------- 1 | #include "openglinstancemanager.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLLight: -------------------------------------------------------------------------------- 1 | #include "opengllight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLLightData: -------------------------------------------------------------------------------- 1 | #include "opengllightdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLLightGroup: -------------------------------------------------------------------------------- 1 | #include "opengllightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLLightManager: -------------------------------------------------------------------------------- 1 | #include "opengllightmanager.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLMarkerResult: -------------------------------------------------------------------------------- 1 | #include "openglmarkerresult.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLMarkerScoped: -------------------------------------------------------------------------------- 1 | #include "openglmarkerscoped.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLMaterial: -------------------------------------------------------------------------------- 1 | #include "openglmaterial.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLMaterialData: -------------------------------------------------------------------------------- 1 | #include "openglmaterialdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLMesh: -------------------------------------------------------------------------------- 1 | #include "openglmesh.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLMeshManager: -------------------------------------------------------------------------------- 1 | #include "openglmeshmanager.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLPointLight: -------------------------------------------------------------------------------- 1 | #include "openglpointlight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLPointLightData: -------------------------------------------------------------------------------- 1 | #include "openglpointlightdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLPointLightGroup: -------------------------------------------------------------------------------- 1 | #include "openglpointlightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLProfiler: -------------------------------------------------------------------------------- 1 | #include "openglprofiler.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLProfilerVisualizer: -------------------------------------------------------------------------------- 1 | #include "openglprofilervisualizer.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRectangleLight: -------------------------------------------------------------------------------- 1 | #include "openglrectanglelight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRectangleLightGroup: -------------------------------------------------------------------------------- 1 | #include "openglrectanglelightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRenderBlock: -------------------------------------------------------------------------------- 1 | #include "openglrenderblock.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRenderBlockData: -------------------------------------------------------------------------------- 1 | #include "openglrenderblockdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRenderPass: -------------------------------------------------------------------------------- 1 | #include "openglrenderpass.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRenderPassQueue: -------------------------------------------------------------------------------- 1 | #include "openglrenderpassqueue.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRenderView: -------------------------------------------------------------------------------- 1 | #include "openglrenderview.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRenderbufferObject: -------------------------------------------------------------------------------- 1 | #include "openglrenderbufferobject.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLRenderer: -------------------------------------------------------------------------------- 1 | #include "openglrenderer.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLSLParser: -------------------------------------------------------------------------------- 1 | #include "openglslparser.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLScene: -------------------------------------------------------------------------------- 1 | #include "openglscene.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLSceneManager: -------------------------------------------------------------------------------- 1 | #include "openglscenemanager.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLShaderProgram: -------------------------------------------------------------------------------- 1 | #include "openglshaderprogram.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLSphereLight: -------------------------------------------------------------------------------- 1 | #include "openglspherelight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLSphereLightGroup: -------------------------------------------------------------------------------- 1 | #include "openglspherelightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLSpotLight: -------------------------------------------------------------------------------- 1 | #include "openglspotlight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLSpotLightData: -------------------------------------------------------------------------------- 1 | #include "openglspotlightdata.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLSpotLightGroup: -------------------------------------------------------------------------------- 1 | #include "openglspotlightgroup.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLStorage: -------------------------------------------------------------------------------- 1 | #include "openglstorage.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLTexture: -------------------------------------------------------------------------------- 1 | #include "opengltexture.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLToneMappingFunction: -------------------------------------------------------------------------------- 1 | #include "opengltonemappingfunction.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLTranslationLight: -------------------------------------------------------------------------------- 1 | #include "opengltranslationlight.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLUniformBufferObject: -------------------------------------------------------------------------------- 1 | #include "opengluniformbufferobject.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLUniformManager: -------------------------------------------------------------------------------- 1 | #include "opengluniformbuffermanager.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLUpdateEvent: -------------------------------------------------------------------------------- 1 | #include "openglupdateevent.h" 2 | -------------------------------------------------------------------------------- /include/Karma/OpenGLVertexArrayObject: -------------------------------------------------------------------------------- 1 | #include "openglvertexarrayobject.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLViewport: -------------------------------------------------------------------------------- 1 | #include "openglviewport.h" -------------------------------------------------------------------------------- /include/Karma/OpenGLWidget: -------------------------------------------------------------------------------- 1 | #include "openglwidget.h" -------------------------------------------------------------------------------- /include/Karma/PreparePresentationPass: -------------------------------------------------------------------------------- 1 | #include "preparepresentationpass.h" -------------------------------------------------------------------------------- /include/Karma/RenderPasses: -------------------------------------------------------------------------------- 1 | #include "renderpasses.h" -------------------------------------------------------------------------------- /include/Karma/SampleScene: -------------------------------------------------------------------------------- 1 | #include "samplescene.h" -------------------------------------------------------------------------------- /include/Karma/ScreenSpaceAmbientOcclusion: -------------------------------------------------------------------------------- 1 | #include "screenspaceambientocclusion.h" -------------------------------------------------------------------------------- /include/Karma/ShadowedLightAccumulationPass: -------------------------------------------------------------------------------- 1 | #include "shadowedlightaccumulationpass.h" -------------------------------------------------------------------------------- /include/Karma/ViewportPresentationPass: -------------------------------------------------------------------------------- 1 | #include "viewportpresentationpass.h" -------------------------------------------------------------------------------- /include/glm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(NAME glm_dummy) 2 | 3 | file(GLOB ROOT_SOURCE *.cpp) 4 | file(GLOB ROOT_INLINE *.inl) 5 | file(GLOB ROOT_HEADER *.hpp) 6 | file(GLOB ROOT_TEXT ../*.txt) 7 | file(GLOB ROOT_NAT ../util/glm.natvis) 8 | 9 | file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp) 10 | file(GLOB_RECURSE CORE_INLINE ./detail/*.inl) 11 | file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp) 12 | 13 | file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp) 14 | file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl) 15 | file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp) 16 | 17 | file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) 18 | file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) 19 | file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) 20 | 21 | source_group("Text Files" FILES ${ROOT_TEXT}) 22 | source_group("Core Files" FILES ${CORE_SOURCE}) 23 | source_group("Core Files" FILES ${CORE_INLINE}) 24 | source_group("Core Files" FILES ${CORE_HEADER}) 25 | source_group("GTC Files" FILES ${GTC_SOURCE}) 26 | source_group("GTC Files" FILES ${GTC_INLINE}) 27 | source_group("GTC Files" FILES ${GTC_HEADER}) 28 | source_group("GTX Files" FILES ${GTX_SOURCE}) 29 | source_group("GTX Files" FILES ${GTX_INLINE}) 30 | source_group("GTX Files" FILES ${GTX_HEADER}) 31 | 32 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) 33 | 34 | if(GLM_TEST_ENABLE) 35 | add_executable(${NAME} ${ROOT_TEXT} ${ROOT_NAT} 36 | ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} 37 | ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} 38 | ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER} 39 | ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}) 40 | endif(GLM_TEST_ENABLE) 41 | 42 | #add_library(glm STATIC glm.cpp) 43 | #add_library(glm_shared SHARED glm.cpp) 44 | -------------------------------------------------------------------------------- /include/glm/detail/intrinsic_exponential.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/detail/intrinsic_exponential.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /include/glm/detail/intrinsic_trigonometric.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/detail/intrinsic_trigonometric.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /include/glm/detail/type_mat.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/type_mat.inl 29 | /// @date 2011-06-15 / 2011-06-15 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | 33 | -------------------------------------------------------------------------------- /include/glm/detail/type_vec.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref core 28 | /// @file glm/detail/type_vec.inl 29 | /// @date 2011-06-15 / 2011-06-15 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | -------------------------------------------------------------------------------- /include/glm/gtc/vec1.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtc_vec1 28 | /// @file glm/gtc/vec1.inl 29 | /// @date 2013-03-16 / 2013-03-16 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | -------------------------------------------------------------------------------- /include/glm/gtx/raw_data.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// Restrictions: 16 | /// By making use of the Software for military purposes, you choose to make 17 | /// a Bunny unhappy. 18 | /// 19 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | /// THE SOFTWARE. 26 | /// 27 | /// @ref gtx_raw_data 28 | /// @file glm/gtx/raw_data.inl 29 | /// @date 2008-11-19 / 2011-06-07 30 | /// @author Christophe Riccio 31 | /////////////////////////////////////////////////////////////////////////////////// 32 | -------------------------------------------------------------------------------- /qtbaseExt/gui/opengl/QOpenGLFunctions_ES3_0: -------------------------------------------------------------------------------- 1 | #include "qopenglfunctions_es3_0.h" -------------------------------------------------------------------------------- /qtbaseExt/qtbaseExt.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # QtOpenGL Root Subdirs 3 | #------------------------------------------------------------------------------- 4 | 5 | TEMPLATE = lib 6 | CONFIG += staticlib 7 | TARGET = qtbaseExt 8 | include(../config.pri) 9 | 10 | HEADERS = gui/opengl/qopenglfunctions_es3_0.h 11 | SOURCES = gui/opengl/qopenglfunctions_es3_0.cpp 12 | -------------------------------------------------------------------------------- /resources/images/AlexsApt.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TReed0803/QtOpenGL/91ac4b5fbcab940d7197fccc48d979f324c85bbd/resources/images/AlexsApt.hdr -------------------------------------------------------------------------------- /resources/images/AlexsApt_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TReed0803/QtOpenGL/91ac4b5fbcab940d7197fccc48d979f324c85bbd/resources/images/AlexsApt_Env.hdr -------------------------------------------------------------------------------- /resources/objects/floor.obj: -------------------------------------------------------------------------------- 1 | # Floor 2 | v -1 0 1 3 | v 1 0 1 4 | v 1 0 -1 5 | v -1 0 -1 6 | f 1 2 3 4 7 | f 4 3 2 1 8 | -------------------------------------------------------------------------------- /resources/objects/quad.obj: -------------------------------------------------------------------------------- 1 | # Quad 2 | v -1 -1 -1 3 | v 1 -1 -1 4 | v 1 1 -1 5 | v -1 1 -1 6 | f 1 2 3 7 | f 1 3 4 8 | -------------------------------------------------------------------------------- /resources/shaders/Bindings.glsl: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Bindings.glsl 3 | *------------------------------------------------------------------------------ 4 | * Defines all of the binding locations for GLSL uniforms. 5 | ******************************************************************************/ 6 | 7 | #ifndef BINDINGS_GLSL 8 | #define BINDINGS_GLSL 9 | 10 | // Samplers 11 | #define K_TEXTURE_0 0 12 | #define K_TEXTURE_1 1 13 | #define K_TEXTURE_2 2 14 | #define K_DEPTH_TEXTURE_BINDING 10 15 | #define K_GEOMETRY_TEXTURE_BINDING 11 16 | #define K_MATERIAL_TEXTURE_BINDING 12 17 | #define K_PHYSICAL_TEXTURE_BINDING 13 18 | #define K_SURFACE_TEXTURE_BINDING 14 19 | #define K_LIGHT_BUFFER_TEXTURE_BINDING 15 20 | #define K_AMBIENT_OCCLUSION_BINDING 16 21 | 22 | // Uniform Blocks 23 | #define K_CURRENT_VIEW_BINDING 1 24 | #define K_PREVIOUS_VIEW_BINDING 2 25 | #define K_LIGHT_BINDING 3 26 | #define K_MATERIAL_BINDING 4 27 | #define K_OBJECT_BINDING 5 28 | #define K_HAMMERSLEY_BINDING 6 29 | #define K_BLUR_BINDING 7 30 | 31 | #endif // BINDINGS_GLSL 32 | -------------------------------------------------------------------------------- /resources/shaders/EncodeDecode.glsl: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * EncodeDecode.glsl 3 | *------------------------------------------------------------------------------ 4 | * Provides all of the capabilities to encode and decode data from the GBuffer. 5 | ******************************************************************************/ 6 | 7 | #ifndef ENCODEDECODE_GLSL 8 | #define ENCODEDECODE_GLSL 9 | 10 | highp vec2 encodeNormal(highp vec3 n) 11 | { 12 | highp vec2 encN = normalize(n.xy) * sqrt(-n.z * 0.5 + 0.5); 13 | return (encN * 0.5 + 0.5); 14 | } 15 | 16 | highp vec3 decodeNormal(highp vec2 n) 17 | { 18 | highp vec4 decN = vec4(n, 0.0, 0.0) * 2.0 + vec4(-1.0, -1.0, 1.0, -1.0); 19 | highp float len = dot(decN.xyz, -decN.xyw); 20 | decN.z = len; 21 | decN.xy *= sqrt(len); 22 | return decN.xyz * 2.0 + vec3(0.0, 0.0, -1.0); 23 | } 24 | 25 | highp float encodeSpecularColor(highp vec3 s) 26 | { 27 | return (s.x + s.y + s.z) / 3.0; 28 | } 29 | 30 | highp vec3 decodeSpecularColor(highp float s) 31 | { 32 | return vec3(s, s, s); 33 | } 34 | 35 | highp float encodeSpecularExponent(highp float s) 36 | { 37 | return s / 255.0; 38 | } 39 | 40 | highp float decodeSpecularExponent(highp float s) 41 | { 42 | return s * 255.0; 43 | } 44 | 45 | #endif // ENCODEDECODE_GLSL 46 | -------------------------------------------------------------------------------- /resources/shaders/ToneMapping.glsl: -------------------------------------------------------------------------------- 1 | vec3 Reinhard(vec3 color) 2 | { 3 | return color / (color + vec3(1.0)); 4 | } 5 | 6 | vec3 HejlDawson(vec3 color) 7 | { 8 | vec3 x = max(vec3(0.0),color-vec3(0.004)); 9 | return (x*(6.2*x+.5))/(x*(6.2*x+1.7)+0.06); 10 | } 11 | 12 | vec3 _Uncharted(vec3 x) 13 | { 14 | const float A = 0.15; 15 | const float B = 0.50; 16 | const float C = 0.10; 17 | const float D = 0.20; 18 | const float E = 0.02; 19 | const float F = 0.30; 20 | const float W = 11.2; 21 | return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F; 22 | } 23 | 24 | vec3 Uncharted(vec3 color) 25 | { 26 | const float W = 11.2; 27 | const float ExposureBias = 2.0f; 28 | return _Uncharted(ExposureBias*color) / _Uncharted(vec3(W)); 29 | } -------------------------------------------------------------------------------- /resources/shaders/debug/screen.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * debug/screen.frag 3 | *------------------------------------------------------------------------------ 4 | * Passhtrough shader, outputs color to fColor. 5 | ******************************************************************************/ 6 | 7 | in highp vec4 vColor; 8 | layout(location = 0) out highp vec4 fColor; 9 | 10 | void main() 11 | { 12 | fColor = vColor; 13 | } 14 | -------------------------------------------------------------------------------- /resources/shaders/debug/screen.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * debug/screen.vert 3 | *------------------------------------------------------------------------------ 4 | * Passhtrough shader, draws directly to screen. 5 | ******************************************************************************/ 6 | 7 | layout(location = 0) in highp vec3 position; 8 | layout(location = 1) in highp vec3 color; 9 | out highp vec4 vColor; 10 | 11 | void main() 12 | { 13 | gl_Position = vec4(position, 1.0); 14 | vColor = vec4(color, 1.0); 15 | } 16 | -------------------------------------------------------------------------------- /resources/shaders/debug/texture.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * debug/screen.frag 3 | *------------------------------------------------------------------------------ 4 | * Passhtrough shader, outputs color to fColor. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | in highp vec2 vUv; 10 | layout(location = 0) out highp vec4 fColor; 11 | layout(binding = K_TEXTURE_0) 12 | uniform sampler2D textureData; 13 | 14 | void main() 15 | { 16 | fColor = vec4(vec3(texture(textureData, vUv).r), 1.0); 17 | } 18 | -------------------------------------------------------------------------------- /resources/shaders/debug/texture.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * debug/screen.vert 3 | *------------------------------------------------------------------------------ 4 | * Passhtrough shader, draws directly to screen. 5 | ******************************************************************************/ 6 | 7 | layout(location = 0) in highp vec3 position; 8 | layout(location = 1) in highp vec3 uv; 9 | out highp vec2 vUv; 10 | 11 | void main() 12 | { 13 | gl_Position = vec4(position, 1.0); 14 | vUv = uv.xy; 15 | } 16 | -------------------------------------------------------------------------------- /resources/shaders/debug/world.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * debug/world.frag 3 | *------------------------------------------------------------------------------ 4 | * Passhtrough shader, outputs color to fColor. 5 | ******************************************************************************/ 6 | 7 | in highp vec4 vColor; 8 | layout(location = 0) out highp vec4 fColor; 9 | 10 | void main() 11 | { 12 | fColor = vColor; 13 | } 14 | -------------------------------------------------------------------------------- /resources/shaders/debug/world.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * debug/world.vert 3 | *------------------------------------------------------------------------------ 4 | * Moves the current point to screen position. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | layout(location = 0) in highp vec3 position; 10 | layout(location = 1) in highp vec3 color; 11 | out highp vec4 vColor; 12 | 13 | void main() 14 | { 15 | gl_Position = Current.WorldToPersp * vec4(position, 1.0); 16 | vColor = vec4(color, 1.0); 17 | } 18 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * GBuffer.vert 3 | *------------------------------------------------------------------------------ 4 | * Calculates previous and current positions, as well as material attributes. 5 | ******************************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | // Per-Vertex Attributes 11 | layout(location = 0) in highp vec3 position; 12 | layout(location = 1) in highp vec3 normal; 13 | 14 | // Framebuffer Outputs 15 | out highp vec3 vViewNormal; 16 | out highp vec4 vCurrClipPosition; 17 | out highp vec4 vPrevClipPosition; 18 | 19 | void main() 20 | { 21 | // Calculations 22 | highp vec4 currViewPos = Object.CurrentModelToView * vec4(position, 1.0); 23 | highp vec4 prevViewPos = Object.PreviousModelToView * vec4(position, 1.0); 24 | highp vec4 viewNormal = Object.NormalTransform * vec4(normal , 1.0); 25 | 26 | // Outputs 27 | vViewNormal = viewNormal.xyz; 28 | vCurrClipPosition = Current.ViewToPersp * currViewPos; 29 | vPrevClipPosition = Previous.ViewToPersp * prevViewPos; 30 | 31 | // Final position 32 | gl_Position = vCurrClipPosition; 33 | } 34 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/ambient.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = backbuffer(); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/backbuffer.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | highp vec2 fragCoord = uvCoord(); 7 | highp vec3 gamma = vec3(1.0); 8 | 9 | // Lets try to motion blur it 10 | highp vec2 texelSize = 1.0 / vec2(textureSize(lightbufferTexture, 0)); 11 | highp vec2 v = velocity(); 12 | highp float speed = length(v / texelSize); 13 | highp int nSamples = clamp(int(speed), 1, 20); 14 | highp vec3 color = pow(lightbuffer().xyz, gamma); 15 | for (highp int i = 1; i < nSamples; ++i) { 16 | highp vec2 offset = -v * (float(i) / float(nSamples - 1) - 0.5); 17 | color += pow(lightbuffer(fragCoord + offset).xyz, gamma); 18 | } 19 | color /= float(nSamples); 20 | fColor = vec4(color, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/composition.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | highp vec2 fragCoord = uvCoord(); 7 | highp vec3 gamma = vec3(1.0); 8 | 9 | // Lets try to motion blur it 10 | highp vec2 texelSize = 1.0 / vec2(textureSize(lightbufferTexture, 0)); 11 | highp vec2 v = velocity(); 12 | highp float speed = length(v / texelSize); 13 | highp int nSamples = clamp(int(speed), 1, 20); 14 | highp vec3 color = pow(lightbuffer().xyz, gamma); 15 | for (highp int i = 1; i < nSamples; ++i) { 16 | highp vec2 offset = -v * (float(i) / float(nSamples - 1) - 0.5); 17 | color += pow(lightbuffer(fragCoord + offset).xyz, gamma); 18 | } 19 | color /= float(nSamples); 20 | fColor = vec4(color, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/depth.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | highp float d = depth(); 7 | fColor = vec4(d, d, d, 1.0); 8 | } 9 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/diffuse.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(baseColor(), 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/lightbuffer.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(lightbuffer().xyz, 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/linearDepth.frag: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | out highp vec4 fColor; 4 | 5 | void main() 6 | { 7 | fColor = vec4(vec3(linearizeDepth(depth())), 1.0); 8 | } 9 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/main.vert: -------------------------------------------------------------------------------- 1 | layout(location = 0) in highp vec3 position; 2 | void main() 3 | { 4 | gl_Position = vec4(position.xyz, 1.0); 5 | } 6 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/metallic.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(metallic()); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/motion.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = lightbuffer(); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/motionBlur.frag: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | out highp vec4 fColor; 4 | uniform int MaxSamples = 20; 5 | uniform float Power = 1.0; 6 | 7 | void main() 8 | { 9 | // Calculate Initial Color 10 | highp vec3 color = lightbuffer().xyz; 11 | 12 | // Calculate the sample size and velocity 13 | highp vec2 texelSize = 1.0 / vec2(Current.Dimensions); 14 | highp vec2 vel = Power * velocity(); 15 | // Note: vel *= currFps / targetFps; For more accuracy 16 | highp float speed = length(vel / texelSize); 17 | highp int nSamples = clamp(int(speed), 1, MaxSamples); 18 | 19 | // Calculate the Iterative motion blur 20 | highp vec2 adder = vel / float(nSamples); 21 | highp vec2 fragCoord = uvCoord() - vel * vec2(0.5); 22 | 23 | // Apply the motion blur 24 | for (highp int i = 1; i < nSamples; ++i) { 25 | color += lightbuffer(fragCoord).xyz; 26 | fragCoord += adder; 27 | } 28 | color /= float(nSamples); 29 | 30 | // Set the final color 31 | fColor = vec4(color, 1.0); 32 | } 33 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/normal.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(abs(normal()), 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/position.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(worldPosition(), 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/roughness.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(roughness()); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/specular.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(metallic()); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/specularExponent.frag: -------------------------------------------------------------------------------- 1 | #include 2 | out highp vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(vec3(specular().w), 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/velocity.frag: -------------------------------------------------------------------------------- 1 | #include 2 | in vec2 vUvCoord; 3 | out highp vec4 fColor; 4 | 5 | void main() 6 | { 7 | highp vec2 color = velocity(vUvCoord); 8 | fColor = vec4(color, 0.0, 1.0); 9 | } 10 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/viewport.frag: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | in vec2 vUvCoord; 6 | out highp vec4 fColor; 7 | 8 | // Tone Mapping Settings 9 | uniform float A = 0.15; 10 | uniform float B = 0.50; 11 | uniform float C = 0.10; 12 | uniform float D = 0.20; 13 | uniform float E = 0.02; 14 | uniform float F = 0.30; 15 | uniform float W = 11.2; 16 | uniform float Exposure = 1.0; 17 | uniform float ExposureBias = 2.0; 18 | 19 | vec3 _ToneMap(vec3 x) 20 | { 21 | return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F; 22 | } 23 | 24 | vec3 ToneMap(vec3 color) 25 | { 26 | return _ToneMap(ExposureBias*color) / _ToneMap(vec3(W)); 27 | } 28 | 29 | void main() 30 | { 31 | highp vec3 color = lightbuffer(vUvCoord).xyz; 32 | color *= Exposure; 33 | color = ToneMap(color); 34 | color = l2rgb(color); 35 | fColor = vec4(color, 1.0); 36 | } 37 | -------------------------------------------------------------------------------- /resources/shaders/gbuffer/viewport.vert: -------------------------------------------------------------------------------- 1 | layout(location = 0) in highp vec3 position; 2 | 3 | uniform mat4 ViewportReposition; 4 | out vec2 vUvCoord; 5 | 6 | void main() 7 | { 8 | vUvCoord = position.xy / 2.0 + 0.5; 9 | gl_Position = vec4(position.xyz, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /resources/shaders/lighting/ambientOcclusion.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/ambientOcclusion.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | // Per-Vertex Attribs 10 | layout(location = 0) in highp vec3 position; 11 | 12 | void main() 13 | { 14 | // Send to Fragment Shader (FSQ) 15 | gl_Position = vec4(position, 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /resources/shaders/lighting/directionLight.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/directionLight.frag 3 | *------------------------------------------------------------------------------ 4 | * Apply the lighting calculation to a given fragment of incident light. 5 | * Uses GBuffer information to access statistics about the scene itself. 6 | ******************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | // Light Properties 13 | flat in vec3 vLightDirection; 14 | flat in vec3 vLightDiffuse; 15 | flat in vec3 vLightSpecular; 16 | 17 | // Light Output 18 | layout(location = 0) out highp vec4 fFragColor; 19 | 20 | void main() 21 | { 22 | vec3 viewDir = normalize(-viewPosition()); 23 | vec3 color = Brdf(baseColor(), vLightDiffuse, vLightDirection, viewDir, normal()); 24 | fFragColor = vec4(max(color * (1.0 - linearDepth()), 0.0), 1.0); 25 | } 26 | -------------------------------------------------------------------------------- /resources/shaders/lighting/directionLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/directionLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | // Per-Vertex Attribs 10 | layout(location = 0) in highp vec3 position; 11 | 12 | // Per-Instance Attribs 13 | layout(location = 1) in highp vec3 lightDirection; 14 | layout(location = 2) in highp vec3 lightDiffuse; 15 | layout(location = 3) in highp vec3 lightSpecular; 16 | 17 | // Output variables 18 | flat out highp vec3 vLightDirection; 19 | flat out highp vec3 vLightDiffuse; 20 | flat out highp vec3 vLightSpecular; 21 | 22 | void main() 23 | { 24 | // Pass Outputs 25 | vLightDirection = -lightDirection; 26 | vLightDiffuse = lightDiffuse; 27 | vLightSpecular = lightSpecular; 28 | 29 | // Send to Fragment Shader (FSQ) 30 | gl_Position = vec4(position, 1.0); 31 | } 32 | -------------------------------------------------------------------------------- /resources/shaders/lighting/environment.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/environment.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | // Per-Vertex Attribs 10 | layout(location = 0) in highp vec3 position; 11 | 12 | void main() 13 | { 14 | // Send to Fragment Shader (FSQ) 15 | gl_Position = vec4(position, 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /resources/shaders/lighting/mapSpotLight.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/mapSpotLight.frag 3 | *------------------------------------------------------------------------------ 4 | * Apply the lighting calculation to a given fragment of incident light. 5 | * Uses GBuffer information to access statistics about the scene itself. 6 | ******************************************************************************/ 7 | 8 | layout(location = 0) out float depth; 9 | 10 | void main() 11 | { 12 | depth = gl_FragCoord.z; 13 | } 14 | -------------------------------------------------------------------------------- /resources/shaders/lighting/mapSpotLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/mapSpotLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | // Per-Vertex Attribs 12 | layout(location = 0) in highp vec3 position; 13 | 14 | void main() 15 | { 16 | // Send to Fragment Shader 17 | gl_Position = Light.ViewToLightPersp * Object.CurrentModelToView * vec4(position, 1.0); 18 | } 19 | -------------------------------------------------------------------------------- /resources/shaders/lighting/mapSpotLightExponential.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/pointLight.frag 3 | *------------------------------------------------------------------------------ 4 | * Apply the lighting calculation to a given fragment of incident light. 5 | * Uses GBuffer information to access statistics about the scene itself. 6 | ******************************************************************************/ 7 | 8 | #include // Light.Radius 9 | #include // map_01 10 | 11 | in highp vec4 vViewPosition; 12 | layout(location = 0) out float expMap; 13 | 14 | void main() 15 | { 16 | float depthDivisor = (1.0 / gl_FragCoord.w); 17 | float mappedDivisor = map_01(depthDivisor, Light.NearPlane, Light.MaxFalloff); 18 | expMap = exp(Light.Exponential * mappedDivisor); 19 | } 20 | -------------------------------------------------------------------------------- /resources/shaders/lighting/pointLight.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/pointLight.frag 3 | *------------------------------------------------------------------------------ 4 | * Apply the lighting calculation to a given fragment of incident light. 5 | * Uses GBuffer information to access statistics about the scene itself. 6 | ******************************************************************************/ 7 | 8 | #include 9 | #include // saturate 10 | #include 11 | 12 | // Light Properties 13 | flat in highp vec4 vLightAttenuation; 14 | flat in highp vec3 vLightViewPosition; 15 | flat in highp vec3 vLightDiffuse; 16 | flat in highp vec3 vLightSpecular; 17 | 18 | // Light Output 19 | layout(location = 0) out highp vec4 fFragColor; 20 | 21 | void main() 22 | { 23 | // GBuffer Access 24 | highp vec3 viewPos = viewPosition(); 25 | highp vec3 normal = normal(); 26 | highp vec3 baseColor= baseColor(); 27 | 28 | // Light Information 29 | highp vec3 lightVec = vLightViewPosition - viewPos; 30 | highp float lightDist = length(lightVec); 31 | 32 | // Construct a finite attenuation 33 | highp vec3 lightDir = lightVec / lightDist; 34 | highp vec3 viewDir = normalize(-viewPos); 35 | highp vec3 polynomial = vec3(1.0, lightDist, lightDist * lightDist); 36 | highp float attenuation = 1.0 / dot(polynomial,vLightAttenuation.xyz); 37 | attenuation *= saturate(1.0 - (lightDist / vLightAttenuation.w)); 38 | 39 | // Execute Brdf 40 | highp vec3 color = Brdf(baseColor, vLightDiffuse, lightDir, viewDir, normal); 41 | fFragColor = vec4(rgb2l(attenuation * color), 1.0); 42 | } 43 | -------------------------------------------------------------------------------- /resources/shaders/lighting/pointLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/pointLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | // Per-Vertex Attribs 10 | layout(location = 0) in highp vec3 position; 11 | 12 | // Per-Instance Attribs 13 | layout(location = 1) in highp vec3 lightViewPosition; 14 | layout(location = 2) in highp vec4 lightAttenuation; 15 | layout(location = 3) in highp vec3 lightDiffuse; 16 | layout(location = 4) in highp vec3 lightSpecular; 17 | layout(location = 5) in highp mat4 modelToClip; 18 | 19 | // Output variables 20 | flat out highp vec3 vLightViewPosition; 21 | flat out highp vec4 vLightAttenuation; 22 | flat out highp vec3 vLightDiffuse; 23 | flat out highp vec3 vLightSpecular; 24 | 25 | void main() 26 | { 27 | // Pass Outputs 28 | vLightViewPosition = lightViewPosition; 29 | vLightAttenuation = lightAttenuation; 30 | vLightDiffuse = lightDiffuse; 31 | vLightSpecular = lightSpecular; 32 | 33 | // Send to Fragment Shader 34 | gl_Position = modelToClip * vec4(position, 1.0); 35 | } 36 | -------------------------------------------------------------------------------- /resources/shaders/lighting/rectangleLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/pointLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | // Per-Vertex Attribs 11 | layout(location = 0) in vec3 position; 12 | 13 | void main() 14 | { 15 | // Send to Fragment Shader 16 | gl_Position = vec4(position, 1.0); 17 | } 18 | -------------------------------------------------------------------------------- /resources/shaders/lighting/shadowDirectionLight.frag: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/shadowDirectionLight.frag 3 | *------------------------------------------------------------------------------ 4 | * Apply the lighting calculation to a given fragment of incident light. 5 | * Uses GBuffer information to access statistics about the scene itself. 6 | ******************************************************************************/ 7 | 8 | #include 9 | #include 10 | 11 | // Light Output 12 | layout(location = 0) out highp vec4 fFragColor; 13 | 14 | void main() 15 | { 16 | // GBuffer Access 17 | highp vec3 viewPos = viewPosition(); 18 | highp vec3 normal = normal(); 19 | highp vec3 diffuse = baseColor(); 20 | highp vec4 specular = vec4(metallic()); 21 | 22 | // Blinn Phong 23 | highp float lambertian = max(dot(Light.ViewDirection, normal), 0.0); 24 | highp vec3 viewDir = normalize(-viewPos); 25 | highp vec3 halfDir = normalize(Light.ViewDirection + viewDir); 26 | highp float specAngle = max(dot(halfDir, normal), 0.0); 27 | highp float specFactor = pow(specAngle, specular.w); 28 | 29 | // Construct Lighting Terms 30 | highp vec3 diffuseTerm = Light.Diffuse * diffuse * lambertian; 31 | highp vec3 specularTerm = Light.Specular * specular.xyz * specFactor; 32 | fFragColor = vec4((diffuseTerm + specularTerm), 1.0); 33 | } 34 | -------------------------------------------------------------------------------- /resources/shaders/lighting/shadowDirectionLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/shadowDirectionLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | // Per-Vertex Attribs 10 | layout(location = 0) in highp vec3 position; 11 | 12 | void main() 13 | { 14 | // Send to Fragment Shader (FSQ) 15 | gl_Position = vec4(position, 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /resources/shaders/lighting/shadowPointLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/shadowPointLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | // Per-Vertex Attribs 10 | layout(location = 0) in highp vec3 position; 11 | 12 | void main() 13 | { 14 | // Send to Fragment Shader 15 | gl_Position = Light.ModelToPersp * vec4(position, 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /resources/shaders/lighting/shadowSpotLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/shadowSpotLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | 9 | // Per-Vertex Attribs 10 | layout(location = 0) in highp vec3 position; 11 | 12 | // Output variables 13 | out highp mat4 vViewToLightBias; 14 | 15 | void main() 16 | { 17 | const mat4 ShadowBiasMatrix = mat4( 18 | 0.5, 0.0, 0.0, 0.0, 19 | 0.0, 0.5, 0.0, 0.0, 20 | 0.0, 0.0, 0.5, 0.0, 21 | 0.5, 0.5, 0.5, 1.0 22 | ); 23 | 24 | // Send to Fragment Shader 25 | vViewToLightBias = ShadowBiasMatrix * Light.ViewToLightPersp; 26 | gl_Position = Light.ModelToPersp * vec4(position, 1.0); 27 | } 28 | -------------------------------------------------------------------------------- /resources/shaders/lighting/sphereLight.vert: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lighting/pointLight.vert 3 | *------------------------------------------------------------------------------ 4 | * Pass-through shader that simply deferrs information to fragment shader. 5 | ******************************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | // Per-Vertex Attribs 11 | layout(location = 0) in vec3 position; 12 | 13 | void main() 14 | { 15 | // Send to Fragment Shader 16 | gl_Position = vec4(position, 1.0); 17 | } 18 | -------------------------------------------------------------------------------- /resources/shaders/ubo/AreaLightBuffer.ubo: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * ubo/SpotLight.ubo 3 | *------------------------------------------------------------------------------ 4 | * All of the current rendering spotlight information. 5 | ******************************************************************************/ 6 | 7 | #ifndef LIGHTBUFFER_UBO 8 | #define LIGHTBUFFER_UBO 9 | 10 | #include 11 | 12 | layout(binding = K_LIGHT_BINDING,std140) 13 | uniform LightBufferProperties 14 | { 15 | mat4 ModelToPersp; 16 | mat4 ViewToLightPersp; 17 | vec3 ViewPosition; 18 | float Radius; 19 | vec3 Color; 20 | float Intensity; 21 | vec4 Data0; 22 | vec4 Data1; 23 | vec4 Data2; 24 | vec4 Data3; 25 | } AreaLight; 26 | 27 | #endif // LIGHTBUFFER_UBO 28 | -------------------------------------------------------------------------------- /resources/shaders/ubo/GlobalBuffer.ubo: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * ubo/GlobalBuffer.ubo 3 | *------------------------------------------------------------------------------ 4 | * All of the global state information. 5 | ******************************************************************************/ 6 | 7 | #ifndef GLOBALBUFFER_UBO 8 | #define GLOBALBUFFER_UBO 9 | 10 | #include 11 | 12 | layout(binding = K_CURRENT_VIEW_BINDING, std140) 13 | uniform CurrentRenderBlock 14 | { 15 | highp mat4 WorldToView; 16 | highp mat4 ViewToWorld; 17 | highp mat4 WorldToPersp; 18 | highp mat4 PerspToWorld; 19 | highp mat4 ViewToPersp; 20 | highp mat4 PerspToView; 21 | highp vec2 Dimensions; 22 | highp vec2 ViewportOffset; 23 | highp float NearPlane; 24 | highp float FarPlane; 25 | highp float DiffPlane; 26 | highp float SumPlane; 27 | highp float Exposure; 28 | } Current; 29 | 30 | layout(binding = K_PREVIOUS_VIEW_BINDING, std140) 31 | uniform PreviousRenderBlock 32 | { 33 | highp mat4 WorldToView; 34 | highp mat4 ViewToWorld; 35 | highp mat4 WorldToPersp; 36 | highp mat4 PerspToWorld; 37 | highp mat4 ViewToPersp; 38 | highp mat4 PerspToView; 39 | highp vec2 Dimensions; 40 | highp vec2 ViewportOffset; 41 | highp float NearPlane; 42 | highp float FarPlane; 43 | highp float DiffPlane; 44 | highp float SumPlane; 45 | highp float Exposure; 46 | } Previous; 47 | 48 | #endif // GLOBALBUFFER_UBO 49 | -------------------------------------------------------------------------------- /resources/shaders/ubo/Hammersley.ubo: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * ubo/Hammersley.ubo 3 | *------------------------------------------------------------------------------ 4 | * Hammersley random value simulation. 5 | ******************************************************************************/ 6 | 7 | #ifndef HAMMERSLEY_UBO 8 | #define HAMMERSLEY_UBO 9 | 10 | #include 11 | 12 | layout(binding = K_HAMMERSLEY_BINDING,std140) 13 | uniform HammersleyBuffer 14 | { 15 | highp vec2 data[60]; 16 | highp float N; 17 | } HammersleyPreprocessed; 18 | 19 | #endif // HAMMERSLEY_UBO 20 | -------------------------------------------------------------------------------- /resources/shaders/ubo/LightBuffer.ubo: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * ubo/SpotLight.ubo 3 | *------------------------------------------------------------------------------ 4 | * All of the current rendering spotlight information. 5 | ******************************************************************************/ 6 | 7 | #ifndef LIGHTBUFFER_UBO 8 | #define LIGHTBUFFER_UBO 9 | 10 | #include 11 | 12 | layout(binding = K_LIGHT_BINDING,std140) 13 | uniform LightBufferProperties 14 | { 15 | highp mat4 ModelToPersp; 16 | highp mat4 ViewToLightPersp; 17 | highp vec3 Attenuation; 18 | highp float MaxFalloff; 19 | highp vec3 ViewPosition; 20 | float InnerAngle; 21 | highp vec3 ViewDirection; 22 | float OuterAngle; 23 | highp vec3 Diffuse; 24 | float DiffAngle; 25 | highp vec3 Specular; 26 | highp float Exponential; 27 | highp float MinFalloff; 28 | highp float NearPlane; 29 | } Light; 30 | 31 | #endif // LIGHTBUFFER_UBO 32 | -------------------------------------------------------------------------------- /resources/shaders/ubo/Material.ubo: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * ubo/Material.ubo 3 | *------------------------------------------------------------------------------ 4 | * All of the current material information 5 | ******************************************************************************/ 6 | 7 | #ifndef MATERIAL_UBO 8 | #define MATERIAL_UBO 9 | 10 | #include 11 | 12 | layout(binding = K_MATERIAL_BINDING, std140) 13 | uniform MaterialBuffer 14 | { 15 | vec3 BaseColor; 16 | float Metallic; 17 | float Roughness; 18 | float padding0; 19 | float padding1; 20 | float padding2; 21 | } Material; 22 | 23 | #endif // MATERIAL_UBO 24 | -------------------------------------------------------------------------------- /resources/shaders/ubo/Object.ubo: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * ubo/Object.ubo 3 | *------------------------------------------------------------------------------ 4 | * All of the current object information 5 | ******************************************************************************/ 6 | 7 | #ifndef OBJECT_UBO 8 | #define OBJECT_UBO 9 | 10 | #include 11 | 12 | layout(binding = K_OBJECT_BINDING,std140) 13 | uniform ObjectBuffer 14 | { 15 | highp mat4 CurrentModelToView; 16 | highp mat4 PreviousModelToView; 17 | highp mat4 NormalTransform; 18 | } Object; 19 | 20 | #endif // OBJECT_UBO 21 | -------------------------------------------------------------------------------- /scripts/GenHeaders.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # GenHeader.pl 4 | # Generates headers for all C++ headers which define a variable GENHEADER. Will 5 | # create a header which is the name of what GENHEADER is defined as, and will 6 | # simply include the file which defined GENHEADER. 7 | 8 | use warnings; 9 | use strict; 10 | use Cwd; 11 | use File::Find; 12 | use File::Path qw( make_path ); 13 | 14 | my $cwd = getcwd; 15 | my $outDir = $cwd . "/include/Karma/"; 16 | 17 | sub make_link 18 | { 19 | my ($basename, $name) = @_; 20 | my $filepath = $outDir . $name; 21 | unless (-e $filepath) 22 | { 23 | print "Creating $filepath...\n"; 24 | open my $file, ">", $filepath or die $!; 25 | print $file "#include \"$basename\""; 26 | close $file; 27 | } 28 | } 29 | 30 | sub parse_header 31 | { 32 | my ( $basename, $filename ) = @_; 33 | 34 | open my $file, "<", $filename or die $!; 35 | while (<$file>) 36 | { 37 | if (/^[\s]*#[\s]*define[\s]+[a-zA-Z_0-9]*_H[\s]+(.*)/) 38 | { 39 | make_link( $basename, $1); 40 | } 41 | } 42 | close $file; 43 | } 44 | 45 | sub parse_all_headers 46 | { 47 | my $filename = $File::Find::name; 48 | if ($filename =~ /\.h$/) 49 | { 50 | parse_header($_, $filename); 51 | } 52 | } 53 | 54 | unless ( -d $outDir ) 55 | { 56 | print "Creating `$outDir`..."; 57 | make_path $outDir or die "Failed to create path: $outDir"; 58 | } 59 | find(\&parse_all_headers, $cwd); 60 | --------------------------------------------------------------------------------