Quantcast
Channel: beginners - openFrameworks
Viewing all 4929 articles
Browse latest View live

Multiple windows events GUI

$
0
0

@edapx wrote:

Hello, I am building an app with two windows, following the template of examples/window/multiwindowExample. In the app containing, among the other things, the GUI, I need to send an event to the ofApp.

What I am doing at the moment is:

main.cpp

#include "ofMain.h"
#include "ofApp.h"
#include "Editor.h"
//#include "ofAppGLFWWindow.h"

int main( ){    
    ofGLFWWindowSettings settings;

    settings.setSize(1400, 700);
    settings.setGLVersion(3, 2);
    settings.setPosition(ofVec2f(300,0));
    settings.resizable = true;
    shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);

    settings.setSize(300, 300);
    settings.setPosition(ofVec2f(0,0));
    settings.resizable = false;
    shared_ptr<ofAppBaseWindow> editorWindow = ofCreateWindow(settings);

    shared_ptr<ofApp> mainApp(new ofApp);
    shared_ptr<Editor> editor(new Editor);
    mainApp->editor = editor;

    ofRunApp(editorWindow, editor);
    ofRunApp(mainWindow, mainApp);
    ofRunMainLoop();
}

Editor.cpp

#include "Editor.h"

void Editor::setup(){
    parameters.setName("parameters");
    gui.setup();
    //gui.add(cube.params);
    gui.add(generateButton.setup("setup"));
    ofBackground(0);
    ofSetVerticalSync(false);
}

void Editor::update(){

}

void Editor::draw(){
    gui.draw();
}

ofApp.cpp, partial

void ofApp::setup(){
    editor.generateButton.addListener(this, &ofApp::generateButtonPressed);
....
}

ofApp.h

#pragma once

#include "ofMain.h"
#include "Editor.h"

class ofApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();

        void generateButtonPressed();

		void keyPressed(int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void mouseEntered(int x, int y);
		void mouseExited(int x, int y);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);


    shared_ptr<Editor> editor;

};

And the error that I am receving is:

“/home/dapx/Documents/of_v0.10.0_linux64gcc5_release/apps/myApps/orthopattern/src/ofApp.cpp:5: error: ‘class std::shared_ptr’ has no member named ‘generateButton’
editor.generateButton.addListener(this, &ofApp::generateButtonPressed);
^”

Any idea?

Posts: 1

Participants: 1

Read full topic


Debug.exe screen not showing ofLog messages

$
0
0

@nadinevdberg wrote:

My debug screen is not showing any ofLog() messages. it doesn’t matter what file or app I run, it’s not showing anything. One of the codes I tested it with is this simple one:



Could this be a visual studio’s problem or an openFrameworks problem?

Thanks

Posts: 1

Participants: 1

Read full topic

Windows PCI / usb card Recommendations for ofVideoGrabber

$
0
0

@Kristoffer_Oerum wrote:

Can anyone recommend a cheapish pcie or usb card with relatively low CPU overhead (ie. Onboard encoseer) for capturing live video via hdmi in from a Panasonic gh4. Target platform Ofx10 under windows 10? I’m having difficulty sourcing the ones I’ve found recommended on this forum from Denmark, so any up to date hints would be great.
ATB
K

Posts: 3

Participants: 2

Read full topic

/clang:-1: linker command failed with exit code 1 (use -v to see invocation)

$
0
0

@chrleon wrote:

Hello, new guy here. Coming from Processing.

I just downloaded OF 0.10.0 from the website the other day. I then opened the project 03_simpleShaderInteractio in xcode and tried to build it.

I managed to remove the 386 build settings, but now the build fails on
/clang:-1: linker command failed with exit code 1 (use -v to see invocation)

I’m relatively new to c++ compiling, so I don’t know where to start. The threads that came up with the same name, did not help me.

macOS 10.14 Mojave
of 0.10.0
xcode 10.0

Posts: 2

Participants: 2

Read full topic

