Skip to content

Commit

Permalink
adding shaders with F6
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciogonzalezvivo committed May 13, 2012
1 parent 69e5400 commit 6e1ed5d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/ofxComposer.cpp
Expand Up @@ -23,8 +23,8 @@ string helpScreen = "\n \
- r: reset mask path\n \
\n \
- F4: Reset surface coorners\n \
- F5: Add ofxGLEditor (temporal!!!)\n \
- F6: Add ofVideoGrabber (temporal!!!)\n \
- F5: Add ofxGLEditor (temporal!!!) and if have it add ofVideoGrabber (temporal!!!)\n \
- F6: Add ofShader (temporal!!!)\n \
- F7: Turn ON/OFF the fullscreen-mode\n \
\n \
Mouse and Coorners: \n \
Expand Down Expand Up @@ -332,9 +332,15 @@ void ofxComposer::_keyPressed(ofKeyEventArgs &e){
// Special keys reserved for Patch Events
//
} else if (e.key == OF_KEY_F5 ){
bGLEditorPatch = addPatchWithOutFile("ofxGLEditor", ofPoint(ofGetMouseX(),ofGetMouseY()));

if ( bGLEditorPatch )
addPatchWithOutFile("ofVideoGrabber", ofPoint(ofGetMouseX(),ofGetMouseY()));
else
bGLEditorPatch = addPatchWithOutFile("ofxGLEditor", ofPoint(ofGetMouseX(),ofGetMouseY()));

} else if ( e.key == OF_KEY_F6 ){
addPatchWithOutFile("ofVideoGrabber", ofPoint(ofGetMouseX(),ofGetMouseY()));
addPatchWithOutFile("ofShader", ofPoint(ofGetMouseX(),ofGetMouseY()));

} else if (e.key == OF_KEY_F7){
ofToggleFullscreen();

Expand Down
1 change: 0 additions & 1 deletion src/ofxComposer.h
Expand Up @@ -51,7 +51,6 @@ class ofxComposer {
ofColor editorFgColor;
#endif


map<int,ofxPatch*> patches;

string configFile;
Expand Down
27 changes: 26 additions & 1 deletion src/ofxPatch.cpp
Expand Up @@ -1099,7 +1099,32 @@ bool ofxPatch::loadType(string _type, string _configFile){
width = videoGrabber->getWidth();
height = videoGrabber->getHeight();
}
}
} else if (_type == "ofShader"){
type = _type;

if ( shader != NULL )
delete shader;

shader = new ofxShaderObj();
shader->allocate(width,height);
loaded = shader->setFragmentShader("uniform sampler2DRect tex0;\n\
uniform sampler2DRect backbuffer;\n\
uniform vec2 resolution;\n\
uniform vec2 mouse;\n\
uniform float time;\n\
\n\
void main(){\n\
vec2 st = gl_FragCoord.xy;\n\
vec4 color = texture2DRect(tex0, st);\n\
gl_FragColor = vec4(color.rgb,1.0);\n\
}");

inPut.clear();
for ( int i = 0; i < shader->getNumberOfTextures(); i++){
LinkDot p;
inPut.push_back(p);
}
}

if ( loaded ){

Expand Down

0 comments on commit 6e1ed5d

Please sign in to comment.