Skip to content

Instantly share code, notes, and snippets.

#include <ole2.h>
#include <ShObjIdl.h>
#include <vector>
#include <string>
class CDropTarget : public IDropTarget
{
public:
CDropTarget() {};
@hb3p8
hb3p8 / markdeep.js
Created June 22, 2016 10:34
Markdeep with localized keywords
/**
markdeep.js
Version 0.12
Copyright 2015-2016, Morgan McGuire, http://casual-effects.com
All rights reserved.
-------------------------------------------------------------
See http://casual-effects.com/markdeep for documentation on how to
@hb3p8
hb3p8 / tiled_voronoi.html
Created March 31, 2021 08:27
Generate normals for car paint base layer
<!DOCTYPE html>
<html>
<head>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<meta charset=utf-8>
</head>
<body>
<canvas width=2048 height=2048 style="width: 800px; height: 800px"></canvas>
</body>
<script language="javascript" src="https://npmcdn.com/regl/dist/regl.js"></script>
// CC0
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#define isdigit(c) (c >= '0' && c <= '9')
namespace ImGui
{
float strToFloat (const char *s) // atof from minilibc
// based on shader by Nikos Papadopoulos, 4rknova / 2013 (https://www.shadertoy.com/view/llGSzw)
// Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
#define ENABLE_LIGHTING
#define ENABLE_SPECULAR
#define OFFSET_X 1
#define OFFSET_Y 1
#define DEPTH 5.5
std::ofstream file ("Mesh.obj");
// Every vertex is a line in output file:
// v pos_x pos_y pos_z
for (int i = 0; i < mesh->numVertices(); ++i) {
file << "v " << mesh->vertices()[i].x() << " "
<< mesh->vertices()[i].y() << " "
<< mesh->vertices()[i].z() << std::endl;
}
@hb3p8
hb3p8 / ImGuiHandler.cpp
Created January 29, 2016 08:33
ImGui OSG wrapper
#include <ImGuiHandler.hpp>
#include <imgui/imgui.h>
#include <iostream>
using namespace sf;
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
// If text or lines are blurry when integrating ImGui in your engine:
vec4 StepJFA (in vec2 fragCoord, in float level)
{
level = clamp(level-1.0, 0.0, c_maxSteps);
float stepwidth = floor(exp2(c_maxSteps - level)+0.5);
float bestDistance = 9999.0;
vec2 bestCoord = vec2(0.0);
vec3 bestColor = vec3(0.0);
for (int y = -1; y <= 1; ++y) {
float const depthGL = read_imagef (depthImage, depthSampler, (int2) (x, y)).x; // in range [0,1]
float2 const pixel = (float2) ( (x + 0.5f) / (float) imageSizeX,
(y + 0.5f) / (float) imageSizeY); // in range [0,1]
float4 point_NDC = (float4) ( 2.0f * pixel.x - 1.0f, // in range [-1,1]
2.0f * pixel.y - 1.0f, // in range [-1,1]
2.0f * depthGL - 1.0f, // in range [-1,1]
1.0f);