Connecting a arduino to ofxFaceTracker - Example-expressions

$
0
0

@QuintenBast wrote:

Hello,

I try to link my arduino to the Example-expressions project of ofxFaceTracker. I want to make sure that if you smile, for example, a LED goes on. Is this even possible?
I hope someone can help me.

Posts: 1

Participants: 1

Read full topic

Integration with Ultralight

$
0
0

@itzaks wrote:

It seems like Ultralight is the successor of Awesomium?

Seems really interesting and useful for building a HTML UI on top of a C++ app. Has anyone given it a shot together with Openframeworks? Would such an integration be possible?

Posts: 1

Participants: 1

Read full topic

ofSerial works for a few seconds then stops

$
0
0

@aaa wrote:

I’m testing out sending some basic serial data from oF -> Arduino and running into some problems. It works for a couple cycles and then stops:

unsigned char myByte = 0;
mySerial.writeByte(myByte);

ofSleepMillis(1000);

myByte = 90;
mySerial.writeByte(myByte);

ofSleepMillis(1000);

myByte = 180;
mySerial.writeByte(myByte);

ofSleepMillis(1000);

myByte = 90;
mySerial.writeByte(myByte);

ofSleepMillis(1000);

ofLog() << "hi";

The Arduino is simply reading these incoming bytes and actuating a servo motor to that position. It works just fine in Processing, which leads me to believe this is a problem with oF or the Raspberry Pi it’s running on. I remember seeing a post for creating long term installations that strongly suggested using MIDI instead of USB Serial comms, perhaps for this exact reason?

Posts: 2

Participants: 2

Read full topic

OF_FULLSCREEN on Linux and Nvidia Drivers

$
0
0

@bbogart wrote:

When using this method to create a fullscreen window (using 0.9.3 and 0.10.0) I get a window with titlebar that fills the screen area, but does not render anything. I’m following up on this thread: How to do fullscreen in of0.9.1

I’m using Ubuntu Xenial with Nvidia drivers 384.130.

OF_GAME_MODE does seem to work as expected.

    // Set up GL3 (programmable renderer) and window the new way.
    ofGLWindowSettings settings;
    settings.width = 1920;
    settings.height = 1920;
    settings.setGLVersion(3, 2);
    settings.windowMode = OF_FULLSCREEN; // This seems to do nothing!
    //settings.windowMode = OF_GAME_MODE; // Works
    ofCreateWindow(settings);
	ofRunApp( new ofApp() );

Yes, this is a 1920x1920 display.

Posts: 2

Participants: 1

Read full topic


Std::chrono How to use this C++ time tool

$
0
0

@bob97086 wrote:

Evidently std::chrono is the modern time-keeping tool of choice for C++. I’ve had problems using it to measure time beginning at a certain program condition and triggering an event when a predefined interval has elapsed.

To further confuse me, Visual C++ seems to be returning a duration in nanoseconds. It is more convenient for me to work in milliseconds or maybe microseconds.

Anybody know of a gentle (but not too gentle) introduction or discussion of chrono, hopefully with numerous examples.

Many thanks!

Posts: 1

Participants: 1

Read full topic

My VideoGrabber example source is not works

$
0
0

@bemoregt wrote:

Hi, Everyone.

My VideoGrabber example source is not works.

I met this error at runtime.

What’s wrong with me?

2018-10-16 17:17:36.230189+0900 videoGrabberExampleDebug[11775:317310] [default] Unable to load Info.plist exceptions (eGPUOverrides)

2018-10-16 17:17:36.452034+0900 videoGrabberExampleDebug[11775:317382] MessageTracer: Falling back to default whitelist

[notice ] Device: 0: USB2.0 PC CAMERA

[notice ] Device: 1: FaceTime HD 카메라(내장형)

[notice ] 0: USB2.0 PC CAMERA

[notice ] 1: FaceTime HD 카메라(내장형)

