Skip to content

Instantly share code, notes, and snippets.

View v3c70r's full-sized avatar
🐱
Cats typing ...

QGu v3c70r

🐱
Cats typing ...
View GitHub Profile
@v3c70r
v3c70r / rotationAxis.md
Last active October 6, 2015 17:17
rotationAxis.md

First, you need to find a plan that parallel to projection plan in object space. gluUnproject() function gonna do the trick for you.

GLint gluUnProject(
	GLdouble winX,  
	GLdouble winY, 
	GLdouble winZ,  
	const GLdouble * model,  
	const GLdouble * proj, 
@v3c70r
v3c70r / CMakeLists.txt
Last active February 16, 2016 17:10
CMake tricks
# List all elements in a var
FOREACH(item ${OPENGL_LIBRARIES})
MESSAGE(STATUS ${item})
ENDFOREACH(item)
/* Copyright (C)
* 2016 - Tsing Gu
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
static vec findNearestPoint(vector<vec> line1, vector<vec>line2)
{
//vec p_0 = {line1[0](0), line1[0](1), line1[0](2)};
//vec q_0 = {line2[0](0), line2[0](1), line2[0](2)};
vec p_0 = line1[0];
vec q_0 = line2[0];
vec u = line1[1];
vec v = line2[1];
//全是伪代码
preMousePos;
updateCamera()
{
if (leftBtnPressed)
{
curMousePos = glfwGetMousePos();
mouseDiff = curMousPose - preMousePos;
applyRotationToCamera(mouseDiff);
preMousePos = curMousePos;
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <iostream>
#include <vector>
#include <stdexcept>
#include <functional>
#include <cstring>
#include <set>
@v3c70r
v3c70r / plot.glsl
Created December 2, 2016 21:30
Plot f(x) or f(y) on screen.
float plotX(vec2 st, float pct){
return smoothstep( pct-0.01, pct, st.y) -
smoothstep( pct, pct+0.01, st.y);
}
float plotY(vec2 st, float pct){
return smoothstep( pct - 0.01, pct, st.x) -
smoothstep(pct, pct + 0.01, st.x);
}
@v3c70r
v3c70r / CMakeLists.txt
Created January 10, 2017 21:48
CodeCoverage using cmake
# An example of how to use gcov/lcov with cmake.
cmake_minimum_required (VERSION 2.8.11)
project(testing)
set (CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
set (CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
add_executable(exe test.cpp)
@v3c70r
v3c70r / GLSLValidator.cpp
Created March 9, 2017 22:46
GLSL_Validator
#include <GL/glew.h>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <GLFW/glfw3.h>
const size_t MAX_SHADER_LOG_LENGTH = 2048;
std::string clangifyError(const char* err, const std::string& fileName)
{
// The ocean FFT
// Can be played on book of shader editor
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;