### HLSL++ Example: Vector and Matrix Operations Source: https://github.com/redorav/hlslpp/blob/master/Readme.md Demonstrates native types, swizzling, HLSL functions, combined constructors, matrix operations, integer operations, casts, float8 vectors, data packing, and matrix creation utilities. ```hlsl // Native types float4 foo4 = float4(1, 2, 3, 4); // Swizzling float3 bar3 = foo4.xzy; // HLSL functions float2 logFoo2 = log(bar3.xz); // Swizzle of swizzle foo4.wx = logFoo2.yx; // Combined constructors float4 baz4 = float4(logFoo2, foo4.zz); // Matrices float4x4 fooMatrix4x4 = float4x4( 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1); // Matrix transformations float4 myTransformedVector = mul(fooMatrix4x4, baz4); // Integer operations int2 ifoo2 = int2(1, 2); int4 ifoo4 = int4(1, 2, 3, 4) + ifoo2.xyxy; // Casts float4 fooCast4 = ifoo4.wwyx; // Float8 float8 foo8 = float8(1, 2, 3, 4, 5, 6, 7, 8); float8 bar8 = float8(1, 2, 3, 4, 5, 6, 7, 8); float8 add8 = foo8 + bar8; // Data packing uint rgba8Packed = pack_float4_rgba8_unorm(foo4); float4 rgba8Unpacked = unpack_rgba8_unorm_float4(rgba8Packed); // Create useful matrices frustum cameraFrustum = frustum::field_of_view_y(fovYRadians, aspectRatio, nearPlane, farPlane); float4x4 projectionMatrix = float4x4::perspective(projection(cameraFrustum, zclip::zero, zdirection::reverse, zplane::finite)); float4x4 identityMatrix = float4x4::identity(); float4x4 rotationAxisMatrix = float4x4::rotation_axis(axis, angleRadians); ``` -------------------------------- ### Configure Xbox 360 Project in Premake Source: https://github.com/redorav/hlslpp/blob/master/premake-xbox360/README.md Set up a Premake workspace for Xbox 360 development, specifying configurations, platforms, and Xbox 360 specific properties. ```lua workspace "MyWorkspace" configurations { "Debug", "Release" } platforms { "MyXbox360Config" } filter { "platforms:MyXbox360Config" } system("xbox360") -- Xbox360-specific properties xexoutput("test_output.xex") titleid("0x1234567") baseaddress("0x88000000") inlineassembly("true") prescheduling("true") callattributedprofiling("callcap") ``` -------------------------------- ### Import Xbox 360 Module in Premake Source: https://github.com/redorav/hlslpp/blob/master/premake-xbox360/README.md Include the Xbox 360 module in your Premake script to enable Xbox 360 specific configurations. ```lua require("premake-xbox360/xbox360") ``` -------------------------------- ### HLSL++ Include Directives for C++ Source: https://github.com/redorav/hlslpp/blob/master/Readme.md Shows different ways to include HLSL++ headers. Use the first option for quick iteration, or specific headers for better compile times. Ensure the 'include' directory is in your include path. ```cpp // The quickest way, expensive in compile times but good for fast iteration #include "hlsl++.h" // If you care about compile times in your cpp files #include "hlsl++/vector_float.h" #include "hlsl++/matrix_float.h" // If you only need type information (e.g. in header files) and don't use any functions #include "hlsl++/vector_float_type.h" #include "hlsl++/quaternion_type.h" ``` -------------------------------- ### Interoperable Shader Data Structure Source: https://github.com/redorav/hlslpp/blob/master/Readme.md Defines a C++ struct compatible with shader constant buffers using HLSL++ interop types. Ensures correct data layout and alignment for GPU uploads. ```cpp struct alignas(16) MyData { hlslpp::interop::float4 data0; hlslpp::interop::float3 data1; float data2; hlslpp::interop::float3x4 data3; }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.