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

Difficulty with shader, No matching function for call to texture2DRect(sampler2DRect, vec2, float)

$
0
0

@nosarious wrote:

I am working with code found on shadertoy to replicate CRT monitor scanlines. There are a number of them, but this is the slimmest one I found:
FixingPixelArtKernel
Another one (a bit more complicated) FixingPixelArt

In these shaders there is a function Fetch which calls another function ToLinear, converting sRGB to Linear.

// sRGB to Linear.
 // Assuing using sRGB typed textures this should not be needed.
 float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
 vec3 ToLinear(vec3 c){return vec3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}

 vec3 Fetch(vec2 pos,vec2 off){
     pos=floor(pos*res+off)/res;
     if(max(abs(pos.x-0.5),abs(pos.y-0.5))>0.5)return vec3(0.0,0.0,0.0);
     return Test(ToLinear(texture2DRect(tex0,vec2(pos.x,-pos.y),-16.0).rgb));
 }

The original code had 'ToLinear(texture2D(' instead of 'ToLinear(texture2DRect'

my problem is that I am consistently getting this error:
No matching function for call to texture2DRect(sampler2DRect, vec2, float)

I haven't been able to find a solution online that makes sense.

The image being used in the shader is an FBO created full-screen every frame from a 3d scene, so I can't use sampler2D.

Posts: 1

Participants: 1

Read full topic


What is the default z axis value in OF?

$
0
0

@cuinjune wrote:

Hi, I want to know what the default z axis value when the z value is not set.

For example, if I do

ofTranslate(50,50); or ofDrawRectangle(50,50,100,100); or ofPoint(50,50);

Then, what would the z axis value be?

I've always thought it is set to zero, but many examples in OF seem to use 1.0 for z axis.

Can anyone please clarify this for me?

Posts: 1

Participants: 1

Read full topic

Resizing on the fly fonts

$
0
0

@christoph wrote:

Hum, this is a newbie question but i m wondering if there is anyway to resize on the fly a font instead of loading multiple size of a same font ?

Posts: 1

Participants: 1

Read full topic

A Basic 3d Scene example from ofBook and openGL version

$
0
0

@cuinjune wrote:

Hi, I tried running the "Basic 3d Scene" example code from ofBook.

http://openframeworks.cc/ofBook/chapters/openGL.html

The example uses ofLight, ofEasyCam, ofBoxPrimitive and ofMaterial.

And I found out in order to run the example properly, I had to add "settings.setGLVersion(3, 2);" in int main( ) {} in main.cpp file as written in the ofBook.

Without this line, I could just see a white box which doesn't seem to get affected by ofLight or ofMaterial.

Could someone please tell me what is disabled in the default openGL version and what gets enabled by setting the openGL version to (3,2)? And why OF doesn't use this version as default?

Thanks in advance!

(I'm using OF v.0.9.8_osx by the way)

Posts: 1

Participants: 1

Read full topic

Can't properly include my class from an external .h/.cpp file

$
0
0

@ch3 wrote:

In a fresh OF project(VS15), I successfully managed to create and access my class named person from an external definition. But I am having problems doing the same on the project I've been working in the past week. I know it's a rather basic question, but I've spend a few hours without being able to figure out what I am missing, or if there is a conflict.

At the top of ofApp.h I have #include "person.h"
The class is accessible in ofApp.cpp when I do this within the ofApp::draw() function

person someone = person();
	someone.draw();

But for some reason, declaring person bob; inside class ofApp in ofApp.h gives me the following two errors even if person.h is included at the top of the same file.

Severity	Code	Description	Project	File	Line	Suppression State
Error	C3646	'bob': unknown override specifier (compiling source file src\person.cpp)	we	d:\mystuff\ch3\dev\visual studio 2015\of_v0.9.8_vs_release\apps\myapps\we\src\ofApp.h	90


Severity	Code	Description	Project	File	Line	Suppression State
Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file src\person.cpp)	we	d:\mystuff\ch3\dev\visual studio 2015\of_v0.9.8_vs_release\apps\myapps\we\src\ofApp.h	90

How is it possible for person to be accessible in the .cpp file but not in the .h one?

I believe I am defining the class in the exact same way in the fresh project where it work. Is there a chance that the definition may be conflicting with other libraries?
The full source code is in gihub.

thank you

Posts: 1

Participants: 1

Read full topic

How to properly draw custom 3d objects using ofPath

$
0
0

@cuinjune wrote:

Hi, I'm trying to test if it's possible to draw any 3d shape I want using ofPath so I can later use it as a ofPolyline or ofMesh.

First, I'm trying to draw a simple pyramid-like shape made of 4 isosceles triangles. (without the bottom square)

Here's the test code I wrote,

