Skip to content

Instantly share code, notes, and snippets.

@gwaldron
gwaldron / cpp
Created April 30, 2024 12:39
Test - toggle the alpha value of featurenode symbols
#include <osgViewer/Viewer>
#include <osgEarth/Notify>
#include <osgEarth/EarthManipulator>
#include <osgEarth/ExampleResources>
#include <osgEarth/MapNode>
#include <osgEarth/FeatureNode>
#include <osgEarth/TMS>
#include <iostream>
using namespace osgEarth;
@gwaldron
gwaldron / callstack.cpp
Created December 8, 2023 14:23
Call stack printer (win/linux)
#ifdef WIN32
#include <Windows.h>
#include <iostream>
#include <dbghelp.h>
#pragma comment(lib, "dbghelp.lib")
void printStackTrace()
{
HANDLE process = GetCurrentProcess();
SymInitialize(process, NULL, TRUE);
@gwaldron
gwaldron / gist:8da30ff660a3addc34ba997b9befc890
Created December 7, 2023 17:24
Simple texture + matrix shader animation.
#include <osgViewer/Viewer>
#include <osg/Geometry>
#include <osg/Texture2D>
#include <osgEarth/Utils>
#include <osgDB/ReadFile>
using namespace osgEarth;
int main(int argc, char** argv)
@gwaldron
gwaldron / gist:d8a37fdda8b711892eedb5b2779c0cac
Last active November 27, 2023 19:46
WebGPU Hello World
<html>
<head>
<title>WebGPU Hello World</title>
<script>
async function main() {
const adapter = await window.navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
canvas = document.getElementById("gpu_canvas");
context = canvas.getContext("webgpu");
@gwaldron
gwaldron / plodify.cpp
Created August 4, 2022 12:20
Turn a model into a paged lod
#include <osg/ArgumentParser>
#include <osg/PagedLOD>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <iostream>
int
main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
@gwaldron
gwaldron / timegui.cpp
Created October 26, 2021 16:26
TimeGUI example (with WMS-T)
/** PASTE ME OVER osgearth_imgui.cpp **/
#include <osgEarth/ImGui/ImGui>
#include <osgEarth/EarthManipulator>
#include <osgEarth/ImageLayer>
#include <osg/ImageSequence>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
@gwaldron
gwaldron / main.cpp
Last active October 26, 2021 15:06
ImageTimeline example
/*** PASTE ME OVER osgearth_imgui.cpp ***/
#include <osgEarth/ImGui/ImGui>
#include <osgEarth/EarthManipulator>
#include <osgEarth/ImageLayer>
#include <osg/ImageSequence>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
@gwaldron
gwaldron / main.cxx
Last active October 26, 2021 11:54
ImageSequence example
#include <osgViewer/Viewer>
#include <osgEarth/Notify>
#include <osgEarth/EarthManipulator>
#include <osgEarth/MapNode>
#include <osg/ImageSequence>
#include <osgDB/ReadFile>
#include <osgEarth/ImageLayer>
using namespace osgEarth;
using namespace osgEarth::Util;
@gwaldron
gwaldron / gist:e60c7ce2b0eb1ebb7418249caaebb5ba
Created March 4, 2021 13:10
Vertical scale shader for osgEarth 3.x
<terrainshader>
<code>
<![CDATA[
#pragma version 330
#pragma vp_location vertex_model
#pragma vp_entryPoint verticalScale
uniform float scale = 1.0;
vec3 vp_Normal;
float oe_terrain_getElevation();
@gwaldron
gwaldron / gist:08726aab39801d314e1b2eb041b7088c
Created November 12, 2020 20:09
Example of memory-backed FeatureSource
#include <osgEarth/EarthManipulator>
#include <osgEarth/ExampleResources>
#include <osgEarth/FeatureSource>
#include <osgEarth/TMS>
#include <osgEarth/FeatureImageLayer>
#include <osgEarth/TerrainEngineNode>
#include <osgEarth/ViewFitter>
#include <osgViewer/Viewer>
using namespace osgEarth;