Skip to content

Instantly share code, notes, and snippets.

@arturoc
arturoc / main.cpp
Created May 16, 2017 15:07
opengles2
int main(){
ofGLESWindowSettings settings;
settings.setGLESVersion(2);
ofCreateWindow(settings);
ofRunApp(new ofApp);
}
{
"Inflation": {
"Inflation": {
"Circle": {
"circle_pct": "0",
"inner_radius": "0.99",
"outer_radius": "1"
},
"Colors": {
"color_1": "0.956863, 0.8, 0, 1",
@arturoc
arturoc / gui.cpp
Created May 15, 2017 17:06
custom save gui/timeline
listeners.push_back(gui.savePressedE.newListener([this]{
auto saveTo = ofSystemSaveDialog(ofGetTimestampString() + ".json", "save settings");
if(saveTo.bSuccess){
auto path = std::filesystem::path(saveTo.getPath());
auto folder = path.parent_path();
auto basename = path.stem().filename().string();
auto extension = ofToLower(path.extension().string());
auto timelineDir = (folder / (basename + "_timeline")).string();
if(extension == ".xml"){
ofXml xml;
@arturoc
arturoc / pixels.cpp
Created August 17, 2015 17:47
ofPixels range based loops
for(auto line: pixels.getLines()){
for(auto pixel: line.getPixels()){
pixel[0] // -> red channel or gray in a grayscale image
auto lineAbovePixel = pixel - pixels.getWidth();
lineAbovePixel[0] // read channel in pixel one line above
}
}
EGLContext context = eglGetCurrentContext();
EGLDisplay eglDisplay = eglGetCurrentDisplay();
glBindTexture(GL_TEXTURE_2D, 0);
EGLint imageAttributes[] = {
EGL_GL_TEXTURE_LEVEL_KHR, 0, // mip map level to reference
EGL_IMAGE_PRESERVED_KHR, EGL_FALSE,
EGL_NONE
};
EGLImageKHR (*eglCreateImageKHR)(EGLDisplay,EGLContext,int,EGLClientBuffer,EGLint*);
#pragma once
#include <vector>
#include <functional>
#include <mutex>
#include <thread>
template<typename T>
class ofEvent{
public:
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
fatal runtime error: assertion failed: !ptr.is_null()
Program received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7fffd7fff700 (LWP 28971)]
0x0000000000483d4b in rt::util::abort::h66e24f48938afe6eMim::v0.10.pre ()
(gdb) bt
#0 0x0000000000483d4b in rt::util::abort::h66e24f48938afe6eMim::v0.10.pre ()
#1 0x00000000007b73d1 in rt::local_ptr::compiled::take::he8a5e3f0ec45f53amAs::v0.1 ()
#2 0x00000000007c7778 in comm::Chan$LT$T$GT$::send::hfedc51b572bd5818fot::v0.1 ()
...
spawn(proc(){
let (port,chan): (comm::Port<Message>, comm::Chan<Message>) = comm::Chan::new();
let mut chan = ~chan;
set_c_callback(c_callback, cast::transmute(&mut *chan));
loop{
//...
}
});
extern "C" fn c_callback (data: *c_void){
// TEST 0.8
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup() {
ofBackground(0, 0, 0);
bricksHigh = 0;
bricksWide = 0;
totalBricks = 0;