2018-10-16 17:17:37.021251+0900 videoGrabberExampleDebug[11775:317310] [] CMIO_Unit_ScopeElement.h:200:SafeGetElement Throwing err: -67454

2018-10-16 17:17:37.023331+0900 videoGrabberExampleDebug[11775:317310] [] CMIOUnitFigBaseObjectImpl.c:246:CMIOUnitCreateFromDescription Invalid paramater

2018-10-16 17:17:37.048151+0900 videoGrabberExampleDebug[11775:317310] [] CMIO_Unit_Input_Device.cpp:244:GetPropertyInfo CMIOUInputFromProcs::GetPropertyInfo() failed for id 102, Error: -67456

2018-10-16 17:17:37.123668+0900 videoGrabberExampleDebug[11775:317382] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

(lldb)

Posts: 1

Participants: 1

Read full topic

Xcode Grey Output Window - need to move

$
0
0

@Kroggel wrote:

Hey,

does anyone know this error. When I build and run any OF App in Xcode, the output Window is just grey. If I take the Window and Move it around it renders all good, but I always need that initial Push which seems kind of buggy.

running Mojave and Xcode 10

Posts: 1

Participants: 1

Read full topic

Slow compile time with oF 0.10

$
0
0

@marinero wrote:

I am using oF 0.10 with Mojave and I have noticed that every time I am compiling a new example/project etc it compiles for a long time. It’s not the speed of my machine, it’s that every time it compiles 182 files and takes 5 mins, as if I was compiling oF itself for the first time.

It used to be that the first time you compiled any oF project it would take 5 mins or so, to compile openFrameworks, but then any new projects or examples would compile within 30 seconds as the majority of oF would have already been compiled and only your ofApp.cpp / main code would need to be compiled and linked to the rest of oF.

Any idea why this isn’t the case any more?

Thanks!

ps for clarification: Once a project is compiled it does take 5-10 seconds to recompile after changes, but a new project in the same oF root folder, will take again 5 mins to compile all 182 oF files.

Posts: 2

Participants: 2

Read full topic

Render won't start unless window moved

$
0
0

@marinero wrote:

I am using oF 0.10 with Mojave and so do most of my students (about 80). All of us have the same issue. For graphics to show on the screen we need to move the window a little bit, otherwise nothing is shown on the canvas.
Anybody have the same issue? Any fixes?

Thanks

Posts: 2

Participants: 2

Read full topic

ofSetFrameRate(60) now necessary?

$
0
0

@marinero wrote:

I am using oF 0.10 with Mojave and so do most of my students (some use windows with VS). What we found out now in this version is that unless you specify ofSetFrameRate(60) the code will run at 150+ fps (depending on what you’re drawing of course).

Is there a reason the fps is not automatically capped any more?

thanks

Posts: 2

Participants: 2

Read full topic

Object and Particle Collision

$
0
0

@Nedelstein wrote:

Hi All,

I am fairly new to OF (and coding in general) so please excuse the noob questions. I am working on a small interactive particle system project and have some questions.

Any help would be greatly appreciated!

I am trying to do some collision (both between particles in the same particle system and between those particles and string elements) and I am running into some issues:

  1. The particles read and react correctly when they collide into each other, but they also seem to be running the collision function on themselves. I have nested for loops and run the collision function only when the particles[i].pos != particles[j].pos, but it doesn’t seem to be making a difference.

  2. I am using drawStringsAsShapes for my string variables, but how do I do collision between them and the particles? I have a letterCollide function in my ParticleSystemTop class, but I think I need to be more specific with the location of the string. Eventually I want the particles to bounce off the letter (when the appropriate key is pressed). Also, I’ll have the particles coming from all directions (right now they’re just coming from the top).

  3. I am running into memory issues. I think this is related to my first question, as the computer is running too many calculations at once. After a little while, the movement of the particles gets really choppy and eventually the project freezes. What am I doing wrong?

Code: https://github.com/Nedelstein/edeln591_dtOF_2018/tree/master/interactiveLettersMidterm

