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

How to use glRenderer and draw a triangle with OpenGL(Beginner)

$
0
0

@sachaamm wrote:

Hi there,
My question is simple how to use ofGLRenderer in my sketch ?
All i want is to draw a triangle with OpenGL.

#pragma once

#include "ofMain.h"

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);

	ofGLRenderer glr;

};

ofApp.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

}

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

}

//--------------------------------------------------------------
void ofApp::draw(){
glr.drawTriangle(0, 0, 0, 1, 1, 1, 2, 2, 2);
}

I get (VS2015)
C2280 'ofApp::ofApp(void)': attempting to reference a deleted function
Can I get some explanations to it ? How to call properly ofGLRenderer function , as drawTriangle() ? Where I can find documentation about using OF with OpenGL ?

Thanks !!!!!

Posts: 2

Participants: 3

Read full topic


ofxTwitter Geo requirement?

$
0
0

@ankerr wrote:

Trying to make the examples for bakercp's ofxTwitter addon, but getting the error:

/openFrameworks-master/addons/ofxTwitter/libs/ofxTwitter/include/ofx/Twitter/Status.h:14:10: fatal error: 'ofx/Geo/Coordinate.h' file not found

include "ofx/Geo/Coordinate.h"

     ^

1 error generated.
make[1]: *** [obj/osx/Release/src/main.o] Error 1
make: *** [Release] Error 2

Trying adding the master branch copy of ofxGeo into the addons, but no luck.

Where am I going wrong?

Posts: 1

Participants: 1

Read full topic

Looking for a slider that allows you to set a specific range of values

$
0
0

@Julian_Puppo wrote:

I know this is a silly question but I can´t really find the answer to it.

I want to make a slider that allows you to set the minim and the max value on the go.
Like the range selector in controlp5 in processing, just like that one.

I´ve already looked in ofxDatGui and ofxImgui and i wasn´t able to find one of those.

There is an example in ofxDatGui wich says "Rangesliders" BUT IS NOT a slider that allows you to select a range.

This is a simple and very common use. Could you tell me wich library has it or where in those librarys i can be able to find the example that im looking for?

Example of the kind of slider im lookiing for but in javascript https://refreshless.com/nouislider/.

Posts: 3

Participants: 2

Read full topic

Myo quaternion to 3D object rotation

$
0
0

@Dazzid_of wrote:

Hi all,
I'm quite lost on rotating a simple cube by using Myo quaternion. I started by placing the ofRotation using w,x,y,z then x,y,z,w but after trying many options I really don't get it. Can someone help me on this?
Thanks
David

Posts: 4

Participants: 3

Read full topic

Hi help with OF on Rpi

$
0
0

@cyrstem wrote:

hi i update my rpi 2 system
and now when i try to get a OF app run from ssh i get this :

[warning] ofAppEGLWindow: init(): X11 not availble on RPI yet, using a native window instead
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): screenRect: 1920x1200
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): windowRect: 1024x768
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
* failed to add service - already in use?

Posts: 1

Participants: 1

Read full topic

ofxFiducialFinder not working on 0.9.8

$
0
0

@Cici wrote:

Hello,

I just switched to 0.9.8 because of updating mys OSX system and the ofxFiducialFinder addon stopped working. It seems to me that it's only minor stuff that needs adjustments but my cpp knowledge is not advanced enough that I could fix it.

I got hung up on the following line, which is causing an error:

const unsigned char* pixels = input.getPixels();

where input is an ofxCvGrayscaleImage&

Did anybody get the ofxFiducialFinder addon to work on 0.9.8?
I'm on OSX10.12.5

Thanks!

Posts: 1

Participants: 1

Read full topic

Problem with insterting points into ofPolyline

$
0
0

@udiskie wrote:

Hello i'm trying to load points from an ofVec2f array into a ofPolyline, but i got a bit lost.

This is what i have:

void MyClass::updatePoints(){
	int seg = 30;
	angle = start;

	for (int i = 0; i < sizeof(points)/sizeof(*points); ++i)
	{
		float y = ofMap(sin(angle),-1,1,0,amplitude);
		points[i].set(i*seg, y);
		line.insertVertex(points[i],i);
		angle += speed;
	}

	start += 0.02;
}

questions:
- why it is endlessly adding points with new values to my polyline instead of overwriting them since i'm giving the same indexes in the "for loop"?

-what other ways are to solve this same problem?

thanks in advance.

Posts: 1

Participants: 1

Read full topic

Project guidance - Arduino

$
0
0

@Charles_Lucien wrote:

Hi All,

