file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
js/meshopt_encoder.js | JavaScript | // This file is part of meshoptimizer library and is distributed under the terms of MIT License.
// Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
var MeshoptEncoder = (function () {
// Built with clang version 19.1.5-wasi-sdk
// Built from meshoptimizer 1.0
var wasm =
'b9H79Tebbbe9ok9... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
js/meshopt_encoder.test.js | JavaScript | import assert from 'assert/strict';
import { MeshoptEncoder as encoder } from './meshopt_encoder.js';
import { MeshoptDecoder as decoder } from './meshopt_decoder.mjs';
process.on('unhandledRejection', (error) => {
console.log('unhandledRejection', error);
process.exit(1);
});
function bytes(view) {
return new Uin... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
js/meshopt_simplifier.d.ts | TypeScript | // This file is part of meshoptimizer library and is distributed under the terms of MIT License.
// Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
export type Flags = 'LockBorder' | 'Sparse' | 'ErrorAbsolute' | 'Prune' | 'Regularize' | 'Permissive';
export const MeshoptSimplifier: {
suppo... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
js/meshopt_simplifier.js | JavaScript | // This file is part of meshoptimizer library and is distributed under the terms of MIT License.
// Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
var MeshoptSimplifier = (function () {
// Built with clang version 19.1.5-wasi-sdk
// Built from meshoptimizer 1.0
var wasm =
'b9H79Tebbbe:... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
js/meshopt_simplifier.test.js | JavaScript | import assert from 'assert/strict';
import { MeshoptSimplifier as simplifier } from './meshopt_simplifier.js';
process.on('unhandledRejection', (error) => {
console.log('unhandledRejection', error);
process.exit(1);
});
var tests = {
compactMesh: function () {
var indices = new Uint32Array([0, 1, 3, 3, 1, 5]);
... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
js/wasi_trace.js | JavaScript | // Usage:
// 1. import { wasi_trace } from './wasi_trace.js';
// 2. Pass wasi_trace as an import object to WebAssembly.instantiate
// 3. Call wasi_trace.init(instance) after instantiation
var instance;
var wasi_snapshot_preview1 = {
fd_close: function () {
return 8;
},
fd_seek: function () {
return 8;
},
fd_... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/allocator.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#ifdef MESHOPTIMIZER_ALLOC_EXPORT
meshopt_Allocator::Storage& meshopt_Allocator::storage()
{
static Storage s = {::operator new, ::operator delete };
return s;
}
#endif
void meshopt_setAllocator... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/clusterizer.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <float.h>
#include <math.h>
#include <string.h>
// The block below auto-detects SIMD ISA that can be used on the target platform
#ifndef MESHOPTIMIZER_NO_SIMD
#if defi... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/indexanalyzer.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <string.h>
meshopt_VertexCacheStatistics meshopt_analyzeVertexCache(const unsigned int* indices, size_t index_count, size_t vertex_count, unsigned int cache_size, unsi... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/indexcodec.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <string.h>
// This work is based on:
// Fabian Giesen. Simple lossless index buffer compression & follow-up. 2013
// Conor Stokes. Vertex Cache Optimised Index Buffer ... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/indexgenerator.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <string.h>
// This work is based on:
// Matthias Teschner, Bruno Heidelberger, Matthias Mueller, Danat Pomeranets, Markus Gross. Optimized Spatial Hashing for Collisio... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/meshletcodec.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <string.h>
// The block below auto-detects SIMD ISA that can be used on the target platform
#ifndef MESHOPTIMIZER_NO_SIMD
// The SIMD implementation requires SSE4.1, ... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/meshoptimizer.h | C/C++ Header | /**
* meshoptimizer - version 1.0
*
* Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://github.com/zeux/meshoptimizer
*
* This library is distributed under the MIT License. See notice at the end of this file.
*/
#pragma once
#include <... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/overdrawoptimizer.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <math.h>
#include <string.h>
// This work is based on:
// Pedro Sander, Diego Nehab and Joshua Barczak. Fast Triangle Reordering for Vertex Locality and Reduced Overdr... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/partition.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <math.h>
#include <string.h>
// This work is based on:
// Takio Kurita. An efficient agglomerative clustering algorithm using a heap. 1991
namespace meshopt
{
// To a... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/quantization.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
union FloatBits
{
float f;
unsigned int ui;
};
unsigned short meshopt_quantizeHalf(float v)
{
FloatBits u = {v};
unsigned int ui = u.ui;
int s = (ui >> 16) & 0x8000;
in... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/rasterizer.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <float.h>
#include <string.h>
// This work is based on:
// Nicolas Capens. Advanced Rasterization. 2004
namespace meshopt
{
const int kViewport = 256;
struct Overdra... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/simplifier.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <float.h>
#include <math.h>
#include <string.h>
#ifndef TRACE
#define TRACE 0
#endif
#if TRACE
#include <stdio.h>
#endif
#if TRACE
#define TRACESTATS(i) stats[i]++;
... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/spatialorder.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <float.h>
#include <string.h>
// This work is based on:
// Fabian Giesen. Decoding Morton codes. 2009
namespace meshopt
{
// "Insert" two 0 bits after each of the 20 ... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/stripifier.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <limits.h>
#include <string.h>
// This work is based on:
// Francine Evans, Steven Skiena and Amitabh Varshney. Optimizing Triangle Strips for Fast Rendering. 1996
nam... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/vcacheoptimizer.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <string.h>
// This work is based on:
// Tom Forsyth. Linear-Speed Vertex Cache Optimisation. 2006
// Pedro Sander, Diego Nehab and Joshua Barczak. Fast Triangle Reorde... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/vertexcodec.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <string.h>
// The block below auto-detects SIMD ISA that can be used on the target platform
#ifndef MESHOPTIMIZER_NO_SIMD
// The SIMD implementation requires SSSE3, w... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/vertexfilter.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <math.h>
#include <string.h>
// The block below auto-detects SIMD ISA that can be used on the target platform
#ifndef MESHOPTIMIZER_NO_SIMD
// The SIMD implementation requires SSE2, whic... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/vfetchoptimizer.cpp | C++ | // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details
#include "meshoptimizer.h"
#include <assert.h>
#include <string.h>
size_t meshopt_optimizeVertexFetchRemap(unsigned int* destination, const unsigned int* indices, size_t index_count, size_t vertex_count)
{
assert(index_cou... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/bitmask.py | Python | #!/usr/bin/python3
from z3 import *
def same8(v):
return Or(v == 0, v == 0xff)
magic = BitVec('magic', 64)
x = BitVec('x', 64)
y = x * magic
s = Solver()
solve_using(s, ForAll([x],
Or(
Not(And([same8((x >> (i * 8)) & 0xff) for i in range(8)])), # x has bytes that aren't equal to 0xff or 0x00
And([(x >>... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/clusterfuzz.cpp | C++ | #include "../src/meshoptimizer.h"
#include <float.h>
#include <stdint.h>
#include <stdlib.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* buffer, size_t size)
{
if (size == 0)
return 0;
srand(buffer[0]);
float vb[100][4];
for (int i = 0; i < 100; ++i)
{
vb[i][0] = rand() % 10;
vb[i][1] = rand() ... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/codecbench.cpp | C++ | #include "../src/meshoptimizer.h"
#include <algorithm>
#include <vector>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
double timestamp()
{
return emscripten_get_now() * 1e-3;
}
#elif defined(_WIN32)
struct LARGE_INTEGER
{
__int64 QuadPa... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/codecfuzz.cpp | C++ | #include "../src/meshoptimizer.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
void fuzzDecoder(const uint8_t* data, size_t size, size_t stride, int (*decode)(void*, size_t, size_t, const unsigned char*, size_t))
{
size_t count = 66; // must be divisible by 3 for decodeIndexBuffer; should be >=64 to c... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/codectest.cpp | C++ | #include "../src/meshoptimizer.h"
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#endif
size_t measure(const char* cmd, const std::vector<unsigned char>& data)
{
FILE* file = fopen("/tmp/codectest.in", "wb");
if (!fil... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/gltfbasis.py | Python | #!/usr/bin/python3
import argparse
import concurrent.futures
import matplotlib.pyplot as plt
import os
import os.path
import re
import subprocess
argp = argparse.ArgumentParser()
argp.add_argument('--basisu', type=str, required=True)
argp.add_argument('--graph', type=str, default="basisu.png")
argp.add_argument('--et... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/objloader.cpp | C++ | #ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#define FAST_OBJ_IMPLEMENTATION
#include "../extern/fast_obj.h"
| zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/simplifyfuzz.cpp | C++ | #include "../src/meshoptimizer.h"
#include <float.h>
#include <stdint.h>
#include <stdlib.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* buffer, size_t size)
{
if (size == 0)
return 0;
srand(buffer[0]);
float vb[100][4];
for (int i = 0; i < 100; ++i)
{
vb[i][0] = rand() % 10;
vb[i][1] = rand() ... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/vcachetester.cpp | C++ | #ifdef _WIN32
#include <assert.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#include <stdio.h>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <vector>
#include "../extern/fast_obj.h"
#include "../src/meshoptimizer.h"
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dcompiler.lib")
#pra... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/vcachetuner.cpp | C++ | #include "../extern/fast_obj.h"
#include "../src/meshoptimizer.h"
#define SDEFL_IMPLEMENTATION
#include "../extern/sdefl.h"
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
const int kCacheSizeMax = 16;
const int kValenceMax = 8;
... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/wasmpack.py | Python | #!/usr/bin/python3
import re
import sys
# regenerate with wasmpack.py generate
table = [32, 0, 65, 2, 1, 106, 34, 33, 3, 128, 11, 4, 13, 64, 6, 253, 10, 7, 15, 116, 127, 5, 8, 12, 40, 16, 19, 54, 20, 9, 27, 255, 113, 17, 42, 67, 24, 23, 146, 148, 18, 14, 22, 45, 70, 69, 56, 114, 101, 21, 25, 63, 75, 136, 108, 28, 118... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
tools/wasmstubs.cpp | C++ | #ifndef __wasi__
#error This file contains libc stubs for WASI SDK and should only be used in non-Emscripten WebAssembly builds
#endif
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
extern unsigned char __heap_base;
static intptr_t sbrkp = intptr_t(&__heap_base);
static const int WASM_PAGE_SIZE = 64 * 1... | zeux/meshoptimizer | 7,278 | Mesh optimization library that makes meshes smaller and faster to render | C++ | zeux | Arseny Kapoulkine | |
src/common.h | C/C++ Header | #pragma once
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <volk.h>
#include <vector>
#define VK_CHECK(call) \
do \
{ \
VkResult result_ = call; \
assert(result_ == VK_SUCCESS); \
} while (0)
#define VK_CHECK_FORCE(call) \
do \
{ \
VkResult result_ = call; \
if (result_ != VK_SUC... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/config.h | C/C++ Header | // Workgroup size for task shader; each task shader thread produces up to one meshlet
#define TASK_WGSIZE 64
// Workgroup size for mesh shader; mesh shader workgroup processes the entire meshlet in parallel
#define MESH_WGSIZE 64
// Should we do meshlet frustum, occlusion and backface culling in task shader?
#define ... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/device.cpp | C++ | #include "common.h"
#include "device.h"
#include "config.h"
#include "swapchain.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Validation is enabled by default in Debug
#ifndef NDEBUG
#define KHR_VALIDATION 1
#else
#define KHR_VALIDATION CONFIG_RELVAL
#endif
// Synchronization validation is disabl... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/device.h | C/C++ Header | #pragma once
bool isInstanceExtensionSupported(const char* name);
VkInstance createInstance();
VkDebugUtilsMessengerEXT registerDebugCallback(VkInstance instance);
uint32_t getGraphicsFamilyIndex(VkPhysicalDevice physicalDevice);
VkPhysicalDevice pickPhysicalDevice(VkPhysicalDevice* physicalDevices, uint32_t physica... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/extern.cpp | C++ | #define FAST_OBJ_IMPLEMENTATION
#include "fast_obj.h"
#define CGLTF_IMPLEMENTATION
#include "cgltf.h"
| zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/fileutils.cpp | C++ | #include "fileutils.h"
#include <assert.h>
#include <stdint.h>
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#else
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#ifdef _WIN32
void* mmapFile(const char* path, size_t* outSize)
{
*outSize = ... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/fileutils.h | C/C++ Header | #include <stddef.h>
void* mmapFile(const char* path, size_t* outSize);
void unmapFile(void* data, size_t size);
| zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/math.h | C/C++ Header | #pragma once
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat4x4.hpp>
#include <glm/ext/quaternion_float.hpp>
#include <glm/ext/quaternion_transform.hpp>
#include <glm/gtc/quaternion.hpp>
using glm::mat2;
using glm::mat3;
usi... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/niagara.cpp | C++ | #include "common.h"
#include "device.h"
#include "resources.h"
#include "textures.h"
#include "shaders.h"
#include "swapchain.h"
#include "config.h"
#include "math.h"
#include "scene.h"
#include "scenert.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <string>
#include <v... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/resources.cpp | C++ | #include "common.h"
#include "resources.h"
#include <string.h>
VkImageMemoryBarrier2 imageBarrier(VkImage image, VkPipelineStageFlags2 srcStageMask, VkAccessFlags2 srcAccessMask, VkImageLayout oldLayout, VkPipelineStageFlags2 dstStageMask, VkAccessFlags2 dstAccessMask, VkImageLayout newLayout, VkImageAspectFlags aspe... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/resources.h | C/C++ Header | #pragma once
struct Buffer
{
VkBuffer buffer;
VkDeviceMemory memory;
void* data;
size_t size;
VkDeviceAddress address;
};
struct Image
{
VkImage image;
VkFormat format;
VkImageView imageView;
VkDeviceMemory memory;
};
VkImageMemoryBarrier2 imageBarrier(VkImage image, VkPipelineStageFlags2 srcStageMask, VkA... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/scene.cpp | C++ | #include "common.h"
#include "scene.h"
#include "config.h"
#include <fast_obj.h>
#include <cgltf.h>
#include <meshoptimizer.h>
#include <time.h>
#include <algorithm>
#include <memory>
#include <cstring>
static void appendMeshlet(Geometry& result, const meshopt_Meshlet& meshlet, const std::vector<vec3>& vertices, c... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/scene.h | C/C++ Header | #pragma once
#include "math.h"
#include <stdint.h>
#include <string>
#include <vector>
struct alignas(8) Meshlet
{
uint16_t center[3];
uint16_t radius;
int8_t cone_axis[3];
int8_t cone_cutoff;
uint32_t dataOffset; // dataOffset..dataOffset+vertexCount-1 stores vertex indices, we store indices packed in 4b uni... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/scenecache.cpp | C++ | #include "common.h"
#include "scene.h"
#include "config.h"
#include "fileutils.h"
#include "meshoptimizer.h"
#include <stdio.h>
#include <string.h>
const uint32_t kSceneCacheMagic = 0x434E4353; // 'SCNC'
const uint32_t kSceneCacheVersion = 3;
struct SceneHeader
{
uint32_t magic;
uint32_t version;
uint32_t mesh... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/scenert.cpp | C++ | #include "common.h"
#include "scenert.h"
#include "scene.h"
#include "resources.h"
#include "config.h"
#include <string.h>
const VkBuildAccelerationStructureFlagsKHR kBuildBLAS = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR;
const VkBuildAccelerationStructureFlagsKHR kBuildCLAS = VK_BUILD_ACCELERATION_... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/scenert.h | C/C++ Header | #pragma once
struct Buffer;
struct Mesh;
struct MeshDraw;
struct Meshlet;
void buildBLAS(VkDevice device, const std::vector<Mesh>& meshes, const Buffer& vb, const Buffer& ib, std::vector<VkAccelerationStructureKHR>& blas, std::vector<VkDeviceSize>& compactedSizes, Buffer& blasBuffer, VkCommandPool commandPool, VkCom... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/shaders.cpp | C++ | #include "common.h"
#include "shaders.h"
#include "config.h"
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#else
#include <dirent.h>
#endif
#include <string>
#include <vector>
#if defined __APPLE__
#include <spirv_cross/spirv.h>
#elif defined __linux__
#include <spirv/unified1/spirv.h>
#elif ... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/shaders.h | C/C++ Header | #pragma once
#include <string>
struct Shader
{
std::string name;
std::vector<char> spirv;
VkShaderStageFlagBits stage;
VkDescriptorType resourceTypes[32];
uint32_t resourceMask;
uint32_t localSizeX;
uint32_t localSizeY;
uint32_t localSizeZ;
bool usesPushConstants;
bool usesDescriptorArray;
};
struct Sh... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/shaders/math.h | C/C++ Header | // 2D Polyhedral Bounds of a Clipped, Perspective-Projected 3D Sphere. Michael Mara, Morgan McGuire. 2013
bool projectSphere(vec3 c, float r, float znear, float P00, float P11, out vec4 aabb)
{
if (c.z < r + znear)
return false;
vec3 cr = c * r;
float czr2 = c.z * c.z - r * r;
float vx = sqrt(c.x * c.x + czr2);... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/shaders/mesh.h | C/C++ Header | #include "../config.h"
struct Vertex
{
float16_t vx, vy, vz;
uint16_t tp; // packed tangent: 8-8 octahedral
uint np; // packed normal: 10-10-10-2 vector + bitangent sign
float16_t tu, tv;
};
struct Meshlet
{
float16_t center[3];
float16_t radius;
int8_t cone_axis[3];
int8_t cone_cutoff;
uint dataOffset;... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/swapchain.cpp | C++ | #include "common.h"
#include "swapchain.h"
#include "config.h"
#include <GLFW/glfw3.h>
#ifdef VK_USE_PLATFORM_WIN32_KHR
#include <GLFW/glfw3native.h>
#endif
#include <algorithm>
#define VSYNC CONFIG_VSYNC
const char** getSwapchainExtensions(uint32_t* count)
{
#ifdef VK_USE_PLATFORM_WIN32_KHR
static const char* e... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/swapchain.h | C/C++ Header | #pragma once
struct Swapchain
{
VkSwapchainKHR swapchain;
std::vector<VkImage> images;
uint32_t width, height;
uint32_t imageCount;
bool dirty;
};
typedef struct GLFWwindow GLFWwindow;
const char** getSwapchainExtensions(uint32_t* count);
VkSurfaceKHR createSurface(VkInstance instance, GLFWwindow* window);
V... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/textures.cpp | C++ | #include "common.h"
#include "textures.h"
#include "resources.h"
#include <stdio.h>
#include <memory>
struct DDS_PIXELFORMAT
{
unsigned int dwSize;
unsigned int dwFlags;
unsigned int dwFourCC;
unsigned int dwRGBBitCount;
unsigned int dwRBitMask;
unsigned int dwGBitMask;
unsigned int dwBBitMask;
unsigned int... | zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/textures.h | C/C++ Header | #pragma once
struct Image;
struct Buffer;
bool loadImage(Image& image, VkDevice device, VkCommandPool commandPool, VkCommandBuffer commandBuffer, VkQueue queue, const VkPhysicalDeviceMemoryProperties& memoryProperties, const Buffer& scratch, const char* path);
| zeux/niagara | 1,665 | A Vulkan renderer written from scratch on stream | C++ | zeux | Arseny Kapoulkine | |
src/AABB2.h | C/C++ Header | #pragma once
#include <algorithm>
template <typename T>
class AABB2
{
public:
AABB2()
{
Reset();
}
AABB2(const Vector2<T>& _boxPoint1, const Vector2<T>& _boxPoint2)
{
Set(_boxPoint1, _boxPoint2);
}
bool Intersects(const AABB2<T>& aabb) const
{
if ((boxPoint1.... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Collider.cpp | C++ | #include "Collider.h"
#include "base/Parallel.h"
#include "base/RadixSort.h"
#include "microprofile.h"
static NOINLINE bool ComputeSeparatingAxis(RigidBody* body1, RigidBody* body2, Vector2f& separatingAxis)
{
// http://www.geometrictools.com/Source/Intersection2D.html#PlanarPlanar
// Adapted to return axis ... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Collider.h | C/C++ Header | #pragma once
#include "Manifold.h"
#include "base/DenseHash.h"
#include "base/AlignedArray.h"
namespace std
{
template <>
struct hash<std::pair<unsigned int, unsigned int>>
{
size_t operator()(const std::pair<unsigned int, unsigned int>& p) const
{
unsigned int lb = p.first;
... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Configuration.h | C/C++ Header | #pragma once
struct Configuration
{
enum SolveMode
{
Solve_Scalar,
Solve_SSE2,
Solve_AVX2,
};
enum IslandMode
{
Island_Single,
Island_Multiple,
Island_SingleSloppy,
Island_MultipleSloppy
};
SolveMode solveMode;
IslandMode islandMode;
int... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Coords2.h | C/C++ Header | #pragma once
template <typename T>
class Coords2
{
public:
Vector2<T> xVector, yVector;
Vector2<T> pos;
Coords2() {}
Coords2(const Vector2<T>& _pos, const T angle)
{
float pi = 3.141592f;
xVector = Vector2<T>(cos(angle), sin(angle));
yVector = Vector2<T>(cos(angle + T(pi) ... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Geom.h | C/C++ Header | #pragma once
#include "Vector2.h"
#include "Coords2.h"
#include "AABB2.h"
#include <cmath>
struct RigidBody;
struct Geom
{
Vector2f GetClippingVertex(const Vector2f& axis) const
{
Vector2f xdim = coords.xVector * size.x;
Vector2f ydim = coords.yVector * size.y;
float xsgn = coords.xVec... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Joints.h | C/C++ Header | #pragma once
#include "RigidBody.h"
#include "Manifold.h"
struct ContactJoint
{
ContactJoint(int body1Index, int body2Index, int collisionIndex)
{
this->contactPointIndex = collisionIndex;
this->body1Index = body1Index;
this->body2Index = body2Index;
normalLimiter_accumulatedI... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Manifold.h | C/C++ Header | #pragma once
#include "Vector2.h"
#include "Geom.h"
#include "RigidBody.h"
#include <limits>
#include <cassert>
static const int kMaxContactPoints = 2;
struct ContactPoint
{
ContactPoint()
{
}
ContactPoint(Vector2f point1, const Vector2f& point2, const Vector2f normal, RigidBody* body1, RigidBody* ... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/RigidBody.h | C/C++ Header | #pragma once
#include "Vector2.h"
#include "Coords2.h"
#include "Geom.h"
#ifdef _MSC_VER
#define NOINLINE __declspec(noinline)
#else
#define NOINLINE __attribute__((noinline))
#endif
struct RigidBody
{
RigidBody() {}
RigidBody(Coords2f coords, Vector2f size, float density)
{
this->coords = coords;... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Solver.cpp | C++ | #include "Solver.h"
#include "base/Parallel.h"
#include "base/SIMD.h"
#include "Configuration.h"
const float kProductiveImpulse = 1e-4f;
const float kFrictionCoefficient = 0.3f;
const int kIslandMinSize = 256;
Solver::Solver()
{
}
NOINLINE void Solver::SolveJoints(WorkQueue& queue, RigidBody* bodies, int bodiesCo... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Solver.h | C/C++ Header | #include "Joints.h"
#include <assert.h>
#include <vector>
#include "base/AlignedArray.h"
template <int N>
struct ContactLimiterPacked
{
float normalProjector1X[N];
float normalProjector1Y[N];
float normalProjector2X[N];
float normalProjector2Y[N];
float angularProjector1[N];
float angularProje... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/Vector2.h | C/C++ Header | #pragma once
#include <limits>
#include <cmath>
template <typename T>
struct Vector2
{
T x, y;
T& operator[](const int i)
{
return *(&(x) + i);
}
inline Vector2<T>() {}
//inline Vector3d(const Vector3d & rhs) { *this = rhs; }
inline Vector2<T>(const T& _x, const T& _y)
: x(... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/World.cpp | C++ | #include "World.h"
#include "base/Parallel.h"
#include "microprofile.h"
World::World()
: gravity(0)
{
}
RigidBody* World::AddBody(Coords2f coords, Vector2f size)
{
RigidBody newbie(coords, size, 1e-5f);
newbie.index = bodies.size;
bodies.push_back(newbie);
return &(bodies[bodies.size - 1]);
}
vo... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/World.h | C/C++ Header | #pragma once
#include "RigidBody.h"
#include "Collider.h"
#include "Solver.h"
struct Configuration;
struct World
{
enum SolveMode
{
Solve_Scalar,
Solve_SSE2,
Solve_AVX2,
};
World();
RigidBody* AddBody(Coords2f coords, Vector2f size);
void Update(WorkQueue& queue, fl... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/AlignedArray.h | C/C++ Header | #pragma once
#include <xmmintrin.h>
#include <string.h>
template <typename T>
struct AlignedArray
{
T* data;
int size;
int capacity;
AlignedArray()
: data(0)
, size(0)
, capacity(0)
{
}
~AlignedArray()
{
_mm_free(data);
}
AlignedArray(const Al... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/DenseHash.h | C/C++ Header | #pragma once
#include <vector>
#include <cassert>
#include <utility>
#include <functional>
// Internal implementation of DenseHashSet and DenseHashMap
namespace detail
{
template <typename Key, typename Item, typename Hash, typename Eq>
class DenseHashTable
{
public:
typedef typename std::vect... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/Parallel.h | C/C++ Header | #pragma once
#include "WorkQueue.h"
#include <atomic>
#include "microprofile.h"
template <typename T>
inline T& parallelForIndex(T* data, unsigned int index)
{
return data[index];
}
inline unsigned int parallelForIndex(unsigned int data, unsigned int index)
{
return data + index;
}
template <typename T, t... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/RadixSort.h | C/C++ Header | #pragma once
inline unsigned int radixUnsignedInt(unsigned int v)
{
return v;
}
inline unsigned int radixInt(int v)
{
// flip sign bit
return static_cast<unsigned int>(v) ^ 0x80000000;
}
inline unsigned int radixUnsignedFloat(const float& v)
{
return *reinterpret_cast<const unsigned int*>(&v);
}
inline unsigned... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/SIMD.h | C/C++ Header | #pragma once
#include <immintrin.h>
#ifdef _MSC_VER
#define SIMD_INLINE __forceinline
#define SIMD_ALIGN(n) __declspec(align(n))
#else
#define SIMD_INLINE __attribute__((always_inline)) inline
#define SIMD_ALIGN(n) __attribute__((aligned(n)))
#endif
namespace simd
{
template <int N> struct VNf_;
template <int N> s... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/SIMD_AVX2.h | C/C++ Header | #pragma once
#include "SIMD_AVX2_Transpose.h"
namespace simd
{
struct V8f
{
__m256 v;
SIMD_INLINE V8f()
{
}
SIMD_INLINE V8f(__m256 v): v(v)
{
}
SIMD_INLINE operator __m256() const
{
return v;
}
SIMD_INLINE static V8f zero()
{
return _mm256_setzero_ps();
}
SIMD_INLINE static V8... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/SIMD_AVX2_Transpose.h | C/C++ Header | #pragma once
// Transpose 4x4 blocks within each lane
#define _MM_TRANSPOSE8_LANE4_PS(row0, row1, row2, row3) \
do { \
__m256 __t0, __t1, __t2, __t3; \
__t0 = _mm256_unpacklo_ps(row0, row1); \
__t1 = _mm256_unpackhi_ps(row0, row1); \
__t2 = _mm256_unpacklo_ps(row2, row3); \
__t3 = _mm256_unpackhi_ps(row2, r... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/SIMD_SSE2.h | C/C++ Header | #pragma once
namespace simd
{
struct V4f
{
__m128 v;
SIMD_INLINE V4f()
{
}
SIMD_INLINE V4f(__m128 v): v(v)
{
}
SIMD_INLINE operator __m128() const
{
return v;
}
SIMD_INLINE static V4f zero()
{
return _mm_setzero_ps();
}
SIMD_INLINE static V4f one(float v)
{
return _mm_set1... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/SIMD_Scalar.h | C/C++ Header | #pragma once
#include <math.h>
namespace simd
{
struct V1f
{
float v;
SIMD_INLINE V1f()
{
}
SIMD_INLINE V1f(float v): v(v)
{
}
SIMD_INLINE operator float() const
{
return v;
}
SIMD_INLINE static V1f zero()
{
return 0.f;
}
SIMD_INLINE static V1f one(float v)
{
return v;
... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/WorkQueue.cpp | C++ | #include "WorkQueue.h"
#include "microprofile.h"
unsigned int WorkQueue::getIdealWorkerCount()
{
return std::max(std::thread::hardware_concurrency(), 1u);
}
WorkQueue::WorkQueue(unsigned int workerCount)
{
for (unsigned int i = 0; i < workerCount; ++i)
workers.emplace_back(workerThreadFun, this, i);
... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/WorkQueue.h | C/C++ Header | #pragma once
#include <vector>
#include <thread>
#include <functional>
#include <queue>
#include <mutex>
#include <condition_variable>
class WorkQueue
{
public:
struct Item
{
virtual ~Item() {}
virtual void run(int worker) = 0;
};
static unsigned int getIdealWorkerCount();
WorkQ... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/base/microprofile.cpp | C++ | #define MICROPROFILE_HELP_ALT "Right-Click"
#define MICROPROFILE_HELP_MOD "Ctrl"
#ifdef _WIN32
#include "../glad/glad.h"
#endif
#define GL_GLEXT_PROTOTYPES
#include <GLFW/glfw3.h>
#ifdef __APPLE__
#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
#include <OpenGL/gl3.h>
#endif
#define MICROPROFILE_WEBSERV... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/glad/glad.c | C | /*
OpenGL loader generated by glad 0.1.28 on Mon Nov 26 05:10:02 2018.
Language/Generator: C/C++
Specification: gl
APIs: gl=4.0
Profile: compatibility
Extensions:
Loader: True
Local files: False
Omit khrplatform: False
Reproducible: False
Commandline:
--pr... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/glad/glad.h | C/C++ Header | /*
OpenGL loader generated by glad 0.1.28 on Mon Nov 26 05:10:02 2018.
Language/Generator: C/C++
Specification: gl
APIs: gl=4.0
Profile: compatibility
Extensions:
Loader: True
Local files: False
Omit khrplatform: False
Reproducible: False
Commandline:
--pr... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/glad/khrplatform.h | C/C++ Header | #ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2018 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, includi... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
src/main.cpp | C++ | #ifdef _WIN32
#include "glad/glad.h"
#endif
#include <GLFW/glfw3.h>
#include "World.h"
#include "Configuration.h"
#include "base/WorkQueue.h"
#include "microprofile/microprofile.h"
#include "microprofile/microprofileui.h"
#include "microprofile/microprofiledraw.h"
struct Vertex
{
Vector2f position;
unsigne... | zeux/phyx | 112 | 2D physics engine with SoA/SIMD optimizations | C | zeux | Arseny Kapoulkine | |
docs/manual.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.23">
<meta name="author" content="website, repository">
<title>pugixml 1.15 manual</... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/quickstart.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.23">
<meta name="author" content="website, repository">
<title>pugixml 1.15 quick st... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/custom_memory_management.cpp | C++ | #include "pugixml.hpp"
#include <new>
// tag::decl[]
void* custom_allocate(size_t size)
{
return new (std::nothrow) char[size];
}
void custom_deallocate(void* ptr)
{
delete[] static_cast<char*>(ptr);
}
// end::decl[]
int main()
{
// tag::call[]
pugi::set_memory_management_functions(custom_allocate, cust... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/include.cpp | C++ | #include "pugixml.hpp"
#include <string.h>
#include <iostream>
// tag::code[]
bool load_preprocess(pugi::xml_document& doc, const char* path);
bool preprocess(pugi::xml_node node)
{
for (pugi::xml_node child = node.first_child(); child; )
{
if (child.type() == pugi::node_pi && strcmp(child.name(), "i... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/load_error_handling.cpp | C++ | #include "pugixml.hpp"
#include <iostream>
void check_xml(const char* source)
{
// tag::code[]
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_string(source);
if (result)
{
std::cout << "XML [" << source << "] parsed without errors, attr value: [" << doc.child("node").attribu... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/load_file.cpp | C++ | #include "pugixml.hpp"
#include <iostream>
int main()
{
// tag::code[]
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file("tree.xml");
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
// end::code[]
}
... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/load_memory.cpp | C++ | #include "pugixml.hpp"
#include <iostream>
#include <cstring>
int main()
{
// tag::decl[]
const char source[] = "<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>";
size_t size = sizeof(source);
// end::decl[]
pugi::xml_document doc;
{
// tag::load_buffer[]
// You can use load_buffer t... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/load_options.cpp | C++ | #include "pugixml.hpp"
#include <iostream>
int main()
{
pugi::xml_document doc;
// tag::code[]
const char* source = "<!--comment--><node><</node>";
// Parsing with default options; note that comment node is not added to the tree, and entity reference < is expanded
doc.load_string(source);
... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/load_stream.cpp | C++ | #include "pugixml.hpp"
#include <fstream>
#include <iomanip>
#include <iostream>
void print_doc(const char* message, const pugi::xml_document& doc, const pugi::xml_parse_result& result)
{
std::cout
<< message
<< "\t: load result '" << result.description() << "'"
<< ", first character of ro... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine | |
docs/samples/modify_add.cpp | C++ | #include "pugixml.hpp"
#include <iostream>
int main()
{
pugi::xml_document doc;
// tag::code[]
// add node with some name
pugi::xml_node node = doc.append_child("node");
// add description node with text child
pugi::xml_node descr = node.append_child("description");
descr.append_child(pu... | zeux/pugixml | 4,499 | Light-weight, simple and fast XML parser for C++ with XPath support | C++ | zeux | Arseny Kapoulkine |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.