Skip to content

Instantly share code, notes, and snippets.

@shiyuugohirao
shiyuugohirao / ofxMonitorUtils.h
Created March 8, 2024 10:00
get Moitor information for openframeworks
#pragma once
#include "ofLog.h"
#include "ofVectorMath.h"
#include "GLFW/glfw3.h"
namespace ofxMonitorUtils {
struct MonitorInfo {
int index;
std::string name;
@shiyuugohirao
shiyuugohirao / ofxNotion.h
Last active February 21, 2024 03:15
simply use to send Notion for e.g. log
/*
ofxNotion
by shugohirao
simply use to send Notion for e.g. log
doc : https://shiyuugo.notion.site/ofxNotion-91b51c9d9fee458e94c1e9261dc7b294?pvs=4
*/
#pragma once
#include "ofMain.h"
@shiyuugohirao
shiyuugohirao / ofxMouseHandler.h
Created July 5, 2023 09:01
handling mouse visibility in openFrameworks
#pragma once
#include "ofMain.h"
inline void updateMouse(int mouseX, int mouseY, float hideTimef = 1.0) {
glm::vec2 cursorPos(mouseX, mouseY);
static glm::vec2 lastCursorPos = cursorPos;
static bool cursorFlag = true;
static float stopCursorTimef = 0;
if (cursorPos == lastCursorPos) {
@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);
@shiyuugohirao
shiyuugohirao / glslUtils.glsl
Last active April 17, 2022 07:50
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 / 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 / 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 / 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 / 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 / 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) {