I'm a processing users and this is my first OF project, I'd love some of your input regarding the best approach for this. I'm using Windows 10 with VS2015.

Using some video processing with openCV I'd like to control a stepper and a servo motor attached to my Arduino. My goal is achieve 200 fps and to get the motors to respond between 50 and 100 millisecond, actually 20 would be ideal!

I understand there's two ways to do this:
1. Install standard firmata on Arduino and control using ofxArduino
2. Upload "response" code to Arduino and control using ofxSerial

Which of these two options is best suited? Any further advice to achieve this kind of response time are much appreciated! :slight_smile:

Thanks, Charles

Posts: 1

Participants: 1

Read full topic


Gesture recognition with GRT

$
0
0

@mikaoP wrote:

Hello. This is not exactly an OF question but as GRT forum is not available i ask here.
I am interested in using GRT to do some gesture recognition. The following link has a video of what i mean. Do you think it is possible do it? In GRT website i have seen there are classification and regression utils, but i think that it is not what i am looking for.

Posts: 1

Participants: 1

Read full topic

Particles + ContourFinder

$
0
0

@Roflmagoo wrote:

Hello everyone,
I'm a little newbie in the huge universe of Openframeworks. I have a generic idea for a little project: I want to create a particle system wich is attracted to the contours of my body.

I'm capable to generate the particle system and to use the openCV contourfinder, but how can I mix the two things?

Thanks guys

Posts: 3

Participants: 2

Read full topic

Transparency of text over video is not working

$
0
0

@mandriv wrote:

Hi everyone, I am very new to openFrameworks and I am having lots of fun working with it so far!

I am trying to achieve semi-transparent text over video, which is drawn using ofVideoGrabber.

When I am using text with no transparency like this:

ofSetColor(51, 153, 0);
_goFont.drawString("GO!", ofGetWidth()/2, ofGetHeight()/2);

I am getting nice text:

View post on imgur.com

However when I want to add some transparency like this:

ofEnableAlphaBlending();
 ofSetColor(51, 153, 0, 127);
_goFont.drawString("GO!", ofGetWidth()/2, ofGetHeight()/2);
ofDisableAlphaBlending();

I am getting this black rectangle:

View post on imgur.com

Many thanks!

Posts: 1

Participants: 1

Read full topic

Reset position to center using quaternion (myo)

$
0
0

@Dazzid_of wrote:

Hi
I'm trying to reset the myo position of a cube to the center when a person is pointing to the screen wearing the myo on the right hand.
I'm using ofNode with two objects, one is "myArm" as a generic object and "geometry" that is the cube that appears in the screen. Myo rotates "geometry". I'm trying to center "geometry" by multiply myArm quaternion by the inverse quaterion of "geometry" called "center", buuuut it doesn't work.
Any suggestion?

            void Arm::reset(ofQuaternion inRotation){
                ofQuaternion center = inRotation.inverse();
                myArm.rotate(myArm.getGlobalOrientation() * center);
            }

Posts: 4

Participants: 2

Read full topic

ofxDatGui and multi-window app

$
0
0

@robotPatrol wrote:

hi,

i'm using ofxDatGui with the multi-window application and i have errors when i declare the gui as a shared pointer in ofApp.h. i combined the multi-window example from oF and the data binding example from ofxDatGui. i receive a 'no matching' flag in ofmain.h and a 'use of undeclared identifier' flag for the shared pointer in ofapp.h.

src.zip (4.4 KB)

ofmain.h

#include "ofMain.h"
#include "ofApp.h"
#include "GuiApp.h"
#include "ofAppGLFWWindow.h"

//========================================================================
int main( ){
ofGLFWWindowSettings settings;

settings.width = 600;
settings.height = 600;
settings.setPosition(ofVec2f(300,0));
settings.resizable = true;
shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);

settings.width = 300;
settings.height = 300;
settings.setPosition(ofVec2f(0,0));
settings.resizable = false;
shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(settings);

shared_ptr<ofApp> mainApp(new ofApp);
shared_ptr<GuiApp> guiApp(new GuiApp);
mainApp->gui = guiApp;

ofRunApp(guiWindow, guiApp);
ofRunApp(mainWindow, mainApp); //no matching function to ofRunApp
ofRunMainLoop();
}

ofApp.h

#pragma once

#include "ofMain.h"
//#include "GuiApp.h"
#include "ofxDatGui.h"


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);

	shared_ptr<GuiApp> gui; //use of undeclared identifier 'GuiApp'
};

ofapp.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
ofBackground(255);
ofSetCircleResolution(200);
}

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

}