Thanks in advance for your help!

Posts: 2

Participants: 1

Read full topic


EasyCamera making a smoother movement

$
0
0

@cyrstem wrote:

hey is there a simple way to manipulate the camera movements speed of Easycam ?
im trying to make a simple animation that when you push a key the camera gets a new target and changes position but its to fast and like to be able to manipulate the speed ?
can it be done?

Posts: 3

Participants: 2

Read full topic

Strange behavior of an Image based class / simple slideshow

$
0
0

@prandam wrote:

I’m doing a simple slideshow that mixes (with random alphas) three instances of a image-based class. The class shows a random image from a folder and then starts doing a fade-in until reaches the alpha value of the object. Once it reaches this point goes again down. When the alphai reaches 0 it calls another image and start the process again.

This works with only one instance of the class ( set by #define NIMAGES 1). If I want three or more images (appearing and disappearing with fades at different times) the script just won’t do this well. When an object changes the file somehow it triggers the same operation in the other layers (before fading out completely) provoking strange jumps and sudden appearances. The other thing is that I’m centering the image but just now is printing them in the 0,0 corner.

I’m really clueless about this. Thanks A LOT for any help.

The code:

main.cpp

#include "ofMain.h"
#include "ofApp.h"


//========================================================================
int main( ){
	
   // ofGLFWWindowSettings settings;
   // settings.multiMonitorFullScreen = true;
   // settings.windowMode = OF_FULLSCREEN;
   // ofCreateWindow(settings);
    
    //ofSetupOpenGL(7560,1920,OF_WINDOW);			// <-------- setup the GL context
    ofSetupOpenGL(2048,1152,OF_WINDOW);
    //ofSetupOpenGL(2520,640,OF_WINDOW);
    
	// this kicks off the running of my app
	// can be OF_WINDOW or OF_FULLSCREEN
	// pass in width and height too:
	ofRunApp(new ofApp());

}

ofApp.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    
    vector<string> files;
    string path = "";
    ofDirectory dir(path);
    //only show png files
    dir.allowExt("jpg");
    //populate the directory object
    dir.listDir();

    //add all paths to files vector 
    for(int i = 0; i < dir.size(); i++){
        files.push_back(dir.getPath(i));
        ofLogNotice(dir.getPath(i));
       // ofLogNotice(files[i]);
    }
    ofRandomize(files);
    ofLogNotice("**********");
    
    //go through and print out all the vectors
    for(int i = 0; i < files.size(); i++){
      //  ofLogNotice(files[i]);
    }
    
    for(int i=0; i<NIMAGES; i++){
        imageLayers[i].setup();
    }
    
}

//--------------------------------------------------------------
void ofApp::update(){
    
    for(int i=0; i<NIMAGES; i++){
        imageLayers[i].update();
    }
    
}

//--------------------------------------------------------------
void ofApp::draw(){
    
    for(int i=0; i<NIMAGES; i++){
        imageLayers[i].draw();
    }
    
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

    for(int i=0; i<NIMAGES; i++){
        imageLayers[i].setup();
    }
}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){ 

}

ofApp.h

#pragma once

#include "ofMain.h"
#include "Wimage.h"

#define NIMAGES 1

class ofApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();

		void keyPressed(int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void mouseEntered(int x, int y);
		void mouseExited(int x, int y);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);

    float x=0;
    
    Wimage wImage;
    
    Wimage imageLayers[NIMAGES];
    
    
		
};

Wimage.cpp

#include "Wimage.h"

Wimage::Wimage(){

}

void Wimage::setup(){
    
    int wWidth = ofGetWidth();   // get window size
    int wHeight =  ofGetHeight();
    
    newImage();
    
    x= wWidth/2-pic.getWidth()/2;
    y= wHeight/2-pic.getHeight()/2;
    
    w = pic.getWidth();
    
    alpha = ofRandom(50, 200);       // alpha
    alphai = 0;
    
}

