Skip to content

Commit 7d6b980

Browse files
committed
Merge branch 'master' of github.com:openframeworks/openFrameworks
2 parents 54accbb + f1cdeae commit 7d6b980

8 files changed

Lines changed: 115 additions & 72 deletions

File tree

addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -202,55 +202,47 @@ var LibraryHTML5Audio = {
202202
},
203203

204204
html5audio_stream_create: function(bufferSize, inputChannels, outputChannels, inbuffer, outbuffer, callback, userData) {
205-
var stream = AUDIO.context.createScriptProcessor(bufferSize, inputChannels, outputChannels);
206-
var inbufferArray = Module.HEAPF32.subarray(inbuffer >> 2,(inbuffer>>2) + bufferSize * inputChannels);
207-
var outbufferArray = Module.HEAPF32.subarray(outbuffer >> 2, (outbuffer>>2) + bufferSize * outputChannels);
208-
209-
stream.onaudioprocess = function(event) {
210-
var i, j, c;
211-
if (inputChannels > 0) {
212-
for (c = 0; c < inputChannels; ++c) {
213-
var inChannel = event.inputBuffer.getChannelData(c);
214-
for (i = 0, j = c; i < bufferSize; ++i, j += inputChannels) {
215-
inbufferArray[j] = inChannel[i];
205+
var stream = AUDIO.context.createScriptProcessor(bufferSize, inputChannels, outputChannels);
206+
var inbufferArray = Module.HEAPF32.subarray(inbuffer >> 2, (inbuffer >> 2) + bufferSize * inputChannels);
207+
var outbufferArray = Module.HEAPF32.subarray(outbuffer >> 2, (outbuffer >> 2) + bufferSize * outputChannels);
208+
209+
stream.onaudioprocess = function(event) {
210+
var i, j, c;
211+
if (inputChannels > 0) {
212+
for (c = 0; c < inputChannels; ++c) {
213+
var inChannel = event.inputBuffer.getChannelData(c);
214+
for (i = 0, j = c; i < bufferSize; ++i, j += inputChannels) {
215+
inbufferArray[j] = inChannel[i];
216+
}
216217
}
217218
}
218-
}
219219

220-
{{{ makeDynCall('viiii', 'callback') }}}(bufferSize, inputChannels, outputChannels, userData);
220+
{{{ makeDynCall('viiii', 'callback') }}}(bufferSize, inputChannels, outputChannels, userData);
221221

222-
if (outputChannels > 0) {
223-
for (c = 0; c < outputChannels; ++c) {
224-
var outChannel = event.outputBuffer.getChannelData(c);
225-
for (i = 0, j = c; i<bufferSize; ++i, j += outputChannels) {
226-
outChannel[i] = outbufferArray[j];
222+
if (outputChannels > 0) {
223+
for (c = 0; c < outputChannels; ++c) {
224+
var outChannel = event.outputBuffer.getChannelData(c);
225+
for (i = 0, j = c; i < bufferSize; ++i, j += outputChannels) {
226+
outChannel[i] = outbufferArray[j];
227+
}
227228
}
228229
}
229-
}
230-
};
230+
};
231231

232-
if (inputChannels > 0) {
233-
navigator.getUserMedia = navigator.getUserMedia ||
234-
navigator.webkitGetUserMedia ||
235-
navigator.mozGetUserMedia ||
236-
navigator.msGetUserMedia;
237-
238-
if (navigator.getUserMedia) {
239-
navigator.getUserMedia(
240-
{audio: true},
241-
function (audioIn){
242-
var mediaElement = AUDIO.context.createMediaStreamSource(audioIn);
243-
mediaElement.connect(stream);
244-
AUDIO.mediaElement = mediaElement;
245-
},
246-
function (error){
247-
console.log("error creating audio in",error);
248-
});
249-
}
250-
}
232+
if (inputChannels > 0) {
233+
navigator.mediaDevices.getUserMedia({ audio: true })
234+
.then(function (audioIn) {
235+
var mediaElement = AUDIO.context.createMediaStreamSource(audioIn);
236+
mediaElement.connect(stream);
237+
AUDIO.mediaElement = mediaElement;
238+
})
239+
.catch(function (error) {
240+
console.log("Error creating audio in", error);
241+
});
242+
}
251243

252-
stream.connect(AUDIO.fft);
253-
},
244+
stream.connect(AUDIO.fft);
245+
},
254246

255247
html5audio_stream_free: function () {
256248

addons/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,6 @@ var LibraryHTML5Video = {
149149
GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_WRAP_S, GLctx.CLAMP_TO_EDGE);
150150
GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_WRAP_T, GLctx.CLAMP_TO_EDGE);
151151
VIDEO.player[player_id].textureId = texId;
152-
153-
if (typeof VIDEO.player[player_id].audioTracks == "undefined") {
154-
VIDEO.player[player_id].muted = true;
155-
}
156152

157153
// Check the file size
158154
//console.log('File size:' + fileSizeInBytes);

addons/ofxKinect/src/ofxKinect.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void ofxKinect::update() {
382382
tryCount = 0;
383383
if(this->lock()) {
384384
if( videoPixels.getHeight() == videoPixelsIntra.getHeight() ){
385-
swap(videoPixels,videoPixelsIntra);
385+
std::swap(videoPixels,videoPixelsIntra);
386386
}else{
387387
int minimumSize = MIN(videoPixels.size(), videoPixelsIntra.size());
388388
memcpy(videoPixels.getData(), videoPixelsIntra.getData(), minimumSize);
@@ -402,7 +402,7 @@ void ofxKinect::update() {
402402
bIsFrameNewDepth = true;
403403
tryCount = 0;
404404
if(this->lock()) {
405-
swap(depthPixelsRaw, depthPixelsRawIntra);
405+
std::swap(depthPixelsRaw, depthPixelsRawIntra);
406406
bNeedsUpdateDepth = false;
407407
this->unlock();
408408

@@ -807,7 +807,7 @@ void ofxKinect::grabDepthFrame(freenect_device *dev, void *depth, uint32_t times
807807

808808
if(kinect->kinectDevice == dev) {
809809
kinect->lock();
810-
swap(kinect->depthPixelsRawBack,kinect->depthPixelsRawIntra);
810+
std::swap(kinect->depthPixelsRawBack,kinect->depthPixelsRawIntra);
811811
kinect->bNeedsUpdateDepth = true;
812812
kinect->unlock();
813813
freenect_set_depth_buffer(kinect->kinectDevice,kinect->depthPixelsRawBack.getData());
@@ -821,7 +821,7 @@ void ofxKinect::grabVideoFrame(freenect_device *dev, void *video, uint32_t times
821821

822822
if(kinect->kinectDevice == dev) {
823823
kinect->lock();
824-
swap(kinect->videoPixelsBack,kinect->videoPixelsIntra);
824+
std::swap(kinect->videoPixelsBack,kinect->videoPixelsIntra);
825825
kinect->bNeedsUpdateVideo = true;
826826
kinect->unlock();
827827
freenect_set_video_buffer(kinect->kinectDevice,kinect->videoPixelsBack.getData());
@@ -972,7 +972,7 @@ bool ofxKinectContext::open(ofxKinect& kinect, int id) {
972972
ofLogError("ofxKinect") << "could not open device " << id;
973973
return false;
974974
}
975-
kinects.insert(pair<int,ofxKinect*>(id, &kinect));
975+
kinects.insert(std::pair<int,ofxKinect*>(id, &kinect));
976976

977977
// set kinect id & serial from bus id
978978
kinect.deviceId = id;
@@ -1003,7 +1003,7 @@ bool ofxKinectContext::open(ofxKinect& kinect, string serial) {
10031003
return false;
10041004
}
10051005
int index = getDeviceIndex(serial);
1006-
kinects.insert(pair<int,ofxKinect*>(deviceList[index].id, &kinect));
1006+
kinects.insert(std::pair<int,ofxKinect*>(deviceList[index].id, &kinect));
10071007
kinect.deviceId = deviceList[index].id;
10081008
kinect.serial = serial;
10091009

@@ -1068,7 +1068,7 @@ void ofxKinectContext::listDevices(bool verbose) {
10681068
if(!isInited())
10691069
init();
10701070

1071-
stringstream stream;
1071+
std::stringstream stream;
10721072

10731073
if(numTotal() == 0) {
10741074
stream << "no devices found";

examples/computer_vision/kinectExample/src/ofApp.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,27 +124,27 @@ void ofApp::draw() {
124124

125125
// draw instructions
126126
ofSetColor(255, 255, 255);
127-
stringstream reportStream;
127+
std::stringstream reportStream;
128128

129129
if(kinect.hasAccelControl()) {
130130
reportStream << "accel is: " << ofToString(kinect.getMksAccel().x, 2) << " / "
131131
<< ofToString(kinect.getMksAccel().y, 2) << " / "
132-
<< ofToString(kinect.getMksAccel().z, 2) << endl;
132+
<< ofToString(kinect.getMksAccel().z, 2) << std::endl;
133133
} else {
134-
reportStream << "Note: this is a newer Xbox Kinect or Kinect For Windows device," << endl
135-
<< "motor / led / accel controls are not currently supported" << endl << endl;
134+
reportStream << "Note: this is a newer Xbox Kinect or Kinect For Windows device," << std::endl
135+
<< "motor / led / accel controls are not currently supported" << std::endl << std::endl;
136136
}
137137

138-
reportStream << "press p to switch between images and point cloud, rotate the point cloud with the mouse" << endl
139-
<< "using opencv threshold = " << bThreshWithOpenCV <<" (press spacebar)" << endl
140-
<< "set near threshold " << nearThreshold << " (press: + -)" << endl
138+
reportStream << "press p to switch between images and point cloud, rotate the point cloud with the mouse" << std::endl
139+
<< "using opencv threshold = " << bThreshWithOpenCV <<" (press spacebar)" << std::endl
140+
<< "set near threshold " << nearThreshold << " (press: + -)" << std::endl
141141
<< "set far threshold " << farThreshold << " (press: < >) num blobs found " << contourFinder.nBlobs
142-
<< ", fps: " << ofGetFrameRate() << endl
143-
<< "press c to close the connection and o to open it again, connection is: " << kinect.isConnected() << endl;
142+
<< ", fps: " << ofGetFrameRate() << std::endl
143+
<< "press c to close the connection and o to open it again, connection is: " << kinect.isConnected() << std::endl;
144144

145145
if(kinect.hasCamTiltControl()) {
146-
reportStream << "press UP and DOWN to change the tilt angle: " << angle << " degrees" << endl
147-
<< "press 1-5 & 0 to change the led mode" << endl;
146+
reportStream << "press UP and DOWN to change the tilt angle: " << angle << " degrees" << std::endl
147+
<< "press 1-5 & 0 to change the led mode" << std::endl;
148148
}
149149

150150
ofDrawBitmapString(reportStream.str(), 20, 652);
@@ -304,4 +304,4 @@ void ofApp::mouseExited(int x, int y){
304304
void ofApp::windowResized(int w, int h)
305305
{
306306

307-
}
307+
}
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
1+
// we set this define in the ofApp class
2+
#if defined(SHADOW_DEPTH_PASS)
3+
uniform mat4 modelMatrix;
4+
in vec4 position;
5+
uniform float iElapsedTime;
6+
uniform float uWiggleVerts;
7+
#else
28
// the mesh we are using does not have texture coordinates
39
// so we are going to send the local vertex positions to use for animation
410
OUT vec3 v_localPos;
11+
#endif
12+
513

614
void main (void){
15+
vec4 npos = position;
16+
npos.xyz += uWiggleVerts * 0.25 * vec3( cos(iElapsedTime*1.3+(position.z*1.25)+position.y*1.25), 0.0, 0.0);
17+
#if defined(SHADOW_DEPTH_PASS)
18+
vec3 worldPosition = (modelMatrix * vec4(npos.xyz, 1.0)).xyz;
19+
sendShadowDepthWorldPosition(worldPosition);
20+
#else
721
v_localPos = position.xyz;
8-
vec4 npos = getTransformedPosition();
9-
// npos.xyz += vec3( cos(iElapsedTime+v_localPos.y*1.85), 0.0, 0.0);
1022
sendVaryings(npos);
1123
gl_Position = modelViewProjectionMatrix * npos;
24+
#endif
1225
}

examples/gl/materialPBRAdvanced/src/ofApp.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ void ofApp::draw(){
7272
int numShadowPasses = light.getNumShadowDepthPasses();
7373
for( int j = 0; j < numShadowPasses; j++ ) {
7474
light.beginShadowDepthPass(j);
75-
renderScene();
75+
renderScene(true);
7676
light.endShadowDepthPass(j);
7777
}
7878
}
7979

8080

8181
camera.begin(); {
8282

83-
renderScene();
83+
renderScene(false);
8484

8585
if( cubeMap.hasPrefilteredMap() ) {
8686
cubeMap.drawPrefilteredCube(0.2f);
@@ -108,11 +108,12 @@ void ofApp::draw(){
108108

109109
stringstream ss;
110110
ss << "Reload shader(r): make changes to shader in data/shaders/main.frag and then press 'r' to see changes.";
111+
ss << endl << "Wiggle verts(w): " << (bWiggleVerts ? "yes" : "no");
111112
ofDrawBitmapStringHighlight(ss.str(), 40, 40);
112113
}
113114

114115
//--------------------------------------------------------------
115-
void ofApp::renderScene() {
116+
void ofApp::renderScene(bool bShadowPass) {
116117

117118
matFloor.setMetallic(0.0);
118119
matFloor.setReflectance(0.01);
@@ -140,7 +141,14 @@ void ofApp::renderScene() {
140141
ofPopMatrix();
141142
matSphere.end();
142143

144+
if( bShadowPass && bWiggleVerts ) {
145+
mDepthShader.begin();
146+
mDepthShader.setUniform1f("iElapsedTime", ofGetElapsedTimef());
147+
mDepthShader.setUniform1f("uWiggleVerts", bWiggleVerts ? 1.0f : 0.0f);
148+
}
149+
// setting custom uniforms on a material automatically adds it to the shader
143150
matLogo.setCustomUniform1f("iElapsedTime", ofGetElapsedTimef());
151+
matLogo.setCustomUniform1f("uWiggleVerts", bWiggleVerts ? 1.0f : 0.0f);
144152
matLogo.begin();
145153
ofPushMatrix();
146154
ofTranslate( -70, -250, 0 );
@@ -149,6 +157,9 @@ void ofApp::renderScene() {
149157
meshLogoHollow.draw();
150158
ofPopMatrix();
151159
matLogo.end();
160+
if(bShadowPass && bWiggleVerts ) {
161+
mDepthShader.end();
162+
}
152163
}
153164

154165
//--------------------------------------------------------------
@@ -161,6 +172,9 @@ bool ofApp::reloadShader() {
161172
if( vbuffer.size() && fbuffer.size() ) {
162173
matLogo.setShaderMain(vbuffer.getText(), GL_VERTEX_SHADER, "main.vert");
163174
matLogo.setShaderMain(fbuffer.getText(), GL_FRAGMENT_SHADER, "main.frag");
175+
// configure the shader to include shadow functions for passing depth
176+
// declare a define so we can use the same shader file and run different bits of code
177+
light.getShadow().setupShadowDepthShader(mDepthShader, "#define SHADOW_DEPTH_PASS\n"+vbuffer.getText());
164178
return true;
165179
}
166180
return false;
@@ -174,6 +188,9 @@ void ofApp::keyPressed(int key){
174188
if( key == 'd' ) {
175189
bDebug = !bDebug;
176190
}
191+
if( key == 'w') {
192+
bWiggleVerts = !bWiggleVerts;
193+
}
177194
}
178195

179196
//--------------------------------------------------------------

examples/gl/materialPBRAdvanced/src/ofApp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ofApp : public ofBaseApp{
99
void update();
1010
void draw();
1111

12-
void renderScene();
12+
void renderScene(bool bShadowPass);
1313

1414
bool reloadShader();
1515

@@ -35,9 +35,12 @@ class ofApp : public ofBaseApp{
3535

3636
ofVboMesh meshPlySphere;
3737

38+
ofShader mDepthShader;
39+
3840
int mode = 0;
3941

4042
ofLight light;
4143
bool bDebug = false;
44+
bool bWiggleVerts = false;
4245

4346
};

libs/openFrameworks/ofMain.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,28 @@
113113
#include "ofNode.h"
114114

115115
//--------------------------
116+
#ifdef OF_LEGACY_INCLUDE_STD
116117
using namespace std;
117-
118+
#else
119+
120+
// this will eventually be disabled by default
121+
#define OF_USE_MINIMAL_STD
122+
#ifdef OF_USE_MINIMAL_STD
123+
using std::string;
124+
using std::stringstream;
125+
using std::endl;
126+
using std::vector;
127+
using std::max;
128+
using std::make_shared;
129+
using std::deque;
130+
using std::cout;
131+
using std::swap;
132+
using std::pair;
133+
using std::map;
134+
using std::shared_ptr;
135+
using std::weak_ptr;
136+
using std::to_string;
137+
#endif
118138
#endif
139+
140+
#endif // OF_MAIN_H

0 commit comments

Comments
 (0)