//--------------------------------------------------------------
void ofApp::draw(){
//	ofSetColor(gui->color);
//	ofDrawCircle(ofGetWidth()*0.5,ofGetWidth()*0.5,gui->radius);
//	ofSetColor(0);
//	ofDrawBitmapString(ofGetFrameRate(),20,20);
}

guiapp.h

#include "GuiApp.h"

void GuiApp::setup()
{
ofxDatGuiLog::quiet();

// create a simple circle and position it in the middle of the screen //
circle = new Circle(150);

// instantiate our gui and a couple of range sliders //
gui = new ofxDatGui( ofxDatGuiAnchor::TOP_RIGHT );
gui->addHeader("ofxDATGUI DATA BINDING EXAMPLE");
sx = gui->addSlider("CIRCLE X", 0, ofGetWidth());
sy = gui->addSlider("CIRCLE Y", 0, ofGetHeight());

// bind the circle's x & y properties to the gui sliders //
sx->bind(circle->x);
sy->bind(circle->y);

ofSetWindowPosition(0, 0);
ofSetWindowShape(1920, 1080);

// center the circle onscreen //
circle->x = ofGetWidth() / 2;
circle->y = ofGetHeight() / 2;

}

void GuiApp::update()
{
    // drag the circle around if the mouse is pressed while over it //
    if (ofGetMousePressed() && gui->getMouseDown() == false){
    ofPoint mouse = ofPoint(ofGetMouseX(), ofGetMouseY());
    if (circle->inside(mouse)) {
        circle->x = mouse.x;
        circle->y = mouse.y;
    }
    }
}

void GuiApp::draw()
{
     circle->draw();
}

void GuiApp::windowResized(int w, int h)
{
// update the slider boundaries //
sx->setMax(ofGetWidth());
sy->setMax(ofGetHeight());
}

guiapp.h

#pragma once

#include "ofMain.h"
//#include "ofxGui.h"
#include "ofxDatGui.h"

class Circle {

public:
Circle(int radius)
{
    x = 100;
    y = 100;
    mRadius = radius;
}

bool inside(ofPoint mouse)
{
    return mouse.distance( ofPoint(x, y) ) <= mRadius;
}

void draw()
{
    ofSetColor(ofColor::red);
    ofSetCircleResolution(100);
    ofDrawCircle(this->x, this->y, mRadius);
}

float x;
float y;

private:
int mRadius;

};

class GuiApp: public ofBaseApp {
public:
void setup();
void update();
void draw();

void windowResized(int w, int h);

bool mDragging;
Circle* circle;
ofxDatGui* gui;
ofxDatGuiSlider* sx;
ofxDatGuiSlider* sy;
};

thanks,
01

Posts: 3

Participants: 2

Read full topic

Referencing Classes in Visual Studio 2015

$
0
0

@Charles_Lucien wrote:

Hi All,

I'm following the examples through ofBook however when I add #include "Ball.h" to ofApp.h I get the following error:
cannot open source file "Ball.h"

Ball.h and Ball.cpp are both located in the src folder, am I missing a reference somewhere?

Thanks,
Charles

Posts: 4

Participants: 2

Read full topic

Install QT creator for linux problem

$
0
0

@SB_LEE wrote:

Hello,
I have an issue with installing qt creator OF template in ubuntu 16.04 LTS.
After installing qt creator 4.1.0 and OF 0.9.8, I'm stuck with QT plugin for openFrameworks.
'install_template.sh' seems not working here.

//
bong@bong-UDOO-x86:~/OF/scripts/qtcreator$ sudo ./install_template.sh
[sudo] password for bong:
./install_template.sh: 7: ./install_template.sh: Bad substitution
//

I can't find any solution about it in this forum but find a same issue here.

How can I solve this?
Any solution would be so helpful.
thanks.

ADD:
I did install OF by following order.
1.Install dependencies.
2.Install codecs.
3.compileOF.sh
4.compilePG.sh

Posts: 3

Participants: 2

Read full topic


L-System Algae, should I use ofNode, ofMesh or vector to store vertices?

$
0
0

@Buoyancist wrote:

Hi!

I'm trying to make simple 2D Algae(https://en.wikipedia.org/wiki/L-system#Example_1:_Algae). I have the function to generate the iterations/rules from which to draw. For example having A as an axiom and with 6 recursions I get the following:

ABAABABAABAABABAABABA

which should be correct as far as I know.

So now I asume I should pass that string to another function which would create the vertices from which to draw, and I'm not sure how to proceed with that.

So my first question is that should I use ofNode or ofMesh or for example vector to store the locations to where the lines should be drawn?

