Skip to content

Instantly share code, notes, and snippets.

@shiyuugohirao
shiyuugohirao / ofxUnsplash.h
Created October 3, 2024 13:24
tiny methods for UnsplashAPI with openFrameworks
#pragma once
#include "ofURLFileLoader.h"
#include "ofFileUtils.h"
#include "ofUtils.h"
namespace ofxUnsplash {
string AccessKey;
inline void setupAccessKey(const string& accessKey) {
AccessKey = accessKey;
@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
Last active August 16, 2024 12:58
handling mouse visibility in openFrameworks
#pragma once
#include "ofAppRunner.h"
/* [Note]
if you use ImGui, add bellow after .begin() not to control mouse by ImGui.
`ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;`
*/
inline void updateMouse(int mouseX, int mouseY, float hideTimef = 1.0) {
glm::vec2 cursorPos(mouseX, mouseY);
@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 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 / 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()){}