Skip to content

Instantly share code, notes, and snippets.

@shiyuugohirao
shiyuugohirao / ofGraphics.h
Created March 5, 2018 21:55
ofColor::white のwarning対策 ### ADD ###追加
#pragma once
#include "ofConstants.h"
#include "ofColor.h"
#include "ofPoint.h"
#include "ofMatrix4x4.h"
#include "ofRectangle.h"
#include "ofTypes.h"
/// \cond INTERNAL
@shiyuugohirao
shiyuugohirao / ofBase64.h
Last active April 13, 2019 04:31
openFrameworks + simple Base64 encoder
//
// ofBase64.h
//
// Created by shugohirao on 2018/05/09.
//
#pragma once
#include "Poco/Base64Encoder.h"
namespace ofBase64 {
@shiyuugohirao
shiyuugohirao / makeWavBuffer().cpp
Last active May 13, 2018 18:15
convert ofSoundBuffer to ofBuffer
//--------------------------------------------------------------
// referrered to ofxSoundObjects
//--------------------------------------------------------------
ofBuffer makeWavBuffer(const ofSoundBuffer &buff){
// write a wav header
short myFormat = 1; // for pcm
int mySubChunk1Size = 16;
int bitsPerSample = 16; // assume 16 bit pcm
int myByteRate = buff.getSampleRate() * buff.getNumChannels() * bitsPerSample/8;
@shiyuugohirao
shiyuugohirao / ofSnippets.h
Last active May 5, 2019 19:40
my snippets for oepnFrameworks
//
// ofSnippets.h
//
// Created by shugohirao on 2018/11/01~.
//
/*==================================================
setup
==================================================*/
static void loadImg2Tex(ofTexture &tex, string path, float scale=1.0) {
@shiyuugohirao
shiyuugohirao / ThreadedSoundPlayFunction.cpp
Created November 6, 2018 04:24
ofSoundPlayer with std::thread
void play(string soundPath, bool bOneShotLife=false){
if(ofFile::doesFileExist(soundPath)){
thread soundThread([=]{
ofSoundPlayer sp;
sp.load(soundPath);
sp.setLoop(false);
cout<< "play talk";
int t = ofGetElapsedTimeMicros();
sp.play();
while(sp.isLoaded() && sp.isPlaying()){}
@shiyuugohirao
shiyuugohirao / getIP.h
Created December 8, 2018 03:14
getIP() on Mac
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
static string getIP(){
int fd;
struct ifreq ifr;
fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET;
@shiyuugohirao
shiyuugohirao / ofxTsumami.h
Last active May 4, 2019 14:51
ofxTsumami is so simple volume knob class for openFrameworks
class ofxTsumami {
private:
float *target;
float radius;pp
float minVal, maxVal, initVal, pressedPct;
string name;
int res;
glm::vec2 pos, pressedPos;
bool bVertical;
@shiyuugohirao
shiyuugohirao / wstringUtils.h
Last active May 1, 2021 22:13
simple wstring & string converter in c++.
// wstringUtils.h
// https://gist.github.com/shiyuugohirao/5fb074dd346f96945136537bc6e2e7b9
#pragma once
#include <stringapiset.h>
#include <WinBase.h>
#include <system_error>
#include <vector>
static std::wstring to_wstring(std::string const& src)
{
@shiyuugohirao
shiyuugohirao / glslUtils.glsl
Last active October 11, 2024 16:20
glsl utils
/*--------------------------------------------------
# glslUtils
- https://gist.github.com/patriciogonzalezvivo/670c22f3966e662d2f83
- https://github.com/ashima/webgl-noise
- https://thebookofshaders.com/
- https://github.com/jamieowen/glsl-blend
--------------------------------------------------*/
/*============================== Color ==============================*/
vec3 rgb2hsb( in vec3 c ){
@shiyuugohirao
shiyuugohirao / ofxIcon.h
Last active March 8, 2024 09:47
setup icon in openFrameworks app (only windows)
#pragma once
#include "ofMain.h"
inline void setupIcon(string iconPath) {
// set window icon
HICON hWindowIcon = NULL;
HICON hWindowIconBig = NULL;
HWND hwnd = ofGetWin32Window();
if (hWindowIcon != NULL) DestroyIcon(hWindowIcon);
if (hWindowIconBig != NULL) DestroyIcon(hWindowIconBig);