void ofApp::draw(){

ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
ofRotate(60, 1, 1, 1);

ofPath path;
path.clear();

//upper triangle (as if seeing the pyramid from the sky)
path.moveTo(-50, -50, 0);
path.lineTo(0, 0, 150);
path.lineTo(50, -50, 0);
path.close();

//left triangle
path.moveTo(-50, -50, 0);
path.lineTo(0, 0, 150);
path.lineTo(-50, 50, 0);
path.close();

//right triangle
path.moveTo(50, -50, 0);
path.lineTo(0, 0, 150);
path.lineTo(50, 50, 0);
path.close();

//lower triangle
path.moveTo(-50, 50, 0);
path.lineTo(0, 0, 150);
path.lineTo(50, 50, 0);
path.close();

path.draw();

}

And unfortunately, this draws nothing.
But if I set the path unfilled by adding the two lines below after path.clear();
path.setFilled(false);
path.setStrokeWidth(2);

Then it shows a stroke of the shape properly as the image below.

But I don't know why it doesn't draw anything when I try to fill the shape.
Does this have to do with overlapping lines between triangles? do they cancel the path?
Or should I make 4 different paths that draw separately? (I'm sure this will work at least)

I want to know if it is possible to properly draw any 3d shape using just one ofPath.
Thank you very much in advance!

Posts: 1

Participants: 1

Read full topic

Error: 'non standard syntax, use & to create pointer to member'

$
0
0

@legshampoo wrote:

I'm trying to use EnumWindows to list all the window titles of other apps, but getting the error:

'non-standard syntax; use '&' to create a pointer to member

Here's my code:

void ofApp::setup(){

	EnumWindows(WorkerProc, NULL);

}

BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam) {
	static TCHAR buffer[50];

	GetWindowText(hwnd, buffer, 50);
	if (_tcsstr(buffer, L"Desired Window")) {
		// do something with hwnd here
		return FALSE;
	}

	return TRUE;
}

and here's how it's defined in ofApp.h:

BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam);

Any ideas? Is it really just missing an '&' somewhere?
My understanding of pointers is lacking...

Posts: 1

Participants: 1

Read full topic

How to display world map( from a shape file) in openframeworks

$
0
0

@lulitdestajo wrote:

Hello there,

Currently in the process of creating interactive world map menu for an installation.

The installation's parameters will be based on the country the participant has selected using the Kinect.
I already have the rest of the installation working with the Kinect.

How would I go about processing/displaying the data within the shapefile? With Processing I used GiCentre's geomap library http://www.gicentre.net/geomap/. Is there a similar addon/library for openframeworks?

How does one usually create an interactive map within openframeworks?

Posts: 1

Participants: 1

Read full topic


Update() vs audiobuffer/audioOut()

$
0
0

@ayruos wrote:

so I was messing around with some audio visual stuff with the Maximilian library and following along this kadenze course. Wanted to understand why and when I should be doing my algorithms in update() and when inside the audiobuffer?

for example, originally I was setting up timers inside update calculating milliseconds but then started using maxiClock which needs to work inside the audiobuffer - what's the difference?

does update/draw/audiobuffer work at different cores/instances/calculations?

Posts: 1

Participants: 1

Read full topic

How to set polyWindingMode in ofPolyline?

$
0
0

@cuinjune wrote:

Hi, I don't know if there's a way to set the polyWindingMode in ofPolyline.

I know it can be done in ofPath but it seems there's no such method in ofPolyline.

Is it impossible?

Posts: 1

Participants: 1

Read full topic

Face tracking : Want to load image from picker or camera in ImagePicker object in Objective c method;

$
0
0

@Tikam_Chandrakar wrote:

Face tracking : Want to load image from picker or camera in UIImagePicker object in Objective c method;
Able to get UIImage now i want to load this UIIMage to ofimage object then I can track the eye and all the face component . but i am unable to load UIImage to ofImage object,

Example

UIImage *selectedPickerImage;
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
selectedPickerImage = info[UIImagePickerControllerOriginalImage];
}

I want to load : UIImage to ofImage for tracking the eyes and all the component.

   ofImage myImage;
  ofxFaceTracker srcTracker;
  ofPoint leftEyePoints;
    ofPoint rightEyePoints;
  ofPoint lipsPointsOuter;
  ofPoint lipsPointsInner;
  ofPoint noseBridge;

