Skip to content

Instantly share code, notes, and snippets.

@vicrucann
vicrucann / CMakeLists.txt
Created June 14, 2016 17:58
OpenSceneGraph + QOpenGLWidget bug when using QTest
project(qtosg_tests)
cmake_minimum_required(VERSION 2.8.11)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core 5.4 REQUIRED)
find_package(Qt5Gui 5.4 REQUIRED)
@vicrucann
vicrucann / CMakeLists.txt
Created June 14, 2016 18:08
OpenSceneGraph + QOpenGLWidget - minimal example
cmake_minimum_required(VERSION 2.8.11)
project(qtosg)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui OpenGL)
find_package(OpenSceneGraph REQUIRED COMPONENTS osgDB osgGA osgUtil osgViewer)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
@vicrucann
vicrucann / osg-shader-pass.cpp
Last active November 2, 2020 17:29
Pass through example of OpenSceneGraph vertex + shader shaders with OpenGL 4.00
#include <Windows.h> // comment if not Windows
#include <osg/Camera>
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
#include <osg/Node>
#include <osg/NodeVisitor>
#include <osg/Object>
@vicrucann
vicrucann / osg-shader-polyline.cpp
Last active December 23, 2021 06:01
OpenSceneGraph simple geometry shader example: turns line adjacency into triangle strip (based on cinder line shader)
#include <Windows.h>
#include <osg/Camera>
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
#include <osg/Node>
#include <osg/NodeVisitor>
#include <osg/Object>
@vicrucann
vicrucann / osg-shader-polyline2.cpp
Created July 13, 2016 20:09
Similar to the osg-shader-polyline, but with round caps (in development)
#include <Windows.h>
#include <osg/Camera>
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
#include <osg/Node>
#include <osg/NodeVisitor>
#include <osg/Object>
@vicrucann
vicrucann / osg-openGL-version.cpp
Created August 5, 2016 18:27
Obtain OpenGL version from OSG
#include <iostream>
#include <stdio.h>
#ifdef _WIN32
#include <Windows.h>
#endif
#include <osgViewer/Viewer>
#include <osg/GLExtensions>
@vicrucann
vicrucann / OsgPathFitter.cpp
Last active August 26, 2016 19:50
QtOSG widget displays Bezier curve fitting to data points, based on Schneider's algorithm for curve fitting
#include "OsgPathFitter.h"
template <typename Container, typename Point2, typename Real>
OsgPathFitter<Container, Point2, Real>::OsgPathFitter(const osg::Vec2Array &path)
: PathFitter<osg::Vec2Array, osg::Vec2f, float>(path)
{
}
template <typename Container, typename Point2, typename Real>
Container *OsgPathFitter<Container, Point2, Real>::fit(Real error)
@vicrucann
vicrucann / bezier.frag
Last active February 24, 2024 23:00
GLSL shader that allows to draw smooth and thick Bezier lines in 3D; added fog effect; using OpenSceneGraph for visualization
#version 330
in VertexData{
vec4 mColor;
} VertexIn;
void main(void)
{
gl_FragColor = VertexIn.mColor;
}
@vicrucann
vicrucann / polygon-fog-shader.cpp
Last active August 3, 2022 08:28
Basic example of a GLSL shader (vertex and fragment shaders) that simulates fog effect; using OpenSceneGraph for visualization
#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32
#include <osg/Camera>
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
#include <osg/Node>
@vicrucann
vicrucann / CMakeLists.txt
Created December 13, 2016 15:28
OpenSceneGraph Photo class: photo flips, move and rotation
cmake_minimum_required(VERSION 2.8.11)
project(osg-photo)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(OpenSceneGraph REQUIRED COMPONENTS osgDB osgGA osgUtil osgViewer)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
set(SOURCES