My second question is, that what are the exact rules how the drawing should be done, I've been reading that wikipedia article and can't really figure it out. For example if the first A in the string is the middle of the screen, where should the second character in the string(B) go?

Thank you for your time, hope I wasn't too unclear.

Posts: 3

Participants: 2

Read full topic

Why won't Teamviewer work correctly with Of?

$
0
0

@rjlwest wrote:

So I'd like to b able to remotely control my Of app via my ipad. I install Teamviewer and can control my macbook no problem with things like youtube, other apps etc. Yet when I use it with my own Openframeworks app, it seems it will only register mouseclicks in the previous mouse coordinate, making things very complicated. What's going on there?

Posts: 1

Participants: 1

Read full topic

How to align text vertically without making it shake

$
0
0

@cuinjune wrote:

Hi, I'm trying to create a simple text alignment program using ofTrueTypeFont.

I found out ofTrueTypeFont draws string based on its bottom left corner as a default.

So I tried to change it's vertical alignment base(Top/Middle/Bottom) with a key press.

Here's the test code below.

I used Sansation font for the testing. Sansation.ttf.zip (14.2 KB)

in ofApp.h

ofTrueTypeFont font;
string text;

enum ALIGN_MODE {

    ALIGN_TO_BOTTOM,
    ALIGN_TO_MIDDLE,
    ALIGN_TO_TOP
};
ALIGN_MODE alignMode;

in ofApp.cpp

//--------------------------------------------------------------
void ofApp::setup(){

    font.load("Sansation.ttf", 50);
    alignMode = ALIGN_TO_BOTTOM;
}

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

    //set text with a randomly changing value
    text = "Value : " + ofToString(ofRandom(100));
}

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

    ofTranslate(100, 100);
    ofSetColor(ofColor::red);

    float stringHeight = font.stringHeight(text);

    switch (alignMode) {

        case ALIGN_TO_BOTTOM:
            font.drawString(text, 0, 0); //doesn't shake
            break;
        case ALIGN_TO_MIDDLE:
            font.drawString(text, 0, stringHeight/2); //shakes
            break;
        case ALIGN_TO_TOP:
            font.drawString(text, 0, stringHeight); //shakes badly
            break;
        default:
            break;
    }
}

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

    switch (key) {
        case '1':
            alignMode = ALIGN_TO_BOTTOM;
            break;
        case '2':
            alignMode = ALIGN_TO_MIDDLE;
            break;
        case '3':
            alignMode = ALIGN_TO_TOP;
            break;
        default:
            break;
    }
}

If you run the program, it will look like the screenshot below.

And If you change the alignment by pressing key '2' or '3', you will see the text shaking up and down badly.

I think it is due to ofTrueTypeFont::stringHeight() returning different values depending on the string.

Would it be possible to align the text vertically without making it shake up and down depending on the string?

Thank you very much in advance!

Posts: 8

Participants: 2

Read full topic

How to change right-handed coordinate to left-handed?

$
0
0

@BentleyJobs wrote:

I'm designing a visulizer for my offline renderer, but I use left-handed coordinate in it.

At first I find a function named setCoordHandedness(). But the renderer didn't implement it.

ofSetCoordHandedness(OF_LEFT_HANDED);

Then I tried to set the camera's vFlip, but the result seems weird.

cam.setFVlip(true);

Is there a common way to change right-handed coordinate to left-handed,to use a user-defined vertex shader maybe?

Posts: 1

Participants: 1

Read full topic

Triggering Still Images from Midi notes

$
0
0

@benthegoof wrote:

Hello gang.
I have a simple application that I would love to be able to do. I am currently running an Ableton Live Set. I have a live Midi track that is generating random midi notes.
I would like to take these midi notes an assign them to different still images. My goal is to have these still images mapped to each note on the keyboard, and thus make a kind-of 'slide show' effect - with each image appearing every time said midi note is played.
It will create a slide show, but also almost a strobe effect as the midi notes do tend to happen quickly.
Its a very simple idea, and i reckon a simple thing to program. I do not know, however, how to do it. Does this already exist somewhere?

I also have tried Vizzable, for Max for Live, and its works. However, it is designed for video and the sheer volume of images almost crashes my computer. I cant find a stable way of doing this, and yet, it seems so simple.

any advice would be most welcome.
Thanks
Ben

Mac OSX 10.10.5
2.9 GHz Intel Core i7
8 GB 1600 MHz DDR3

Posts: 2

Participants: 2

Read full topic

Viewing all 4929 articles
Browse latest View live