myImage.load(selectedPickerImage);

  if(myImage.getWidth() > 0)
{
srcTracker.update(ofxCv::toCv(myImage));
leftEyePoints = srcTracker.getImageFeature(ofxFaceTracker::LEFT_EYE).getCentroid2D();
rightEyePoints = srcTracker.getImageFeature(ofxFaceTracker::RIGHT_EYE).getCentroid2D();
lipsPointsOuter = srcTracker.getImageFeature(ofxFaceTracker::OUTER_MOUTH).getCentroid2D();
lipsPointsInner = srcTracker.getImageFeature(ofxFaceTracker::INNER_MOUTH).getCentroid2D();
noseBase = srcTracker.getImageFeature(ofxFaceTracker::NOSE_BASE).getCentroid2D();
noseBridge = srcTracker.getImageFeature(ofxFaceTracker::NOSE_BRIDGE).getCentroid2D();
faceOutline = srcTracker.getImageFeature(ofxFaceTracker::FACE_OUTLINE).getCentroid2D();
mouthImage = grabMouth();
}

I am not able to do that load UIImage in ofImage object. Please suggest and help.

Posts: 1

Participants: 1

Read full topic

ofEnableSmoothing() doesn't have any effect

$
0
0

@cuinjune wrote:

Hi, I'm using OF 0.9.8 on Mac OSX 10.11

I see no difference between enabling and disabling the smoothing.

I know it's only effective when drawing in Lines (unfilled).

But when I test it, I just see no difference at all.

Is it not working on some OS? or is it really hard to see the difference?

And one more question, how is smoothing different to setting the global number of samples.

I mean I can do antialiasing by adding such code as below in main.cpp. and how it is different from setting the smoothing?

ofAppGlutWindow window.setGlutDisplayString("rgba double samples>=4 depth");
or
ofGLFWWindowSettings settings.numSamples = 4;

Posts: 1

Participants: 1

Read full topic

Why do we need ofSetPolyMode and when to use it?

$
0
0

@cuinjune wrote:

Hi, I'm curious in what circumstance, would one wants to use ofSetPolyMode(ofPolyWindingMode)

There are these modes,

OF_POLY_WINDING_ODD 	        ,
OF_POLY_WINDING_NONZERO         ,
OF_POLY_WINDING_POSITIVE        ,
OF_POLY_WINDING_NEGATIVE        ,
OF_POLY_WINDING_ABS_GEQ_TWO

I tested them and they have effect on some shapes (unclosed shapes mostly) but on more common shapes like rectangle, circle.. it didn't have any effect on the shape.

Could anyone please briefly explain when would I want to use it?

Posts: 2

Participants: 2

Read full topic

ofPath for 2d and ofMesh for 3d?

$
0
0

@cuinjune wrote:

Hi, I've been wondering why there are only 2d shape drawing methods(rectangle, triangle..) in ofPath and why there are only 3d shape drawing methods(box, sphere...) in ofMesh.

As far as I know, both can be used for 2d and 3d drawings right? But I don't know why their methods are being separated as if ofPath is for 2d and ofMesh is for 3d.

Can anyone please explain this? Thanks!!

Posts: 1

Participants: 1

Read full topic

getRGB (ofColor)?

$
0
0

@christoph wrote:

hum... any idea to enable a split from a color in RGB instead of getHSB ? (to use with a color picker wich gives back a ofColor)

Posts: 1

Participants: 1

Read full topic


ofxMidi send controller change not working

$
0
0

@fdiba wrote:

Hello,

I'm trying to use ofxMidi to control a midi interface and I need to send some controller change.

I have tried to use midiOut.sendControlChange(channel, number, value).

The messages are correctly sended but it's like they are not understood (I know thanks to a led that messages are correctly sent).

For information, I am used to do the same thing with different midi interfaces using Processing, themidibus library and function like sendControllerChange(channel, number, value) and it works perfetly.

I have chosen the correct port in the ofApp setup function and I'm using the function sendControlChange in mousePressed. I'm sure about the port and the number. Both are 0 and I have chosen values between 0 and 255 while using sendControlChange(channel, number, value).