void Wimage::update(){
    
    if (fadeout==0) {
        alphai=alphai+1;
        if (alphai>alpha) {
            alphai=alpha; fadeout=1;
        }
    } else {  alphai=alphai-1;
        if (alphai<0) {
            alphai=0; fadeout=0; newImage();
        }
    }
}

void Wimage::draw(){

    pic.draw(x,y);
    ofSetColor(255,255,255,alphai);
    
}

void Wimage::newImage() {
    
    string path = "";
    ofDirectory dir(path);
    dir.allowExt("jpg");
    dir.listDir();
    alphai=0;
    pic.load(dir.getPath(ofRandom(dir.size())));

}


Wimage.h

#ifndef Wimage_hpp
#define Wimage_hpp

#include <stdio.h>
#include "ofMain.h" // we need to include this to have a reference to the openFrameworks framework

class Wimage {
    
public: // place public functions or variables declarations here
    
    // methods, equivalent to specific functions of your class objects
    void setup();   // setup method, use this to setup your object's initial state
    void update();  // update method, used to refresh your objects properties
    void draw();    // draw method, this where you'll do the object's drawing
    
    void newImage();  // new image for layer
    
    
    ofImage pic;   // image
    
    // variables
    float x;        // position
    float y;
    float w;        // width
    float h;        // height
    float ratio;    // aspect ratio 
    

    float alpha;    // starting alpha value
    float alphai;   // alpha variable for fade in-outs
    int fadeout=0;  // flag for fade
    
    ofColor color;  // color using ofColor type
    
    Wimage();  // constructor - used to initialize an object, if no properties are passed the program sets them to the default value


private: // place private functions or variables declarations here

};

#endif /* wImage_hpp */

Posts: 1

Participants: 1

Read full topic

ofAddListener, ofEvent: Undefined symbols for architecture x86_64

$
0
0

@a__ wrote:

macOS High Sierra 10.13.6
XCode 9.4.1
of_v0.10.0_osx_release
base SDK: Latest macOS (macOS 10.13)
arch: x86_64 i386


Using ofAddListener causes the following error:

Undefined symbols for architecture x86_64:
    "ofApp::onVolumeChange(float&)", referenced from:
        ofApp::setup() in ofApp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Following the ofEvents documentation I have the following app:

ofApp.h

#pragma once
#include "ofMain.h"
#include "ofEvents.h"
#include "MyClass.hpp"
class ofApp : public ofBaseApp{
    public:
	void setup();
	void update();
	void draw();
    void onVolumeChange(float & volume);
    MyClass myClass;
};

ofApp.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    ofAddListener(myClass.onVolumeChange, this, &ofApp::onVolumeChange); // this causes the error
}

//--------------------------------------------------------------
void ofApp::update(){}

//--------------------------------------------------------------
void ofApp::draw(){}

MyClass.hpp

#pragma once
#include "ofMain.h"
class MyClass {
    public:
    void setup();
    void update();
    ofEvent<float> onVolumeChange;
};

MyClass.cpp

#include "MyClass.hpp"
//------------------------------------------------------------------
void MyClass::setup(){}

//------------------------------------------------------------------
void MyClass::update(){
    float value = 10.0f;
    ofNotifyEvent(onVolumeChange, value);
}

What am I doing wrong?

edit: forgot to mention the weirdest part— the events examples all run fine. Examples from addons relying ofEvents (ofxSimpleTimer) run fine; the error occurs in new projects. If I copypaste everything verbatim into a new project the error appears.

Posts: 1

Participants: 1

Read full topic

Windows 7, Qt creator(4.5.0), oF(0.10.0), no ofMain.h file

IBM Watson and OpenFrameworks

$
0
0

@Regi wrote:

Hi,

Inwas wondering if anyonee has experimented with IBM’s Watson and OpenFrameworks and wouldn’t mind sharing some experiences?

Thanks!

Posts: 1

Participants: 1

Read full topic

Viewing all 4929 articles
Browse latest View live