Do you know what I'm missing ? I'm using windows 10 (hope it's not related).

I have written some basic code here (that doesn't work as expected) : https://github.com/fdiba/BTM/tree/master/midi_test

Posts: 1

Participants: 1

Read full topic

GLSL and Cross Platform

$
0
0

@cuinjune wrote:

Hi, I just started learning the basics of Shaders and GLSL.

I learned that there are different GLSL versions based on different openGL versions.

And I'm curious if it would be possible to make one shader file to run on multiple platforms (e.g OSX and iOS)
As I checked, shadersES2 and shadersGL2 are pretty similar but shadersGL3 seemed to have some more deprecated variables.

So I googled, and I found a post regarding the cross-platform solution between openGL and GLES using preprocessor tricks.

But are shadersES2 and shadersGL2 really replaceable like the post?
I checked OF shader examples and some examples seemed to use different variable names.

As you can see, shadersES2 has texture2D whereas shadersGL2 has texture2DRect.
How different are they? Should I learn both if I want to make the cross platform shader files?

Posts: 1

Participants: 1

Read full topic

What do ofPushView and ofPopView do?

$
0
0

@cuinjune wrote:

Hi, I've been wondering what exactly the ofPush/popView methods save and restore.
How is it different to ofPush/popMatrix and when do you use it?
Is it related to ofViewPort? I can't really find any information regarding these methods.

Posts: 3

Participants: 2

Read full topic

[SOLVED] Calling draw methods in a child class

$
0
0

@no_u wrote:

EDIT: Of course two minutes later I realised that it's ofDrawRectangle() and not ofDrawRect(), which is why I was having this error. Thank you OF Forum, for forcing me to go through my code ... though I only noticed too late! Leaving this here as an example for others though. :smile:
Love, no_u


Hello! I'm kind of new to this and I'm having trouble understanding how classes I write can use the OF functions (like ofDrawRect()).

I have three classes, which are pretty straightforward (they don't inherit from one another, but they do interact.) I want these classes to be able to use OF functions.

The header, MyClasses.h:

#ifndef _MYCLASSES
#define _MYCLASSES

#include "ofMain.h"

class MyClassOne : public ofBaseApp{
public:
    // Constructor:
    Geomancy();
    void setup();
};

class MyClassTwo : public ofBaseApp{
public:
    // Constructor:
    MyClassTwo();
    void setup();
    void draw();
private:

};

class MyClassThree : public ofBaseApp{
public:
    // Constructor:
    MyClassThree();
    void setup();
    void draw(int whichType);
};

#endif

MyClasses.cpp:

#include "ofApp.h"
#include "MyClasses.h"


MyClassOne::MyClassOne() {
}

MyClassTwo::MyClassTwo() {
}

MyClassThree::MyClassThree() {
}

void MyClassOne::setup() {
// some stuff
}

void MyClassTwo::setup() {
// some more stuff
}

void MyClassThree::setup() {
    ofSetColor(ofRandom(255), ofRandom(255), ofRandom(255));
}

void MyClassThree::draw(int whichType) {
// This line is where xCode says the error is:
    ofDrawRect(tileX, tileY, TILE_DIM, TILE_DIM);
}

Weirdly, xCode doesn't complain about using ofSetColor() if I call it, but when I try to use MyClassThree::draw(int whichType) xCode says the following:

Use of undeclared identifier 'ofDrawRect'

Obviously I'm misunderstanding something here. Any pointers gratefully received! :slight_smile:

Posts: 1

Participants: 1

Read full topic

Mesh shape splitting on one side

$
0
0

@alaska wrote:

So, I've never used those calculations before so its hard for me to think of how to solve it, you can see what I'm referring to in the comments above the lines both in setup and update.
Thanks in advance for any guidance!

include "ofApp.h"

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

ofBackground(255);

gridWidth = 300;
gridHeight = 300;

//making the initial sphere
    for(int j=0; j<gridWidth; j++){
    for(int i=0; i<gridHeight; i++){

        //remove split but is problematic on the right side
        phi = ofMap(j, 0, gridHeight-1, 0, PI);
        theta = ofMap(i, 0, gridWidth-1, 0, 2*PI);

        radius = 300;
        x = radius*cos(theta)*sin(phi);
        y = radius*sin(theta)*sin(phi);


        mesh.addVertex(ofPoint(x, y));
        mesh.addColor(ofColor(random()));


    }

}


//defining the indicies
for(int y=0; y<gridWidth-1; y++){
    for(int x=0; x<gridHeight-1; x++){

        a = x + gridWidth*y;
        b = (x+1) + gridWidth*y;
        c = x + gridWidth * (y+1);
        d = (x+1)+ gridWidth * (y+1);

        mesh.addTriangle(a, b, c);
        mesh.addTriangle(b, d, c);
    }
}

}

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

//adding movement
float wob = ofGetElapsedTimef();

for(int j=0; j<gridWidth; j++){
    for(int i=0; i<gridHeight; i++){

        int index = i+gridWidth*j;
        ofPoint p = mesh.getVertex(index);


        //if you remove 2* you can see only half being split but if I were to also multiply in the first line it still doesn't slove it
        phi = ofMap(j, 0, gridHeight-1, 0, PI);
        theta = ofMap(i, 0, gridWidth-1, 0, 2*PI);


        //radius = 300 * (ofNoise(phi*mouseX/300, theta*mouseY/300, wob*1)); (used previously to find coordinates)
        radius = 300 * (ofNoise(phi*mx/300, theta*my/300, wob*1));

        x = radius*cos(theta)*sin(phi);
        y = radius*sin(theta)*sin(phi);


        mesh.setVertex(index, ofPoint(x, y));
        mesh.setColor(index, ofColor(random()));
    }
}

Posts: 1

Participants: 1

Read full topic

Viewing all 4929 articles
Browse latest View live